'Autocorrelation of a wave file

I'm playing around with audio signal processing. For that purpose, I'm using a single channel wave file from here.

My first experiment was to look at the auto-correlation of the signal as done by the following code.

from scipy.io import wavfile
from scipy import signal
import numpy as np

sample_rate_a, data_a = wavfile.read('sounds/CantinaBand3.wav')

corr = signal.correlate(data_a, data_a)
lags = signal.correlation_lags(len(data_a), len(data_a))
corr = corr / np.max(corr)

lag = lags[np.argmax(corr)]
print(lag, np.max(corr))

Given that it is an auto-correlation, I would have expected to see a peak of 1.0 at lag 0 (since I normalize the correlation matrix).

However, the program outputs a peak of 1.0 at lag -36141. At lag 0, the correlation is -0.3526826588536898.

Currently, I do not have any explanation for this behavior. Is there an error in my calculation of the correlation or the lags?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source