0

I pretty much have no idea how I would go about doing this- I need to find the frequency of a played sine wave at a specific point in time. I've been doing some research and see that it involves a Fourier transform. I've found a DFT class but am not really sure how to use it.

My questions are these:

How do I save a sound file from a mic at a specific point in time? What format will this be saved in? From this, how would I go about using an FFT/DFT to find the frequencies in that sample?

I don't really have a clear understanding of the mathematics behind the FFT (and yes, I've tried to understand it), so am not really sure what outputs/inputs represent.

Alternatively if there are any libraries that support this type of thing, a link would be much appreciated.

Thanks in advance

Fraser Price
  • 899
  • 6
  • 15
  • 36
  • Basically, you take the FFT of the sound and find the highest peak. (You don't have to have a perfect understanding of the math, but it helps to have a basic comprehension of complex numbers.) As to "point in time", an FFT is generally performed on buffers of sound data representing anywhere from about 1/20 second to maybe 5 seconds -- 1/8 second or so is common. So you simply pick the set of samples you want for the "specific point in time". – Hot Licks Feb 24 '14 at 21:26
  • Ok thanks. What do the complex in/outputs represent? – Fraser Price Feb 24 '14 at 21:52
  • The "phase" of the sound. Generally one just deals with the "square" of the complex value so that the phase is removed and you only deal with amplitude. It's kind of like having the velocity of a car in the X and Y directions, and calculating the overall speed disregarding direction. – Hot Licks Feb 24 '14 at 22:13
  • http://dsp.stackexchange.com/ is the place to go with more detailed questions (that aren't language/system-specific), once you've got your feet on the ground. – Hot Licks Feb 24 '14 at 22:14
  • @HotLicks So imaginary + real act as i and j vectors...? – Fraser Price Feb 24 '14 at 22:14
  • @HotLicks Thank's for the link – Fraser Price Feb 24 '14 at 22:15
  • Yep, basically. I have to think about it for awhile every time I dive into it. – Hot Licks Feb 24 '14 at 22:15
  • 2
    I suggest reading the frequent similar question that have been asked on the matter. The answer is always the same - finding the highest magnitude bin from an FFT is not terribly reliable. Make it reliable is hard work. – marko Feb 24 '14 at 23:08
  • Although marko is correct that the FFT isn't the best way to get a fundamental frequency of a complex note, since OP is just looking for the frequency of a sine wave, an FFT should work fine. – tom10 Feb 25 '14 at 02:15
  • @marko - You could link to the "frequent similar question". – Hot Licks Feb 25 '14 at 02:49
  • Here's [one](http://stackoverflow.com/questions/17476686/extract-audio-frequency-from-instrument-to-find-a-musical-note/17477156#17477156) to start with. They're usually have titles like 'guitar tuner in ios|android]' - although the problem space is the same. – marko Feb 25 '14 at 08:42

0 Answers0