Setting up the echo cancellation in Pulseaudio is done by loading the module-echo-cancel-module:
Code: Select all
pactl load-module module-echo-cancel aec_method=webrtc
Code: Select all
load-module module-echo-cancel aec_method=webrtc
Built-in Audio Analog Stereo (echo cancelled with Built-in Audio Analog Stereo)
The name by default contains your default input and output device's name, echo cancelled with itself.
It works like this:
You start the application and change the default output AND input device to the echo-cancelled stream either from within the application (if the application "sees" the Pulseaudio streams) or externally (this works for all applications) from pavucontrol/desktop volume control applet. I recommend using pavucontrol (pavucontrol package) for this.
Also there is a really nice system tray application called "pasystray" (pasystray package) that can do it from drop-down menus (also launching pavucontrol and pretty much every pulseaudio manager application).
Notes:
- Echo cancellation works only if BOTH the recording and playback streams go through the echo cancel virtual device.
- If you set an application via the external method to use the echo cancel device, Pulseaudio will remember the setting for that application and next time it is launched it will automatically be played back through the echo cancel device.
Possible Issues:
- when the microphone has adjustable gain control and you use voice applications through pulseaudio the echo-cancel module it may happen that in certain applications the auto gain control is over-sensitive and leads to sudden gain changes which generate annoying background noises when the gain is suddenly increased.
The vailable controls can be easily found by using the terminal "alsamixer" application. Note that most likely after launch you will see only the "pulse" device, so you will have to change it to your hardware device by pressing F6, select your card (NOT the ones that have HDMI in their name) then press TAB to cycle to your "capture" tab. See if you have there an adjustable slider that has something like "Rear Mic Boost" (varies depending of your actual capture device name).
Solutions:
1. Disable the AGC in the echo-canceller module (certain applications will still provide AGC on their own, but might alleviate the issue with 2 overlapping AGC methods):
Code: Select all
pactl unload-module module-echo-cancel
pactl load-module module-echo-cancel aec_method=webrtc aec_args="analog_gain_control=0\ digital_gain_control=0"
Code: Select all
load-module module-echo-cancel aec_method=webrtc aec_args="analog_gain_control=0\ digital_gain_control=0"
http://thread.gmane.org/gmane.comp.audi ... eral/25742
2. Prevent Pulseaudio from accessing the echo canceller altogether - this will prevent everything from messing with the adjustable gain control, but this is a hacky solution and will have to be redone EVERY TIME PULSEAUDIO IS UPDATED.
This is done by finding and editing the input control files in /usr/share/pulseaudio/alsa-mixer/paths/ directory. There is no "one solution fits all" here, you have to locate the file that controls your specific input device.
I will use my settings as example. I have only a built in card and i use the "Rear Mic" (physically the rear input on the desktop) for microphone.
I have:
Code: Select all
$ ls -1 /usr/share/pulseaudio/alsa-mixer/paths/
analog-input-aux.conf
analog-input.conf
analog-input.conf.common
analog-input-dock-mic.conf
analog-input-fm.conf
analog-input-front-mic.conf
analog-input-front-mic.conf~
analog-input-headphone-mic.conf
analog-input-headphone-mic.conf~
analog-input-headset-mic.conf
analog-input-headset-mic.conf~
analog-input-internal-mic-always.conf
analog-input-internal-mic.conf
analog-input-internal-mic.conf~
analog-input-linein.conf
analog-input-mic.conf
analog-input-mic.conf~
analog-input-mic.conf.common
analog-input-mic-line.conf
analog-input-rear-mic.conf
analog-input-rear-mic.conf~
analog-input-tvtuner.conf
analog-input-video.conf
analog-output.conf
analog-output.conf.common
analog-output-headphones-2.conf
analog-output-headphones.conf
analog-output-lineout.conf
analog-output-mono.conf
analog-output-speaker-always.conf
analog-output-speaker.conf
hdmi-output-0.conf
hdmi-output-1.conf
hdmi-output-2.conf
hdmi-output-3.conf
hdmi-output-4.conf
hdmi-output-5.conf
hdmi-output-6.conf
hdmi-output-7.conf
iec958-stereo-output.conf
So i will locate its section that looks like this:
Code: Select all
[Element Rear Mic Boost]
required-any = any
switch = select
volume = merge
override-map.1 = all
override-map.2 = all-left,all-right
Code: Select all
volume = merge
Code: Select all
volume = zero
Code: Select all
pulseaudio -k
*IMPORTANT* Restarting pulseaudio will have the following side effects: All applications that use pulseaudio and are running when it is restarted will be unable to play sound until they are restarted too.
The only exceptions i know of is pavucontrol and the volume control applet that will wait until the server is restarted and re-establish connection to it, but pretty much all other applications will lose playback capabilities until they are restarted.
Update: For me, i had to apply the fix nr 2 to get rid of Google Hangout's aggressive AGC on my home computer (caused loud background noise when it was silence around me). Fix nr. 1. was not enough as it seems certain applications will do AGC on their own and abuse the mic boost features. Chrome is such an application as it does the same on plain webrtc sites too not just their own hangouts.
Applying the 2nd fix restricted the AGC range to the "Capture" element's, not using the boost element.
Note that certain sound cards dont have adjustable boost on mic (most USB headsets) and those will not have thi issue.