Use clocks to create automated, algorithmic scheduling. Among the things that clocks "play" are routines, tasks, and patterns.
To see how a clock "plays" a routine, first examine how a function works in a routine.
The first argument (and usually the only argument) to a routine is a function.
A .yield message to an expression in a function (in a routine) returns a value.
The routine above returns nil when its evaluated a second time. This is because once a routine "yields" and if there's no additional code after the .yield message, the routine is finished, over, and done - unless it receives a reset message. Then it can start over again.
The first three .next messages return a string. The fourth .next message returns nil.
Reset the routine.
Use a .do message in a routine to make a loop.
Evaluate the routine one more time than the loop in the routine allows.
The routine returned three strings followed by nil.
Rewrite the routine so that it includes a .wait message.
Then "play" the routine, eg, send it a .play message.
Append a .reset message to the routine so that it can start over.
When a routine receives a .play message, control (of the routine) is redirected to a clock. The clock uses the receiver of the .wait message as a unit of time to schedule ("play") the routine.
SuperCollider has three clocks, each of which has a help file.
The .play message is a convenience that allows one to write
Enclose synths within routines. It's often the case that the synthdef used by the synth in routines should have an envelope with a doneAction parameter set to 2 (to deallocate the memory needed for the synth after its envelope has finished playing).
Process synths spawned in a routine through effects that run outside of the routine.
go to 20_Debugging