[vox-tech] Marking Audio file based on Freq.

Bill Broadley bill at cse.ucdavis.edu
Tue Mar 11 03:26:47 PDT 2008


Alex Mandel wrote:
> Fun challenge if anyone is up for it.
> 
> How do I locate all instances of a particular frequency in an audio file?

Audio file implies noise.... which implies matching, some form of FFT is
likely what you are looking for.  Are you sure you are looking for a single
frequency?  Not multiple tones?  Interference patterns?  Touch tones
are a combination of 6 frequencies I think (or something like that).

> Don't worry about format.
> Preferred solution will use Audacity, Octave, R or some other FOSS 
> software. More points the easier it is to use (really a Audacity plugin 
> at least in concept would be great)

How about python?

Say you have 256 samples of a waveform, we will generate it here since
you didn't post any actual wave forms:

Some initialization:
from Numeric import *
from FFT import *
import Gnuplot, Gnuplot.funcutils

Generate a sample waveform:
x=arange(256.0)
inp=sin(2*pi*(1250.0/10000.0)*x) + sin(2*pi*(625.0/10000.0)*x)

Let's plot it to see what it looks like:
g = Gnuplot.Gnuplot(debug=1)
g('set data style linespoints')
d = Gnuplot.Data(x, inp)
g.plot(d)

Now lets take a FFT:
myFFT = 10*log10(abs(real_fft(inp)))
x=arange(len(myFFT))

And plot that:
d = Gnuplot.Data(x, myFFT)
g.plot(d)

You should see noticeable peaks.  So basically what you are going to need to 
do is figure out what frequencies to look for and how long, then break up the
audio into pieces (say 0.1 seconds) then to find a 0.5 second pulse look for
4 in a row above whatever threshold fits your inputs.

Here's an article with more background, my only complaint about it is that
it uses a proprietary graphing library that I couldn't find the python
bindings for (and I dislike academic use only licenses anyways).  The code
above is a minor adaption of the code from the article.

http://www.onlamp.com/pub/a/python/2001/01/31/numerically.html

> Bonus if it flags all the points in say the marker track of audacity, 
> which would make it easy for me to shuffle through and listen to the 
> identified segments.

Not sure on the audacity file format, but it should be relatively easy to
write out a new .wav file, a list of time stamps, or related markup
for whatever tools you using.

> Really any ideas on how to approach this would be welcome.

I tend towards coding because I often become frustrated with the abilities
(like pattern matching) of preexisting tools.  Certainly a bit more info
about what you are trying to do and how you solve it (programming or existing
applications) would be interesting.


More information about the vox-tech mailing list