3
$\begingroup$

I wish to calculate the time difference between a signal (may or may not be periodic), arriving at the right and left channel of a stereo microphone pair kept at a distance of about 30 cm. I am doing so to localize the acoustic source.

I compute the FFT of the left channel and the right channel, and then find the values of the FFT at a particular frequency bin of interest. I then divide the (complex) values to get the phase difference in radians. I then convert the phase difference to a time difference ( time difference = phase difference / 2* pi ) and use this to calculate the angle of arrival of the acoustic source.

What are the ambiguities that could occur in this method of calculating the time difference, as compared to a cross-correlation method of finding time difference?

I am using this method rather than cross-correlation due to the frequency dependence of the phase difference.

$\endgroup$
1
  • $\begingroup$ Samyukta - Please see my response to this post on equalizing the left and right channels including the compact Matlab code that can be used; the delay of the equalizer response would be the delay between the channels; accounting for all multipath effects. dsp.stackexchange.com/questions/31318/… $\endgroup$ Commented Nov 4, 2016 at 4:01

2 Answers 2

2
$\begingroup$

For a constant time difference, the unwrapped phase difference measured at the centers of the two windows is linearly related to frequency. (To measure phase at the center of an FFT window, use an fftshift prior to the FFT, or flip the phase of the odd numbered FFT result bins.) So you can use all of the FFT results, not just one bin. The low frequency bins may help in determining the potentially ambiguous phase unwrapping of the higher frequency bins, if the signal is sufficiently wideband.

$\endgroup$
1
  • $\begingroup$ what hot says is true. but, at high frequencies, you might somehow get off by a whole multiple of $2 \pi$. really the safest thing to say is to say that difference of the principle values of the phase (what is between $-\pi$ and $+\pi$) between the two is, ideally, $$ \phi_y[k] - \phi_x[k] = 2 \pi (\tfrac{k}{N} \tau_{yx} + m[k]) $$ where $m[k]$ is an integer and $m[0]=0$ and $0 \le m[k+1]-m[k] \le 1$. And $\tau_{yx}$ is the distance, measured in sample periods, that microphone $y$ is further from the source than microphone $x$. And $N$ is the FFT size. $\endgroup$ Commented Jun 2, 2017 at 3:18
1
$\begingroup$

I don't think your method will work very effectively. check out this post about detecting phase in different types of signals. The link suggests that for more complex signals using FFTs for detecting phase is a poor method.

I would suggest using more standard beamforming based DOA methods, such as the Delay-and-Sum beamformer. There is a Matlab toolbox to help if the maths looks a bit confusing. However seeing as you are interested in a narrowband (i.e. one frequency) in a wideband source (audio, 20Hz-20kHz) I would suggest applying a bandpass filter to the audio data first and then performing a DOA algorithm.

Also bare in mind that to avoid Spatial Aliasing, the distance between microphones must be < $\frac{\lambda}{2}$ where $\lambda$ is the wavelength of the frequency of interest. At 30cm the highest frequency you can localize without ambiguity would be about 560Hz

$\endgroup$
2
  • $\begingroup$ I did however tried to use a bandpass filter to keep only the frequencies of interest. I had applied the same filter (bandpass elliptic, elliptic to have a high attenuation in the stop band for a low order of filter). The code is implemented in python. However, after applying the filter, not only is the algorithm extremely slow, it also isn't able to correctly calculate the time difference between the sound arriving at the two microphones. $\endgroup$ Commented Nov 7, 2016 at 10:15
  • $\begingroup$ My main issue with your method is the use of the FFT to extrapolate the phase. My suggestion would be to implement a Delay-and-Sum DOA algorithm. I have implemented that exact algorithm with 4 microphones and it computes 10 times faster than real time. $\endgroup$
    – Makoto
    Commented Nov 7, 2016 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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