According to the jitlib_fading help file, it is possible to set a custom envelope for an Ndef (example taken from the mentioned help file, c) custom fade envelope):
~out = { arg gate=1, fadeTime = 0.1; EnvGen.kr(Env.asr(fadeTime, 1, fadeTime), gate, doneAction: Done.freeSelf) * 0.2 * SinOsc.ar([1,1] * Rand(440, 550)) };
Since I am working extensively with chains of Ndef sources, e.g.
Ndef(\a)[0] = {WhiteNoise.ar(0.1)};
Ndef(\a)[1] = \filter -> {|in| LPF.ar(in, \freq.kr(100))};
I was wondering if it is also possible to set a custom envelope for an Ndef slot like in the example above, instead of using the default envelope.
However, by trying out to set an envelope in the last Ndef slot (which appears naturally in many cases), it seems that the default envelope is still used.
Ndef(\a)[2] = \filter -> {|in| in * EnvGate(0, doneAction: Done.freeSelf, curve: [-5, 5])}
use xset to test fading:
Ndef(\a).fadeTime = 5
Ndef(\a).xset(\freq, 500);
Ndef(\a).xset(\freq, 1500);
Ndef(\a).xset(\freq, 300);
Ndef(\a).xset(\freq, 800);
This of course makes sense, since at instantiation of the first Ndef slot, the default envelope is created (no custom envelope provided yet).
Two questions:
-
Is there any way around that, somehow, or do I need to fake an envelope (e.g. by providing
fadeTimeandgatecontrols plus an envelope that does not use them in the first slot)? -
What
doneActionwould I need to use to make this work (there are a lot of Synths…)?
Any help is appreciated, thanks a lot in advance!