cross correlation sound

This is a discussion on cross correlation sound within the DSP forums in Other Technologies category; Hello, My name is maz and I am working on simple sound source localization. I have to find the location of a sound source on a 2d plane. (I am not considering z axis). I have 4 mics placed on a wooden platform, the co-ordinates of which are m1(0,0), m2(0,6), m3(4,6), m4(4,0). del12 is the difference between the distance from mic 1 to the source and from mic 2 to the source. del12=(delay between the 1st mic and the 2nd x v sound i.e. 340m/s)/fs i.e. 44000. My question is how do I calculate the delay between these two sound ...

Go Back   Application Development Forum > Other Technologies > DSP

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-24-2008, 04:57 AM
maz_p5
Guest
 
Default cross correlation sound

Hello,
My name is maz and I am working on simple sound source localization. I
have to find the location of a sound source on a 2d plane. (I am not
considering z axis). I have 4 mics placed on a wooden platform, the
co-ordinates of which are m1(0,0), m2(0,6), m3(4,6), m4(4,0). del12 is
the
difference between the distance from mic 1 to the source and from mic 2
to
the source. del12=(delay between the 1st mic and the 2nd x v sound i.e.
340m/s)/fs i.e. 44000. My question is how do I calculate the delay
between
these two sound signals using cross-correlation in matlab. (I am not
considering sound for the start as i have taken the readings in a sound
free environment). I do not know since I am still learning. Can you
please
explain with the help of the matlab code. Thank you. PLEASE HELP


Reply With Quote
  #2  
Old 08-24-2008, 05:31 AM
kronecker@yahoo.co.uk
Guest
 
Default Re: cross correlation sound

On Aug 24, 8:57 pm, "maz_p5" <maz...@hotmail.com> wrote:
> Hello,
> My name is maz and I am working on simple sound source localization. I
> have to find the location of a sound source on a 2d plane. (I am not
> considering z axis). I have 4 mics placed on a wooden platform, the
> co-ordinates of which are m1(0,0), m2(0,6), m3(4,6), m4(4,0). del12 is
> the
> difference between the distance from mic 1 to the source and from mic 2
> to
> the source. del12=(delay between the 1st mic and the 2nd x v sound i.e.
> 340m/s)/fs i.e. 44000. My question is how do I calculate the delay
> between
> these two sound signals using cross-correlation in matlab. (I am not
> considering sound for the start as i have taken the readings in a sound
> free environment). I do not know since I am still learning. Can you
> please
> explain with the help of the matlab code. Thank you. PLEASE HELP


There are many papers which formulate this type of problem. You could
start here

IEEE TRANSACTIONS ON ACOUSTICS, SPEECH, AND SIGNAL PROCESSING, VOL.
ASSP-29, NO. 3, JUNE 1981
Time Delay Estimation for Passive Sonar
Signal Processing by C.Carter

For the 3 microphone solution there is a simple formula (eq 8a and 8b
in this paper). This will give you the range and the bearing.
You can use more microphones and then the problem is over-determined
(more equations than unknowns).
Cross correlation per-se is not brilliant. See the paper where they
use Generalized Cross Correlation.


K.
Reply With Quote
  #3  
Old 08-24-2008, 10:58 AM
Eric Jacobsen
Guest
 
Default Re: cross correlation sound

On Sun, 24 Aug 2008 02:31:35 -0700 (PDT), kronecker@yahoo.co.uk wrote:

>On Aug 24, 8:57 pm, "maz_p5" <maz...@hotmail.com> wrote:
>> Hello,
>> My name is maz and I am working on simple sound source localization. I
>> have to find the location of a sound source on a 2d plane. (I am not
>> considering z axis). I have 4 mics placed on a wooden platform, the
>> co-ordinates of which are m1(0,0), m2(0,6), m3(4,6), m4(4,0). del12 is
>> the
>> difference between the distance from mic 1 to the source and from mic 2
>> to
>> the source. del12=(delay between the 1st mic and the 2nd x v sound i.e.
>> 340m/s)/fs i.e. 44000. My question is how do I calculate the delay
>> between
>> these two sound signals using cross-correlation in matlab. (I am not
>> considering sound for the start as i have taken the readings in a sound
>> free environment). I do not know since I am still learning. Can you
>> please
>> explain with the help of the matlab code. Thank you. PLEASE HELP

