First I'd suggest normalizing the signals to 0 dB ("Normalize" effect). This makes the signals easier to work with.
http://manual.audacityteam.org/o/man/normalize.html
If you want to batch process a lot of files, you can add the Normalize effect and your new Nyquist plug-in to a Chain.
http://manual.audacityteam.org/o/man/ch ... ation.html
There's a bit of noise in the sample which can easily be removed with a low-pass filter. For example:
http://www.cs.cmu.edu/~rbd/doc/nyquist/ ... l#index444
but probably a better way to "filter" the signal is to resample it to a low frequency by taking the average amplitude of every, say 20, samples. This will effectively be a 1100Hz low-pass filter (the bandwidth at 44100 H is 22050 Hz, so at 1/20th of the sample rate the bandwidth will be 1102.5 Hz). It also reduces the amount of data to be processed to 1/20th of the original, so should be quicker and more efficient.
Code: Select all
(snd-avg *track* 20 20 op-average)
http://www.cs.cmu.edu/~rbd/doc/nyquist/ ... l#index663
We can then loop through the samples and look at the amplitude.
One way of doing this is to use a "DO" loop (
http://www.audacity-forum.de/download/e ... ef-093.htm) and grab each sample with SND-FETCH (
http://www.cs.cmu.edu/~rbd/doc/nyquist/ ... l#index263). This is how "Sound Finder" and "Silence Finder" work (look for their ".NY" files in your Audacity Plugins folder.
However, since we are only looking at short amounts of audio (3 seconds at our low sample rate will be less than 7000 samples), we can do this more quickly by grabbing the whole lot as an array with SND-FETCH-ARRAY
http://www.cs.cmu.edu/~rbd/doc/nyquist/ ... l#index265
So your code may look something like:
Code: Select all
(let* ((sig (snd-avg *track* 20 20 op-average))
(ln (snd-length sig ny:all))
(data (snd-fetch-array sig ln ln)))
(process data))
where "PROCESS" is your number crunching function (
http://www.audacity-forum.de/download/e ... ef-087.htm)
Note that the size of the "STEP" determines the precision. Smaller values will give higher precision, but you may get some false hits due to noise, and the amount of data (hence the size of the data array) will increase). I don't recall what the max size is for SND-FETCH-ARRAY, but it is at least 1 million.