Skip to content

Build an Effect Chain

The built-in effects are in std/effects; each one’s arguments are in the effects reference. Third-party effects are loaded with Effect() — see Use a Plugin. Every effect’s first argument is its slot name, which identifies it in the chain.

set_effects sets the track’s whole chain, as a list. The signal runs through it in list order:

use "std/instruments" { Sampler, Kit };
use "std/effects" { Delay, Lowpass };
let drums = AudioTrack("drums");
drums.set_instrument(Sampler(Kit("CR-78")));
drums << [bd sd bd sd];
drums.set_effects(#[Delay("delay", 0.25, 0.5), Lowpass("lowpass", 800, 3.0)]); // delay, then filter
PLAY;

show(drums) prints the chain in order.

Edit the list and run the set_effects line again. Effects whose names are still in the list keep running; new names are added, missing names are removed, and moved names are reordered:

use "std/effects" { Highpass };
drums.set_effects(#[Highpass("highpass", 120), Delay("delay", 0.25, 0.5), Lowpass("lowpass", 800, 3.0)]);

The arguments you give are written to the effect that is already in the chain, so changing Lowpass("lowpass", 800, 3.0) to Lowpass("lowpass", 2000, 3.0) and re-running moves the cutoff. Arguments you leave out are not written, and keep whatever value the effect has now. Giving a name to a different kind of effect replaces it with a new one. Two effects on one track can’t share a name.

Keep a handle to the effect, put it on the track, then set parameters through the handle:

use "std/effects" { Delay };
let drums = AudioTrack("drums");
let echo = Delay("delay", 0.25, 0.5);
drums.set_effects(#[echo]);
echo.set_parameter("Time", 0.4); // method form, chainable
echo.parameter("Time") << 0.15; // operator form

The << form also takes a signal, so the parameter moves — see Sweep a Parameter with an LFO.

Setting a parameter before set_effects is fine: the value is applied when the effect is built. Reading one — parameter, parameters() — needs the effect on a track first.

An empty list removes every effect:

drums.set_effects(#[]);