>
>There are many papers which formulate this type of problem. You could
>start here
>
>IEEE TRANSACTIONS ON ACOUSTICS, SPEECH, AND SIGNAL PROCESSING, VOL.
>ASSP-29, NO. 3, JUNE 1981
>Time Delay Estimation for Passive Sonar
>Signal Processing by C.Carter
>
>For the 3 microphone solution there is a simple formula (eq 8a and 8b
>in this paper). This will give you the range and the bearing.
>You can use more microphones and then the problem is over-determined
>(more equations than unknowns).
>Cross correlation per-se is not brilliant. See the paper where they
>use Generalized Cross Correlation.
>


I was going to download this paper and discovered that just being a
member of the Signal Processing Society isn't enough to get access to
transactions papers. I dropped my transaction subscription a couple
of years ago since the new papers have seemed pretty irrelevant to
what I do.

Annoying.

Eric Jacobsen
Minister of Algorithms
Abineau Communications
http://www.ericjacobsen.org

Blog: http://www.dsprelated.com/blogs-1/hf/Eric_Jacobsen.php
Reply With Quote
  #4  
Old 08-24-2008, 10:59 PM
kevinjmcgee@netscape.net
Guest
 
Default Re: cross correlation sound

On Aug 24, 4:57*am, "maz_p5" <maz...@hotmail.com> wrote:
> Hello,
> My name is maz and I am working on simple sound source localization. I
> have to find the location of a sound source on a 2d plane. (I am not
> considering z axis). I have 4 mics placed on a wooden platform, the
> co-ordinates of which are m1(0,0), m2(0,6), m3(4,6), m4(4,0). del12 is
> the
> difference between the distance from mic 1 to the source and from mic 2
> to
> the source. del12=(delay between the 1st mic and the 2nd x v sound i.e.
> 340m/s)/fs i.e. 44000. My question is how do I calculate the delay
> between
> these two sound signals using cross-correlation in matlab. (I am not
> considering sound for the start as i have taken the readings in a sound
> free environment). I do not know since I am still learning. Can you
> please
> explain with the help of the matlab code. Thank you. PLEASE HELP


Perhaps I can help with the cross correlation. Let’s envision a 2
dimensional plane with north, south, east and west directions. Now
suppose we have two sensors on the horizontal east/west axis. Each
sensor is spaced the same distance either side of the vertical north/
south axis. Call the east sensor #1 and the west sensor #2. Now
suppose we have some waveform (a sine wave, truncated sinc, AWGN,
whatever) moving down from the north. We'll presume that the signal
is planar (the 'far field' condition; i.e.: no wavefront curvature).

Arriving from the north, the waveform will hit both sensors at the
same time. Note that with omnidirectional sensors, you can't tell if
the waveform is arriving from the north or south. However, many
sensors have some directionality to them, so let's presume that our 2
sensors are more sensitive to the north/east/west directions.

Now we sample and zero pad outputs of both sensors in an appropriate
way to avoid doing a circular cross correlation. Then we FFT each
zero padded sensor output, conjugate one of the results, multiply them
in the frequency domain, and inverse transform. This is a cross
correlation. If we didn't do the conjugation bit before multiplying
the 2 FFT results, we'd get a convolution of the 2 sensor outputs, and
that's not what we want.

If we were to look at the result when the waveform arrives from the
north, we’d find that there’s a peak in the cross correlation result
at the 0 point after the inverse FFT (zero time delay).

Now suppose the waveform arrives from the northeast. It will arrive
at sensor 1 before sensor 2. We’d do the same processing as before,
but it begs the question: “which zero padded sensor FFT results do we
conjugate?” It makes a difference. For the above example, if you
conjugate the FFT result of sensor 2 (the left or west side one),
you’d find that, as the waveform arrival moves from the north to the
northeast, the peak in your cross correlation result moves to the
right of the 0 point in the results. When the waveform moves from the
north to the northwest, the peak moves to the left of the 0 point in
the results (i.e.: it shows up in the upper part of the inverse FFT
results).

The above describes cross correlation processing, but there are
problems with it. For instance, with many waveforms, the cross
correlation peak will appear as a maximum with a gentle roll off as
one moves away from the peak. The moment you add some noise to the
problem, things become very difficult. It’s better to use a
‘generalized’ cross correlator, where one uses a window or filter in
the frequency domain (and they’re very different than what most people
are used to). When using a properly calculated frequency domain
window, the improvement of the time delay estimation in a noisy
environment can be significant. Here’s 3 references that may or may
not be helpful:

