Classes | UGens > Synth control

FreeSelfWhenDone : UGen : AbstractFunction : Object

Free the enclosing synth when a UGen is finished


Some UGens set a 'done' flag when they are finished playing. FreeSelfWhenDone will free the enclosing synth when this flag is set to true.

See Done for a complete list of these UGens.

Note that many of these UGens have doneActions, which are another way of accomplishing the same thing. See Done for more detail.

NOTE: One must be careful when using binary operations on UGens with done flags, as these will return a BinaryOpUGen, and thus prevent the done flag from being accessible. See example below.

Class Methods



the UGen to check for done.

Inherited class methods

Instance Methods

Inherited instance methods



// simple example
{ var env;
env =, 1, 1);; // free synth at end of line, 0, 0.5) * env

// the previous example works, because FreeSelfWhenDone operates on the Line
// this version won't work
{ var env, output;
env =, 1, 1);
output =, 0, 0.5) * env;
output.postln; // output is a BinaryOpUGen, which has no 'done' flag; // won't ever be done

// record for four seconds
b = Buffer.alloc(s, 44100 * 4.0, 1);
SynthDef("help-RecordBuf",{ arg out=0,bufnum=0;
    var formant, recbuf;
    formant =,1000, 4), 2000, 800, 0.125);
    recbuf =, bufnum, recLevel:, 1), loop: 0);
    // The RecordBuf doesn't loop, so you can check it for 'done' status;
}).play(s,[\out, 0, \bufnum, b]);

// play it back
SynthDef("help-RecordBuf play",{ arg out=0,bufnum=0;
    var playbuf;
    playbuf =,bufnum);; // frees the synth when the PlayBuf is finished, playbuf);
}).play(s,[\out, 0, \bufnum, b]);