Automatic Channel Mixing in Ecasound

This article explains how Ecasound handles mismatched audio channels between inputs and outputs, detailing why Ecasound lacks a dedicated automatic mixing flag, how to perform channel mixing using the -erm and -erc flags, and how to achieve true automatic channel adaptation using driver-level plugins.

The Short Answer: Explicit Routing Over Automatic Mixing

Ecasound does not include a single global flag that automatically detects and downmixes or upmixes mismatched channel counts between inputs and outputs. By design, Ecasound requires strict channel matching along its processing chains. If an input stream has a different channel count than the output target, Ecasound halts with a channel count mismatch error rather than applying arbitrary mixing algorithms.

To handle mismatched channels natively in Ecasound, you must use explicit channel routing and mixing operator flags.

Channel Mixing with -erm

To mix channels from an input into an output channel, Ecasound provides the route-and-mix operator:

-erm:from_channel,to_channel

This flag takes audio data from from_channel and mixes (sums) it into to_channel.

For example, to downmix a two-channel stereo file (stereo.wav) into a single mono file (mono.wav), channel 2 must be mixed into channel 1 before the output format is defined:

ecasound -a:1 -i stereo.wav -erm:2,1 -f:s16_le,1,44100 -o mono.wav

In this command:

Channel Copying with -erc

When expanding a mono source to a stereo output (upmixing), summing channels is unnecessary. Instead, use the route-and-copy operator:

-erc:from_channel,to_channel

This flag copies the signal from from_channel directly to to_channel. To duplicate a mono input to both channels of a stereo output:

ecasound -a:1 -i mono.wav -f:s16_le,2,44100 -erc:1,2 -o stereo.wav

Here, the audio engine establishes a 2-channel output stream, receives the mono signal on channel 1, and duplicates that signal onto channel 2 via -erc:1,2.

Achieving Automatic Channel Mixing via ALSA

If your workflow strictly requires automatic, dynamic channel conversion without configuring explicit -erm or -erc flags in Ecasound, offload the conversion to ALSA's plug layer.

The ALSA plug plugin automatically handles rate, format, and channel count conversions on the fly:

ecasound -i mono.wav -o alsa,plug:default

By routing the output through plug:default (or plug:hw:0,0), ALSA automatically duplicates mono streams across stereo speakers or downmixes multichannel audio to match the physical hardware configuration, bypassing the need for manual chain routing in Ecasound.