Done:
Filter:
Classes | UGens > Synth control | Server > Nodes

Done : UGen : AbstractFunction : Object

Monitors another UGen to see when it is finished
Source: EnvGen.sc

Description

Some UGens set a 'done' flag when they are finished playing. This UGen echoes that flag when it is set to track a particular UGen.

The UGens trackable by Done are:

Class Methods

Done.kr(src)

Arguments:

src

The UGen to monitor

Inherited class methods

Undocumented class methods

Done.freeAllInGroup

Done.freeGroup

Done.freeSelf

Done.freeSelfAndDeepFreeNext

Done.freeSelfAndDeepFreePrev

Done.freeSelfAndFreeAllInNext

Done.freeSelfAndFreeAllInPrev

Done.freeSelfAndNext

Done.freeSelfAndPrev

Done.freeSelfPauseNext

Done.freeSelfPausePrev

Done.freeSelfToHead

Done.freeSelfToTail

Done.none

Done.pauseSelf

Instance Methods

Inherited instance methods

Examples

The 'done' flag can be used to trigger other things in the same synth:

(
SynthDef("Done-help", { arg out, t_trig;
    var line, a, b;

    line= Line.kr(1,0,1);

    a= SinOsc.ar(440,0,0.1*line); //sound fading out
    b= WhiteNoise.ar(Done.kr(line)*0.1); //noise starts at end of line

    Out.ar(out, Pan2.ar(a+b));
}).add;
)

Synth("Done-help"); //note that this synth doesn't have it's own doneAction, so you'll need to manually deallocate it

The 'done' flag can be used to trigger a delayed freeing of the current synth, which is not possible by using doneActions alone:

play {
    var env = Line.kr(1,0,2);
    var sig = PinkNoise.ar(env);
    FreeSelf.kr(TDelay.kr(Done.kr(env),3));
    GVerb.ar(sig,70,7);
}

Actions

A number of UGens implement doneActions. These allow one to optionally free or pause the enclosing synth and other related nodes when the UGen is finished. You can use the constants in this class to name doneActions, which can be clearer than using the number codes alone. The available doneActions are as follows:

namevaluedescription
none0do nothing when the UGen is finished
pauseSelf1pause the enclosing synth, but do not free it
freeSelf2free the enclosing synth
freeSelfAndPrev3free both this synth and the preceding node
freeSelfAndNext4free both this synth and the following node
freeSelfAndFreeAllInPrev5free this synth; if the preceding node is a group then do g_freeAll on it, else free it
freeSelfAndFreeAllInNext6free this synth; if the following node is a group then do g_freeAll on it, else free it
freeSelfToHead7free this synth and all preceding nodes in this group
freeSelfToTail8free this synth and all following nodes in this group
freeSelfPausePrev9free this synth and pause the preceding node
freeSelfPauseNext10free this synth and pause the following node
freeSelfAndDeepFreePrev11free this synth and if the preceding node is a group then do g_deepFree on it, else free it
freeSelfAndDeepFreeNext12free this synth and if the following node is a group then do g_deepFree on it, else free it
freeAllInGroup13free this synth and all other nodes in this group (before and after)
freeGroup14free the enclosing group and all nodes within it (including this synth)

For information on freeAll and deepFree, see Group and Server Command Reference.

Alternatives

Another way to free a synth when some UGen is done playing is to use FreeSelfWhenDone, or FreeSelf in combination with Done. For example, this can be used to delay the freeing to let reverb tails fade out, etc.