Forums

Undo frequency change by audio device before echo cancellation?

Started by roschler June 17, 2010
I am squarely in the camp of knowing barely enough DSP to be
dangerous.  I have successfully coded up some FIR filters to assist in
sample rate conversions between audio files but that's about it.  My
ambition could easily exceed my capacity here.

I want to do echo cancellation of audio coming into a microphone that
is positioned right next to an output speaker on an audio device I
own.  Whenever audio is played out the speaker it comes right back
into the microphone.  I have found a good open source echo
cancellation module on the Web so I've got that part covered.  But to
get the best results, I want to undo the frequency response of the
device's speaker, which is a small 2 to 3 inch single speaker that
heavily modifies the output audio, before I attempt to do echo
cancellation on the microphone's input which contains the affected
speaker output.  My end goal is to be able to listen as best as
possible to the microphone input with minimal interference from any
prompts, etc. being played out the speaker.

I have a pristine copy of the audio that I am sending out the speaker
so getting that is not a problem.  Here is what I am thinking of
doing.  I want to create a filter that undoes the alteration to the
output audio coming out the speaker.  Since the mic is right on top of
the speaker I would think that the frequency profile of the alteration
is fairly constant so I don't have to consider environmental
reverberation.  I have read that the way this is usually done is to
take a sound source that emits an all frequency blast, an "impulse",
record it coming out the output device, and then some operation is
done to calculate the change in frequency response caused by the
output device and that is later encoded into a filter that undoes the
alteration.

Is this something I could tackle with my capability?  Note, if you
know of a good tutorial or software module that does this just point
me in that direction.

Thanks,
Robert

roschler wrote:

> I am squarely in the camp of knowing barely enough DSP to be > dangerous. I have successfully coded up some FIR filters to assist in > sample rate conversions between audio files but that's about it. My > ambition could easily exceed my capacity here. > > I want to do echo cancellation of audio coming into a microphone that > is positioned right next to an output speaker on an audio device I > own. Whenever audio is played out the speaker it comes right back > into the microphone. I have found a good open source echo > cancellation module on the Web so I've got that part covered. But to > get the best results, I want to undo the frequency response of the > device's speaker, which is a small 2 to 3 inch single speaker that > heavily modifies the output audio, before I attempt to do echo > cancellation on the microphone's input which contains the affected > speaker output. My end goal is to be able to listen as best as > possible to the microphone input with minimal interference from any > prompts, etc. being played out the speaker. > > I have a pristine copy of the audio that I am sending out the speaker > so getting that is not a problem. Here is what I am thinking of > doing. I want to create a filter that undoes the alteration to the > output audio coming out the speaker. Since the mic is right on top of > the speaker I would think that the frequency profile of the alteration > is fairly constant so I don't have to consider environmental > reverberation. I have read that the way this is usually done is to > take a sound source that emits an ayll frequency blast, an "impulse", > record it coming out the output device, and then some operation is > done to calculate the change in frequency response caused by the > output device and that is later encoded into a filter that undoes the > alteration. > > Is this something I could tackle with my capability? Note, if you > know of a good tutorial or software module that does this just point > me in that direction.
The coupling between speaker and mike is very much dependent on the environment. You can try to find the "common part" of the response by analyzing the coefficients of the converged adaptive filter, but this is likely to be different at every time. If there is a common part, you can certainly cancel it. However the common part tells about strong speaker-mike coupling in your audio setup, which means the AEC is not going to work well. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
>I am squarely in the camp of knowing barely enough DSP to be >dangerous. I have successfully coded up some FIR filters to assist in >sample rate conversions between audio files but that's about it. My >ambition could easily exceed my capacity here. > >I want to do echo cancellation of audio coming into a microphone that >is positioned right next to an output speaker on an audio device I >own. Whenever audio is played out the speaker it comes right back >into the microphone. I have found a good open source echo >cancellation module on the Web so I've got that part covered. But to >get the best results, I want to undo the frequency response of the >device's speaker, which is a small 2 to 3 inch single speaker that >heavily modifies the output audio, before I attempt to do echo >cancellation on the microphone's input which contains the affected >speaker output. My end goal is to be able to listen as best as >possible to the microphone input with minimal interference from any >prompts, etc. being played out the speaker. > >I have a pristine copy of the audio that I am sending out the speaker >so getting that is not a problem. Here is what I am thinking of >doing. I want to create a filter that undoes the alteration to the >output audio coming out the speaker. Since the mic is right on top of >the speaker I would think that the frequency profile of the alteration >is fairly constant so I don't have to consider environmental >reverberation. I have read that the way this is usually done is to >take a sound source that emits an all frequency blast, an "impulse", >record it coming out the output device, and then some operation is >done to calculate the change in frequency response caused by the >output device and that is later encoded into a filter that undoes the >alteration. > >Is this something I could tackle with my capability? Note, if you >know of a good tutorial or software module that does this just point >me in that direction.
The frequency response of that path will vary as the environment varies, and the echo canceller should already be allowing for that in its adaptive process. If you don't get great cancellation its either a weakness in the canceller algorithm, or non-linearities in the speaker or microphone. A typical nasty rattly little 2" speaker's non-linearities are the usual performance limiter. Better mounting often helps a lot. Steve
On Jun 18, 12:27&#2013266080;am, roschler <robert.osch...@gmail.com> wrote:
> I am squarely in the camp of knowing barely enough DSP to be > dangerous. &#2013266080;I have successfully coded up some FIR filters to assist in > sample rate conversions between audio files but that's about it. &#2013266080;My > ambition could easily exceed my capacity here. > > I want to do echo cancellation of audio coming into a microphone that > is positioned right next to an output speaker on an audio device I > own. &#2013266080;Whenever audio is played out the speaker it comes right back > into the microphone. &#2013266080;I have found a good open source echo > cancellation module on the Web so I've got that part covered. &#2013266080;But to > get the best results, I want to undo the frequency response of the > device's speaker, which is a small 2 to 3 inch single speaker that > heavily modifies the output audio, before I attempt to do echo > cancellation on the microphone's input which contains the affected > speaker output. &#2013266080;My end goal is to be able to listen as best as > possible to the microphone input with minimal interference from any > prompts, etc. being played out the speaker. > > I have a pristine copy of the audio that I am sending out the speaker > so getting that is not a problem. &#2013266080;Here is what I am thinking of > doing. &#2013266080;I want to create a filter that undoes the alteration to the > output audio coming out the speaker. &#2013266080;Since the mic is right on top of > the speaker I would think that the frequency profile of the alteration > is fairly constant so I don't have to consider environmental > reverberation. &#2013266080;I have read that the way this is usually done is to > take a sound source that emits an all frequency blast, an "impulse", > record it coming out the output device, and then some operation is > done to calculate the change in frequency response caused by the > output device and that is later encoded into a filter that undoes the > alteration. > > Is this something I could tackle with my capability? &#2013266080;Note, if you > know of a good tutorial or software module that does this just point > me in that direction. > > Thanks, > Robert
In addition to everything said, there are less obvious (hidden) issues that you might to factor in as well, of course depending on how good a job you'r aiming for. I can't remember exactly now, but I think just a while back I came across a paper talking about a sort of drift effect caused by a mismatch of the sampling rate between the DAC and ADC of your speaker and mic, respectively. This basically means that your adaptive filter has to incorporate a rate change stage to keep the loop in perfect lock. -Momo