DSPRelated.com
Forums

FFT

Started by maz_p5 September 10, 2008
Hi,

I am working on calculating the delay between the 2 sound sources arrived
on the microphones. The sound sources are not exactly the same due to the
various factors. I have tried cross - correlation but I have unsuccessful.
I have heard about frequency cross-correlation using FFT for determining
the delay. How do I do that in MATLAB? Can someone please explain with the
help of an example code. Thank you. 
On Sep 10, 4:50&#4294967295;pm, "maz_p5" <maz...@hotmail.com> wrote:
> Hi, > > I am working on calculating the delay between the 2 sound sources arrived > on the microphones. The sound sources are not exactly the same due to the > various factors. I have tried cross - correlation but I have unsuccessful. > I have heard about frequency cross-correlation using FFT for determining > the delay. How do I do that in MATLAB? Can someone please explain with the > help of an example code. Thank you.
Well, you find the fourier transform of each signal and then find the hermitian inner product of the two spectra. Then find the inverse fourier transform of the inner product. This will be the cross correlation. Now since you have finite length signals and will likely be doing discrete fourier transforms (via the FFT), you will have periodicity (wrap around) to contend with. Now if you stop before doing the final inverse transform, you can find the argument of each product term in the hermitian inner product and plot these as a function of frequency. The slope (derivative) of this phase function is the time difference. Since you keep asking for Matlab code, do you understand the theory and not know Matlab or do you not understand either one? I gave you a very functional and efficient method for solving the time difference of arrival equations. It should be quite simple to translate it to Matlab. A simpler but less efficient way is to divide your search space up into a big grid, then for each grid square calculate the total squared error. Then pick the grid that has the least error. You may even further subdivide that grid square into smaller grids until your positional error meets some criteria. Maybe you can get this way to work. Clay
On Sep 11, 8:50 am, "maz_p5" <maz...@hotmail.com> wrote:
> Hi, > > I am working on calculating the delay between the 2 sound sources arrived > on the microphones. The sound sources are not exactly the same due to the > various factors. I have tried cross - correlation but I have unsuccessful. > I have heard about frequency cross-correlation using FFT for determining > the delay. How do I do that in MATLAB? Can someone please explain with the > help of an example code. Thank you.
Cross correlation will work but it is a bit slow and gives a distinct peak at the delay only when the sound source is white! You need generalized cross-correlation for this. Perhaps the Hanan Thomson method or the SCOT transform. Doing an FFT in the frequency domain will not solve the fundamental problem, only speed things up. K.
On 10 sep, 22:50, "maz_p5" <maz...@hotmail.com> wrote:
> Hi, > > I am working on calculating the delay between the 2 sound sources arrived > on the microphones. The sound sources are not exactly the same due to the > various factors. I have tried cross - correlation but I have unsuccessful. > I have heard about frequency cross-correlation using FFT for determining > the delay. How do I do that in MATLAB? Can someone please explain with the > help of an example code. Thank you.
Hi, as an alternative to the response of Clay, you can also compute the phase of the ratio of the fft of your signals. Indeed, suppose that the temporal relation between your signals x1 and x2 is: x2(n)= alpha * x1 (n- tau) (where alpha and tau are resp. unknown scale coefficient and time shift). Then, the FFT of these signals read: X2(f)=alpha * X1(f) * exp{- j*2*pi*f*tau}. As a consequence, the variations of the phase of the ratio X2(f)/X1(f) with respect to the frequency correspond to a line and its slope is equal to 2*pi*tau. Using a simple regression line of these variations provides tau. This very simple procedure has been used for time- frequency ratios in source separation problems [1] (this paper is accessible from www.ast.obs-mip.fr/puigt ) and gives good performance. Hope this will help you. Matthieu [1] M. Puigt, Y. Deville, Time-frequency ratio-based blind separation methods for attenuated and time-delayed sources, Mechanical System and Signal Processing (MSSP), Volume 19, Issue 6, pp. 1348-1379, November 2005.