Time delay using xcorr function, two microphones
Ältere Kommentare anzeigen
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

Antworten (1)
Nikhil Sonavane
am 18 Mai 2020
0 Stimmen
Kategorien
Mehr zu Correlation and Convolution finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!