Fourier Analysis – Extracting Exact Frequencies from FFT Output

fourier analysissignal processing

Say I pass 512 samples into my FFT

My microphone spits out data at 10KHz, so this represents 1/20s.

(So the lowest frequency FFT would pick up would be 40Hz).

The FFT will return an array of 512 frequency bins
– bin 0: [0 – 40Hz)
– bin 1: [40 – 80Hz)
etc

So if my original sound contained energy at say 115Hz, how can I accurately retrieve this frequency?

That is going to lie in bin #2, but very close to bin #3. so I would expect both bins to contain something nonzero.

Question: how about the bins either side of this? Would they be guaranteed to be zero if there are no other frequencies close in the original signal?

Main question: is there some algorithm for deciphering the original frequency given the relative bin strengths?

Best Answer

Remember that the FFT is circular. Inputs which contain an integer number of cycles will come out clean as a single point, in the corresponding bin. Those which do not, act as if they are multiplied by a rectangular pulse in the time domain, which creates convolution by a sinc function in the frequency domain. Since sinc has unlimited support, your supposition that all bins except the closest two would be zero is incorrect.

Finding a closed-form analytic solution may be impossible, in which case your best bet would be to start with the center frequency for the two strongest bins and use binary search to find the frequency in-between that most closely corresponds to your actual spectrum.