How to get the fundamental frequency from FFT?
Solution 1
The simplest technique I've had success with is to use FFT and then perform a Harmonic Product Spectrum. It is simple to implement and not very resource intensive, you just need to correctly downsample your result FFT and make products.
The following question should also be useful: Detecting the fundamental frequency
Solution 2
I try to reply with my basic remembrance: when ytou have the FFT of your signal, the fundamental isn't te one with the maximum amplitude ?
Lucas Speranza
Updated on July 09, 2022Comments
-
Lucas Speranza almost 2 years
I am developing a flash guitar, and the only apparent method to discover the frequency of the mic's data looks to be using FFT. Nevertheless, after something like 30 hours of research I could not discover the best way to do that. Should I use Harmonic Product Spectrum (HPS), Cepstrum or Maximum Likelihood? The tuner will have to show frequencys from 25 to 3000Hz.
Also, if someone knows about some open source code ready to find the fundamental frequency, please tell me. I can translate it to ActionScript.
Thanks!
-
Nemeth over 13 yearsNo, it ain't. It's the first harmonic of the spectrum.
-
Jim Lewis over 13 years@Nemeth: "first harmonic" is a synonym for "fundamental" as far as I know, and it generally does have the maximum amplitude.
-
Paul R over 13 years@Jim: for many instruments the fundamental does not have the highest amplitude - I'm not sure about guitars, but it may depend on the note and the type of guitar. Either way, it's better to use a proper pitch detection algorithm, rather than arbitrarily looking at single components such as the fundamental.
-
Jim Lewis over 13 years@Paul: For a plucked guitar string, the max amplitude in the harmonic series will be the fundamental. For brass instruments, it's true that many notes are produced as 2nd, 3rd, 4th etc. overtones of the fundamental. Guitar is usually notated an octave higher than it actually sounds, which can also confuse things a bit...
-
Paul R over 13 years@Jim: bowed instruments, e.g. violin and cello, typically have very little energy at the fundamental. Note that pitch perception works pretty well even when the fundamental is completely absent.
-
Jim Lewis over 13 years@Paul: Thanks for the examples! I had never heard of "Helmholtz motion" before...there's some interesting physics going on there.
-
Lucas Speranza over 13 yearsWhat should I use instead of FFT?
-
Nemeth over 13 years@Jim You are right, it is the definition, so it is a synonym.The average spectrum have the maximum amplitude at the first harmonic, as you can see here kb.osu.edu/dspace/bitstream/handle/1811/45171/… but it ain't necessary so, as well explained by @Paul. Actually, it is hard to define a fundamental tone for musical instruments, as they are actually semi-periodic.
-
Nemeth over 13 yearsYou could use autocorrelation : en.wikipedia.org/wiki/Autocorrelation But, as you are working with a guitar, it seems to me that pitch it's a more important concept than fundamental tone here. So you should see RAPT (robust algorithm for pitch tracking) here : ee.columbia.edu/~dpwe/papers/Talkin95-rapt.pdf
-
mmatloka over 13 yearsAccording to articles RAPT is a very good algorithm. However I have seen one opensource implementation of this in C and it had hundreds of lines.
-
AldaronLau almost 6 yearsCepstrum is slow and complicated. You should use bitstream autocorrelation: cycfi.com/2018/03/…