I have to calculate time delay between two signals.I am using the GCC-PHAT method. First, I cut the signals into smaller parts (~0.5s) and then try to calculate the delay. When I display those two signals on the graph, the delay is very obvious.
The problem is that for some parts of that long signal, my program calculates the correct delay, but for some parts the delay is totally incorrect. In both cases, when I display those two signals on the graph, the delay seems very obvious.
duration=20000 a=hanning(duration+1) [signal1,Fs] = audioread(mic1); [signal2,Fs] = audioread(mic2); start=1000; stop=start+duration; x1=[a.*signal1(start:stop)]; x2=[a.*signal2(start:stop)]; A=fft(x1); B=fft(x2); PHAT=A.*conj(B)./(abs((A).*conj(B))); result=abs(ifft(PHAT));
I recorded those signals in a closed room, so there are probably also reverberations. Am I doing something wrong? Or is this method just not very effective in my circumstances?
I also tried to prefilter signals, but the results were the same. There is also no improvement, if I change the length of the signals.