Plays back break point envelopes. The envelopes are instances of the Env class. The envelope and the arguments for levelScale
, levelBias
, and timeScale
are polled when the EnvGen is triggered, and at the start of a new envelope segment. All values remain constant for the duration of each segment.
envelope |
An Env instance, or an Array of Controls. (See Control and the example below for how to use this.) The envelope is polled when the EnvGen is triggered, and at the start of a new envelope segment. The Env inputs can be other UGens. |
gate |
This triggers the envelope and holds it open while > 0. If the Env is fixed-length (e.g. Env.linen, Env.perc), the gate argument is used as a simple trigger. If it is an sustaining envelope (e.g. Env.adsr, Env.asr), the envelope is held open until the gate becomes 0, at which point is released. If gate < 0, force release with time |
levelScale |
The levels of the breakpoints are multiplied by this value. This value can be modulated, but is only sampled at the start of a new envelope segment. |
levelBias |
This value is added as an offset to the levels of the breakpoints. This value can be modulated, but is only sampled at the start of a new envelope segment. |
timeScale |
The durations of the segments are multiplied by this value. This value can be modulated, but is only sampled at the start of a new envelope segment. |
doneAction |
An integer representing an action to be executed when the env is finished playing. This can be used to free the enclosing synth, etc. See Done for more detail. |
If the gate of an EnvGen is set to -1 or below, then the envelope will cutoff immediately. The time for it to cutoff is the amount less than -1, with -1 being as fast as possible, -1.5 being a cutoff in 0.5 seconds, etc. The cutoff shape and final value are read from the Env's last node.
If the synthDef has an arg named "gate", the convenience method of Node can be used: node.release(releaseTime)
Forced release ignores multi-node release stages, always performing a one-node release, reading curve and end value from the Env's last node, and overwriting its duration.
When using an envelope to modulate a filter's cutoff/center frequency, at higher resonance settings, a short attack time can produce a spike in volume. If this effect is not desired, and the filter's attack is always at the beginning of the synth (as is usually the case when playing a pattern), the artifact can be avoided by setting the envelope's initial level closer to target level for shorter attack times (below about 0.05 sec).
The following example shows how to do this in a SynthDef: Attack times between 0 and 0.05 seconds will produce initial envelope values between 1.0 (attack time = 0 means no attack) and 0.0. If the attack time is greater than 0.05 seconds, the envelope will start at 0.0. (The envelope is between 0.0 and 1.0 and mapped onto a valid frequency range.)
To hear the (potentially loud) short-attack artifacts, edit the var envInit
line to read var envInit = 0;
.
The above works only for initial values. If a short attack is retriggered in the middle of a synth, then the envelope cannot adjust the low value for reattack (because the envelope's initial value is used only once, at the beginning of the synth, and never touched again). In that case, open the amplitude envelope slightly later to avoid the artifact.
For more information about the control bus mapping used in the line a = Synth(\sine, [freq: f.asMap]);
, see Node: -map and Bus: -asMap.