cross correlation sound

This is a discussion on cross correlation sound within the DSP forums in Other Technologies category; >On Aug 27, 6:53=A0am, "maz_p5" <maz...@hotmail.com> wrote: >> >>On Aug 25, 5:04=3DA0pm, 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. =A0I hope I=3D92m not adding to the guy=3D92s confusion, but= > cross >> >>correlation isn=3D92t ...

Go Back   Application Development Forum > Other Technologies > DSP

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #11  
Old 08-28-2008, 07:13 PM
maz_p5
Guest
 
Default Re: cross correlation sound

>On Aug 27, 6:53=A0am, "maz_p5" <maz...@hotmail.com> wrote:
>> >>On Aug 25, 5:04=3DA0pm, 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. =A0I hope I=3D92m not adding to the guy=3D92s confusion,

but=
> cross
>> >>correlation isn=3D92t the easiest thing for a beginner to figure out.

=
>=A0I
>> >>started writing a response to his last question (obviously, I=3D92m

a
>> >>little late), and rather than throw it away, I=3D92ll 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.

=A0Consider
>> >>a pure sinusoidal signal. =A0If the peak is displaced by 5 points to

th=
>e
>> >>right of the 0 point, it says that one waveform is delayed by 5

sample
>> >>times from the other. =A0If the peak is displaced 5 points to the

left
>> >>of the 0 point (it=3D92s in the upper half of the inverse FFT

outputs),
>> it
>> >>says that the other waveform is delayed by 5 sample times. =A0So (for

a=
>n
>> >>FFT of even N), if the peak is between points 0 and N/2, then

that=3D92=
>s
>> >>your time delay in sample times. =A0If 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. =A0Perhaps you're being overly confused by the
>> >>sound speed, sensor displacement, etc. =A0The sensor displacement

would
>> >>come into play if they are, say, a multiple number of wavelengths
>> >>apart. =A0In that case, the actual physical delay would be the
>> >>displacement of the peak plus some multiple of N sample times. =A0And

i=
>f
>> >>you=3D92re 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=3Drand(1000,1);
>> y=3Drand(1000,1);
>> x(500)=3D40; %peak
>> y(200)=3D35; %peak
>> z=3Dxcorr(x,y);
>> plot(z)
>>
>> You will see a peak at 1300. Is this the delay =3D 1300 - length of

data
>> i.e. delay between the two signals =3D 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] =3D Rxy[m-N], m=3D1, 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] =3D 40 and y[500] =3D 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.
>


Hi,

Thanks.. Seems I am getting a little closer now. Can you pass me your
email id, so that I can send you my .wav files captured from the
microphones so that we can cross-check our delay results. Please, if you do
not mind.
Thanks.

Reply With Quote
  #12  
Old 08-28-2008, 07:15 PM
maz_p5
Guest
 
Default Re: cross correlation sound

>On Aug 27, 6:53=A0am, "maz_p5" <maz...@hotmail.com> wrote:
>> >>On Aug 25, 5:04=3DA0pm, 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. =A0I hope I=3D92m not adding to the guy=3D92s confusion,

but=
> cross
>> >>correlation isn=3D92t the easiest thing for a beginner to figure out.

=
>=A0I
>> >>started writing a response to his last question (obviously, I=3D92m

a
>> >>little late), and rather than throw it away, I=3D92ll 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.

=A0Consider
>> >>a pure sinusoidal signal. =A0If the peak is displaced by 5 points to

th=
>e
>> >>right of the 0 point, it says that one waveform is delayed by 5

sample
>> >>times from the other. =A0If the peak is displaced 5 points to the

left
>> >>of the 0 point (it=3D92s in the upper half of the inverse FFT

outputs),
>> it
>> >>says that the other waveform is delayed by 5 sample times. =A0So (for

a=
>n
>> >>FFT of even N), if the peak is between points 0 and N/2, then

that=3D92=
>s
>> >>your time delay in sample times. =A0If 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. =A0Perhaps you're being overly confused by the
>> >>sound speed, sensor displacement, etc. =A0The sensor displacement

