I've a signal $x(n)$. I've generated its delayed copy named $x1(n)$ and applied xcorr function of MATLAB to find out the delay. It gives accurate delay.

Now I generated a noise signal and replaced the delay in $x1(n)$ by that noise. In this case, xcorr is not giving me accurate results. Do we have any such technique which works in case of noisy delays as well and gives us accurate delay?

I'm adding my code here as well.

close all;

[x, fs] = audioread('testing_voice.wav');

delay1 = 25;

%generating white noise equal to the length of delay

x = x(1:5760);
x1 = [X;x];
x1 = x1(1:5760);

[r,b] = xcorr(x1,x, 'normalized');
[~, index] = max(abs((r)));
delay = b(index);

Where delay = b(index) return us the total delay in signal.


1 Answer 1


That should work fine. If it doesn't, the issue is most likely with your signal 'testing_voice.wav'. Could be scaling, noise, or just too much pauses in the speech. Probable root cause is scaling: while your noise burst is short, the power is larger than any wave can carry so it's possible that your noise energy simply dominates the speech.

Matlab comes with a music signal. You can try

audioFile = load('handel.mat');
x = audioFile.y;
  • $\begingroup$ Thank you @Hilmar. I've tried this and it is working fine even in the presence of noise. So probably there is something wrong with our signal. Thank you for pointing it out. $\endgroup$ Sep 24, 2021 at 6:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.