J. C. Hassab, R. E. Boucher, “Optimum Estimation of Time Delay by a
Generalized Correlator,” IEEE T-ASSP, vol. 27, no. 4, Aug. 1979, pp.
373-380.

J. C. Hassab, R. E. Boucher, “Performance of the Generalized Cross
Correlator in the Presence of a Strong Spectral Peak in the Signal,”
IEEE T-ASSP, vol. 29, no. 3, June 1981, pp. 549-555.

J. C. Hassab, R. E. Boucher, “An Experimental Comparison of Optimum
and Sub-Optimum Filters’ Effectiveness in the Generalized Correlator,”
J. Sound and Vibration, 1981, pp. 4+ (12 pages total).

You might look for some simpler processing references to start with
(e.g.: use the references mentioned in the above).

The description provided here barely scratches the surface. I
couldn’t begin to describe the problems of dealing with weak AWGN
signals in strong sinusoidal noise. In addition, sensor spacing plays
a role. Typically, in an acoustic system, sensor spacing is at the
‘half wavelength’ of the ‘design frequency’ of the sensor array. Then
anti-aliasing is applied to limit the frequencies in the input to be
below the design frequency (or sometimes not, depending on the
sophistication of the processing).

I would suggest that you try some simple simulation experiments at
first using different waveforms and change the delays between them
while using a simple cross correlator. You might try a generalized
cross correlator, but that’s very ambitious without having taken a
course in time delay estimation.
Reply With Quote
  #5  
Old 08-25-2008, 05:56 AM
maz_p5
Guest
 
Default Re: cross correlation sound

>On Aug 24, 4:57=A0am, "maz_p5" <maz...@hotmail.com> wrote:
>> Hello,
>> My name is maz and I am working on simple sound source localization. I
>> have to find the location of a sound source on a 2d plane. (I am not
>> considering z axis). I have 4 mics placed on a wooden platform, the
>> co-ordinates of which are m1(0,0), m2(0,6), m3(4,6), m4(4,0). del12 is
>> the
>> difference between the distance from mic 1 to the source and from mic

2
>> to
>> the source. del12=3D(delay between the 1st mic and the 2nd x v sound

i.e.
>> 340m/s)/fs i.e. 44000. My question is how do I calculate the delay
>> between
>> these two sound signals using cross-correlation in matlab. (I am not
>> considering sound for the start as i have taken the readings in a

sound
>> free environment). I do not know since I am still learning. Can you
>> please
>> explain with the help of the matlab code. Thank you. PLEASE HELP

>
>Perhaps I can help with the cross correlation. Let=92s envision a 2
>dimensional plane with north, south, east and west directions. Now
>suppose we have two sensors on the horizontal east/west axis. Each
>sensor is spaced the same distance either side of the vertical north/
>south axis. Call the east sensor #1 and the west sensor #2. Now
>suppose we have some waveform (a sine wave, truncated sinc, AWGN,
>whatever) moving down from the north. We'll presume that the signal
>is planar (the 'far field' condition; i.e.: no wavefront curvature).
>
>Arriving from the north, the waveform will hit both sensors at the
>same time. Note that with omnidirectional sensors, you can't tell if
>the waveform is arriving from the north or south. However, many
>sensors have some directionality to them, so let's presume that our 2
>sensors are more sensitive to the north/east/west directions.
>
>Now we sample and zero pad outputs of both sensors in an appropriate
>way to avoid doing a circular cross correlation. Then we FFT each
>zero padded sensor output, conjugate one of the results, multiply them
>in the frequency domain, and inverse transform. This is a cross
>correlation. If we didn't do the conjugation bit before multiplying
>the 2 FFT results, we'd get a convolution of the 2 sensor outputs, and
>that's not what we want.
>
>If we were to look at the result when the waveform arrives from the
>north, we=92d find that there=92s a peak in the cross correlation result
>at the 0 point after the inverse FFT (zero time delay).
>
>Now suppose the waveform arrives from the northeast. It will arrive
>at sensor 1 before sensor 2. We=92d do the same processing as before,
>but it begs the question: =93which zero padded sensor FFT results do we
>conjugate?=94 It makes a difference. For the above example, if you
>conjugate the FFT result of sensor 2 (the left or west side one),
>you=92d find that, as the waveform arrival moves from the north to the
>northeast, the peak in your cross correlation result moves to the
>right of the 0 point in the results. When the waveform moves from the
>north to the northwest, the peak moves to the left of the 0 point in
>the results (i.e.: it shows up in the upper part of the inverse FFT
>results).
>
>The above describes cross correlation processing, but there are
>problems with it. For instance, with many waveforms, the cross
>correlation peak will appear as a maximum with a gentle roll off as
>one moves away from the peak. The moment you add some noise to the
>problem, things become very difficult. It=92s better to use a
>=91generalized=92 cross correlator, where one uses a window or filter in
>the frequency domain (and they=92re very different than what most people
>are used to). When using a properly calculated frequency domain
>window, the improvement of the time delay estimation in a noisy
>environment can be significant. Here=92s 3 references that may or may
>not be helpful:
>
>J. C. Hassab, R. E. Boucher, =93Optimum Estimation of Time Delay by a
>Generalized Correlator,=94 IEEE T-ASSP, vol. 27, no. 4, Aug. 1979, pp.
>373-380.
>
>J. C. Hassab, R. E. Boucher, =93Performance of the Generalized Cross
>Correlator in the Presence of a Strong Spectral Peak in the Signal,=94
>IEEE T-ASSP, vol. 29, no. 3, June 1981, pp. 549-555.
>
>J. C. Hassab, R. E. Boucher, =93An Experimental Comparison of Optimum
>and Sub-Optimum Filters=92 Effectiveness in the Generalized