would
>> >>come into play if they are, say, a multiple number of wavelengths
>> >>apart. =A0In that case, the actual physical delay would be the
>> >>displacement of the peak plus some multiple of N sample times. =A0And

i=
>f
>> >>you=3D92re 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=3Drand(1000,1);
>> y=3Drand(1000,1);
>> x(500)=3D40; %peak
>> y(200)=3D35; %peak
>> z=3Dxcorr(x,y);
>> plot(z)
>>
>> You will see a peak at 1300. Is this the delay =3D 1300 - length of

data
>> i.e. delay between the two signals =3D 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] =3D Rxy[m-N], m=3D1, 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] =3D 40 and y[500] =3D 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.
>


Hi,

Thanks.. Seems I am getting a little closer now. Can you pass me your
email id, so that I can send you my .wav files captured from the
microphones so that we can cross-check our delay results. Please, if you do
not mind.
Thanks.

Reply With Quote
  #13  
Old 08-29-2008, 12:24 AM
kevinjmcgee@netscape.net
Guest
 
Default Re: cross correlation sound

On Aug 28, 7:15*pm, "maz_p5" <maz...@hotmail.com> wrote:
> >On Aug 27, 6:53=A0am, "maz_p5" <maz...@hotmail.com> wrote:
> >> >>On Aug 25, 5:04=3DA0pm, 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. =A0I hope I=3D92m not adding to the guy=3D92s confusion,

> but=
> > cross
> >> >>correlation isn=3D92t the easiest thing for a beginner to figure out.

> =
> >=A0I
> >> >>started writing a response to his last question (obviously, I=3D92m

> a
> >> >>little late), and rather than throw it away, I=3D92ll 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.

> =A0Consider
> >> >>a pure sinusoidal signal. =A0If the peak is displaced by 5 points to

> th=
> >e
> >> >>right of the 0 point, it says that one waveform is delayed by 5

> sample
> >> >>times from the other. =A0If the peak is displaced 5 points to the

> left
> >> >>of the 0 point (it=3D92s in the upper half of the inverse FFT

> outputs),
> >> it
> >> >>says that the other waveform is delayed by 5 sample times. =A0So (for

> a=
> >n
> >> >>FFT of even N), if the peak is between points 0 and N/2, then

> that=3D92=
> >s
> >> >>your time delay in sample times. =A0If the peak is from N/2 + 1 toN

> -
> >> >>1, then the delay would be counted from there up to the 0 point.
> >> >>Seems simple enough. =A0Perhaps you're being overly confused by the
> >> >>sound speed, sensor displacement, etc. =A0The sensor displacement

> would
> >> >>come into play if they are, say, a multiple number of wavelengths
> >> >>apart. =A0In that case, the actual physical delay would be the
> >> >>displacement of the peak plus some multiple of N sample times. =A0And

> i=
> >f
> >> >>you=3D92re 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=3Drand(1000,1);
> >> y=3Drand(1000,1);
> >> x(500)=3D40; %peak
> >> y(200)=3D35; %peak
> >> z=3Dxcorr(x,y);
> >> plot(z)

>
> >> You will see a peak at 1300. Is this the delay =3D 1300 - length of

> data
> >> i.e. delay between the two signals =3D 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] =3D Rxy[m-N], m=3D1, 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] =3D 40 and y[500] =3D 35, the peak should show upat
> >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.

>
> Hi,
>
> Thanks.. Seems I am getting a little closer now. Can you pass me your
> email id, so that I can send you my .wav files captured from the
> microphones so that we can cross-check our delay results. Please, if you do
> not mind.
> Thanks.- Hide quoted text -
>
> - Show quoted text -


