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.

Original pressure v time graph

Fourier transform graph frequency v amplitude

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!

  • $\begingroup$ 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. $\endgroup$
    – Jdip
    Sep 25, 2022 at 3:34
  • 2
    $\begingroup$ I wouldn't use the DFT at all for pitch detection. $\endgroup$ Sep 25, 2022 at 4:49
  • $\begingroup$ You might also want to look into chromagrams $\endgroup$
    – Jdip
    Sep 25, 2022 at 5:37
  • $\begingroup$ @Jdip what would be the method of down sampling the spectrum? Also, when would I stop down sampling? $\endgroup$ Sep 26, 2022 at 17:48
  • $\begingroup$ 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. $\endgroup$
    – Jdip
    Sep 26, 2022 at 18:24

1 Answer 1


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.

  • $\begingroup$ Ya, that clipping doesn't look good. $\endgroup$
    – Peter K.
    Sep 25, 2022 at 16:05
  • $\begingroup$ 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 $\endgroup$ Sep 25, 2022 at 21:43
  • $\begingroup$ Sorry again If I sound like a noob $\endgroup$ Sep 25, 2022 at 22:08
  • $\begingroup$ 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 $\endgroup$
    – ederwander
    Sep 27, 2022 at 11:42
  • $\begingroup$ 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. $\endgroup$
    – Hilmar
    Sep 28, 2022 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.