Ecasound Multichannel Audio with ALSA Multi-Device
This article explains how to output multi-channel surround sound from
Ecasound to an ALSA multi-device setup. It covers the compatibility
between Ecasound and ALSA's pcm.multi plugin, provides the
necessary ALSA configuration syntax, and demonstrates the exact Ecasound
command-line parameters required to map and route surround channels
across multiple physical or virtual audio interfaces.
Ecasound fully supports outputting multi-channel surround sound to an
ALSA multi-device configuration. Because Ecasound interacts with ALSA at
the standard PCM layer, any logical device defined in your ALSA
configuration (~/.asoundrc or
/etc/asound.conf) can serve as an Ecasound output target,
including complex multi-channel device bindings.
Configuring ALSA
pcm.multi
To output surround sound across multiple stereo cards or distinct
hardware ports, you must aggregate them into a single ALSA virtual
multi-channel device using the multi plugin.
A sample 4-channel configuration combining two stereo sound cards
(hw:0,0 and hw:1,0) looks like this:
pcm.multichannel {
type multi
slaves.a.pcm "hw:0,0"
slaves.a.channels 2
slaves.b.pcm "hw:1,0"
slaves.b.channels 2
bindings.0.slave a
bindings.0.channel 0
bindings.1.slave a
bindings.1.channel 1
bindings.2.slave b
bindings.2.channel 0
bindings.3.slave b
bindings.3.channel 1
}
pcm.surround_out {
type route
slave.pcm "multichannel"
ttable.0.0 1
ttable.1.1 1
ttable.2.2 1
ttable.3.3 1
}
The route plugin wrapper (pcm.surround_out)
ensures proper channel mapping and format negotiation for applications
like Ecasound.
Routing Ecasound to the ALSA Device
Once the ALSA multi-channel device is configured, launch Ecasound and
point the output to the virtual ALSA PCM name using the
-o alsa,devicename syntax.
To route a 4-channel surround file to the surround_out
device defined above:
ecasound -i surround_track.wav -f:s16_le,4,48000 -o alsa,surround_outTo route discrete mono or stereo inputs into specific surround channels, configure distinct chains in Ecasound and assign them to the aggregate device:
ecasound \
-a:front -i front_stereo.wav -f:s16_le,2,48000 \
-a:rear -i rear_stereo.wav -f:s16_le,2,48000 \
-a:front,rear -f:s16_le,4,48000 -o alsa,surround_out \
-a:front -chorder:1,2,0,0 \
-a:rear -chorder:0,0,1,2In this command:
-f:s16_le,4,48000sets the global stream format to 16-bit, 4 channels, at 48 kHz.-a:front,reargroups both processing chains to a single 4-channel ALSA endpoint.-chordersets the channel assignment: thefrontchain occupies channels 1 and 2, while therearchain routes to channels 3 and 4.
Important Considerations
When binding separate physical sound cards together using ALSA
pcm.multi, both cards should ideally share a common
hardware word clock. If separate consumer sound cards run on independent
internal clocks, sample drift will occur over time, eventually causing
buffer under-runs or synchronization loss. For multi-channel outputs
spanning a single multi-channel audio card or synchronized professional
interfaces, playback remains stable indefinitely.