ADSR

An envelope that rises while its gate is on and falls back when it goes off.

Parameters

NameTypeDescription
ValueoutputFloatThe level of the envelope, between 0 and 1.
DoneoutputTriggerFires when the release has finished and the level is back at 0.
GateBoolHolds the envelope open for as long as it is on.
TriggerTriggerPlays the envelope once, as if the gate were held on for the trigger length.
Trigger LengthFloatHow many seconds the gate stays on after a trigger.
AttackFloatHow many seconds the level takes to rise to 1 after the gate goes on.
DecayFloatHow many seconds the level takes to fall from 1 to the sustain level.
SustainFloatThe level held for as long as the gate stays on, between 0 and 1.
ReleaseFloatHow many seconds the level takes to fall back to 0 after the gate goes off.
CurveEnumThe shape of each rise and fall.Choices: Linear, Exponential

ADSR shapes a level over time in the way a synthesizer shapes a note. When the gate goes on the level rises to 1 during the attack, falls to the sustain level during the decay and stays there for as long as the gate is held. When the gate goes off the level falls to 0 during the release, and Done fires when it gets there. Between notes the level is 0.

The trigger plays the envelope without a gate. It holds the gate on for the trigger length and then lets it go, so one trigger gives one complete rise and fall. A gate that is turned on during a release, or a trigger that arrives while the envelope is already playing, starts a new attack from the level of that moment. The level never jumps.

Linear moves at a steady pace. Exponential moves fast at first and slows down towards the end, which sounds and looks more natural.

A usual setup is a Beat on the trigger and the value on the brightness or size of something, so it flashes on every beat.

Keywords: envelope, attack, decay, sustain, release, gate, fade