How to do autocorrelation with audio signal and parameters

37 Ansichten (letzte 30 Tage)
Hello,
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.
a= audiorecorder(8000,8,1);
disp('start speaking')
recordblocking(a,5);
disp('End of recording')
myrec= getaudiodata(a);
plot(myrec);
audiowrite('test9.wav',myrec,8000)
'test9.wav' is my recorded wav file, now please help me in how to find autocorrelation with the mentioned r1,r2,k1,k2 parameters.
Thank you

Akzeptierte Antwort

Sourav Bairagya
Sourav Bairagya am 18 Sep. 2019
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);
stem(lags,c);
Hope this will help you.
For more information you can follow these links.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by