Autocorrelation - How to implement step by step

  • Context: Undergrad 
  • Thread starter Thread starter atferrari
  • Start date Start date
  • Tags Tags
    Autocorrelation
Click For Summary

Discussion Overview

The discussion revolves around the implementation of autocorrelation to determine the time lag between audio signals received by two microphones positioned at different distances from a sound source. Participants explore the necessary formulas and steps for processing the data collected by a microprocessor, including considerations for normalization and the effects of sound magnitude.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • Agustín Tomás seeks clarification on the formula for autocorrelation and the steps required to process the audio data collected by two microphones.
  • One participant suggests calculating the lag by subtracting the distances of the microphones from the sound source and dividing by the speed of sound, but notes this does not directly answer how to compute it using autocorrelation.
  • Another participant proposes a method where the first microphone sends a signal to the second when it detects sound, recording the time until the second microphone also detects the sound, which they suggest could be used to determine lag.
  • A different approach is suggested involving a ratio of batches recorded by each microphone, factoring in the distances to the sound source and the speed of sound.
  • Agustín Tomás emphasizes the desire to use autocorrelation specifically, expressing uncertainty about the need for normalization and how to implement it.
  • A later reply indicates a shift in understanding, suggesting that cross-correlation may be more appropriate since the signals from each microphone are treated as different channels.

Areas of Agreement / Disagreement

Participants express differing views on the appropriate method for calculating lag, with some advocating for autocorrelation and others suggesting cross-correlation. The discussion remains unresolved regarding the specific implementation details and the necessity of normalization.

Contextual Notes

There are unresolved assumptions regarding the relationship between the recorded batches of sound and the distances of the microphones from the sound source. The discussion also reflects uncertainty about the effects of sound magnitude on the measurements.

atferrari
Messages
8
Reaction score
0
Hola, my first time in this forum.

Two microphones at diferent distances from an audio source are receiving the same steady signal (frequency/amplitude unchanged).

A microprocessor takes succesive samples of both channels in batches of N samples. Time between samples is ts microseconds.

Once a batch is ready I want the micro to calculate the time difference (lag) between the incoming signals.

I know I have to use autocorrelation here (cross correlation of itself, right?).

In spite of reading a lot I could not conclude what is the formula to be solved thus how to program the micro to calculate the lag between both channels.

Can anyone tell:

The actual formula to be implemented?.

What are the succesive steps required to process the data set just acquired?

Normalization, is it needed? If so, how do you actually do it and when?

I am not into high level maths so bear with me. Math notation is sometimes quite hard for me to follow.

Gracias for any help.

Agustín Tomás
 
Physics news on Phys.org
When you say the lag between the channels, do you mean that you want to find how much longer it takes microphone 2 to get the sound microphone 1 got?

If this is the case, if you subtract the distance from microphone 2 to the sound source from the distance of microphone 1 from the sound source,

and then divide that difference by the speed of sound, you should get the lag between what time one microphone gets the sound and the other one get it.

This assumes that the computer processor? of both microphones doesn't lag - I don't know if you mean computer lag or the difference between when sound reaches the microphone.

This doesn't answer your question if you want the computer to calculate it, by only using the sound batches N. If this is the case I'm still trying to use a special diagram to solve it.


Hope this helps.
 
i might suggest to the OP to post this at the USENET newsgroup comp.dsp.
 
To RandomMystery and rbj

Thanks for replying.

You got my idea right, "lag" is the difference between when sound reaches the microphone.

If the audio source moves wrt microphones, in any sense it does, distances will change even if distance between microphones keeps.

I want the microprocessor to calculate it using autocorrelation.
 
As soon as the first microphone picks up some noise, it should send a signal to the second microphone to record time. It then stops recording that time, when the same sound reaches it. The time recorded is the lag.

Now, do you also want an equation to also factor in the magnitude of the sound? The method above should work, but the equipment that is farther away from the sound source, will register it as having less batches of N. I'm assuming that when one microphone gets N batches, the other one won't recognize the sounds as N batches, but as N - x batches, (since it's farther away)
If that's the case, we need to find some ratio or relation ship between the batches of one microphone and the other. Which I'm still trying to do with the same diagram.
 
Okay, this might work:


(Distance from the farther microphone to the sound source - the Distance from the nearer microphone to the sound source)
(Batch N from the nearer microphone - Batch N from the farther microphone)



Test and see if this ratio is true for every distance (or just enough to prove it's accuracy). If it is true, then all you have to do is:


(Batch N from the nearer microphone - Batch N from the farther microphone)(the same ratio written above)
(the speed of sound)

*This looks kind of messy, the underline indicates divide by what's under it.
You only have to find that ratio once, if my assumptions are correct. Assuming that your not moving the microphones, but only the sound source.

Edit: To calculate the distance, have a computer start recording time when sound is released, then have the microphone send a signal to stop the recording time when the signal reaches the microphone. Divide the duration of the recording by the speed of sound to get the distance. Make sure you have the right units.
 
Last edited:
Hola RM,

Quoting myself:

Can anyone tell:

The actual formula to be implemented?.

What are the succesive steps required to process the data set just acquired?

Normalization, is it needed? If so, how do you actually do it and when?


As the the title says, with Autocorrelation. I want to solve it that way.

Thanks for your time, anyway.
 
Hi RM,
I have been told to use cross correlation since the signal en each channel is to be considered a different one. No outocorrelation then.

Sorry for wasting your time. Thanks.
 

Similar threads

Replies
7
Views
4K
  • · Replies 13 ·
Replies
13
Views
4K