Search code examples
audiosignal-processingfftpitchpitch-tracking

Real time pitch detection


For real time pitch detection of a user's singing FFT and autocorrelation don't get a good result. I can't find C / C++ methods.

Microphone input data is correct and when using a sine wave results are more or less the correct pitch. I'm visualizing autocorrelation by taking the values out of results array and each index, plotting index on the X axis and the value on Y axis (both are divided by 100,000, I'm using OpenGL, using VST plugins isn't an option). It looks like random dots. How to visualize the raw audio and autocorrelation data?


Solution

  • Taking a step back... To get this working you MUST figure out a way to plot intermediate steps of this process. What you're trying to do is not particularly hard, but it is error prone and fiddly. Clipping, windowing, bad wiring, aliasing, DC offsets, reading the wrong channels, the weird FFT frequency axis, impedance mismatches, frame size errors... who knows. But if you can plot the raw data, and then plot the FFT, all will become clear.