Nope, sorry, not gonna do that - I've got too many other things to do
right now. Besides, once you do the cross correlations, you've got
the information you need to solve your problem. First, I would
suggest that you turn those time delays into angles of arrival.
Here's how to visualize it. The cross correlation delays, as computed
by MATLAB, range from -999, -998, ... -1, 0, +1, ... , +998, +999.
You'll have 4 delays - one for each pair of sensors. Now consider
each sensor pair as lying on an east/west axis. A delay of 0 says
"the waveform arrives at both sensors at the same time." What it
means physically is that the waveform is arriving perpendicular to the
2 sensors (at a 90 degree angle, or from the north). Now consider a
delay of +1. This corresponds to the waveform arriving almost (but
not quite) from due north towards the 2 sensors. You’ll have to
figure out what that 1 sample time delay means in terms of actual
physical distance traveled by the waveform for the given sound speed.
Draw the problem out on a piece of graph paper to determine the
angular units if need be. Then figure out the angle for other
delays. Positive delays mean that the waveform arrival is more from
the right or northeast direction, and negative delays mean that the
waveform arrival is more from left or northwest direction.

So, given your time delays, turn them into angles. Now take a piece
of graph paper and draw the actual physical arrangement of your sensor
array. Then mark the points exactly halfway between each pair of
sensors that were used to generate the time delays (e.g.: for your 0,0
and 0,6 pair, mark the 0,3 point; for the 0,0 and 4,0 pair, mark the
2,0 point). Using those 4 marked points, physically draw the 4 angles
that correspond to your time delays and get a visual idea of what it
all means. Your 4 arrival angles should cross a some point in the x,y
plane. For a high signal to noise ratio signal, they should all pass
directly through an x,y point on the plane. That's the origin of the
sound.

I'd suggest you do it that way at first, because it gives you more of
a visual interpretation of what you're actually doing. Once you've
got the basic idea, then you can go about figuring out how to program
the "drawing of the angles" to estimate the x,y point. And remember
that for the low signal to noise ratio cases, the simple cross
correlator will start to have a lot of problems, and the generalized
version is far more preferable. But for the high signal to noise
ratio case, just use the simple cross correlator to determine the
delays, figure out the angles, and you should get a solution to your
problem.
Reply With Quote
  #14  
Old 09-04-2008, 07:28 AM
maz_p5
Guest
 
Default Re: cross correlation sound

>On Aug 27, 6:53=A0am, "maz_p5" <maz...@hotmail.com> wrote:
>> >>On Aug 25, 5:04=3DA0pm, 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. =A0I hope I=3D92m not adding to the guy=3D92s confusion,

but=
> cross
>> >>correlation isn=3D92t the easiest thing for a beginner to figure out.

=
>=A0I
>> >>started writing a response to his last question (obviously, I=3D92m

a
>> >>little late), and rather than throw it away, I=3D92ll 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.

=A0Consider
>> >>a pure sinusoidal signal. =A0If the peak is displaced by 5 points to

th=
>e
>> >>right of the 0 point, it says that one waveform is delayed by 5

sample
>> >>times from the other. =A0If the peak is displaced 5 points to the

left
>> >>of the 0 point (it=3D92s in the upper half of the inverse FFT

outputs),
>> it
>> >>says that the other waveform is delayed by 5 sample times. =A0So (for

a=
>n
>> >>FFT of even N), if the peak is between points 0 and N/2, then

that=3D92=
>s
>> >>your time delay in sample times. =A0If 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. =A0Perhaps you're being overly confused by the
>> >>sound speed, sensor displacement, etc. =A0The sensor displacement

would
>> >>come into play if they are, say, a multiple number of wavelengths
>> >>apart. =A0In that case, the actual physical delay would be the
>> >>displacement of the peak plus some multiple of N sample times. =A0And

i=
>f
>> >>you=3D92re 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=3Drand(1000,1);
>> y=3Drand(1000,1);
>> x(500)=3D40; %peak
>> y(200)=3D35; %peak
>> z=3Dxcorr(x,y);
>> plot(z)
>>
>> You will see a peak at 1300. Is this the delay =3D 1300 - length of

