# xcorr MATLAB is not giving accurate result in case of noisy signals

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.

clear;
close all;

delay1 = 25;

%generating white noise equal to the length of delay
mu=0;
sigma=2;
X=sigma*randn(delay1,1)+mu;

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.

audioFile = load('handel.mat');