Correlator,=94
>J. Sound and Vibration, 1981, pp. 4+ (12 pages total).
>
>You might look for some simpler processing references to start with
>(e.g.: use the references mentioned in the above).
>
>The description provided here barely scratches the surface. I
>couldn=92t begin to describe the problems of dealing with weak AWGN
>signals in strong sinusoidal noise. In addition, sensor spacing plays
>a role. Typically, in an acoustic system, sensor spacing is at the
>=91half wavelength=92 of the =91design frequency=92 of the sensor array.

T=
>hen
>anti-aliasing is applied to limit the frequencies in the input to be
>below the design frequency (or sometimes not, depending on the
>sophistication of the processing).
>
>I would suggest that you try some simple simulation experiments at
>first using different waveforms and change the delays between them
>while using a simple cross correlator. You might try a generalized
>cross correlator, but that=92s very ambitious without having taken a
>course in time delay estimation.


Hello,
This sounds really confusing to me. I think it doesnt matter from where
the sound is coming as far as there will be a difference in the arrival and
difference in the position of the peak when i plot the wave file in matlab.
I have captured sound from a position between the 4 mics and I can see the
difference in the peak.
lets not consider noise at all because I have taken the readings in a
nosie free environment. can i find the time difference of arrival using
"xcorr"? if yes, How can i do that?
>

Reply With Quote
  #6  
Old 08-25-2008, 05:04 PM
kronecker@yahoo.co.uk
Guest
 
Default Re: cross correlation sound

On Aug 25, 9:56 pm, "maz_p5" <maz...@hotmail.com> wrote:
> >On Aug 24, 4:57=A0am, "maz_p5" <maz...@hotmail.com> wrote:
> >> Hello,
> >> My name is maz and I am working on simple sound source localization. I
> >> have to find the location of a sound source on a 2d plane. (I am not
> >> considering z axis). I have 4 mics placed on a wooden platform, the
> >> co-ordinates of which are m1(0,0), m2(0,6), m3(4,6), m4(4,0). del12 is
> >> the
> >> difference between the distance from mic 1 to the source and from mic

> 2
> >> to
> >> the source. del12=3D(delay between the 1st mic and the 2nd x v sound

> i.e.
> >> 340m/s)/fs i.e. 44000. My question is how do I calculate the delay
> >> between
> >> these two sound signals using cross-correlation in matlab. (I am not
> >> considering sound for the start as i have taken the readings in a

> sound
> >> free environment). I do not know since I am still learning. Can you
> >> please
> >> explain with the help of the matlab code. Thank you. PLEASE HELP

>
> >Perhaps I can help with the cross correlation. Let=92s envision a 2
> >dimensional plane with north, south, east and west directions. Now
> >suppose we have two sensors on the horizontal east/west axis. Each
> >sensor is spaced the same distance either side of the vertical north/
> >south axis. Call the east sensor #1 and the west sensor #2. Now
> >suppose we have some waveform (a sine wave, truncated sinc, AWGN,
> >whatever) moving down from the north. We'll presume that the signal
> >is planar (the 'far field' condition; i.e.: no wavefront curvature).

