samedi 26 avril 2014

Calculate autocorrelation in time domain vs FFT


Vote count:

0




I'm doing a pitch detection using a combination of an AKF and AMDF.

First I was using AKF in the time domain like this:



Get a buffer of 2048 samples
Window it (Hamming window)
sum=Sum(Buffer[i]*Buffer[i+lag]) for all i < 2048 - lag
akf = sum / 2048


And repeat the last 2 steps for all lags to be considered. (actually doing interpolation for non-integer lags)


Now I found that you can use FFT to calculate the AKF:



Get a buffer of 2048 samples
Window it (Hamming window)
fftBuf=fft(buffer)
buffer[i]=real(fftBuf[i])^2+imag(fftBuf[i])^2
fftBuf=fft(buffer) //ifft=fft for real signals
akfBuf = real(fftBuf) / 2048


I expected that the results will be the same or at least similar. But they are not. E.g for a 65.4Hz Sine wave (note C2) I get ~0.2 for a the corresponding lag of 674.25 using the time-domain approach and ~536.795 using the fft.


What did I miss? Or isn't both the same?



asked 38 secs ago






Aucun commentaire:

Enregistrer un commentaire