data
>> i.e. delay between the two signals =3D 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] =3D Rxy[m-N], m=3D1, 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] =3D 40 and y[500] =3D 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.
>


Hi,

I want verification if the results below are correct.

The sounds are captured at 44100 Hz into the two microphones.

The length of both the sounds is - 430120 samples (bcuz both we captured
simultaneously)

The peak of m1 occurs at = 176426
The peak of m2 occurs at = 176437

Now, I cross-correlate both the signals m1 and m2 using z=xcorr(m1,m2);

The peak of z occurs at = 430101

Is this the delay between the two signals or is c = length(m1)-430101 the
delay between the two signals?

I am getting confused on this part because I have seen papers showing both
the ways.
Please let me know. Thank you.


Reply With Quote
  #15  
Old 09-05-2008, 12:53 AM
kevinjmcgee@netscape.net
Guest
 
Default Re: cross correlation sound


m2 is later than m1, so it's the same as you had before with y later
than x. So the peak should be interpreted as occurring on the left or
lower half of your results. Treat the first N-1 output points as the
left side results (waveform y later than waveform x), the N point as
being the zero delay point and the second N-1 output points as the
right side (waveform x later than waveform y). You should have 2N - 2
outputs. So if the delay shows up in the first or lower half of the
results, then your delay is the distance (in number of samples)
between the zero delay point (point N, or the exact middle of your
total number of points) and the peak to its left ( delay = N minus the
peak). When the delay shows up in the second or upper half of the
results, the delay is computed from the zero delay point up to the
peak (subtract N from the location of the peak).

But one problem I see is that you have a difference of 11 points
between m1 and m2. I'm not quite sure how you arrived at some of the
numbers you're using.
Reply With Quote
  #16  
Old 09-05-2008, 04:24 AM
kevinjmcgee@netscape.net
Guest
 
Default Re: cross correlation sound

On Sep 5, 12:53*am, kevinjmc...@netscape.net wrote:
> m2 is later than m1, so it's the same as you had before with y later
> than x. *So the peak should be interpreted as occurring on the left or
> lower half of your results. *Treat the first N-1 output points as the
> left side results (waveform y later than waveform x), the N point as
> being the zero delay point and the second N-1 output points as the
> right side (waveform x later than waveform y). *You should have 2N - 2
> outputs. *So if the delay shows up in the first or lower half of the
> results, then your delay is the distance (in number of samples)
> between the zero delay point (point N, or the exact middle of your
> total number of points) and the peak to its left ( delay = N minus the
> peak). *When the delay shows up in the second or upper half of the
> results, the delay is computed from the zero delay point up to the
> peak (subtract N from the location of the peak).
>
> But one problem I see is that you have a difference of 11 points
> between m1 and m2. I'm not quite sure how you arrived at some of the
> numbers you're using.


I knew those numbers were suspicious! 430120 can be factored by 8
then 5 to yield 10753, which is a prime number. So MATLAB is probably
zero padding to do the computations. That's why your delay is 11, but
your calculated delay is 19. Very tricky.
Reply With Quote
  #17  
Old 09-05-2008, 05:21 AM
maz_p5
Guest
 
Default Re: cross correlation sound

>On Sep 5, 12:53=A0am, kevinjmc...@netscape.net wrote:
>> m2 is later than m1, so it's the same as you had before with y later
>> than x. =A0So the peak should be interpreted as occurring on the left

or
>> lower half of your results. =A0Treat the first N-1 output points as

the
>> left side results (waveform y later than waveform x), the N point as
>> being the zero delay point and the second N-1 output points as the
>> right side (waveform x later than waveform y). =A0You should have 2N -

2
>> outputs. =A0So if the delay shows up in the first or lower half of the
>> results, then your delay is the distance (in number of samples)
>> between the zero delay point (point N, or the exact middle of your
>> total number of points) and the peak to its left ( delay =3D N minus

the
>> peak). =A0When the delay shows up in the second or upper half of the
>> results, the delay is computed from the zero delay point up to the
>> peak (subtract N from the location of the peak).
>>
>> But one problem I see is that you have a difference of 11 points
>> between m1 and m2. I'm not quite sure how you arrived at some of the
>> numbers you're using.

