[pulseaudio-discuss] Testing echo cancellation on an armhf OMAP phone

Arun Raghavan arun.raghavan at collabora.co.uk
Mon Dec 17 21:26:19 PST 2012


On Tue, 2012-12-18 at 06:58 +0200, Tanu Kaskinen wrote:
> On Mon, 2012-12-17 at 21:49 +0000, Neil Jerram wrote:
> > Hi pulseaudio folk.  I've been following the list for a while, but this
> > is my first post...
> > 
> > I'm working with PulseAudio on the GTA04 phone, specifically trying to
> > use it to route the audio during a call, with echo cancellation.

That's quite interesting!

> > Without the echo cancellation, the picture would be:
> > 
> >  +----------+                                +--------------------+
> >  | GSM chip |------ module-loopback -------->|earpiece (sink)     |
> >  |  sound   |                                |                    |
> >  |   card   |<------- module-loopback -------|microphone (source) |
> >  +----------+                                +--------------------+
> > 
> > The earpiece and microphone belong to a single sound card, which is
> > different from the GSM chip sound card.
> > 
> > The GSM source and sink are named
> > alsa_input.platform-soc-audio.1.analog-mono and
> > alsa_output.platform-soc-audio.1.analog-mono.  The earpiece is
> > alsa_output.platform-soc-audio.0.analog-stereo and the microphone is
> > alsa_input.platform-soc-audio.0.analog-stereo.
> > 
> > To add in echo cancellation, I load module-echo-cancel, and then start
> > up the loopbacks like this:
> > 
> >   exec pactl load-module module-loopback \
> >     source=alsa_input.platform-soc-audio.0.analog-stereo.echo-cancel \
> >     rate=8000 \
> >     sink=alsa_output.platform-soc-audio.1.analog-mono
> > 
> >   exec pactl load-module module-loopback \
> >     source=alsa_input.platform-soc-audio.1.analog-mono \
> >     rate=8000 \
> >     sink=alsa_output.platform-soc-audio.0.analog-stereo.echo-cancel
> > 
> > Does that all sound correct in theory?
> 
> Yes, I think so.

As Tanu says, yes it does.

> > Now, I'm not actually at the point of doing all that yet.  First I'm
> > trying to test the echo cancellation.  To do that, I:
> > 
> > - load module-echo-cancel
> > 
> > - do "paplay -d
> >   alsa_output.platform-soc-audio.0.analog-stereo.echo-cancel
> >   /media/card/Documents/audio/ogg/Do\ They\ Know\ It\'s\ Christmas.ogg"
> >   in one terminal
> > 
> > - do "parecord -d
> >   alsa_input.platform-soc-audio.0.analog-stereo.echo-cancel
> >   --file-format=wav > record1.wav" in another terminal
> > 
> > - speak into the microphone.
> > 
> > Then the idea is that I would play record1.wav back and see if contains
> > an echo of the song.
> > 
> > However, I seem to be hitting various problems, which I suspect are all
> > to do with resampling.
> > 
> > -  With the default resample method (speex-float-3), I don't get any
> >    sound at the earpiece, except for intermittent crackling.
> > 
> > -  I then tried speex-fixed-3.  This gives recognisable song playback at
> >    the earpiece, but with strange echo-like distortions - i.e. as though
> >    short snatches of the song are being repeated.
> > 
> > -  I then tried src-sinc-fastest, and found that PulseAudio exited as
> >    soon as I loaded module-echo-cancel.
> > 
> > -  I then tried src-linear.  This gives good song playback, except for
> >    occasional clicks and crackles.
> > 
> > The song is at 44.1 kHz, I think the sound card's default rate is 48
> > kHz, and it looks from the log as though module-echo-cancel causes the
> > song to be resampled to 32 kHz (and presumably then back to 48 kHz?).
> > Is that all expected, and is there any way of reducing this amount of
> > playback resampling?

You could try setting the resampler to 'ffmpeg', which is really
light-weight. speex-fixed-0 might be useful to test as well.

> If you haven't configured the sample rate of module-echo-cancel, then it
> will default to 32 kHz (I don't know why), which indeed will cause
> unnecessary resampling just as you described. If the hardware runs at 48
> kHz, then I think it's best to pass "rate=48000" to module-echo-cancel.
> 
> I think it would make sense to modify module-echo-cancel to use the rate
> of the microphone by default...

Different echo-cancellation algorithms work best at certain sample rates
(depending on the filters they embed). I've picked the highest viable
one for each canceller as the default, so setting something higher is
not a good idea.

What would make sense is to pick the sample rate that you're getting
from the GSM sound card, which it seems you're doing already
(rate=8000)?

Also, are you using the webrtc echo canceller or speex?

Cheers,
Arun



More information about the pulseaudio-discuss mailing list