3
$\begingroup$

I'm trying to figure out how exactly an auto correlation corresponds to a time domain signal.

Now I'm trying to find pitch periods in an audio file and 99% of the time I'm getting it spot on. Unfortunately however that 1% of the time is throwing me some annoying issues.

Now at present I scan through my window for the highest peak (ie the highest abs( sample value )). This seems to match up really nicely in most cases.

Now when I auto correlate I would expect the central peak to be this peak that I have identified (It will always have a positive number if i read it right). Is this correct?

Secondly, A peak that is n samples away from the central peak of the auto correlation will be n samples away from the peak I've identified in time domain, ok?

Sooo, if this is correct then I'm having a strange problem. I'm finding a peak in the auto correlation 91 samples from the center of my auto correlation. Unfortunately when I look at the signal in the time domain (inside an audio editing app) then my central peak corresponds perfectly to a negative peak in the audio. However, there are no peaks 91 samples away from that peak.

If I look forward the next real peak is 142 samples away and the previous peak to it is 75 samples away. I do notice a very tiny peak 91 samples or so in front of my peak but the sample never even goes negative. So why does this end up showing up as by far the strongest peak in the auto correlation?

Any help with this would be hugely appreciated!

$\endgroup$
  • 4
    $\begingroup$ Some plots of the data that you're looking at would help. $\endgroup$ – Jason R Apr 5 '12 at 16:29
  • $\begingroup$ @Jason R - Just off home will post some up soon. Some theory confirmation would be nice though ;) $\endgroup$ – Goz Apr 5 '12 at 16:30
  • $\begingroup$ What sort of data are you using? Speech? Music? Artificially generated? $\endgroup$ – Phonon Apr 5 '12 at 16:47
  • $\begingroup$ @Phonon: Its speech. $\endgroup$ – Goz Apr 5 '12 at 17:49
  • $\begingroup$ @Goz arent you looking at the absolute value of the auto-correlation plot? The second peak you are talking about might be negative peak in reality. $\endgroup$ – Spacey Apr 6 '12 at 16:11
5
$\begingroup$

One useful way of thinking about how autocorrelation relates to the original time domain signal is to consider that autocorrelation is equivalent to the inverse FFT of the power spectrum of the original signal. In physical terms this can be thought of as breaking down the time domain signal into its constituent sinusoids, stripping any phase information from each of these (i.e. make each component a cosine wave) and then combine them again. In effect you've taken away all the phase information from the signal. So this is why you get a big peak at T = 0, since all the cosine components "line up" at this point. The other positive peaks in the autocorrelation occur where you get one or more cosine components with coincident positive peaks, e.g. at values of T which correspond to the periods of the fundamental and harmonics of a periodic signal.

Hopefully this hand-waving non-mathematical description helps to make the concept of autocorrelation have a little more physical significance. (If not then feel free to ignore it!)

$\endgroup$
  • 1
    $\begingroup$ +1 This is actually a great answer, precisely because it is intuitive! :-) $\endgroup$ – Spacey May 11 '12 at 15:14
8
$\begingroup$

Autocorrelation is not about finding the distance between individual peaks. It is more about finding those lag distances that minimize the averaged squared delta between everything, all the peaks, all the valleys, all the flat spots, all in combination, and etc. Because of this averaging over the entire window, the lag distance may not correspond to the distance between any single pair of point phenomena.

$\endgroup$
  • $\begingroup$ Ok cool thats interesting ... however can you confirm or deny whether my getting the central position is correct? $\endgroup$ – Goz Apr 5 '12 at 17:48
2
$\begingroup$

Large off-center peaks in an audio auto-correlation are typically caused by

  1. Acoustic Reflections or echos
  2. Strong harmonic components in the signal
  3. Any combination thereof

You can think about the auto-correlation as follows: Make a copy of the original signal, shift it in time and then measure how similar the time shifted and the original signals are.

Let's do this with a sine wave: Every time the time lag is an integer multiple of the sine period the two signals line up perfectly and the auto-correlation has a maximum. If the time lag is half of a period, the two signals line up perfectly but out of phase. In this case the auto-correlation negative and has a negative peak. For a perfect sine wave, the auto-correlation is a sine wave as well. For a more complex tone with fundamentals and harmonics the auto-correlation tends to have multiple peaks which are evenly spaced. During speech this wall happen mostly during vowels.

Now consider the case where the speech is recorded with a microphone and the microphone is sitting on a little stand on the desk (which any good recording engineer would avoid like the plague). The mic picks up the voice directly, but the voice also bounces of the desk and gets to the microphone a little later. If you do an auto-correlation of that you will see a strong peak as soon as time lag lines up the reflection lines with the original speech. So reflections create a single off-center auto-correlation peak. The time position of that corresponds to the difference in travel paths of the original sound and the reflection. If the reflection path is, for example, 70cm longer you would see the auto-correlation peak at 2ms or 91 samples @44.1kHz.

Things get a lot more complicated if you have multiple reflections and multiple harmonics in the same signal.

$\endgroup$
2
$\begingroup$

Now when I auto correlate I would expect the central peak to be this peak that I have identified (It will always have a positive number if i read it right). Is this correct?

No this is not correct. An autocorrelation is an averaging across an entire window's worth of data. Just look at the definition of correlation, you see that a point n in the correlation function is the average sample value of the signal when multiplied with itself at circular shift n. So the largest peak is going to affect this the correlation, but it is averaged away across the entire signal.

So why might a peak in the signal correspond with a peak in the correlation? Let's consider a signal where every even sample is 1 and every odd sample is 0. Then you would say that the first largest peak is at 0, and second at 2. We also notice peaks in our autocorrelation function at these indices. The point is that the reason you are seeing a peak in these positions is because these very strong peaks are a periodic feature of the signal. It's not because there is 1 sharp peak at that index, but because many sharp peaks correlate for that value of circular shift. This is likely to be the case for very pure signals, but not the case when involving less simplistic signals with multiple harmonics. Your analysis breaks down very quickly.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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