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

Neil Jerram neil at ossau.homelinux.net
Mon Dec 17 13:49:48 PST 2012


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.

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?

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?

Now - still with src-linear - if I try the parecord line at the same
time as the playback, the log goes crazy with umpteen rapid repeats of:

Dec 17 21:04:34 neo pulse.sh: I: [alsa-source] alsa-source.c: Trying resume...
Dec 17 21:04:34 neo pulse.sh: I: [alsa-source] alsa-util.c: Trying to disable ALSA period wakeups, using timers only
Dec 17 21:04:34 neo pulse.sh: I: [alsa-source] alsa-util.c: Device hw:0 doesn't support 44100 Hz, changed to 48000 Hz.
Dec 17 21:04:34 neo pulse.sh: I: [alsa-source] alsa-util.c: ALSA period wakeups disabled
Dec 17 21:04:34 neo pulse.sh: W: [alsa-source] alsa-source.c: Resume failed, couldn't restore original sample settings.

and I get no content (apart from the WAV header) in the file that I'm
trying to record.

On the other hand, if I try the parecord on its own when not also
playing back, it works fine.

I'd very much appreciate any input on whether what I'm doing looks right
(which I'm not yet confident at all about) and on the observations of
things not working as I'd expect.

Many thanks,
     Neil


More information about the pulseaudio-discuss mailing list