Combine Mono Files into Polyphonic WAV Using Ecasound

Ecasound is a command-line multitrack audio processing tool capable of combining multiple discrete mono audio files into a single polyphonic (multichannel) WAV file. This process is accomplished by assigning each mono file to an independent processing chain, routing that file's signal to a specific channel position using channel routing operators, and binding all chains together into a multichannel audio destination.

Understanding the Ecasound Architecture

To merge audio tracks, Ecasound relies on four core elements:

  1. Chains (-a:N): Independent processing paths. Each mono file must run in its own chain so that its signal can be routed independently.
  2. Inputs (-i:filename.wav): The source files assigned to specific chains.
  3. Channel Ordering (-chorder): An operator that positions the mono stream into a specific output slot while filling the remaining channels with silence (0).
  4. Multichannel Output (-o:output.wav and -f): A unified target configured to accept all chains simultaneously with an explicit multichannel specification.

The Command Syntax

To combine four separate mono files into a single 4-channel polyphonic WAV file, use the following terminal command:

ecasound \
  -a:1 -i:track1.wav -chorder:1,0,0,0 \
  -a:2 -i:track2.wav -chorder:0,1,0,0 \
  -a:3 -i:track3.wav -chorder:0,0,1,0 \
  -a:4 -i:track4.wav -chorder:0,0,0,1 \
  -a:1,2,3,4 -f:s16_le,4,44100 -o:polyphonic.wav

Breakdown of the Command

  • Chain Assignment (-a:1, -a:2, etc.): Declares chains 1 through 4. Every setting following a chain declaration applies strictly to that chain until another -a parameter appears.
  • Source Mapping (-i:trackN.wav): Binds each discrete mono recording to its designated chain.
  • Channel Positioning (-chorder): The -chorder:c1,c2,...,cN operator maps input channels to target channels. Passing 0 inserts an empty (silent) channel.
    • -chorder:1,0,0,0 places the audio from track1.wav onto channel 1 while muting channels 2, 3, and 4.
    • -chorder:0,1,0,0 places the audio from track2.wav onto channel 2, leaving the others silent.
    • This structure ensures that signals do not automatically sum together onto the first channel.
  • Output Binding (-a:1,2,3,4): Selects all active chains simultaneously so that they output to the same destination.
  • Format Specification (-f:format,channels,rate): Explicitly sets the output stream format. In -f:s16_le,4,44100, s16_le specifies signed 16-bit little-endian PCM audio, 4 sets the total channel count, and 44100 establishes the sample rate.
  • Target File (-o:polyphonic.wav): Writes the summed, multi-channel stream into the final target WAV container.

Scaling to Different Channel Counts

This method scales to any number of channels supported by the WAV format specification:

  • Stereo (2-channel): Set -f:s16_le,2,44100 and use -chorder:1,0 for the first chain and -chorder:0,1 for the second chain.
  • Surround 5.1 (6-channel): Set -f:s24_le,6,48000 (for 24-bit, 48 kHz production) and pad six comma-separated arguments in each -chorder operator, moving the 1 index to position each mono track into the correct channel layout (Left, Right, Center, LFE, Left Surround, Right Surround).