view intercom/aec_test.txt @ 6:22a74b01a099 default tip

implement more meaningful test program
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Fri, 25 Jun 2010 16:14:50 +0200
parents 13be24d74cd2
children
line wrap: on
line source

/***************************************************************
A.5 Test source code
***************************************************************/

The microphone and loudspeaker signals have to be synchronized on a
sample-to-sample basis to make acoustic echo cancellation working.
An AC97 conformal on-board soundcard in a Personal Computer can be set
in a special stereo mode: The left channnel records microphone signal
and the right channel records loudspeaker signal.

To set-up a Linux PC with ALSA sound system, electret microphone like 
Labtec Verse 333 connected to Mic in and loudspeaker connected to right
Line out enter:

  amixer -q set 'Master',0 70% unmute
  amixer -q set 'PCM',0 70% unmute
  amixer -q set 'Line',0 0% mute
  amixer -q set 'CD',0 0% mute
  amixer -q set 'Mic',0 0% mute
  amixer -q set 'Video',0 0% mute
  amixer -q set 'Phone',0 0% mute
  amixer -q set 'PC Speaker',0 0% mute
  amixer -q set 'Aux',0 0% mute
  amixer -q set 'Capture',0 50%,0%
  amixer -q set 'Mic Boost (+20dB)',0 1
  amixer -q cset iface=MIXER,name='Capture Source' 0,5
  amixer -q cset iface=MIXER,name='Capture Switch' 1

To test the acoustic echo cancellation we simulate a real telephone
conversation in 5 steps: 
  (1) record far-end speaker,
  (2) perform acoustic echo cancellation (this should change nothing)
  (3) playback far-end speaker and at the same time record near-end speaker
  (4) perform acoustic echo cancellation
  (5) playback near-end speaker (far-end speech should be cancelled)
  
# To compile the test program aec_test read file aec_test.cpp.
  
# To record 10 seconds of speech into the file b.raw enter:
arecord -c 2 -t raw -f S16_LE -r 16000 -d 10 >b.raw
  
# To perform AEC at the far-end enter:
./aec_test <b.raw >b1.raw

# To playback file b1.raw and simultaneously record b2.raw enter both 
# commands in one go:
aplay -c 2 -t raw -f S16_LE -r 16000 b1.raw &
arecord -c 2 -t raw -f S16_LE -r 16000 -d 10 >b2.raw
  
# To perform AEC at the near-end enter:
./aec_test <b2.raw >b3.raw

# To playback the echo-cancelled near-end enter:
aplay -c 2 -t raw -f S16_LE -r 16000 b3.raw

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.