Thorvald Natvig
2005-May-31 14:45 UTC
[Speex-dev] trouble getting speex_echo_cancel() to work
I'm trying to convert my current headphones and microphone chat application to support loudspeakers and microphone, and so I thought I'd give speex_echo_cancel() a try. Since my users quite frequently have other sound-producing applications running on their computer (such as winamp), I sample 'wave' recording device of the soundcard in addition to the microphone. I then call speex_echo_cancel() as speex_echo_cancel(st, data sampled from microphone device, data sampled from output of soundcard, output pointer, y-buffer) .. which as I understand it should be correct? I've gone to some effort to make sure that the two sets of sampled data are from the exact same time (seems my two soundcards don't sample 32khz at the exact same rate, they differ by about 0.1%), but it doesn't remove any of the echo, it just provides some weird artifacts in addition to the original signal. I'm using a framesize of 640, the same as the speex framesize at 32khz uwb, and tested this with speex 1.1.8 If anyone has some idea on what I'm doing wrong, please let me know :)
Jean-Marc Valin
2005-May-31 16:05 UTC
[Speex-dev] trouble getting speex_echo_cancel() to work
Hi, A couple things you may want to check: - set sampling rate to 8 kHz (at least for now) - make sure the far end signal in the playback signal is always a bit in advance (never late) compared to the mic signal. - Set the tail length to something around 100 ms. Also, if you're using two different soundcards (as I understand) for the playback and the capture, you're *never* going to get echo canceller to work because the playback and capture need to be *exactly* in sync. Jean-Marc Le mardi 31 mai 2005 ? 23:38 +0200, Thorvald Natvig a ?crit :> I'm trying to convert my current headphones and microphone chat > application to support loudspeakers and microphone, and so I thought I'd > give speex_echo_cancel() a try. > > Since my users quite frequently have other sound-producing applications > running on their computer (such as winamp), I sample 'wave' recording > device of the soundcard in addition to the microphone. > > I then call speex_echo_cancel() as > > speex_echo_cancel(st, data sampled from microphone device, data sampled > from output of soundcard, output pointer, y-buffer) > > .. which as I understand it should be correct? > > I've gone to some effort to make sure that the two sets of sampled data > are from the exact same time (seems my two soundcards don't sample 32khz > at the exact same rate, they differ by about 0.1%), but it doesn't remove > any of the echo, it just provides some weird artifacts in addition to the > original signal. > > I'm using a framesize of 640, the same as the speex framesize at 32khz > uwb, and tested this with speex 1.1.8 > > If anyone has some idea on what I'm doing wrong, please let me know :) > > _______________________________________________ > Speex-dev mailing list > Speex-dev@xiph.org > http://lists.xiph.org/mailman/listinfo/speex-dev >-- Jean-Marc Valin <Jean-Marc.Valin@USherbrooke.ca> Universit? de Sherbrooke
Thorvald Natvig
2005-Jun-02 07:05 UTC
[Speex-dev] trouble getting speex_echo_cancel() to work
> - set sampling rate to 8 kHz (at least for now) > - make sure the far end signal in the playback signal is always a bit in > advance (never late) compared to the mic signal. > - Set the tail length to something around 100 ms. > > Also, if you're using two different soundcards (as I understand) for the > playback and the capture, you're *never* going to get echo canceller to > work because the playback and capture need to be *exactly* in sync.I did a bit more testing, and ended up creating a set of testsamples, as follows: ideal.pcm => me saying "This is what I'd like to hear" junk.pcm => me saying "With a bit of luck, this is gone" mixdown.pcm => ideal.pcm, with junk.pcm started 7 ms later and 3 dB lower. (All of this as 8000 Hz, 16-bit signed) I then copied junk.pcm to play.sw, mixdown.pcm to mic.sw and ran testecho. The output sounds almost identical to the mixdown, and far from "ideal". As a 2nd test, I made play.sw and mic.sw identical (both the mixdown). The result is the same as the mixdown, with the volume slowly decaying until it's about 15 dB lower at the end of the 8 sec sample. Somewhat encouraged by this, I made a much longer set of samples, and in the mixdown I inserted the "desired" sound 5 seconds into the mix to let the filter have time to adapt. Indeed, after a few seconds, the echo is reduced by about 15 dB, but that will still be loud enough to be annoying and distractive when talking. Are there any tunable parameters I can set to allow the echo canceller to be a bit more aggressive?