Envelope

Curved AD, AR and ADSR gain envelopes with looping and explicit retrigger behavior.

  • Dynamics
  • Since 0.2.0
  • adsr
  • gate
  • shape
  • dynamics

Open in TuneToys

Envelope as the Patch draws it, at default values: inlets on the left, outlets on the right.

An envelope shapes how loud a sound is over time. It listens to a gate: when the gate turns on the sound rises, and when it turns off the sound dies away.

What it does#

The envelope multiplies the audio passing through it by a gain that follows an attack, decay, sustain and release shape. A rising edge on Gate starts the envelope. Depending on Type it can be a full ADSR (attack, decay, sustain, release), an AD (attack then decay to zero) or an AR (attack, hold while the gate stays on, release). Curve bends every segment between concave, linear and convex. It can loop for as long as the gate is held.

It is a gain stage for audio, not a control signal: put it on the sound path.

Events#

The done outlet sends an event: it is 1 for one block when the envelope finishes and returns to silence, that is when the release ends after Gate turned off or an AD cycle completes, and 0 otherwise. A looping envelope never finishes, and a Gate that rises during the release restarts it without a done. Cable it into a trigger input, such as Counter or Sample and hold, to advance something each time a note has fully died away.

When to use it#

Use it to turn a continuous source such as Oscillator into notes, to make plucks and swells, or to build rhythmic gating. The Polyphonic instrument already has an envelope for each voice.

Ports#

PortDirectionSignalLanes
audioInputAudioInferred from the cable
audioOutputAudioInferred from the cable
doneOutputControl1

Parameters#

ParameterLabelRangeDefaultUnitScaleNotes
attack_msAttack0 to 1000010mslinearTime to rise to full gain.
decay_msDecay0 to 10000120mslinearTime to fall to sustain in ADSR, or zero in AD. Shown when type is 0 or 1.
sustainSustain0 to 10.7%linearHeld ADSR gain. Shown when type is 0. Stored as a fraction; shown ×100 as a percentage.
release_msRelease0 to 10000200mslinearTime to return to zero. Shown when type is 0 or 2.
gateGate0 to 10linearOn or off. A rising edge retriggers; held on runs the oscillator or envelope. A control cable switches it at 0.5.
typeType0 to 20linearSelects the implemented algorithm. Choices are discrete and are not LFO targets. Choices: 0 ADSR, 1 AD, 2 AR.
curveCurve-1 to 10linearContinuous concave/linear/convex segment curvature.
loopLoop0 to 10linearRepeats complete envelope cycles while Gate is held. Choices: 0 Off, 1 While held.
retriggerRetrigger0 to 10linearRestart from the current gain or reset to zero on a rising Gate. Choices: 0 Current level, 1 From zero.
hold_msLoop hold0 to 10000100mslinearDuration of the held part in repeating ADSR/AR cycles. Shown when loop is 1.

Attack (attack_ms)#

The time, from 0 to 10000 ms, taken to rise to full gain after the gate turns on.

Decay (decay_ms)#

The time to fall to the sustain level in ADSR, or to zero in AD. It applies to the ADSR and AD types.

Sustain (sustain)#

The held gain while the gate stays on in an ADSR envelope, shown from 0 to 100 % of full gain (stored as a fraction from 0 to 1).

Release (release_ms)#

The time to return to zero after the gate turns off. It applies to the ADSR and AR types.

Gate (gate)#

The trigger, on (1) or off (0). Turning it on starts the envelope and holding it on keeps it running. Bind it to a momentary button or toggle in a Frame, or cable a control signal in: it counts as on from 0.5.

Type (type)#

Chooses ADSR, AD or AR. It is a discrete choice.

Curve (curve)#

Bends the segments, from -1 to 1. Zero is linear; values on either side give concave or convex curvature.

Loop (loop)#

When On, complete envelope cycles repeat while Gate is held.

Retrigger (retrigger)#

On a rising Gate edge, either restart from the current gain (smooth) or reset to zero first.

Loop hold (hold_ms)#

The time the held part lasts in each repeat of a looping ADSR or AR cycle. It is shown only while Loop is on.

Tips#

  • A short Attack with a medium Decay and zero Sustain makes a pluck.
  • Looping an AD envelope is a quick way to make a repeating sound for testing effects.
  • The envelope works on any channel count.
  • done is a one-block pulse, like Compare in Trigger mode. Cable it into a trigger input; to sequence notes, let it clock a Counter that picks the next pitch.

See also#

Oscillator, Polyphonic instrument, Compressor.

Help patches

Each help patch is an ordinary Toy that teaches one idea. The diagram shows the Patch; the preview shows its Frame. Open it in TuneToys to play and edit it.

1. Shape a tone with attack and release

