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:
- Chains (
-a:N): Independent processing paths. Each mono file must run in its own chain so that its signal can be routed independently. - Inputs (
-i:filename.wav): The source files assigned to specific chains. - Channel Ordering (
-chorder): An operator that positions the mono stream into a specific output slot while filling the remaining channels with silence (0). - Multichannel Output (
-o:output.wavand-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.wavBreakdown 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-aparameter appears. - Source Mapping (
-i:trackN.wav): Binds each discrete mono recording to its designated chain. - Channel Positioning (
-chorder): The-chorder:c1,c2,...,cNoperator maps input channels to target channels. Passing0inserts an empty (silent) channel.-chorder:1,0,0,0places the audio fromtrack1.wavonto channel 1 while muting channels 2, 3, and 4.-chorder:0,1,0,0places the audio fromtrack2.wavonto 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_lespecifies signed 16-bit little-endian PCM audio,4sets the total channel count, and44100establishes 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,44100and use-chorder:1,0for the first chain and-chorder:0,1for 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-chorderoperator, moving the1index to position each mono track into the correct channel layout (Left, Right, Center, LFE, Left Surround, Right Surround).