# How to Find "pitch" from Fourier Series

The end goal of my project is to create an autotune program, But the problem I'm trying to solve right now concerns finding the pitch of someone singing a note. I have written some code that performs a Discrete Fourier Transform on a sample of 2048 values derived via my microphone. Heres the results of the code:

The top graph is the original pressure v time graph and the bottom is the Fourier Transform amplitude v frequency graph.

Basically my question is this: From this point, how would I determine the "pitch" or "frequency" of the original sample? Im sorry if I seem to be a noob (I am), I just can't find many resources that are much help to me on this. Any help is greatly appreciated!

• I can’t find the reference at the moment, but if you compute the spectrum, downsample it by 2, multiply the original spectrum by the downsampled spectrum, then multiply the result by a downsampled- by-three spectrum, etc, the end resulting spectrum has a peak at the fundamental frequency. Thanks harmonics.
– Jdip
Sep 25, 2022 at 3:34
• I wouldn't use the DFT at all for pitch detection. Sep 25, 2022 at 4:49
• You might also want to look into chromagrams
– Jdip
Sep 25, 2022 at 5:37
• @Jdip what would be the method of down sampling the spectrum? Also, when would I stop down sampling? Sep 26, 2022 at 17:48
• I think you should take Robert's and Hilmar's advice and try the methods they've hinted at. BUT if you wanted to try this, it's just discarding every 2nd sample and experimenting when to stop. Better for offline applications. Like they've said, this method for real-time application won't give you adequate results.
– Jdip
Sep 26, 2022 at 18:24

## 1 Answer

The DFT is not great tool for pitch detection. At a sample rate of 48kHz and an FFT length of 2048, the frequency resolution is only 23 Hz. Human voice range starts at 80 Hz and, for example, the difference between an A2 (110Hz) and Bb2 is only 6 Hz.

To get a frequency resolution that's decent enough for tuning, you'd have the crank the FFT length WAY up but that becomes awkward to manage and very slow. Alternatively you need spectral interpolation, Cepstrum, etc but none of these is great.

Better choices for pitch detection are phase locked loops or delay locked loops.

As a side note: your time domain waveform looks like it's badly clipped.

• Ya, that clipping doesn't look good.
– Peter K.
Sep 25, 2022 at 16:05
• Ok but the thing is that the end goal of my project is to create an autotune program. So I kinda have to use FFTs. Is there any way to take the average of the individual sinusoid frequencies to find the original pitch Sep 25, 2022 at 21:43
• Sorry again If I sound like a noob Sep 25, 2022 at 22:08
• I always read Hilmar talk about PLL (Phase Locked Loop) to track Pitch but I never saw any implementation how to do it lol... Hey @Hilmar show us how it's done ??? lol Sep 27, 2022 at 11:42
• If you are interested, just ask a separate question. The principle is simple enough, but to get something that's reliable, fast and accurate in the real world, you have to sort out a lot of fairly tricky details. I've done this a few times, but these are commercial applications, so they are proprietary. Sep 28, 2022 at 13:08