[Speex-dev] [patch] speex AEC state save & restore

Steve Underwood steveu at coppice.org
Mon Apr 4 05:08:55 PDT 2011

On 04/04/2011 06:58 PM, Simon Morlat wrote:
> Hi,
> I implemented a small patch that allows the internal convergence state
> of the echo canceller to be saved in a file for later use, especially
> after a process restart or machine reboot. This enables immediate echo
> cancellation the second time the AEC is run.
> Of course this works only if the acoustic environment of the device
> doesn't change and if the soundcard latency is constant.
That's probably a fair assumption for a desktop machine, but totally 
bogus for a notebook. Is there a clear way to tell the difference, and 
make a judgement as to whether this feature should be enabled.

> To use this feature, proceeed as this:
>   - use speex_echo_ctl() with SPEEX_ECHO_GET_BLOB to obtain a
> SpeexEchoStateBlob, at the end of an audio session, when the echo
> canceller is supposed to be converged.
>   - save the blob to a disk file for example, using
> speex_echo_state_blob_get_data() and speex_echo_state_blob_get_size() to
> retrieve the actual data
> To restore the state later, after a reboot or a process restart, do the
> following:
>   - read the data from the file where you previously save the blob's
> contents
>   - instanciate a blob object from this data using
> speex_echo_state_blob_new_from_memory()
>   - assign the blob to the echo canceller using speex_echo_ctl() with
> SPEEX_ECHO_SET_BLOB, before the echo canceller starts processing data.
> The way it works is that is saves the foreground weights of the echo
> canceller filter. When restored, it is also restored in the background
> filter. Some sanity checks on the configuration parameters ( frame size,
> filter length, channels) are performed to verify that the restoration is
> applicable to the current echo state object.
> I wonder if there are parameters other than weights that should be saved
> too. Feel free to comment, adapt, apply or reject.
> On a side comment, I would like to congratulate the author(s) of the
> Speex Echo Canceller, because it really works very well compared to
> competition and provide good cancellation even in difficult situations.
> The performance of the non-linear echo suppression with the
> speex_preprocess() api is really amazing.
It works well if the sound card has synchronised mic and speaker 
sampling, and is horrible otherwise. So, its great on Macs, and pot luck 
on PCs. Perhaps the canceller should detect one sampling rate sliding 
against the other, and talk alternate action?


More information about the Speex-dev mailing list