[Speex-dev] how to use echo cancel

Jiang zhou zjiang at sipod.com
Fri Nov 26 23:32:02 PST 2004


Hi, all

I want to use echo cancel in our application. We we have use iLBC codec. I
have test it but it seem don't cancel the echo voice. 
The follow function Voice_EchoCancel is all my echo code.  Before encod a
frame I call this function. 
sample is recorded from mic and echo is a static buffer when playback a
decoded frame it will copy it to this static buffer.

I have a test on this system. But I can hear my own voice. Can someone help
me on use this fucntion. 

Thank you
Jiang zhou

void Voice_EchoCancel(short *sample,short *echo,int len)
{
    static int is_init =0;
    static SpeexEchoState *st = 0;
    static int NN = 160;
    static short echo_buf[1024], ref_buf[1024], e_buf[1024];

    int i;
    
    if( NN!= len )
    {
        NN = len;
        is_init = 0;
        if(st )
            speex_echo_state_destroy(st);
        st = NULL;
    }
    if(is_init == 0 )
    {
        st = speex_echo_state_init(NN, 800);
    }
    
    for (i=0;i<NN;i++)
        ref_buf[i] = sample[i];
    for (i=0;i<NN;i++)
        echo_buf[i] = echo[i];
    speex_echo_cancel(st, ref_buf, echo_buf, e_buf, NULL);
    for (i=0;i<NN;i++)
        sample[i] = e_buf[i];
    
}




More information about the Speex-dev mailing list