Pass Multiple Inputs to a Single Chain in Ecasound
This article explains how to route multiple audio input files into a single chain using Ecasound. In Ecasound, assigning multiple input objects to the same active chain automatically sums (mixes) the incoming audio streams together into that chain, allowing you to process multiple tracks simultaneously with shared chain operators and route them to a single output.
Basic Command Syntax
To assign multiple inputs to one chain, define the active chain using
the -a switch, followed sequentially by multiple
-i input options before specifying your output with
-o.
ecasound -a:1 -i:track1.wav -i:track2.wav -o:mixed_output.wavIn this command:
-a:1creates and selects chain1.-i:track1.wavattaches the first audio file to chain1.-i:track2.wavattaches the second audio file to the still-active chain1.-o:mixed_output.wavsets the destination output for the processed signal of chain1.
Signal Mixing Behavior
When multiple audio inputs are routed to a single chain, Ecasound mixes their samples in real-time. If both files are stereo (2 channels), corresponding channels are added together.
To prevent clipping caused by summing signal levels, apply an
attenuation or volume-scaling effect to the chain using the
-ea operator:
ecasound -a:1 -i:track1.wav -i:track2.wav -ea:50 -o:mixed_output.wavHere, -ea:50 reduces the overall volume of the combined
inputs in chain 1 to 50% to maintain audio headroom.
Ensuring File Compatibility
For inputs to be combined directly in a single chain without processing errors, the files should share compatible audio parameters:
- Sample Rate: Ensure all inputs match (e.g., 44.1
kHz or 48 kHz). If they differ, specify global audio parameters using
-f:bits,channels,sample_rateto force resampling. - Channel Count: If mixing files with differing channel counts (e.g., mono and stereo), assign them to separate chains first and route them to a shared loop device or intermediate chain to avoid channel mismatches.
Sequential Inputs Alternative
If your goal is to play multiple files one after the other rather
than mixing them simultaneously, do not pass multiple -i
flags to the same chain. Instead, use Ecasound's playlist input
format:
ecasound -a:1 -i:playlist,file_list.txt -o:continuous_output.wavWhere file_list.txt contains the paths to each audio
file on separate lines.