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.wav

In this command:

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.wav

Here, -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:

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.wav

Where file_list.txt contains the paths to each audio file on separate lines.