How can I determine the frequency of a sound in (nearly) real time?

A bit of backstory - bear with me.

I fly RC planes. We recently had a speed competition (which I won 141 MPH WOOT!). The problem is that we have a difficult time determining the speed of the aircraft. The planes are too small and too fast to easily pick up on radar. Stop watches over a distance have been suggested, but determined to be too inaccurate. Flying through traps (optical sensors) would make the timing easier, but it would be very tough to fly through the traps and the equipment would be expensive.

What we’ve resorted to doing is recording the sound of the plane passing by, then determining the speed using this program:

http://www.sprut.de/electronic/soft/scope.htm#download

What it does is analyze the frequency of the sound the airplane makes. As the the airplane passes, the frequency drops due to the doppler effect. By comparing the frequency of the approach sound to that of the departure sound, you can determine the speed. The program works, but it’s cumbersome.

To get a speed, I have to record the sound of my plane going by, load it on my computer, edit it down to about 10 secs or so, convert it to a .wav file and upload it to the program. Then, I have to convert the temp from F. to C. analyze the signal, make a guess at the best places to put my lines (look at the site if you don’t know what I’m talking about) and then convert the speed that it gives me from KPH to MPH.

So here’s the deal. The equation to determine speed from the frequency of the sound is pretty straightforward if you know delta(f) ( based on the the frequency of the sound approaching and the frequency of the sound departing) and the speed of sound. The (simplified)equation to determine the speed of sound based on temp is pretty straightforward. I would think that writing a program that would determine the speed automatically would be pretty doable - if I could get the numbers for the approach and departure sound frequencies.

So somehow, I need to be able to determine the frequency of the sound of the plane. It’s going to be the loudest thing that the mic is picking up so I should be able to filter out the quiter sounds. I’m imagining a program that records the frequency of the sound once every 1/4 sec. It will save the last 8 or 9 samples. Delta (f) would just be the current sample averaged with the sample from 2 seconds ago - though I"m not sure on the interval. Most of the actual coding needs to be hashed out, but the bottom line is that I need to determine the frequency of a sound at something like 1/4 sec intervals.

Does anyone know how that could be done? Oh, and has anything I’ve just explained made any sense? I’ll be happy to try and clarify what I’m talking about.

This may be useful: http://local.wasp.uwa.edu.au/~pbourke/other/dft/

A quick-and-dirty way to do this is to take your samples and measure the time between zero-crossings. If your sound is a nice sine wave (it won’t be), you can get the frequency in one step this way.

The FFT code is probably what you need.

One caveat: The Doppler effect will only tell you the radial component of velocity. So if the plane flies very near the detector, or you take your samples from a long time before and a long time after the flyby, then the plane will be flying almost straight towards you before, and almost straight away from you after, and errors will be small. If, however, the airplane flies past the detector at some distance, or you use points too close to the flyby, then it won’t be flying straight towards and straight away, and you’ll underestimate the speed.

Fourier transer? ::shudder::
I’m having calc II flashbacks (or was it calc III? I’m trying to repress).

I went and translated the website in my OP. As it turns out, he uses FFT to obtain the frequencies in his program. This may be a tougher problem than I had anticipated.

I’ve found the best results from taking my MP3 player (which records as well) and setting it in the middle of the runway. Then I try to fly a couple of feet off the ground. There is still a bit of error, but there’s way more error in determining the frequency with the current program, so I figure the radial component error is negligable.

OK, with an impact parameter of only a couple of feet isn’t too bad. Of course, then the next caveat is that the maximum speed close to the ground might not necessarily be the same as the maximum speed well away from the ground (due to boundary-layer effects), but that’s something to worry about on another day.

And don’t despair about the FFTs-- There are packages already written for that for any computer environment you can think of. You don’t have to write the FFT code yourself; just plug the data you have into one someone else wrote.

If you have MatLab, the code is:

Y = fft(X)
:smiley:

A musician with absolute pitch could tell you what note it was, and you could look it up. Or you could calculate it - if you include all the sharps and flats, there are 12 notes per octive, whose frequencies are in the ratio 1:2^(1/12), and I think 440 Hz represents a standard A or Middle C or something like that.

By the way, some people are referring to Fourier transforms, and the FFT or Fast Fourier Transform is only one specific way of calculating it, in the special case where the dataset you’re using contains 2^n observations where n is an integer. The FFT is computationally fast, but computers are fast enough to quickly do Fourier transforms of arbitrary (meaning not 2^integer) numbers of observations today.