Multiple doneAction:2?

Hi list,

sorry if this has been asked before:

In one synthdef I have two EnvGens with doneAction:2 which both take different
times to complete their envelopes. It seems the earlier one will free
the synth node. Is there a way to have the EnvGen that finishes last
free the node instead? I have looked at the docs for Done but can’t seem
to find it.

thanks!
P

Yes. Use two Done.kr’s and a FreeSelf.kr. Done.kr outputs 1 if the input UGen’s done flag is set, otherwise 0. Multiply the two Done.kr’s together so that FreeSelf.kr is triggered if and only if both Done.kr’s are nonzero.

(
{
	var env1, env2, snd;
	env1 = EnvGen.ar(Env([0, 1, 0], [0.1, 1]));
	env2 = EnvGen.ar(Env([0, 1, 0], [0.1, 5]));
	snd = Saw.ar(440) * env1 * env2;
	FreeSelf.kr(Done.kr(env1) * Done.kr(env2));
	snd ! 2;
}.play(fadeTime: 0);
)

Nathan,
thank you so much, this sounds like a great solution!
Btw, what does .play(fadeTime: N) specify?
P

fadetime is a jitlib thing. If you were using jitlib, it would control the crossfading time between proxyspace nodes

fadeTime isn’t only jitlib – it’s also an argument to Function:play – “Crossfade time for attack and release of the synth. The default is 0.02 seconds, which is just enough to avoid a click.”

hjh

1 Like

Ah cool! So you don’t have to use an EnvGen