2

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!

1 Answers1

4

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.

Hilmar
  • 44,604
  • 1
  • 32
  • 63
  • Ya, that clipping doesn't look good. – Peter K. Sep 25 '22 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 – BigChungus443 Sep 25 '22 at 21:43
  • Sorry again If I sound like a noob – BigChungus443 Sep 25 '22 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 – ederwander Sep 27 '22 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. – Hilmar Sep 28 '22 at 13:08