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

Scaling to Different Channel Counts

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