Ecasound Channel Mapping: 8-Channel to 2-Channel

Ecasound manages multi-channel audio routing by decoupling hardware input/output objects from internal processing chains, allowing flexible mapping between an 8-channel soundcard and 2-channel (stereo) chains. Because an audio interface exposes all 8 channels simultaneously while processing chains often operate on stereo pairs, Ecasound relies on explicit channel count declarations, routing operators (-erc and -erm), channel selection filters (-chorder), or internal loop devices to distribute and combine channels accurately.

The Chain Architecture Model

In Ecasound, processing paths are designated as chains using the -a:chain_name flag. Each chain operates with a specific format defined by the -f flag (e.g., -f:s32_le,2,48000 for a 2-channel chain).

When communicating with an 8-channel soundcard via ALSA or JACK, the soundcard object itself requires an 8-channel format:

-f:s32_le,8,48000 -i:alsa,hw:0

Because a 2-channel chain cannot directly ingest an 8-channel stream without an explicit mapping instruction, Ecasound offers distinct methods to bridge the gap.

Method 1: Using the Channel Order Operator (-chorder)

The -chorder operator isolates specific channels from a multi-channel stream and maps them sequentially to the active chain. If a chain is configured for 2 channels, applying -chorder limits the chain's input to the specified indices.

To capture physical inputs 3 and 4 of an 8-channel interface into a stereo chain:

ecasound -a:1 -f:s32_le,8,48000 -i:alsa,hw:0 -f:s32_le,2,48000 -chorder:3,4 -o:stereo_output.wav

In this command:

  1. The hardware input enters chain 1 as an 8-channel stream.
  2. The format is reassigned to 2 channels.
  3. -chorder:3,4 maps hardware channel 3 to chain channel 1, and hardware channel 4 to chain channel 2.

Method 2: Channel Copy and Move Operators (-erc and -erm)

When routing from a 2-channel chain to specific outputs on an 8-channel device, running the chain in full 8-channel mode and manipulating internal channels is often the most direct approach.

To route a stereo file to physical outputs 5 and 6 of an 8-channel card:

ecasound -a:1 -i:stereo.wav -f:s32_le,8,48000 -erc:2,6 -erm:1,5 -f:s32_le,8,48000 -o:alsa,hw:0

Here, the chain's channel width is expanded to 8. The second input channel is copied to output channel 6, and the first input channel is moved to output channel 5, leaving all other outputs silent.

Method 3: Intermediate Loop Devices

To run multiple independent 2-channel chains that share a single 8-channel soundcard, Ecasound provides internal virtual buses via loop devices (loop,label). This prevents resource conflicts where multiple chains compete for the same physical soundcard.

Splitting an 8-Channel Input into Multiple Stereo Chains

An 8-channel master chain reads from the card and sends the stream to a loop device. Multiple 2-channel chains then consume specific channels from that loop:

# Chain 1 captures 8 channels into loop 'capture'
-a:master_in -f:s32_le,8,48000 -i:alsa,hw:0 -o:loop,capture

# Chain A processes channels 1 and 2
-a:pair1 -f:s32_le,8,48000 -i:loop,capture -f:s32_le,2,48000 -chorder:1,2 -o:out1.wav

# Chain B processes channels 3 and 4
-a:pair2 -f:s32_le,8,48000 -i:loop,capture -f:s32_le,2,48000 -chorder:3,4 -o:out2.wav

Merging Multiple Stereo Chains into an 8-Channel Output

To multiplex multiple stereo sources into specific channels of a single 8-channel output device:

# Chain A routes stereo audio to channels 1 and 2 of an 8-channel loop
-a:pair1 -i:file1.wav -f:s32_le,8,48000 -o:loop,playback

# Chain B routes stereo audio to channels 3 and 4 of the same 8-channel loop
-a:pair2 -i:file2.wav -f:s32_le,8,48000 -erc:2,4 -erm:1,3 -o:loop,playback

# Master Chain takes the consolidated 8-channel loop and sends it to the soundcard
-a:master_out -f:s32_le,8,48000 -i:loop,playback -o:alsa,hw:0

By combining -chorder for channel extraction, -erc/-erm for channel positioning, and loop devices for submixing, Ecasound provides complete control over routing stereo chains through multi-channel interfaces.