11.3.13.6. Working with the TempoClock Class
Here is a brief explanation of some Functions available with the TempoClock Class. Throughout this section, the variable "t" is used to represent any particular TempoClock.
var t = TempoClock.new( tempo, beats );
This creates a new TempoClock. The arguments are optional, and have the following meanings:
tempo: tempo of the clock, given in beats per second. To input a value in beats-per-minute, divide it by 60. Defaults to 60 beats per minute, or one per second.
beats: starts the clock at this time. Default is zero.
t.stop;
t = nil;
Equivalent to the "free" method for a Synth of Bus Object. This stops the clock, discards all scheduled events, and releases the resources used to run the clock. Setting the variable to "nil" afterwards is optional, but recommended, to avoid later programming mistakes.
t.clear;
Discards all scheduled events, but keeps the clock running.
t.tempo;
Returns the current tempo in beats-per-second.
t.tempo_( newTempo );
Allows you to change the clock's tempo. The new tempo should be in beats-per-second. To input a tempo in beats-per-minute, divide the value by 60.
t.play( aFunction );
Schedules the Function to begin execution on the next beat.
There are many other Functions in the TempoClock Class, related to absolute scheduling, scheduling with bars, and conversion of beats to and from seconds.