Tutorial on Autocorrelation?

Viewed 5954

Ive recently been considering using Autocorrelation for Pitch Detection. However, I am finding it difficult on finding good sources of where to learn autocorrelation, by this I mean sources that make it easy to understand autocorrelation step-by-step.

Im not that very good a programmer yet and also not really big on formulas so the sources that I find are really difficult to understand.

Basically, what I know now is the concept of autocorrelation is like a compare-and-contrast method of a signal? But I would really appreciate it if I can have more understanding of the autocorrelation algorithm.

Thank you very much!

UPDATE: Here is a sample code I got from a site. Maybe you can use it as reference. Ive tested this code and it does return the correct pitch properly (albeit there are some incorrect ones here and there)

maxOffset = sampleRate / minFreq;
minOffset = sampleRate / maxFreq;

for (int lag = maxOffset; lag >= minOffset; lag--)
{
   float corr = 0; // this is calculated as the sum of squares
   for (int i = 0; i < framesize; i++)
   {
      int oldIndex = i - lag;
      float sample = ((oldIndex < 0) ? prevBuffer[frames + oldIndex] : buffer[oldIndex]);
      corr += (sample * buffer[i]);
   }

   if (corr > maxCorr)
   {
      maxCorr = corr;
      maxLag = lag;
   }
}

return sampleRate / maxLag;
1 Answers
Related