To illustrate the use of the cross correlation function, a source location example is shown below. For this it is assumed that there is a noise source at some unknown position between 2 microphones. A cross correlation technique and a transfer function like approach were used to determine the location.
To simulate the noise a broad band Gaussian signal was bandpass filtered from 500 to 1500Hz. This random signal, s(t), was generated at 10000 samples/second. Two delayed signals, p1(t) and p2(t), were then formed. Assuming the speed of sound in air is 1000ft/second then p1(t) was formed from s(t) with a 25 msec delay by ignoring the first 250 values. Similarly p2(t) was formed with 14msec delay by ignoring the first 140 values. In order to represent dispersion and other specific path effects, two unrelated Gaussian broad band signals, n1(t) and n2(t), were also generated, each with approximately 20% of the overall energy of the original signal. The microphone simulation signals, x1(t) and x2(t), were then formed from
x1(t) = p1(t) + n1(t)
x2(t) = p2(t) + n2(t)
A section of x1(t) and x2(t) is shown below
Correlating x2 with x1 as reference gave a peak in the cross correlation at -11 msecs as shown below
The distance between the microphones was 39 feet. A delay of -11 msecs represents a distance of -11 feet.
Thus if we let the distance of the source from microphone one be d1 and from microphone two be d2 then we have
d1 + d2 = 39
d2 – d1 = -11
Solving gives d2 = 14 feet and d1 = 25 feet which are the correct results.
Note that if we correlate x1 with x2 as the reference then the delay is 11 msecs as shown below.
In this case we have
d1 + d2 = 39
d1 – d2 = 11
Solving again gives d1 = 25 and d2 = 14.
An alternative approach is to carry out a form of transfer function analysis between the 2 microphones responses. This is not a strict transfer function which is normally an excitation and response to that excitation. However the delay information is still contained in the signals. Now the transfer function H(f) is defined by
where Gxx is the auto spectrum of the “excitation” and Gxy is the cross spectrum of the response with respect to the excitation. Once H(f) is known then the impulse response function h(t) may be found by inverse Fourier transforming H(f). The way in which h(t) is formed means that positive time delays are from 0 time to the mid time point and negative delays are from the last time point back to the midpoint. An option is available to carry out the time shift automatically.
The graphs below show the two auto spectra, the cross spectrum, the pseudo transfer function, the coherence function and the impulse response function.
The two auto spectra above are very similar as would be expected but differences are discernable. Also the broadband nature of the uncorrelated noise is evident at around the 62dB level.
The cross spectrum and the transfer function are also very similar except for scale. In both cases the phase has been unwrapped which shows the effective linear delay.
For reference purposes we have also shown the Coherence function.
As would be expected in this case the coherence outside the effective bandwidth of the signal is essentially zero. The coherence indicates that everything between about 500 to 1500 Hz is safe to believe but outside that region there is little or no relationship.
Finally the “Impulse Response” function was formed by calculating an inverse FFT of the “transfer function” and selecting the timeshift option to get positive and negative time shown.
The peak is just before zero. Showing an expanded view reveals the time delay as -11 msec as expected.
If we had just inverse transformed the cross spectrum we would have just got the correlation function. Dividing by the input auto spectrum is useful however because it effectively normalises the data. Another helpful scheme is to multiply the cross spectrum by the coherence as this effectively eliminates the unrelated parts. This is not necessary here as we have a sufficient signal to noise ratio.