4

I have read all the wikipedia articles and stackoverflow articles on fft and resolution. However, nothing has helped in learning how to get high resolution frequency without having a huge latency issues.

If I understand signal processing correctly:

I have a sampling rate of 44,100, and I take 256 block. Then the frequency resolution would be 44,100/2/256 = 86.1 Hz per frequency bin with FFT.

Constantly I see examples like http://www.tunelab-world.com/, and http://www.spectraplus.com/ that are able to determine the frequency down to .01 Hz.

If I did that with my above method I would need 4410,000 bins to get that kind of resolution. At 44,100 sampling rate it would take 100 seconds to fill in the data from the input.

I know I am missing something, but I can't figure what.

How can I get a signal, and then draw a graph or display the frequency of a peak with that kind of accuracy without taking a gazillion bins or waiting forever?

Thanks in advance for your help!

Ryan
  • 41
  • 1
  • 3
  • What is "real time" ? You realise that there is such a thing as the Heisenberg uncertainty principle ? And why would it take 100 seconds ? – koan Jul 24 '11 at 22:11
  • Actually, when you take a 256 samples of a real signal (no imaginary part), after the fft the 'useful' bins go from indices 0 to 128 (that is N /2 + 1) for a total of 129 bins. The ones left are just a mirror of the first ones, being the middle (index 128) bin the 'mirror'. – villoren Jun 23 '14 at 16:25

3 Answers3

3

If you want a high frequency resolution FFT output, you have to perform the FFT over many samples: there is simply no way round that.

What you are probably seeing in other applications is overlapping: they may do a 4096 pt FFT on the first set of data, then move along 256 samples and do another 4096 pt FFT (on 3840 of the samples they have already used, plus a new 256 samples).

This allows you to show regular (different) updates with a fine frequency resolution. It will be no good for capturing transient signals, but looks good on an active display.

Adrian Taylor
  • 452
  • 2
  • 3
  • Would a sustained note on a piano be considered transient? My understanding is that it isn't because the frequency would be somewhat constant. – Ryan Jul 25 '11 at 05:03
  • I wouldn't have thought so: a transient signal in this case is something so much shorter than the FFT sample length that its amplitude gets diminished by all the time it's not there. But, if you have a 100 second sample time and the note only lasts for a second, then yes it would be transient: you would still see a peak at the right bin, but not a strong one. If everything else is just as transient, you may be OK though (it's all relative). – Adrian Taylor Jul 25 '11 at 06:42
  • @Ryan although the fundamental frequency of a single piano note is constant, its harmonic content over time is not. – heltonbiker May 12 '14 at 18:27
2

The reason you can get better accuracy is that the frequency estimation problem lends itself to being solved with higher accuracy than many other estimation problems.

The Cramer-Rao Lower Bound (CRLB) on the accuracy is given by:

enter image description here

which means that the variance of the frequency estimate (a measure of the expected error) goes down as the cube of T, the duration of the measurements. "Normal" estimation problems tend to have this measure go down as the square of T.

Using the FFT maximizer (the bin with the largest peak) will only get you the square of T.

As Adrian Taylor says, the examples you give are probably starting with a higher number of samples and then updating by a shorter duration.

For kicks, there are some frequency estimation algorithms here that might be of interest. They are quicker than the FFT, and more accurate.

Peter K.
  • 8,028
  • 4
  • 48
  • 73
  • Thank you for the article link, and explanation. With those frequency estimation algorithms, I presume that they work on time-domain data, and not the frequency-domain data that is obtained from a FFT of the data. – Ryan Jul 25 '11 at 05:07
  • @Ryan, yes, most of the useful algorithms work on time-domain data --- though there are several that use FFT points and interpolate around the peak to get a more accurate estimate. If you're already doing the FFT for other reasons, those might be worthwhile to look at. If you need more pointers, let me know and I'll see what I can do. – Peter K. Jul 25 '11 at 12:02
1

SpectraPlus says "High Resolution FFT Analysis up to 1,048,576 pts"; that won't get you to 0.01 Hz resolution at 44.1 kHz.

TuneLab seems to go down to 0.01 cents, but the "spectrum display" appears to have a resolution of around 2.5 Hz at 440 Hz. The "phase display" is nothing special.

What are you trying to do? If you merely want to implement a guitar tuner, you don't need (and probably don't want) an FFT. Not knowing any better, I'd go for a PLL.

tc.
  • 33,468
  • 5
  • 78
  • 96
  • TuneLab's phase display does seem to show a resolution of around 2.5 Hz. I can see that now. I have run tunelab through some tests with a tone generator in Audacity, and have been able to determine that it can distinguish between 440.00 Hz and about 440.010. So, if the spectrum display is only at 2.5 Hz resolution, are they able to determine the frequency independent of the FFT spectrum frequency resolution, through some other way? (I am hoping to make a piano tuning program.) – Ryan Jul 25 '11 at 05:06
  • As I said, I'd go for a PLL if you already know what note you're aiming for. You can also interpolate between FFT bins to guess the peaks; I have no idea how accurate this is. You can even try to detect the harmonics present to determine what the fundamental is, but that starts to become difficult. – tc. Sep 09 '11 at 17:53