Ecasound Linear Crossfade Operator Guide
This article provides a direct overview of how to perform linear
crossfading between two audio streams using Ecasound. While Ecasound
lacks a single dedicated "crossfade" filter, it achieves precise linear
crossfading via the -klg (linear envelope)
controller operator applied to the -ea
(amplify) effect operator across multiple audio chains. Below is a
breakdown of how the operator works, its syntax, and an implementation
example.
The Linear Crossfade
Operator: -klg
In Ecasound, dynamic parameter automation is handled by controller
operators. The operator responsible for linear changes over time is
-klg.
To crossfade between two separate streams, -klg is
assigned to each stream's chain to dynamically control the amplitude
parameter of the -ea operator. One chain ramps its volume
down linearly, while the other ramps its volume up.
Syntax of the -klg
Operator
-klg:fx_param,start_val,end_val,len,delay
The operator takes five parameters:
fx_param: The index of the parameter being controlled. When attached to-ea(amplify), this value is1(representing amplification percentage).start_val: The starting value of the parameter (e.g.,100for full volume,0for silence).end_val: The ending value after the transition completes (e.g.,0for silence,100for full volume).len: The duration of the linear transition in seconds.delay: The delay in seconds before the transition starts.
Implementing a Crossfade Between Two Streams
To perform a linear crossfade between two input files, configure two separate processing chains that mix into a single output.
Command Example
ecasound \
-a:1 -i:stream1.wav -ea:100 -klg:1,100,0,5,10 \
-a:2 -i:stream2.wav -ea:0 -klg:1,0,100,5,10 \
-a:1,2 -o:mixed_output.wavHow the Command Works
- Chain Allocation (
-a:1and-a:2): Sets up two parallel processing chains forstream1.wavandstream2.wav. - Stream 1 Fade-Out:
-ea:100sets the base volume to 100%.-klg:1,100,0,5,10begins after a 10-second delay, linearly decreasing parameter 1 of-eafrom 100% to 0% over 5 seconds.
- Stream 2 Fade-In:
-ea:0sets the base volume to 0% (silence).-klg:1,0,100,5,10begins after a 10-second delay, linearly increasing parameter 1 of-eafrom 0% to 100% over 5 seconds.
- Mixed Output
(
-a:1,2 -o:mixed_output.wav): Merges both chains into a single destination audio file with the linear crossfade applied.