Control envelope

A control-rate ADSR, AD or AR envelope on a gate lane, 0 to 1, with velocity scaling and a done event.

  • Control
  • Since 0.2.0
  • envelope
  • adsr
  • gate
  • modulation
  • velocity

Open in TuneToys

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

Control envelope turns a gate lane into a 0 to 1 control lane that rises, holds and falls like an envelope. It is the control-rate sibling of Envelope: the same stages and curves, but the result is a lane you cable into any parameter instead of a gain applied to audio.

What it does#

While the gate lane is at 0.5 or more it is held. A rising edge starts the attack; in ADSR the level then decays to Sustain and stays there until the gate falls, then Release returns it to zero. AD ignores the falling gate and runs attack then decay on its own; AR rises to full and holds until the gate falls. Curve bends every segment, Loop repeats whole cycles while the gate is held, and Retrigger chooses whether a new edge starts from the current level or from zero. The stage logic is the audio envelope's own, so the two agree.

Velocity scales the peak from the gate lane's value at the rising edge: at 0 the gate value is ignored, at 1 a gate of 0.75 peaks at 0.75. Use the velocity lane of MIDI to control, or a gate multiplied by a level, to get velocity-sensitive envelopes. The gate must still reach 0.5 to open.

Resolution#

Control runs once per audio block, and the output is the level at the block's last frame. Stage times are exact, but the lane steps about 2.7 ms at 128 frames and 48 kHz, so very short attacks look like a step. Cable the output into a parameter's cable input to let that parameter smooth it.

Events#

The done outlet is 1 for one block when a cycle ends: a release finishes, or an AD decay completes. A retrigger during a release is not a completed cycle. Cable it into Counter or another trigger input.

When to use it#

Use it to shape a filter, a level or any parameter per note, or to build a one-shot modulator from a trigger. Prefer Envelope when the envelope shapes audio directly.

Ports#

PortDirectionSignalLanes
gateInputControl1
controlOutputControl1
doneOutputControl1

Parameters#

ParameterLabelRangeDefaultUnitScaleNotes
typeType0 to 20linearSelects the implemented algorithm. Choices are discrete. Choices: 0 ADSR, 1 AD, 2 AR.
attack_msAttack0 to 1000010mslinearTime to rise to full level.
decay_msDecay0 to 10000120mslinearTime to fall to sustain in ADSR, or zero in AD.
sustainSustain0 to 10.7%linearHeld ADSR level. Stored as a fraction; shown ×100 as a percentage.
release_msRelease0 to 10000200mslinearTime to return to zero after the gate falls.
hold_msLoop hold0 to 10000100mslinearDuration of the held part in repeating ADSR/AR cycles. Shown when loop is 1.
curveCurve-1 to 10linearContinuous concave/linear/convex segment curvature.
loopLoop0 to 10linearRepeats complete envelope cycles while the gate is held. Choices: 0 Off, 1 While held.
retriggerRetrigger0 to 10linearWhere a new gate edge starts the attack. Choices: 0 Current level, 1 From zero.
velocityVelocity0 to 10linearHow much the gate lane value at the rising edge scales the peak. 0 ignores it.

Type (type)#

ADSR, AD or AR. A discrete choice.

Attack (attack_ms), Decay (decay_ms), Sustain (sustain), Release (release_ms)#

The stage times and the held level. Decay applies to ADSR and AD, Sustain to ADSR, Release to ADSR and AR.

Loop hold (hold_ms)#

How long a looping cycle rests at its held level before releasing. Visible when Loop is on.

Curve (curve)#

Concave below 0, linear at 0, convex above 0, applied to every segment.

Loop (loop) and Retrigger (retrigger)#

Loop repeats cycles while the gate is held. Retrigger picks the start of a new attack: the current level, or zero.

Velocity (velocity)#

How much the gate value at the rising edge scales the peak, 0 to 1.

Tips#

  • A square Control LFO is a quick gate for trying an envelope.
  • Keep Velocity at 0 for a plain gate; at 1 the gate value is the peak.
  • Release only has something to do while the gate falls from above zero; done waits for it to finish.

See also#

Envelope, Control LFO, Counter, MIDI to control, Cables.

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 note

beginner Teaches: attack_ms, decay_ms, sustain, release_ms

A square LFO is the gate; a control envelope turns each pulse into a swell and fade on the tone.

Patch: Oscillator audio output connected to Gain audio input. Gain audio output connected to Patch outputs audio input. Control LFO control output connected to Control envelope gate input. Control envelope control output connected to Gain @level input.
Connections as text
  • Oscillator audio output connected to Gain audio input
  • Gain audio output connected to Patch outputs audio input
  • Control LFO control output connected to Control envelope gate input
  • Control envelope control output connected to Gain @level input
  • A gate at 0.5 or more is held; below it the envelope releases.
  • The output is 0 to 1 and rides the gain level.
Frame preview: Shape a noteFrame “Shape a note” with 6 elements: knob Attack, knob Decay, text heading, text hint, knob Release, knob Sustain.80 msAttack200 msDecaySHAPE A NOTEThe gate is high for half of each second. Attack and Decay shape the rise; Sust…400 msRelease0.5 %Sustain
Frame preview (static). Controls show their default values.

Open in TuneToys

2. Velocity and done

intermediate Teaches: velocity, decay_ms

An AD envelope scales its peak by the gate value, and its done outlet steps a counter that picks the next pitch.

Patch: Oscillator audio output connected to Gain audio input. Scale control output connected to Oscillator @frequency input. Gain audio output connected to Patch outputs audio input. Control LFO “gate” control output connected to Math a input. Control LFO “level” control output connected to Math b input. Math out output connected to Control envelope gate input. Control envelope control output connected to Gain @level input. Control 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.
Connections as text
  • Oscillator audio output connected to Gain audio input
  • Scale control output connected to Oscillator @frequency input
  • Gain audio output connected to Patch outputs audio input
  • Control LFO “gate” control output connected to Math a input
  • Control LFO “level” control output connected to Math b input
  • Math out output connected to Control envelope gate input
  • Control envelope control output connected to Gain @level input
  • Control 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
  • Velocity 1 makes the gate value the peak; 0 ignores it.
  • done is 1 for one block when the envelope ends.
Frame preview: Velocity and doneFrame “Velocity and done” with 4 elements: knob Decay, text heading, text hint, knob Velocity.250 msDecayVELOCITY AND DONEThe gate is multiplied by a random level each pulse, so Velocity makes some hit…1Velocity
Frame preview (static). Controls show their default values.

Open in TuneToys

  • Envelope Curved AD, AR and ADSR gain envelopes with looping and explicit retrigger behavior.
  • Control LFO A free-running or tempo-synced low-frequency oscillator on a control lane, 0 to 1, with depth, offset, phase, skew, random shapes and a reset input.
  • Counter Count rising edges of a trigger lane, with step, limit, wrap and reset. Lane 1 is the normalised count, lane 2 the raw count.
  • MIDI to control Turn MIDI into six control lanes: pitch, gate, velocity, bend, pressure and one CC, with last-note priority.

Edit this page on GitHub

esc

↑ ↓ move↩ open⌘↩ new tabesc close