Linux Echo Canceller

Over the last year and a half, many of us have spent more time than we’d like in front of our computers. Many meetings have happened that way, as well as listening to talks and lectures, or giving them. Our computers’ sound systems have therefore been likely used much more heavily than before, and in different ways. I’ve always had an amp and a pair of speakers hooked up to my computer. Well, as far back as I can recall, at least. But I didn’t generally use these for calls, preferring a headset for that purpose. Over the last few months this changed, though, as it’s significantly more comfortable to take meetings and give lectures without that kind of encumbrance. Unfortunately this creates the possibility of feedback, which quickly deteriorates the quality of a call. Most meeting software will internally handle this in some way, but not all methods are created equal. I have taken meetings with people where the software at their end will actually silence their microphone to reduce echoes – so if anyone else speaks while they try to will effectively silence them.

I’m sure that many have found themselves in this kind of situation, so I thought I’d write a few words about this, in the (usual) hope that it will be useful to others. There are better ways, at least on some systems. In this case I’ll be talking about Linux-based systems, such as the one I use. Specifically, this is meant for systems where the sound is handled by PulseAudio. All that needs to be done is to first select the correct output and input sources (e.g. speakers and microphone). Next, just load the echo canceller module and set it up, as follows:

pactl unload-module module-echo-cancel
pactl load-module module-echo-cancel aec_method=webrtc source_name=noechosource sink_name=noechosink
sleep 1
pacmd set-default-source noechosource
pacmd set-default-sink noechosink
pacmd set-source-volume noechosource 65536
pacmd set-sink-volume noechosink 65536

The first two lines remove the module (if already loaded) and reload it with the required parameters – in this case we’re setting the echo canceller algorithm to ‘webrtc’ and giving a name for the virtual source and sink created. After waiting a second to make sure the echo canceller is set up, the remaining lines choose these virtual end points as the current system default, and max out volume for input and output. I keep a script with these commands, that I run every time I want to use the echo canceller. To dismantle the whole thing, just execute the first command again.

Finally, a word or two about the gear. I now regularly use my amp and speakers to listen to other attendees, while using a good microphone for capturing my own voice. The amp needs to be connected to a well-shielded port on the PC; many front-panel connections, for example, tend to have cables going through the case, passing next to noisy components. This makes them practically useless. A better option, where available (and incidentally what I’m using myself) is an optical digital connections from the back panel to the amp. On the input side, USB-connected microphones that are intended for podcasters (e.g. condenser mikes) tend to be really good, and don’t cost too much. This is what I use for lecturing. Often, the webcam itself will have a built-in microphone that will serve its purpose (though of course the sound quality won’t be as good as a dedicated mike). Sometimes these have a volume that’s too low, but that too is fixed by the echo canceller and denoiser module.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.