In the EnvGen help I read “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 remain constant for the duration of the envelope.”
The following code demonstrates that a change to the Env object after the EvnGen has been triggered leads to a change in the generated envelope. It seems that only the current segment is kept constant. What would be a good workaround? I tried latching the fade value with the same trigger starting the envelope, but this led to even less predictable behaviour. I can also provide an example, but maybe somebody can already shade some light on what I am doing (wrong) here and what I should be doing to keep the envelope specification constant until the next trigger to EnvGen.
(
fork {
x = { |fade = 0.5|
var env = Env.new([0, 1, 1, 0], [fade, 1 - (fade * 2), fade], \sin);
EnvGen.ar(env, 1, timeScale:6).poll();
}.play();
2.wait();
x.set(\fade, 0);
4.wait();
"************* 6 seconds".postln();
}
)