>
> >Arriving from the north, the waveform will hit both sensors at the
> >same time. Note that with omnidirectional sensors, you can't tell if
> >the waveform is arriving from the north or south. However, many
> >sensors have some directionality to them, so let's presume that our 2
> >sensors are more sensitive to the north/east/west directions.

>
> >Now we sample and zero pad outputs of both sensors in an appropriate
> >way to avoid doing a circular cross correlation. Then we FFT each
> >zero padded sensor output, conjugate one of the results, multiply them
> >in the frequency domain, and inverse transform. This is a cross
> >correlation. If we didn't do the conjugation bit before multiplying
> >the 2 FFT results, we'd get a convolution of the 2 sensor outputs, and
> >that's not what we want.

>
> >If we were to look at the result when the waveform arrives from the
> >north, we=92d find that there=92s a peak in the cross correlation result
> >at the 0 point after the inverse FFT (zero time delay).

>
> >Now suppose the waveform arrives from the northeast. It will arrive
> >at sensor 1 before sensor 2. We=92d do the same processing as before,
> >but it begs the question: =93which zero padded sensor FFT results do we
> >conjugate?=94 It makes a difference. For the above example, if you
> >conjugate the FFT result of sensor 2 (the left or west side one),
> >you=92d find that, as the waveform arrival moves from the north to the
> >northeast, the peak in your cross correlation result moves to the
> >right of the 0 point in the results. When the waveform moves from the
> >north to the northwest, the peak moves to the left of the 0 point in
> >the results (i.e.: it shows up in the upper part of the inverse FFT
> >results).

>
> >The above describes cross correlation processing, but there are
> >problems with it. For instance, with many waveforms, the cross
> >correlation peak will appear as a maximum with a gentle roll off as
> >one moves away from the peak. The moment you add some noise to the
> >problem, things become very difficult. It=92s better to use a
> >=91generalized=92 cross correlator, where one uses a window or filter in
> >the frequency domain (and they=92re very different than what most people
> >are used to). When using a properly calculated frequency domain
> >window, the improvement of the time delay estimation in a noisy
> >environment can be significant. Here=92s 3 references that may or may
> >not be helpful:

>
> >J. C. Hassab, R. E. Boucher, =93Optimum Estimation of Time Delay by a
> >Generalized Correlator,=94 IEEE T-ASSP, vol. 27, no. 4, Aug. 1979, pp.
> >373-380.

>
> >J. C. Hassab, R. E. Boucher, =93Performance of the Generalized Cross
> >Correlator in the Presence of a Strong Spectral Peak in the Signal,=94
> >IEEE T-ASSP, vol. 29, no. 3, June 1981, pp. 549-555.

>
> >J. C. Hassab, R. E. Boucher, =93An Experimental Comparison of Optimum
> >and Sub-Optimum Filters=92 Effectiveness in the Generalized

> Correlator,=94
> >J. Sound and Vibration, 1981, pp. 4+ (12 pages total).

>
> >You might look for some simpler processing references to start with
> >(e.g.: use the references mentioned in the above).

>
> >The description provided here barely scratches the surface. I
> >couldn=92t begin to describe the problems of dealing with weak AWGN
> >signals in strong sinusoidal noise. In addition, sensor spacing plays
> >a role. Typically, in an acoustic system, sensor spacing is at the
> >=91half wavelength=92 of the =91design frequency=92 of the sensor array.

> T=
> >hen
> >anti-aliasing is applied to limit the frequencies in the input to be
> >below the design frequency (or sometimes not, depending on the
> >sophistication of the processing).

>
> >I would suggest that you try some simple simulation experiments at
> >first using different waveforms and change the delays between them
> >while using a simple cross correlator. You might try a generalized
> >cross correlator, but that=92s very ambitious without having taken a
> >course in time delay estimation.

>
> Hello,
> This sounds really confusing to me. I think it doesnt matter from where
> the sound is coming as far as there will be a difference in the arrival and
> difference in the position of the peak when i plot the wave file in matlab.
> I have captured sound from a position between the 4 mics and I can see the
> difference in the peak.
> lets not consider noise at all because I have taken the readings in a
> nosie free environment. can i find the time difference of arrival using
> "xcorr"? if yes, How can i do that?
>
>