>
>I knew those numbers were suspicious! 430120 can be factored by 8
>then 5 to yield 10753, which is a prime number. So MATLAB is probably
>zero padding to do the computations. That's why your delay is 11, but
>your calculated delay is 19. Very tricky.
>

Hi,

yes it is tricky and that is exactly what is confusing me as to which is
the right one.

No, it is not zero padding. Actually i start recording using some other
recording software and not MATLAB bcuz MATLAB doesnt support four multiple
inputs. I start recording, and as soon as i capture the peak, then i stop
the recording after about couple of seconds.

Now what should i do. How do i verify if my delay calculation is correct?
Reply With Quote
  #18  
Old 09-05-2008, 07:01 AM
kevinjmcgee@netscape.net
Guest
 
Default Re: cross correlation sound

On Sep 5, 5:21*am, "maz_p5" <maz...@hotmail.com> wrote:
> >On Sep 5, 12:53=A0am, kevinjmc...@netscape.net wrote:
> >> m2 is later than m1, so it's the same as you had before with y later
> >> than x. =A0So the peak should be interpreted as occurring on the left

> or
> >> lower half of your results. =A0Treat the first N-1 output points as

> the
> >> left side results (waveform y later than waveform x), the N point as
> >> being the zero delay point and the second N-1 output points as the
> >> right side (waveform x later than waveform y). =A0You should have 2N-

> 2
> >> outputs. =A0So if the delay shows up in the first or lower half of the
> >> results, then your delay is the distance (in number of samples)
> >> between the zero delay point (point N, or the exact middle of your
> >> total number of points) and the peak to its left ( delay =3D N minus

> the
> >> peak). =A0When the delay shows up in the second or upper half of the
> >> results, the delay is computed from the zero delay point up to the
> >> peak (subtract N from the location of the peak).

>
> >> But one problem I see is that you have a difference of 11 points
> >> between m1 and m2. I'm not quite sure how you arrived at some of the
> >> numbers you're using.

>
> >I knew those numbers were suspicious! *430120 can be factored by 8
> >then 5 to yield 10753, which is a prime number. *So MATLAB is probably
> >zero padding to do the computations. *That's why your delay is 11, but
> >your calculated delay is 19. *Very tricky.

>
> Hi,
>
> yes it is tricky and that is exactly what is confusing me as to which is
> the right one.
>
> No, it is not zero padding. Actually i start recording using some other
> recording software and not MATLAB bcuz MATLAB doesnt support four multiple
> inputs. I start recording, and as soon as i capture the peak, then i stop
> the recording after about couple of seconds.
>
> Now what should i do. How do i verify if my delay calculation is correct?- Hide quoted text -
>
> - Show quoted text -


OK. Let's just focus on what your output really means. Your inputs
are two N point time domain recordings. MATLAB will give you 2N - 1
outputs (keep in mind that I'm not familiar with it - I do my own
cross correlations in C++ because I know how my stuff works, and I can
trust it). I said previously that you get 2N - 2 points - that's
wrong - MATLAB gives you 2N - 2 points plus the N point, which is 2N-1
points. The N point is halfway betweeen point 0 (the first output),
and point 2N-1 (the last point). In the middle of all those points is
point N. It is the zero delay point. If the peak in the cross
correlation shows up at the N point in the outputs, it means that
there is no delay between the 2 waveforms. If the peak shows up on
the left side of the 2N-1 outputs (the peak is at a point less than
N), it means that one waveform is delayed from the other by the
distance in sample times from the point N to the left. Just imagine
the points as being from -(N-1) to N to +(N-1), with N in the center
as being the 'no delay between them.' So if the peak shows up on the
left side of the results (peak location less than N), your delay is N
minus the location of the peak, expressed as a positive number. If
the peak shows up on the right side of the results (peak location
greater than N), then your delay is (peak location - N), which will be
a positive number.

