Automate Crossfades in Ecasound: Ambience and Dialogue
Automating crossfades between dialogue and background ambience in
Ecasound allows you to achieve clean, professional audio ducking and
transitions from the command line. This guide demonstrates how to
configure multitrack chains, apply the amplify effect
(-ea), and attach linear envelope controllers
(-kl) or control envelope files (-kos) to
dynamically automate volume shifts between tracks.
The Basic Concept
Ecasound achieves automated level transitions by applying parameter
controllers to chain operators. Volume adjustment is handled by the
amplify operator (-ea:gain_percentage). By attaching a
linear controller (-kl) to this operator, you can instruct
Ecasound to automatically change the gain from a starting level to an
ending level over a specific duration.
Step-by-Step Chain Setup
To automate a crossfade, you must run both audio streams simultaneously across distinct chains and merge them into a single output:
- Assign Chains: Assign the dialogue track to Chain 1
(
-a:1) and the ambience track to Chain 2 (-a:2). - Set Inputs and Output: Assign the source files via
-i:file.wavand specify a master output (-a:all -o:master.wav). - Apply Gain Operators: Add
-ea:100to provide a baseline gain parameter for automation. - Attach Controllers: Attach a linear envelope controller to the gain parameter of the ambience track to lower its volume when dialogue starts, and raise it when dialogue ends.
Command Line Implementation
The -kl option takes the following syntax:
-kl:fx_param,initial_val,final_val,time_sec
fx_param: The parameter index of the target operator (for-ea, gain is parameter1).initial_val: Starting value (e.g.,100for 100% volume).final_val: Ending value (e.g.,20for a ducked 20% volume).time_sec: The transition duration in seconds.
Example: Fading Ambience Under Dialogue
To crossfade background ambience down from 100% to 25% over a 3-second period as dialogue begins:
ecasound -a:1 -i:dialogue.wav \
-a:2 -i:ambience.wav -ea:100 -kl:1,100,25,3 \
-a:all -f:s16_le,2,44100 -o:mixed_output.wavComplex Crossfading with Control Envelopes
When working with ongoing dialogue requiring multiple crossfades in
and out, linear inline controllers can become restrictive. Instead, map
the gain operator to a time-stamped text file using the sampled
controller option (-kos).
Create an Automation File (
ambience_env.txt): Define timestamps (in seconds) and corresponding gain levels:0.0 100 2.0 100 4.0 20 10.0 20 12.0 100Execute Ecasound with the Envelope File: Link the text file to the amplify operator using
-kos:ecasound -a:1 -i:dialogue.wav \ -a:2 -i:ambience.wav -ea:100 -kos:1,ambience_env.txt \ -a:all -o:mixed_output.wav
In this setup, the ambience track remains at full volume for the first two seconds, crossfades down to 20% over two seconds, remains ducked under the dialogue until second 10, and smoothly fades back to 100% by second 12.