You know from the ccor in samples. Suppose the peak occurs at 5 sample
intervals. Then the TDOA is 5*Ts where Ts is the sampling interval of
your original data. It could also be -5 steps though so watch the
sign.

K.
Reply With Quote
  #7  
Old 08-25-2008, 09:34 PM
kevinjmcgee@netscape.net
Guest
 
Default Re: cross correlation sound

On Aug 25, 5:04*pm, kronec...@yahoo.co.uk wrote:

> You know from the ccor in samples. Suppose the peak occurs at 5 sample
> intervals. Then the TDOA is 5*Ts where Ts is the sampling interval of
> your original data. It could also be -5 steps though so watch the
> sign.
>
> K.- Hide quoted text -
>
> - Show quoted text -


Thanks, K. I hope I’m not adding to the guy’s confusion, but cross
correlation isn’t the easiest thing for a beginner to figure out. I
started writing a response to his last question (obviously, I’m a
little late), and rather than throw it away, I’ll post it anyways.

After doing the cross correlation, you're back in the time domain.
You had a sample rate, so if the peak is displaced by 'x' number of
samples from the zero point (or, in your case, since you're using
MATLAB, the 1 point), you can directly determine the delay. Consider
a pure sinusoidal signal. If the peak is displaced by 5 points to the
right of the 0 point, it says that one waveform is delayed by 5 sample
times from the other. If the peak is displaced 5 points to the left
of the 0 point (it’s in the upper half of the inverse FFT outputs), it
says that the other waveform is delayed by 5 sample times. So (for an
FFT of even N), if the peak is between points 0 and N/2, then that’s
your time delay in sample times. If the peak is from N/2 + 1 to N -
1, then the delay would be counted from there up to the 0 point.
Seems simple enough. Perhaps you're being overly confused by the
sound speed, sensor displacement, etc. The sensor displacement would
come into play if they are, say, a multiple number of wavelengths
apart. In that case, the actual physical delay would be the
displacement of the peak plus some multiple of N sample times. And if
you’re using some kind of short time impulse type signal, you might
not get any result (e.g.: the waveform hits the second sensor 10
seconds after hitting the first sensor, but the time span of the
inverse FFT is only 1 second).

Reply With Quote
  #8  
Old 08-27-2008, 03:36 AM
maz_p5
Guest
 
Default Re: cross correlation sound

>On Aug 25, 5:04=A0pm, kronec...@yahoo.co.uk wrote:
>
>> You know from the ccor in samples. Suppose the peak occurs at 5 sample
>> intervals. Then the TDOA is 5*Ts where Ts is the sampling interval of
>> your original data. It could also be -5 steps though so watch the
>> sign.
>>
>> K.- Hide quoted text -
>>
>> - Show quoted text -

>
>Thanks, K. I hope I=92m not adding to the guy=92s confusion, but cross
>correlation isn=92t the easiest thing for a beginner to figure out. I
>started writing a response to his last question (obviously, I=92m a
>little late), and rather than throw it away, I=92ll post it anyways.
>
>After doing the cross correlation, you're back in the time domain.
>You had a sample rate, so if the peak is displaced by 'x' number of
>samples from the zero point (or, in your case, since you're using
>MATLAB, the 1 point), you can directly determine the delay. Consider
>a pure sinusoidal signal. If the peak is displaced by 5 points to the
>right of the 0 point, it says that one waveform is delayed by 5 sample
>times from the other. If the peak is displaced 5 points to the left
>of the 0 point (it=92s in the upper half of the inverse FFT outputs), it
>says that the other waveform is delayed by 5 sample times. So (for an
>FFT of even N), if the peak is between points 0 and N/2, then that=92s
>your time delay in sample times. If the peak is from N/2 + 1 to N -
>1, then the delay would be counted from there up to the 0 point.
>Seems simple enough. Perhaps you're being overly confused by the
>sound speed, sensor displacement, etc. The sensor displacement would
>come into play if they are, say, a multiple number of wavelengths
>apart. In that case, the actual physical delay would be the
>displacement of the peak plus some multiple of N sample times. And if
>you=92re using some kind of short time impulse type signal, you might
>not get any result (e.g.: the waveform hits the second sensor 10
>seconds after hitting the first sensor, but the time span of the
>inverse FFT is only 1 second).
>
>


Hi,
Thank you but I seriously cant get the hang of what you are trying to say.
I am an amateur in MATLAB and hence i am getting confused. I also think
that its not necessary to consider the things you are saying.

