[Speex-dev] Reseting Echo State

Peter Meerwald pmeerw at pmeerw.net
Wed May 26 01:07:32 PDT 2010


> I want to make echo tail parameter in my app changeable during run-time.
> Should I use speex_echo_state_reset function for this? Just call
> speex_echo_state_init function with new values after that?

> Or perform a full de-initialization and initialize echo cancellation
> with new tail value?

speex_echo_state_reset() currently fails to fully reset the EC state; esp. 
the correct reset of last_y is important (see partial fix below) -- I'd 
rather do a de-init for now

diff --git a/libspeex/mdf.c b/libspeex/mdf.c
index 8a5c031..2a5088c 100644
--- a/libspeex/mdf.c
+++ b/libspeex/mdf.c
@@ -536,13 +536,13 @@ EXPORT void speex_echo_state_reset(SpeexEchoState 
*st)
    M = st->M;
    C=st->C;
    K=st->K;
-   for (i=0;i<N*M;i++)
+   for (i=0;i<C*K*N*M;i++)
       st->W[i] = 0;
 #ifdef TWO_PATH
-   for (i=0;i<N*M;i++)
+   for (i=0;i<C*K*N*M;i++)
       st->foreground[i] = 0;
 #endif
-   for (i=0;i<N*(M+1);i++)
+   for (i=0;i<K*N*(M+1);i++)
       st->X[i] = 0;
    for (i=0;i<=st->frame_size;i++)
    {
@@ -551,7 +551,7 @@ EXPORT void speex_echo_state_reset(SpeexEchoState *st)
       st->Eh[i] = 0;
       st->Yh[i] = 0;
    }
-   for (i=0;i<st->frame_size;i++)
+   for (i=0;i<C*N;i++)
    {
       st->last_y[i] = 0;
    }
@@ -578,7 +578,7 @@ EXPORT void speex_echo_state_reset(SpeexEchoState *st)
    st->Davg1 = st->Davg2 = 0;
    st->Dvar1 = st->Dvar2 = FLOAT_ZERO;
 #endif
-   for (i=0;i<3*st->frame_size;i++)
+   for (i=0;i<K*(PLAYBACK_DELAY+1)*st->frame_size;i++)
       st->play_buf[i] = 0;
    st->play_buf_pos = PLAYBACK_DELAY*st->frame_size;
    st->play_buf_started = 0;


regards, p.

-- 

Peter Meerwald
Kaigasse 3 / 8
A-5020 Salzburg / AUSTRIA
+43-664-2444418 (mobile)


More information about the Speex-dev mailing list