How to do autocorrelation with audio signal and parameters
조회 수: 112(최근 30일)
I have an audio file in .wav file. I'm trying to do autocorrelation with amplitudes r1= 0.6, r2=0.3, and delay parameters as k1=5sec, k2=12sec. Now, how do I carry on the autocorrelation with these values in place. I'll paste my code till whatever i've written. Please help me in aswering what to do next pertaining to my code.
disp('End of recording')
'test9.wav' is my recorded wav file, now please help me in how to find autocorrelation with the mentioned r1,r2,k1,k2 parameters.
Sourav Bairagya 2019년 9월 18일
To perform correlation between two signals, you can use ‘xcorr’ function.
In ‘xcorr’, if you provide only one input, output will be the autocorrelation of the signal for different lags.
[c,lags] = xcorr(x);
Here, ‘lags’ array stores the amounts of lags by which the signal is delayed, and ‘c’ array stores the corresponding values of the autocorrelation for that value of delays. Hence, after plotting ‘c’ against ‘lags’, you can visualize the values of autocorrelation at different delays.
To get normalized output (i.e. autocorrelation at zero delay will be 1 (max value when two signals are same) and for other delays it will be normalized with respect to this max value), you can use this command
[c,lags] = xcorr(x,'normalized');
Now, in your case if you are trying to find correlation between two versions of the input signal (one is with amplitude r1=0.6 and delay=5 sec and other is with amplitude r2=0.3 and delay=12 sec), then first generate those using ‘delayseq(input, delay, fs)’ function of ‘Phased Array System Toolbox’. Here, ‘delay’ is in seconds and ‘fs’is the sampling frequency.
x1 = delayseq(x,5,8000) % assuming fs = 8000 Hz and delay = 5 sec
x2 = delayseq(x,12,8000) % assuming fs = 8000 Hz and delay = 12 sec
x1 = 0.6*x1;
x2 = 0.3*x2;
Then you can use ‘xcorr’ function to find correlation between them.
[c,lags] = xcorr(x1,x2);
Hope this will help you.
For more information you can follow these links.