My question is simple - how do i calculate the delay between the peaks of
2 different signals? (both of my signals are just simple horizontal lines
with a peak at a particular sample i.e noise is almost null. The signals
have just one peak in them, both arriving at different time. The rest of
the signal is almost close to a straight line. The signals are captured at
44000Hz and the total size of both the signals is 431020).

I hope someone can help me now with a simple solution. If possible please
try and explain with a code. Thank you.

Reply With Quote
  #9  
Old 08-27-2008, 06:53 AM
maz_p5
Guest
 
Default Re: cross correlation sound

>>On Aug 25, 5:04=A0pm, kronec...@yahoo.co.uk wrote:
>>
>>> You know from the ccor in samples. Suppose the peak occurs at 5

sample
>>> intervals. Then the TDOA is 5*Ts where Ts is the sampling interval of
>>> your original data. It could also be -5 steps though so watch the
>>> sign.
>>>
>>> K.- Hide quoted text -
>>>
>>> - Show quoted text -

>>
>>Thanks, K. I hope I=92m not adding to the guy=92s confusion, but cross
>>correlation isn=92t the easiest thing for a beginner to figure out. I
>>started writing a response to his last question (obviously, I=92m a
>>little late), and rather than throw it away, I=92ll post it anyways.
>>
>>After doing the cross correlation, you're back in the time domain.
>>You had a sample rate, so if the peak is displaced by 'x' number of
>>samples from the zero point (or, in your case, since you're using
>>MATLAB, the 1 point), you can directly determine the delay. Consider
>>a pure sinusoidal signal. If the peak is displaced by 5 points to the
>>right of the 0 point, it says that one waveform is delayed by 5 sample
>>times from the other. If the peak is displaced 5 points to the left
>>of the 0 point (it=92s in the upper half of the inverse FFT outputs),

it
>>says that the other waveform is delayed by 5 sample times. So (for an
>>FFT of even N), if the peak is between points 0 and N/2, then that=92s
>>your time delay in sample times. If the peak is from N/2 + 1 to N -
>>1, then the delay would be counted from there up to the 0 point.
>>Seems simple enough. Perhaps you're being overly confused by the
>>sound speed, sensor displacement, etc. The sensor displacement would
>>come into play if they are, say, a multiple number of wavelengths
>>apart. In that case, the actual physical delay would be the
>>displacement of the peak plus some multiple of N sample times. And if
>>you=92re using some kind of short time impulse type signal, you might
>>not get any result (e.g.: the waveform hits the second sensor 10
>>seconds after hitting the first sensor, but the time span of the
>>inverse FFT is only 1 second).
>>
>>

>
>Hi,
>Thank you but I seriously cant get the hang of what you are trying to

say.
>I am an amateur in MATLAB and hence i am getting confused. I also think
>that its not necessary to consider the things you are saying.
>
>My question is simple - how do i calculate the delay between the peaks

of
>2 different signals? (both of my signals are just simple horizontal

lines
>with a peak at a particular sample i.e noise is almost null. The signals
>have just one peak in them, both arriving at different time. The rest of
>the signal is almost close to a straight line. The signals are captured

at
>44000Hz and the total size of both the signals is 431020).
>
>I hope someone can help me now with a simple solution. If possible

please
>try and explain with a code. Thank you.
>

Also lets say for eg,

x=rand(1000,1);
y=rand(1000,1);
x(500)=40; %peak
y(200)=35; %peak
z=xcorr(x,y);
plot(z)

You will see a peak at 1300. Is this the delay = 1300 - length of data
i.e. delay between the two signals = 300. is this the right way?
Reply With Quote
  #10  
Old 08-28-2008, 12:41 AM
kevinjmcgee@netscape.net
Guest
 
Default Re: cross correlation sound

On Aug 27, 6:53*am, "maz_p5" <maz...@hotmail.com> wrote:
> >>On Aug 25, 5:04=A0pm, kronec...@yahoo.co.uk wrote:

>
> >>> You know from the ccor in samples. Suppose the peak occurs at 5

> sample
> >>> intervals. Then the TDOA is 5*Ts where Ts is the sampling interval of
> >>> your original data. It could also be -5 steps though so watch the
> >>> sign.

>
> >>> K.- Hide quoted text -

>
> >>> - Show quoted text -

