How to Apply Audio Fading Curves in Ecasound

This article provides an overview of how Ecasound manages dynamic volume changes to create fade-ins and fade-outs at the boundaries of audio tracks. Rather than using fixed, destructive fade effects, Ecasound relies on an architecture of chain operators paired with dynamic parameter controllers. By attaching envelope controllers to amplification parameters, users can generate mathematically precise linear, logarithmic, or custom volume curves across specified time intervals.

The Underlying Mechanism: Operators and Controllers

Ecasound achieves fading by separating audio modification from parameter automation. Audio volume is modified using the amplify effect operator (-ea), while the volume level itself is automated over time using controller operators (prefixed with -k).

When a controller is placed immediately after an effect operator in the command line, it targets a specific parameter of that effect, varying its value from a designated starting point to an ending point over a defined duration.

Implementing a Fade-In

To fade an audio track in at the start, you combine the amplify operator (-ea) with a linear envelope controller (-kl).

The linear controller syntax follows this structure: -kl:fx_param,start_value,end_value,length

To apply a 3-second linear fade-in at the start of an audio file:

ecasound -i input.wav -ea:100 -kl:1,0,100,3 -o output.wav

In this command, parameter 1 of -ea begins at 0 and scales up to 100 across the first 3 seconds of processing.

Implementing a Fade-Out

Applying a fade-out requires modulating the amplification parameter toward the end of a track. Because Ecasound operates as a real-time stream engine, the controller must be triggered after a specific time delay corresponding to the track's duration minus the fade time.

This can be accomplished by setting a delay on the controller using the extended controller syntax or chain routing. Alternatively, a linear controller can be paired with chain presets to ramp down from unity gain:

-kl:1,100,0,fade_duration

When dealing with precise end-of-track fades, script-driven commands typically read the total length of the input file using ecasound -i input.wav -e or metadata tools, and then schedule the fade-out controller to activate at total_length - fade_duration.

Controlling Curve Shapes

Human hearing perceives loudness logarithmically. A strictly linear fade (-kl) can sound abrupt near silence or appear to drop off too quickly. Ecasound accommodates non-linear curves through alternative controllers:

By pairing the base amplification effect with specialized continuous controllers, Ecasound provides flexible, non-destructive control over audio transitions directly from the command line.