The reason I'm concerned is that you seem to have a delay between
waveforms of 11 sample times in a previous post, but your calculated
result indicates a delay of 19 sample times. Something is wrong. I
don't know how MATLAB actually computes cross correlations (do you
know how it does it?). Your sample length is so large that it might
not do it with a direct calculation. That's what led me to believe
that it's might be doing it some other way, and your sample length
doesn't factor well (it has a very large prime factor).

I won't be back until sometime tonight, but I'll think about your
problem a bit further. In the mean time, is N actually 430120
samples, and your programmed delay 11 sample times, and your sample
rate 44100, and your computed delay at 430101? Please check your
numbers.

Reply With Quote
  #19  
Old 09-05-2008, 07:51 AM
maz_p5
Guest
 
Default Re: cross correlation sound

>On Sep 5, 5:21=A0am, "maz_p5" <maz...@hotmail.com> wrote:
>> >On Sep 5, 12:53=3DA0am, kevinjmc...@netscape.net wrote:
>> >> m2 is later than m1, so it's the same as you had before with y

later
>> >> than x. =3DA0So the peak should be interpreted as occurring on the

lef=
>t
>> or
>> >> lower half of your results. =3DA0Treat the first N-1 output points

as
>> the
>> >> left side results (waveform y later than waveform x), the N point

as
>> >> being the zero delay point and the second N-1 output points as the
>> >> right side (waveform x later than waveform y). =3DA0You should have

2N=
> -
>> 2
>> >> outputs. =3DA0So if the delay shows up in the first or lower half of

t=
>he
>> >> results, then your delay is the distance (in number of samples)
>> >> between the zero delay point (point N, or the exact middle of your
>> >> total number of points) and the peak to its left ( delay =3D3D N

minus
>> the
>> >> peak). =3DA0When the delay shows up in the second or upper half of

the
>> >> results, the delay is computed from the zero delay point up to the
>> >> peak (subtract N from the location of the peak).

>>
>> >> But one problem I see is that you have a difference of 11 points
>> >> between m1 and m2. I'm not quite sure how you arrived at some of

the
>> >> numbers you're using.

>>
>> >I knew those numbers were suspicious! =A0430120 can be factored by 8
>> >then 5 to yield 10753, which is a prime number. =A0So MATLAB is

probably
>> >zero padding to do the computations. =A0That's why your delay is 11,

but
>> >your calculated delay is 19. =A0Very tricky.

>>
>> Hi,
>>
>> yes it is tricky and that is exactly what is confusing me as to which

is
>> the right one.
>>
>> No, it is not zero padding. Actually i start recording using some

other
>> recording software and not MATLAB bcuz MATLAB doesnt support four

multipl=
>e
>> inputs. I start recording, and as soon as i capture the peak, then i

stop
>> the recording after about couple of seconds.
>>
>> Now what should i do. How do i verify if my delay calculation is

correct?=
>- Hide quoted text -
>>
>> - Show quoted text -

>
>OK. Let's just focus on what your output really means. Your inputs
>are two N point time domain recordings. MATLAB will give you 2N - 1
>outputs (keep in mind that I'm not familiar with it - I do my own
>cross correlations in C++ because I know how my stuff works, and I can
>trust it). I said previously that you get 2N - 2 points - that's
>wrong - MATLAB gives you 2N - 2 points plus the N point, which is 2N-1
>points. The N point is halfway betweeen point 0 (the first output),
>and point 2N-1 (the last point). In the middle of all those points is
>point N. It is the zero delay point. If the peak in the cross
>correlation shows up at the N point in the outputs, it means that
>there is no delay between the 2 waveforms. If the peak shows up on
>the left side of the 2N-1 outputs (the peak is at a point less than
>N), it means that one waveform is delayed from the other by the
>distance in sample times from the point N to the left. Just imagine
>the points as being from -(N-1) to N to +(N-1), with N in the center
>as being the 'no delay between them.' So if the peak shows up on the
>left side of the results (peak location less than N), your delay is N
>minus the location of the peak, expressed as a positive number. If
>the peak shows up on the right side of the results (peak location
>greater than N), then your delay is (peak location - N), which will be
>a positive number.
>
>The reason I'm concerned is that you seem to have a delay between
>waveforms of 11 sample times in a previous post, but your calculated
>result indicates a delay of 19 sample times. Something is wrong. I
>don't know how MATLAB actually computes cross correlations (do you
>know how it does it?). Your sample length is so large that it might
>not do it with a direct calculation. That's what led me to believe
>that it's might be doing it some other way, and your sample length
>doesn't factor well (it has a very large prime factor).
>
>I won't be back until sometime tonight, but I'll think about your
>problem a bit further. In the mean time, is N actually 430120
>samples, and your programmed delay 11 sample times, and your sample
>rate 44100, and your computed delay at 430101? Please check your
>numbers.
>
>