>
> >>Thanks, K. *I hope I=92m not adding to the guy=92s confusion, butcross
> >>correlation isn=92t the easiest thing for a beginner to figure out. *I
> >>started writing a response to his last question (obviously, I=92m a
> >>little late), and rather than throw it away, I=92ll post it anyways.

>
> >>After doing the cross correlation, you're back in the time domain.
> >>You had a sample rate, so if the peak is displaced by 'x' number of
> >>samples from the zero point (or, in your case, since you're using
> >>MATLAB, the 1 point), you can directly determine the delay. *Consider
> >>a pure sinusoidal signal. *If the peak is displaced by 5 points to the
> >>right of the 0 point, it says that one waveform is delayed by 5 sample
> >>times from the other. *If the peak is displaced 5 points to the left
> >>of the 0 point (it=92s in the upper half of the inverse FFT outputs),

> it
> >>says that the other waveform is delayed by 5 sample times. *So (for an
> >>FFT of even N), if the peak is between points 0 and N/2, then that=92s
> >>your time delay in sample times. *If the peak is from N/2 + 1 to N -
> >>1, then the delay would be counted from there up to the 0 point.
> >>Seems simple enough. *Perhaps you're being overly confused by the
> >>sound speed, sensor displacement, etc. *The sensor displacement would
> >>come into play if they are, say, a multiple number of wavelengths
> >>apart. *In that case, the actual physical delay would be the
> >>displacement of the peak plus some multiple of N sample times. *And if
> >>you=92re using some kind of short time impulse type signal, you might
> >>not get any result (e.g.: the waveform hits the second sensor 10
> >>seconds after hitting the first sensor, but the time span of the
> >>inverse FFT is only 1 second).

>
> >Hi,
> >Thank you but I seriously cant get the hang of what you are trying to

> say.
> >I am an amateur in MATLAB and hence i am getting confused. I also think
> >that its not necessary to consider the things you are saying.

>
> >My question is simple - how do i calculate the delay between the peaks

> of
> >2 different signals? (both of my signals are just simple horizontal

> lines
> >with a peak at a particular sample i.e noise is almost null. The signals
> >have just one peak in them, both arriving at different time. The rest of
> >the signal is almost close to a straight line. The signals are captured

> at
> >44000Hz and the total size of both the signals is 431020).

>
> >I hope someone can help me now with a simple solution. If possible

> please
> >try and explain with a code. Thank you.

>
> Also lets say for eg,
>
> x=rand(1000,1);
> y=rand(1000,1);
> x(500)=40; %peak
> y(200)=35; %peak
> z=xcorr(x,y);
> plot(z)
>
> You will see a peak at 1300. Is this the delay = 1300 - length of data
> i.e. delay between the two signals = 300. is this the right way?- Hide quoted text -
>
> - Show quoted text -


Well, I use C++, not MATLAB, but I think that what you're doing is:
generate 1000 points for both x and y; set point 500 in x to 40 and
point 200 in y to 35; cross correlate x and y; plot results. For two
N point inputs, xcorr in MATLAB gives you 2*N outputs, and it provides
them in a c[m] = Rxy[m-N], m=1, 2, ... 2N-1 format, so the first 1000
points are actually the 'left side' results where waveform y is
delayed from waveform x. The next 1000 points are the 'right side' of
the results, where waveform x is delayed from waveform y. Since your
peak is on the right side (at 1300), it says that your x waveform is
delayed by 300 sample times from the y waveform. That's exactly where
you would expect it to be. Just treat the first 1000 output points as
the left side results (waveform y delayed from waveform x) and the
second 1000 output points as the right side (waveform x delayed from
waveform y). The N point is the 'no delay between the inputs' point.

With your inputs as they are, the output tells you that the x waveform
is 300 sample times later than the y waveform. I think if you made
your inputs x[200] = 40 and y[500] = 35, the peak should show up at
output point 700, based on my interpretation of the MATLAB
documentation (point 700 would be the 700-1000 result, which is
-300). It would tell you that y is now 300 sample times later than
x. You might want to check that to see if my interpretation of the
documentation is correct.

Good job, maz. Now all you've got to do is generate all the delays
needed for your 4 sensor problem and try to solve for the (x,y)
position of the source. And be careful of the fact that your sensor
spacing may be some multiple of the wavelength, which could cause a
problem (I couldn't tell in physical units what your sensor spacing
was from your original post). You could also turn time delays into
angles and try solving things that way.
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 09:11 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.