I need to estimate the delay between a loudspeaker signal and a microphone signal in real-time. The delay might be as large as 400ms. If I buffer up both time domain signals in a 500ms buffer, what is the best method for estimating the delay? I need something that will work with noisy signals (noisy meaning light office noise). Thanks
Estimation of delay between speaker signal and microphone signal (AEC)
Started by ●March 22, 2013
Reply by ●March 22, 20132013-03-22
On 3/22/2013 9:23 AM, Mauritz Jameson wrote:> I need to estimate the delay between a loudspeaker signal and a > microphone signal in real-time.Do you mean cut away plain delay part from the response?> The delay might be as large as > 400ms.How could be? 400ms is a lot.> If I buffer up both time domain signals in a 500ms buffer, what is > the best method for estimating the delay?For offline processing, you could try direct Wiener filter solution; but it would likely require lot more data then 500ms for stable work.> I need something that will > work with noisy signals (noisy meaning light office noise).Could you run special test signal or this is intended to operate with actual speech signals? For test signal, run a sum of sinewaves. Measure phases on the receive side. Resolve ambiguity by solving the system of equations. For speech, estimate the delay by LMS response over decimated data (straight LMS over 400ms would be too much of computation). Vladimir Vassilevsky DSP and Mixed Signal Designs www.abvolt.com
Reply by ●March 22, 20132013-03-22
Maybe use a large fft to cross-correlate? You would need to zero-pad the input to make sure you are getting linear correlation and not circular. Don't know what your sample-rate is, but I'm guessing you could get by with a 32k or 64k fft size. If you knew what the minimum delay was, you could make the problem easier by inserting a delay in one path, which would reduce the size of the cross-correlation. Bob
Reply by ●March 22, 20132013-03-22
>I need to estimate the delay between a loudspeaker signal and a microphonesignal in real-time. Real-Time? Like the microphone is moving?>The delay might be as large as 400ms.So across 100 meters or so of space? Are you doing sound for Red Rocks?> >If I buffer up both time domain signals in a 500ms buffer, what is thebest method for estimating the delay? I need something that will work with noisy signals (noisy meaning light office noise).> >Thanks >The key is to feed in a known signal and look for it. Transmit some kind of pattern and correlate the recieved data with it to lock onto it. With a delay that large, the first thing that comes to mind is to feed in some kind of impulse and look for it in the microphone signal. If you fire the impulse at a known low frequency rate, say once a second, you could lock onto one impulse and save a bit of time looking for recurring impulses, because you know about how frequently they happen. Another idea I have thats kind of based on the first idea would be to low frequency amplitude a sine wave. Narrow band filter the recieved signal about the sine wave. Apply a peak detection algorithm on that signal (like an AM radio reciever). You should be left with the low frequency component. You can now measure the phase difference between the transmitted and recieved component, which you can use to get the time delay.
Reply by ●March 22, 20132013-03-22
On 3/22/13 11:06 AM, radams2000@gmail.com wrote:> Maybe use a large fft to cross-correlate?and search for the maximum correlation value. if it's possible that you have a polarity reversal from microphone to loudspeaker, then you need to look for the maximum in magnitude. be sure your signal is reasonably broadbanded you don't want to do this with a single sine wave. you will get several plausible peaks in the cross correlation and your result could be off by an integer number of wavelengths. if the microphone and loudspeaker remain stationary (relative to each other), you can perform a moving average of each lag over the multiple cross-correlations and smooth things out a little.> You would need to zero-pad the input to make sure you are getting linear correlation and not circular. Don't know what your sample-rate is, but I'm guessing you could get by with a 32k or 64k fft size. > > If you knew what the minimum delay was, you could make the problem easier by inserting a delay in one path, which would reduce the size of the cross-correlation.yup. and if the number of lags in the correlation is small, even if the window is big, you might find it easier to just crank out the cross-correlation the old fashioned way. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by ●March 22, 20132013-03-22
On Fri, 22 Mar 2013 09:54:01 -0500, Vladimir Vassilevsky wrote:> On 3/22/2013 9:23 AM, Mauritz Jameson wrote: >> I need to estimate the delay between a loudspeaker signal and a >> microphone signal in real-time. > > Do you mean cut away plain delay part from the response? > >> The delay might be as large as >> 400ms. > > How could be? 400ms is a lot. > >> If I buffer up both time domain signals in a 500ms buffer, what is the >> best method for estimating the delay? > > For offline processing, you could try direct Wiener filter solution; but > it would likely require lot more data then 500ms for stable work.The "Wiener filter" that I was taught is basically a steady-state Kalman filter arrived at by computation in the frequency domain, and wouldn't have any bearing on this problem except possibly as a means to best filter out noise from the signal.. What Wiener filter are you referring to?>> I need something that will >> work with noisy signals (noisy meaning light office noise). > > Could you run special test signal or this is intended to operate with > actual speech signals? > > For test signal, run a sum of sinewaves. Measure phases on the receive > side. Resolve ambiguity by solving the system of equations.Depending on the environment, and given 400ms of anticipated delay, a pulse may be better. Or a pulse to get the rough delay, followed by the sine sweep to refine things. -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
Reply by ●March 22, 20132013-03-22
I've done this experiment with large FFT / crosscorrelation a couple of years ago on a laptop (also with sound source on a mobile phone). "Portaudio" on mingw works fine, can do full-duplex audio. Use a cyclic signal right from the start. then there is no need for windowing and it doesn't matter where you cut your FFT slice. What I do remember is that reflections were surprisingly strong - often higher than the direct path. And, it's easy to generate very unpleasant test signals...
Reply by ●March 22, 20132013-03-22
I can't even tell if I'm understanding the problem correctly. Is appliying a known signal at the speaker and measuring it at the microphone even a viable option? Or are we talking about something that estimates the delay in situ, i.e. during a performance?
Reply by ●March 22, 20132013-03-22
On Mar 22, 10:23�am, Mauritz Jameson <mjames2...@gmail.com> wrote:> I need to estimate the delay between a loudspeaker signal and a microphone signal in real-time. The delay might be as large as 400ms. > > If I buffer up both time domain signals in a 500ms buffer, what is the best method for estimating the delay? I need something that will work with noisy signals (noisy meaning light office noise). > > ThanksGeneralized cross-correlation (ordinary cross-correlation is one particular instance of it) would be your standard textbook answer btw, this group is free so you get what you pay for...
Reply by ●March 22, 20132013-03-22
On 3/22/13 3:31 PM, dszabo wrote:> I can't even tell if I'm understanding the problem correctly. Is appliying > a known signal at the speaker and measuring it at the microphone even a > viable option?that was my assumption.> Or are we talking about something that estimates the delay > in situ, i.e. during a performance?even with a vocal or some other source, if there *is* a feedback path that adds to that at the microphone, then i think there are system identification techniques to identify the nature of the loop transfer function and the delay could be derived from the phase of that loop transfer function. i think the SFX (sabine feedback exterminator) does something like that. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."






