home/ atoms/ sc-envelopes

SuperCollider's Env class defines a breakpoint envelope that EnvGen (or the .kr shortcut) plays back as a control signal

The Env class specifies an envelope as a sequence of time-level breakpoints. Helper constructors build common shapes: Env.perc(attack, release, level, curve) for percussive shapes; Env.triangle(dur, level) for symmetric attack+release; Env.linen(attack, sustain, release, level) which adds a flat sustain; and Env.pairs([[time, level], …], curveType) for arbitrary shapes. For sustained notes, Env.asr and Env.adsr hold until a gate closes, then release. The envelope is realized on the server by EnvGen.kr, but the shortcut form Env.perc.kr(doneAction: 2) wraps this transparently and appending .kr(doneAction: 2) frees the node when the envelope finishes. Envelopes are not limited to amplitude: by scaling their output (multiplication, or .range) they can modulate any parameter, such as frequency or filter cutoff. Env.plot visualizes a shape without producing sound.

Examples

Env.perc(0.01, 1).plot;                       // visualize, no sound
{PinkNoise.ar(Env.perc(0.01, 0.5).kr(2))}.play;
{SinOsc.ar(440) * Env.triangle(1).kr(2)}.play;
{SinOsc.ar(Env.pairs([[0,200],[1,1000]], \lin).kr)}.play;   // envelope on frequency

Assessment

Name the four ADSR stages and what each does in time. Use Env.linen (or Env.adsr) to write a synth that fades in over 0.5 s, holds for 2 s, then fades out over 1 s and frees itself; for the adsr version, sustain while a key is held and release when x.set(\gate, 0) is sent.

“exible typ eofenvelop e. Envistheob jectyouwillb eusingallth”
corpus · a-gentle-introduction-to-supercollider-bruno-ruviaro · chunk 14
“Envis the object you will be using all the time to define all sorts of envelopes.Envhas many useful methods; we can only look at a few here.”
corpus · a-gentle-introduction-to-supercollider-ruviaro-archive-org-c · chunk 14