[Speex-dev] Acoustic echo cancellation

Li Maoquan
Tue, 19 Apr 2011 00:21:58 -0000

>>>> Hi,
>>>
>>> I have a scenario in a mobile VoIP app that requires echo
cancellation but
>>> is somewhat different from what's described in the docs.
>>>
>>> Audio is received from and sent to the network at 8000Hz. Each
packet
>>> contains 160 samples worth a playback of 20ms.
>>>
>>> But the hardware requires aggregation for both playback and
capture. So for
>>> playback, I coalesce 4 packets in a buffer and queue them as a
larger buffer
>>> for playback.
>>> On the send side, I read a large buffer (worth 4 packets) and send
them out
>>> over time 20ms apart.
>>>
>>> I tried using speex_echo_playback just when a 160-sample packet
arrives from
>>> the network, before coalescing and speex_echo_capture just before a
packet
>>> is sent out to the network but that doesn't seem to work
properly (doesn't
>>> cancel any echo).
>>
>> The most likely reason is that you didn't align the far-end and
near-end samples.
>> So the filter can not converge.
>
>Thanks for your response. Can you please explain what you mean by
>align samples from near-end and far-end? And how is that usually
>accomplished?

You need to know the total delay caused by DAC buffer before speaker, ADC buffer
after microphone and acoustic path between speaker and microphone. Simply to
say,
if you play an impluse signal and its first echo appears after N sample cycles,
you can call N as the delay between y (echo in near-end signal) and x (far-end
signal). Then you can buffer far-end signal for N-M cycles before sending to
AEC.
M is a little number (such as 100) in order to avoid filter failure when echo
path drifts.

>>
>>>> So, in this scenario above, please recommend a good place to
insert
>>> speex_echo_playback and speex_echo_capture. Should I be just before
the read
>>> and write to hardware? In that case, should I use a larger
"frame size" of
>>> 160 samples x 4?
>>
>> Of course you can set frame size to 160*4. Otherwise you can feed
samples 4 times
>> to the AEC if you don't want to modify the frame size.
>>
>>>
>> Thanks in advance,
>> Daniel.
-------------- next part --------------
An HTML attachment was scrubbed...