Time delay using xcorr function, two microphones

3 次查看(过去 30 天)
I need to determine the time difference in the signal arrival between two microphones. The microphones are 2m apart, I play two chrip audio signals and record it using 'audiorecorder'. As a result, I receive the plot below. One color is the signal recorded by one microphone, and the other color is the signal recored by the other one. So my question is how should I use xcorr function to get delay and is it even possible? I know vector of delays samples divided by sample frequency is equal to delay in seconds.
Thank you for any help.
close all;
clear all;
if true
clear;figure; grid on; hold on;
Fs = 4000; %sample frequency [Hz]
dt = 5; %time
r=audiorecorder(Fs,16,2); %recording
recordblocking(r,dt);
my_Speech=getaudiodata(r);
% convert to time (s)
tmax = length(my_Speech)/Fs;
t = linspace(0, tmax, dt*Fs);
%figure
plot(t*1000,my_Speech);
axis([0 tmax*1000 -2 2]);
xlabel('time (ms)');
% analysis
j = 1;
for i=1:length(my_Speech)
if my_Speech(i)>0.15
pick(j) = 1000*i/Fs;
fprintf('%3d --> %8.1f ms\n',j, pick(j));
j=j+1;
end
end
end

回答(1 个)

Nikhil Sonavane
Nikhil Sonavane 2020-5-18
You may refer another MATLAB answer which may help you solve your query.

产品

Community Treasure Hunt

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

Start Hunting!

Translated by