An envelope: it shapes how a sound starts, holds and fades, each time a note is played.

In the menu: controls, then envelopes.
Each setting has a knob, which disappears when something is connected to its input.
Think of how different instruments start and stop. A piano note starts instantly and then slowly fades, even while you hold the key down. An organ note starts instantly, stays exactly as loud for as long as you hold the key, and stops the moment you let go. A violinist can let a note swell up gradually and fade gently away. Most of what makes an instrument recognisable is in how each note begins and ends.
An oscillator, by itself, does none of this: it plays at a steady level, on and on. The adsr gives a synth its shape. Each time its trigger turns on (when you press a key), it makes a value that rises and falls over time in four stages, which give it its name:

The envelope's graph on the node shows its shape, each stage in its own colour, and while it plays a line sweeps across it to show where it is. Here's a synth that uses it to shape a note's loudness: hold the button down, and the note swells up, settles, and then fades when the button is let go. The scope on the right draws the note's outline, which is the envelope's shape:

Here's the same short tune played on the same sound, with four different envelopes. Only the adsr's settings change, but each sounds like a different kind of instrument:

The curve changes how each stage moves. At 0 the envelope moves in straight lines, at an even pace; at 1 it moves quickly at first and then slows down, gliding into place. Real sounds fade in the curved way, so a high curve usually sounds more natural. Here's one note fading away over two seconds, first with the curve at 0, then at 1. With the straight fade, the note seems to stay loud and then suddenly drop away at the end; with the curved fade it dies away smoothly, like a struck bell or a plucked string:
The adsr always moves smoothly from wherever it is. If you let go of a key before the attack has finished, it starts its release from where it got to, so a quick tap makes a short, quiet blip rather than a full note. If you press a key again while the last note is still fading, it rises again from where it is, without first dropping to nothing, which would click.

Two tips. Even a sound that should start "instantly" usually wants an attack of a few milliseconds, or the sudden jump makes a click. And to keep a note from cutting off abruptly, give it at least a short release.
The tutorial in chapter 2 builds a synth around an adsrThe ADSR envelope generator is as old as the voltage-controlled synthesizer: the four-stage contour was proposed by the composer Vladimir Ussachevsky to Robert Moog in the 1960s, and attack, decay, sustain and release have been the standard way to describe a note's dynamic contour ever since. This one is modelled on the analogue kind, with each stage an exponential segment, and behaves like a good hardware envelope: no clicks, no resets on retrigger, and stage times that mean what they say.
On loudness, an envelope shapes dynamics; on a filter's cutoff, it shapes timbre over the note, and this is arguably the more characterful use. Classic subtractive patches often use two adsrs: one for the amplifier, and one for the filter, with its own, usually shorter, decay. A short filter decay over a resonant low pass is the classic "pluck" or "blip" bass; a slower one gives the "wah" of synth brass. Here's a bassline with the loudness held steady by one adsr, while a second opens a resonant ladder filter, first with a snappy decay (attack 3 ms, decay 250 ms, sustain 0.1), then a slower, brassier one (attack 150 ms, decay 300 ms, sustain 0.4):
The factor to frequency converter between the adsr and the filter sets the envelope's depth: its low frequency is the cutoff the note settles towards (or closes to), and its high frequency the cutoff at the envelope's peak.
The ear hears loudness roughly logarithmically, so a decay that falls by an even number of decibels each second sounds even, and that's exactly what an acoustic instrument's free decay does. At curve 1, each stage is a straight line in decibels, falling about 80 dB over its time, which is the natural decay of a struck string or bar. At curve 0, the stage is a straight line in amplitude, which in decibels holds up and then falls off a cliff at the end. The other settings fall between. 0.75, the default, falls about 50 dB in a gently bowed line and then closes cleanly, a good compromise for most sounds.

The attack is never more curved than a charging capacitor's, as on an analogue envelope: it rises steeply at first and eases into the top, which sounds smooth and quick, rather than the slow-then-sudden of an attack shaped like a decay played backwards.
The adsr is a "retriggering from the current level" design. A trigger during the release starts a new attack from wherever the envelope has fallen to, and the attack time is the time to rise from 0, so the rise is shorter when it starts higher. A note that's let go before its attack finishes releases from there, taking the release time to get to 0. Neither ever jumps, so fast repeated notes stay click-free. The trigger has to turn off for the envelope to start again, so notes played legato on one trigger, without a gap, don't restart it.
Each setting is an input, and they're read continuously, so:
Each stage is the step response of a one-pole low-pass filter, computed exactly sample by sample: the envelope y heads exponentially for a target T beyond the stage's end, and the stage ends when y reaches its end value e. Choosing T so that y reaches e at exactly the stage's time t makes the times exact, whatever the curve.
Every sample during the attack, decay and release:
![y[n+1] = T + k (y[n] − T)](../images/nodes/adsr-eq-step.png)
For a stage from s to e taking t seconds, the target overshoots the end by a ratio R of the stage's size, and the coefficient follows from R and the number of samples N:

Since y[n] − T = (s − T) kⁿ, after N samples y − T = −(1 + R)(e − s) · R / (1 + R) = −R (e − s), so y = e exactly. The stage's shape, as a function of the time τ into it, is

As R → ∞, (1 + R)(1 − q^(τ/t)) → τ/t, a straight line. As R → 0, the segment approaches a pure exponential that only reaches its end at infinity, and the stage's time is how long it takes to get within R of it.
The stages use these starting and ending points: the attack from 0 (s) to 1 (e); the decay from 1 to the sustain level S; the release from the level y₀ at which it starts to 0. The release's target, −R y₀, is scaled by y₀, so the release takes the release time from any level. The attack's target is fixed at 1 + R, from s = 0, whatever the level it starts from, so starting higher it reaches 1 sooner.
The curve c (0 to 1) sets R geometrically, from 100 (all but straight) to 10⁻⁴:

The attack's ratio never falls below 0.3, so its slope falls by at most a factor of (1 + R)/R ≈ 4.3 from start to end, like a capacitor charging towards 1.3 times the comparator's threshold in an analogue envelope generator.
For small R, the fraction of the stage left to go, (y − e)/(s − e) = (1 + R) q^(τ/t) − R, is close to q^(τ/t), so in decibels it's a straight line:

At c = 1, R = 10⁻⁴, so the stage falls 80 dB linearly, and the last −R term closes the remaining gap at the end. At c = 0.75 (R ≈ 0.0032) it's 50 dB, followed by a short, steeper close.
Because kᴺ is exactly the intended ratio, the recurrence samples the continuous exponential exactly (impulse invariance), with no accumulating error over a stage beyond floating-point rounding; the state is a double-float. Each sample costs one multiply and one add, and k and T are only recomputed when a stage starts. The settings are read every sample, so the sustain input can be modulated at audio rate; times are read at each stage's start.
Back to Controls: envelopes