How to get the fundamental frequency from FFT?
Asked Answered
S

3

3

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!

Societal answered 6/2, 2011 at 17:13 Comment(0)
P
7

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

Pewter answered 26/4, 2011 at 6:10 Comment(0)
B
1

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 ?

Burgenland answered 6/2, 2011 at 17:16 Comment(7)
No, it ain't. It's the first harmonic of the spectrum.Jury
@Nemeth: "first harmonic" is a synonym for "fundamental" as far as I know, and it generally does have the maximum amplitude.Lemoine
@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.Faraway
@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...Lemoine
@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.Faraway
@Paul: Thanks for the examples! I had never heard of "Helmholtz motion" before...there's some interesting physics going on there.Lemoine
@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.Jury
J
0

The FFT it's not the best way to find a fundamental frequency of a musical instrument. Actually, yes, it would be a better idea to use cepstrum. You can find a similar questions here: Algorithm to determine fundamental frequency from potential harmonics and here : MATLAB - Missing fundamental from an FFT

Jury answered 6/2, 2011 at 17:30 Comment(4)
What should I use instead of FFT?Societal
You 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.pdfJury
According 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.Coccidiosis
Cepstrum is slow and complicated. You should use bitstream autocorrelation: cycfi.com/2018/03/…Exequies

© 2022 - 2024 — McMap. All rights reserved.