How Ecasound Sums Audio Signals in a Single Chain
This article explains the internal mechanism Ecasound uses to mix multiple audio inputs routed into a single processing chain. It covers the mathematical summation process, internal sample resolution, channel alignment rules, and gain staging techniques necessary to avoid digital clipping when combining multiple signals.
When multiple audio inputs are attached to a single chain in Ecasound
(for example, configuring a chain with
-a:1 -i:input1.wav -i:input2.wav), the engine combines
these streams using linear digital summing. During each processing
cycle, Ecasound reads an identical buffer size of audio frames from each
specified input source and performs sample-by-sample arithmetic addition
across corresponding channels before passing the data to any chain
operators or downstream outputs.
The mathematical process operates on a direct additive basis:
Sample_Out[channel, frame] = Sample_Input1[channel, frame] + Sample_Input2[channel, frame] + ... + Sample_InputN[channel, frame]
Internal Processing and Bit Depth
Ecasound utilizes high-precision internal representations (typically 32-bit or 64-bit floating-point, depending on build configuration and operating mode) while processing audio data within a chain. Because arithmetic addition occurs in this high-headroom space, summing two signals that each peak near 0 dBFS will not cause distortion or clipping inside the chain's processing buffer.
However, if the summed signal is subsequently written to an integer-based output format—such as a standard 16-bit or 24-bit PCM WAV file or a hardware sound card output—any values exceeding the normalized full scale range (values greater than +1.0 or less than -1.0) will be hard-clipped unless gain reduction is applied.
Channel Alignment and Matching
Ecasound matches channels strictly by index during the summing operation:
- Channel 1 (Left) of Input A is added directly to Channel 1 (Left) of Input B.
- Channel 2 (Right) of Input A is added directly to Channel 2 (Right) of Input B.
If inputs have mismatched channel counts, Ecasound matches existing
channel indices up to the maximum common channel count. For deliberate
channel routing, splitting, or mixing individual tracks to specific
destinations within the chain, you must use channel routing operators
(such as the -erc copy or -erm mute operators)
prior to or following the summing stage.
Gain Control and Headroom Management
Because summing signals increases overall acoustic amplitude, multiple inputs combined at nominal levels often exceed 0 dBFS. Ecasound does not automatically normalize or reduce the level of incoming signals when mixing them into a single chain. To prevent clipping on the final output, you must explicitly attenuate the combined signal using chain operators:
-ea:gain_%: Adjusts the linear gain of all channels in the chain (e.g.,-ea:50reduces the overall summed level by 50%).-eal:limit_%: Applies a soft limiter to catch peaks that breach the threshold after summation.
By default, summing in Ecasound is transparent, unweighted, and linear, leaving total dynamic control and channel distribution to the user's explicit parameter definitions.