Hi,

Yes the nos. are correct.
When i stop recording, i open the .wav files in matlab which are 430120
samples long. If i had to record it in matlab, then i would obviously set N
to some value which is = multiple of sampling frequency i.e. N= 44100 x 10
for 10 sec recording; which is not the case here.
So, N= 430120.
max(m1)=176426
max(m2)=176437
z=xcorr(m1,m2);
max(z)=430101
Thank you.
-Maz
Reply With Quote
  #20  
Old 09-06-2008, 12:51 AM
kevinjmcgee@netscape.net
Guest
 
Default Re: cross correlation sound

On Sep 5, 7:51*am, "maz_p5" <maz...@hotmail.com> wrote:
> >On Sep 5, 5:21=A0am, "maz_p5" <maz...@hotmail.com> wrote:
> >> >On Sep 5, 12:53=3DA0am, kevinjmc...@netscape.net wrote:
> >> >> m2 is later than m1, so it's the same as you had before with y

> later
> >> >> than x. =3DA0So the peak should be interpreted as occurring on the

> lef=
> >t
> >> or
> >> >> lower half of your results. =3DA0Treat the first N-1 output points

> as
> >> the
> >> >> left side results (waveform y later than waveform x), the N point

> as
> >> >> being the zero delay point and the second N-1 output points as the
> >> >> right side (waveform x later than waveform y). =3DA0You should have

> 2N=
> > -
> >> 2
> >> >> outputs. =3DA0So if the delay shows up in the first or lower halfof

> t=
> >he
> >> >> results, then your delay is the distance (in number of samples)
> >> >> between the zero delay point (point N, or the exact middle of your
> >> >> total number of points) and the peak to its left ( delay =3D3D N

> minus
> >> the
> >> >> peak). =3DA0When the delay shows up in the second or upper half of

> the
> >> >> results, the delay is computed from the zero delay point up to the
> >> >> peak (subtract N from the location of the peak).

>
> >> >> But one problem I see is that you have a difference of 11 points
> >> >> between m1 and m2. I'm not quite sure how you arrived at some of

> the
> >> >> numbers you're using.

>
> >> >I knew those numbers were suspicious! =A0430120 can be factored by 8
> >> >then 5 to yield 10753, which is a prime number. =A0So MATLAB is

> probably
> >> >zero padding to do the computations. =A0That's why your delay is 11,

> but
> >> >your calculated delay is 19. =A0Very tricky.

>
> >> Hi,

>
> >> yes it is tricky and that is exactly what is confusing me as to which

> is
> >> the right one.

>
> >> No, it is not zero padding. Actually i start recording using some

> other
> >> recording software and not MATLAB bcuz MATLAB doesnt support four

> multipl=
> >e
> >> inputs. I start recording, and as soon as i capture the peak, then i

> stop
> >> the recording after about couple of seconds.

>
> >> Now what should i do. How do i verify if my delay calculation is

> correct?=
> >- Hide quoted text -

>
> >> - Show quoted text -