beginner Teaches: attack_ms, decay_ms, sustain, release_ms, gate

An ADSR envelope played from a gate button.

Patch: Oscillator audio output connected to Envelope audio input. Envelope audio output connected to Patch outputs audio input.
Connections as text
  • Oscillator audio output connected to Envelope audio input
  • Envelope audio output connected to Patch outputs audio input
  • Press and hold Gate. The tone rises over Attack, falls to Sustain over Decay, and holds.
  • Let go and it fades over Release.
Frame preview: Shape a tone with attack and releaseFrame “Shape a tone with attack and release” with 6 elements: knob Attack, knob Decay, momentary Hold to play, text heading, knob Release, knob Sustain.80 msAttack250 msDecayHold to playSHAPE A TONE WITH ATTACK AND RELEASE600 msRelease0.6 %Sustain
Frame preview (static). Controls show their default values.

Open in TuneToys

2. AD and AR shapes, and curve

intermediate Teaches: type, curve

Switch envelope type and bend the segments.

Patch: Oscillator audio output connected to Envelope audio input. Envelope audio output connected to Patch outputs audio input.
Connections as text
  • Oscillator audio output connected to Envelope audio input
  • Envelope audio output connected to Patch outputs audio input
  • AD ignores Sustain and Release. AR ignores Decay and Sustain.
  • Curve bends every segment: negative, zero and positive values give different shapes.
Frame preview: AD and AR shapes, and curveFrame “AD and AR shapes, and curve” with 7 elements: knob Attack, knob Curve, knob Decay, momentary Hold to play, text heading, knob Release, segmented Type.20 msAttack0Curve700 msDecayHold to playAD AND AR SHAPES, AND CURVE700 msReleaseADSRADARType
Frame preview (static). Controls show their default values.

Open in TuneToys

3. Loop the envelope and retrigger

advanced Teaches: loop, hold_ms, retrigger

A looping envelope that repeats while the gate is held.

Patch: Oscillator audio output connected to Envelope audio input. Envelope audio output connected to Patch outputs audio input.
Connections as text
  • Oscillator audio output connected to Envelope audio input
  • Envelope audio output connected to Patch outputs audio input
  • With Loop on, the envelope repeats for as long as Gate stays on.
  • Loop hold sets how long each repeat stays at full level.
Frame preview: Loop the envelope and retriggerFrame “Loop the envelope and retrigger” with 5 elements: toggle Gate, text heading, knob Loop hold, segmented Loop, segmented Retrigger.GateLOOP THE ENVELOPE AND RETRIGGER150 msLoop holdOffWhile heldLoopCurrent l…From zeroRetrigger
Frame preview (static). Controls show their default values.

Open in TuneToys

4. Count finished notes

advanced Teaches: release_ms, control-lanes

A square LFO gates an envelope; each time the release finishes, the done outlet steps a counter that opens a filter one notch further.

Patch: Oscillator audio output connected to Envelope audio input. Envelope audio output connected to Filter audio input. Filter audio output connected to Patch outputs audio input. Control LFO control output connected to Envelope @gate input. Envelope done output connected to Counter trigger input. Counter control output connected to Select lanes control input. Select lanes control output connected to Scale control input. Scale control output connected to Filter @cutoff input.
Connections as text
  • Oscillator audio output connected to Envelope audio input
  • Envelope audio output connected to Filter audio input
  • Filter audio output connected to Patch outputs audio input
  • Control LFO control output connected to Envelope @gate input
  • Envelope done output connected to Counter trigger input
  • Counter control output connected to Select lanes control input
  • Select lanes control output connected to Scale control input
  • Scale control output connected to Filter @cutoff input
  • The square LFO drives the gate socket: high opens the envelope, low starts the release.
  • done is 1 for one block when the release ends; it clocks the counter like a trigger.
  • Lane 1 of the counter (count / limit) is scaled and cabled into the filter cutoff, downstream of the envelope.
Frame preview: Count finished notesFrame “Count finished notes” with 3 elements: text heading, text hint, knob Release.COUNT FINISHED NOTESThe gate opens twice a second. Each time the release has fully died away, done …200 msRelease
Frame preview (static). Controls show their default values.

Open in TuneToys

  • Oscillator Selected waveform kernels, continuous morphing, harmonic shapes and phase/gate control; an optional MIDI input plays notes in the Toy's tuning.
  • Polyphonic instrument Eight owned, velocity-sensitive oscillator voices with ADSR, sustain and MPE, played from a MIDI cable in the Toy's tuning.
  • Compressor Peak/RMS compression with a sidechain key input, detector filtering, hold, adaptive release and channel linking.

Edit this page on GitHub

esc

↑ ↓ move↩ open⌘↩ new tabesc close