ADSR
Generate attack-decay-sustain-release envelope curves.
What it does
ADSR watches a trigger signal for a threshold crossing and turns each crossing into a shaped envelope: a ramp to a peak (Attack), a fall to a held level (Decay and Sustain), then a fade to zero once the trigger drops (Release). The classic synthesiser envelope, driving any animatable parameter.
A Number or Boolean input gives one envelope. A Number Array gives one independent envelope per element, such as a particle system's per-point triggers. Each stage's shape bends from linear toward ease-in or ease-out, and an audio-rate buffer is available instead of one value per frame.
When to use it
A one-shot pop or hit reaction to a value crossing a threshold.
Layered or looping envelopes from repeated triggers, where a hit can restart, stack, or top out while still ringing.
Per-point or per-particle triggers, each getting its own envelope.
An audio-rate amplitude envelope rather than one number per frame.
| Parameter | Type | Default | What it does |
|---|---|---|---|
trigger | Number or Boolean or Number[] or Vec3 or Color | — | Trigger signal. Number/Boolean for single channel, NumberArray for multi-channel. Vec3/Color use magnitude/luminance. |
reset | Boolean or Number | — | — |
threshold | Number | 0.500 | Threshold value for trigger detection |
edge | String | "Rising" | Rising: trigger on crossing above threshold. Falling: below. Both: either direction. One of: Rising, Falling, Both. |
retrigger | String | "Restart" | Restart: reset envelope. Max: layered maximum. Ignore: wait until idle. Add: stack envelopes. One of: Restart, Max, Ignore, Add. |
attack | Number | 0.050 | Attack time in seconds |
peak | Number | 1 | Peak envelope value |
decay | Number | 0.300 | Decay time in seconds |
sustain | Number | 0 | Sustain level as fraction of peak |
release | Number | 0.100 | Release time in seconds |
attack_curve | Number | 0 | Attack curve: -1 ease-in, 0 linear, 1 ease-out |
decay_curve | Number | 0 | Decay curve: -1 ease-in, 0 linear, 1 ease-out |
release_curve | Number | 0 | Release curve: -1 ease-in, 0 linear, 1 ease-out |
sample_rate | Number | 0 | 0 = scalar per frame, >0 = audio-rate envelope buffer |
Gotchas
Retrigger controls what happens if the trigger fires again before the envelope has finished. Restart snaps back to Attack. Max layers a new envelope in and keeps the louder of the two. Ignore drops new triggers until the current one goes idle. Add stacks envelopes on top of each other.
Scrubbing the timeline backward resets the envelope's trigger count and phase state. Expect a jump in count and a fresh Attack the next time you land on a rising edge, rather than a continuation.
The envelope output, an audio-rate buffer, only fills once Sample Rate is above 0. At Sample Rate 0 you get value and normalized per frame instead, and envelope stays empty.
A Number Array wired into Trigger drives many envelopes from one node. Each element gets its own Attack, Decay, Sustain, and Release state, and value and normalized come back as matching arrays.
Worked example
Add an ADSR. Wire a Number or Boolean signal into Trigger. Anything that crosses your Threshold fires the envelope.
Set Attack, Decay, Sustain, and Release to shape the hit: short Attack and Decay with Sustain at 0 gives a quick percussive pop.
Bend Attack Curve or Release Curve toward -1 or 1 if linear feels too mechanical.
Take
value(ornormalizedfor a 0-1 range) into the parameter you want to animate: scale, opacity, light intensity.For faster than per-frame, raise Sample Rate and read the
envelopeoutput instead.
See also
Oscillate · State Machine · Delay · Numbers, signals & audio