GENERALIZED CROSS CORRELATION xcorr of TWO SIMULTANEOUSLY RECORDED AUDIO SIGNALS!
4 次查看(过去 30 天)
显示 更早的评论
Hi everyone! I'm trying to record two audio signals simultaneously and estimating the angle of sound source using the following code:
if true
fs = 48000 ;
recObj1 = audiorecorder(fs, 16, 1, 1);
recObj2 = audiorecorder(fs, 16, 1, 2);
record(recObj1); % recording starts
record(recObj2); % recording starts
pause(5); % recording for 5 seconds
stop(recObj1); % recording stops
stop(recObj2); % recording stops
out1 = getaudiodata(recObj1, 'int16');
out2 = getaudiodata(recObj2, 'int16');
[c, lags] = xcorr(out1, out2);
[a1, b1] = max(out1);
[a2, b2] = max(out2);
[a3, b3] = max(c);
s = lags(b3);
time_delay = s/fs ;
dis = 1 ; % distance between two microphones in meters
c = 342 ; % avg speed of sound at room temperature
angle = acosd((time_delay*c)/dis); % calculation of estimated angle
end
But the lags or time_delay is always different whenever I run the program again. IS it the right way of angle estimation using Cross Correlation function in MATLAB ? Please help if there is an efficient way of estimating the angles through slight changing or modification The sounds are being recorded by using 02 external USB microphones . Thank you!
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!