Clock is an abstract class: it only defines an abstract set of methods that all clocks should implement. See its subclasses: SystemClock, TempoClock, AppClock for specific implementations.
A Clock keeps track of time and allows tasks to be scheduled for some time in the future (e.g. using sched, schedAbs or play methods). A task can be any Object. When the time at which a task was scheduled is up, the task is awoken, i.e. its awake method is evaluated. If the value returned by this method is a number, the task is automatically rescheduled for the time equal to its last scheduled time plus the return value (in beats).
Objects of different classes may do different things in response to being scheduled on a clock by having own implementation of the awake
method. The Object: -awake method that all classes inherit simply calls the same object's next method, forwarding the beats
argument as well as the return value, so subclasses may implement either one to equivalent effect, as far as clock scheduling is concerned. 1
Examples of useful objects to be scheduled on clocks:
next
method do something useful aside from returning a new value in a stream.Whenever a task is awaken, its awake
method is called in the context of the main thread. Just before that, the main thread's logical time is set to the scheduling time of the awaken task, and its clock is set to the scheduling clock. Note however that if the task is a Routine it will then immediately start or resume its Function, setting itself as the current thread.