# Findin the source direction using cross-correlation function

I am new to DSP and I'm working on the following problem.

We have a sound source in the far ﬁeld and a microphone array consisting of two microphones with distance d. We want to determine the source direction by using the cross-correlation of the microphone signals x and y.

I was told that in order to find the angle, we first need to calculte the time delay (in samples) between the microphone signals x and y. I know we can do this by finding the maximum of cross-correlation function R_XY. However, I don't understand why the global maximum of R_XY happenes at this time delay, namely k0.

Let's say we find this time delay. Then how do we calculate the angle? (assuming we know the distance between these two microphones, sound-propagation velocity and the sampling frequency.

With just two microphones you cannot distinguish a unique location on a plane, but you can resolve two possible locations (but your accuracy may be significantly degraded due to reflections/ multipath). This is demonstrated in the graphic below:

Given one microphone and one resolved range (from time delay and sound propagation velocity), the possible location of the source is anywhere on a circle (on a 2D plane, or anywhere on a sphere in 3D space). With two microphones, this can be reduced to two points (on a 2D plane, or a circle in 3D space where the two spheres overlap).

To uniquely determine the location of the source on a 2D plane, 3 microphones would be required. But if you have further information, such as you know the source is in front of you such that you only need to resolve azimuth angle from -90° to +90°, then one of the two points that are resolved can be neglected.

Therefore the solution is solving the for the x,y location given the simultaneous equations for two circles on a 2D plane:

$$(x-x_1)^2 + (y-y_1)^2 = r_1^2$$ $$(x-x_2)^2 + (y-y_2)^2 = r_2^2$$

As a reminder if needed such a solution is worked out here: http://www.analyzemath.com/CircleEq/circle_intersection.html

By the way, this is exactly how location is determined with GPS (triangulation) as depicted in the graphic below showing how a unique location on a plane can be determined with known range to three satellites:

The graphic says "Simplified" as it is location on a 2D plane, but the explanation above using spheres instead of circles applies to determine location in a 3D space. Give the knowledge that the satellites are above, only 3 satellites would actually be required if we had accurate time as the other location in 3D space is in outer space so can be neglected. However, since we do not have sufficient time accuracy in the receiver, a 4th satellite is needed to determine that final unknown (thus with 4 satellites and 4 ranges to each we end up with 4 equations with 4 unknowns which can all be solved: x, y, z location in 3D space and time t).

• What if we want to do it with the help of cross-correlation function? – Niousha Nov 21 '18 at 20:07
• I am not sure of your question, are you asking how to find the max value in the cross correlation function? The cross correlation function gives you correlation vs delay, so it would make sense that your best estimate of delay occurs when the cross correlation is at a max value, correct? What is your question exactly? – Dan Boschen Nov 21 '18 at 20:10
• That's one of my questions. I don't understand why the best estimate of delay occurs when the cross-correlation function is at its max value? – Niousha Nov 21 '18 at 20:17
• I see-- I assume then that you don't know what correlation is? – Dan Boschen Nov 21 '18 at 20:18
• I know that cross-correlation measures the similarity between two signals, right? – Niousha Nov 21 '18 at 20:23