WebRTC Echo Cancellation only works if Microphone and Speakers are on the same device
- PipeWire version (
pipewire --version
): 0.3.47 - Distribution and distribution version (
PRETTY_NAME
from/etc/os-release
): Ubuntu 20.04.3 LTS - Desktop Environment: i3
- Kernel version (
uname -r
): 5.13.0-28-generic
Description of Problem:
I'm currently moving to Pipewire, and I'm having trouble getting the echo cancellation produce usable results. Under Pulseaudio I used the following settings (and mapped them to the args
in the echo cancel module):
analog_gain_control=0 digital_gain_control=0 # Mapped this to webrtc.gain_control = false
intelligibility_enhancer=1 # There doesn't seem to be an equivalent in Pipewire
high_pass_filter=1 # webrtc.high_pass_filter = true
extended_filter=1 # webrtc.extended_filter = true and webrtc.delay_agnostic = true
drift_compensation=0 # Looking at the source, this seems to be fixed to off anyway
noise_suppression=0 # webrtc.noise_suppression = false
voice_detection=0 # webrtc.voice_detection = false
Now if I use the built-in mic and speaker of my laptop, everything works if I additionally set audio.channels = 1
. But as soon as I use another speaker and/or another microphone, it stops working (as in, very audible echo in the microphone stream). I checked that all applications route the audio through the Echo-cancel Sink and that the Echo-Cancel Sink/Source use the desired devices. In the past, I had problems in Pulseaudio if I used devices with a significant delay, e.g., a wireless mic that I prefer to use (that has ~40ms latency). However, turning on the extended_filter
fixed this problem for Pulseaudio and the echo cancellation is extremely robust with any device combination. This isn't the case for pipewire. I also tried to set node.latency
to 80ms (highest I can go without introducing stuttering), but it doesn't have any effect. Playing around with all the other arguments didn't produce any better results.
How Reproducible:
Use the echo cancellation with separate devices for microphone and speakers.
Steps to Reproduce:
- Plug in two USB audio devices (or an internal audio device and a USB audio device)
- Set up the echo cancellation module, e.g., with a file in
~/.config/pipewire/pipewire.conf.d/echo-cancel.conf
:
context.modules = [
{
name = libpipewire-module-echo-cancel
args = {
library.name = aec/libspa-aec-webrtc
aec.args = {
webrtc.extended_filter = true
webrtc.delay_agnostic = true
webrtc.high_pass_filter = true
webrtc.noise_suppression = false
webrtc.voice_detection = false
webrtc.gain_control = false
webrtc.experimental_agc = false
webrtc.experimental_ns = false
}
audio.channels = 1
source.props = {
node.name = "Echo Cancellation Source"
}
sink.props = {
node.name = "Echo Cancellation Sink"
}
}
}
]
- Use one device as a source and one as a sink.
- Run audio through the echo cancellation sink and observe if the audio is audible in the echo cancellation source.
Actual Results:
The echo is audible.
Expected Results:
The echo should be absent or at least faint.
Additional Info (as attachments):
-
pw-dump > pw-dump.log
: pw-dump.log