>
> >OK. *Let's just focus on what your output really means. *Your inputs
> >are two N point time domain recordings. *MATLAB will give you 2N - 1
> >outputs (keep in mind that I'm not familiar with it - I do my own
> >cross correlations in C++ because I know how my stuff works, and I can
> >trust it). *I said previously that you get 2N - 2 points - that's
> >wrong - MATLAB gives you 2N - 2 points plus the N point, which is 2N-1
> >points. *The N point is halfway betweeen point 0 (the first output),
> >and point 2N-1 (the last point). *In the middle of all those points is
> >point N. *It is the zero delay point. If the peak in the cross
> >correlation shows up at the N point in the outputs, it means that
> >there is no delay between the 2 waveforms. *If the peak shows up on
> >the left side of the 2N-1 outputs (the peak is at a point less than
> >N), it means that one waveform is delayed from the other by the
> >distance in sample times from the point N to the left. *Just imagine
> >the points as being from -(N-1) to N to +(N-1), with N in the center
> >as being the 'no delay between them.' *So if the peak shows up on the
> >left side of the results (peak location less than N), your delay is N
> >minus the location of the peak, expressed as a positive number. *If
> >the peak shows up on the right side of the results (peak location
> >greater than N), then your delay is (peak location - N), which will be
> >a positive number.

>
> >The reason I'm concerned is that you seem to have a delay between
> >waveforms of 11 sample times in a previous post, but your calculated
> >result indicates a delay of 19 sample times. *Something is wrong. *I
> >don't know how MATLAB actually computes cross correlations (do you
> >know how it does it?). *Your sample length is so large that it might
> >not do it with a direct calculation. That's what led me to believe
> >that it's might be doing it some other way, and your sample length
> >doesn't factor well (it has a very large prime factor).

>
> >I won't be back until sometime tonight, but I'll think about your
> >problem a bit further. *In the mean time, is N actually 430120
> >samples, and your programmed delay 11 sample times, and your sample
> >rate 44100, and your computed delay at 430101? *Please check your
> >numbers.

>
> Hi,
>
> Yes the nos. are correct.
> When i stop recording, i open the .wav files in matlab which are 430120
> samples long. If i had to record it in matlab, then i would obviously setN
> to some value which is = multiple of sampling frequency i.e. N= 44100x 10
> for 10 sec recording; which is not the case here.
> So, N= 430120.
> max(m1)=176426
> max(m2)=176437
> z=xcorr(m1,m2);
> max(z)=430101
> Thank you.
> -Maz- Hide quoted text -
>
> - Show quoted text -


I'm presuming that your max(m1) and max(m2) values are actual
physically measured peaks occurring in your recordings. The delay is
11 sample times between them, and I presume that you got it by
eyeballing the data. But your calculated delay is N - 430101 = 19.
Since it's on the left or lower side of the result (the computed delay
is less than N), then it should actually be considered to be a
negative delay, but we'll ignore that for now. As for the rest of
your numbers, I find it quite extraordinary that you just so happen to
have an N that has a huge prime factor (10753) in it. Similarly, your
data length is about 9.75 seconds, which corresponds to a couple of
miles at a sound speed of 1100 feet/sec.

But your 'measured' and calculated results differ. I can't help but
think that MATLAB may be padding the numbers without your knowledge
because of that large prime factor in N. I seriously doubt that
MATLAB is doing the calculation using a direct N squared computation
(that's 1.85... x10 to the 11th calculations!). So it's probably
factoring N into more manageable amounts. The problem is that prime
factor of 10753. Quite possibly, it's adding a few zero padded points
such that N can be factored more favorably. MATLAB will zero pad the
data if you give it two different input lengths, and it wouldn't
surprise me if it did something similar when it comes up against a
large prime like 10753. So try changing the value you're using for N,
and chop a few data points off your recordings. For instance, 409600
is 640 squared, and MATLAB should have no problem with it.

Otherwise, you may have a problem with how MATLAB is actually
performing the calculation internally, and I can't help you with that.
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 09:49 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.