clockblocks package
Clockblocks is a library for controlling the flow of musical time, part of SCAMP (Suite for Computer-Assisted Music in Python).
Each Clock runs on its own thread, and clocks form families under a single master
clock, whose Scheduler wakes each thread back up when its call to
wait() is due. The scheduler keeps the whole clock family coordinated under a
shared, ideal timeline, which is not polluted by the small delays that user code inevitably incurs. How
aggressively a clock catches up when it does fall behind is set by its timing policy, which ranges from
waiting out each delay in full to staying pinned to the absolute schedule.
The rate at which beats pass within a clock is given by its tempo, which may vary over time, as described by
a TempoEnvelope. Clocks are also nestable: fork()
spawns a child clock running a function in a parallel, subordinate timeline. A child clock’s tempo is felt
relative to that of its parent, so the true rate at which time passes in a clock is the product of the clock’s
own rate and that of each of its ancestors.
Taken together, these features allow a composer to create multiple, polyphonic (and perhaps poly-tempo) layers of music, each with its own tempo curve, all coordinated under a master clock.
Modules:
Module defining the central |
|
Module containing the enums used to express units of duration and rate: |
|
Exception hierarchy for clockblocks. |
|
Module containing the |
|
Module containing |
|
Module containing the |
|
Module defining the |
|
Module containing the |
|
Module containing the free functions that make up clockblocks' most convenient interface. |
Public-Facing API (result of import *):
|
Recursively nestable clock. |
|
Fine-tuning options for a clock family, passed to a master |
|
Where a clock sits in its lifecycle. |
|
Units with which we measure duration or Moment positioning. |
|
The three different, and mutually determined, ways of expressing tempo. |
|
Raised inside a forked clock's own thread when its wait is woken by kill(), so the fork wrapper can unwind the user function cleanly. |
|
Base class for clockblocks errors. |
|
Raised when something tries to wait or fork on a clock that's no longer ALIVE (either killed already, or — for fork — still PENDING in its start_delay). |
|
Raised when a context-inferring clock operation (the module-level wait/fork/etc.) is attempted from a thread that has no clock active on it. |
|
Raised by operations that are only valid on the master (top-level) clock — e.g. run_as_server() — when called on a child clock. |
|
Raised when wait() is called from a thread that is holding the scheduler via hold_scheduler() — most commonly inside a MIDI / OSC / HID callback, which runs under such a hold. |
|
Raised when wait() is called from a thread that doesn't own the clock. |
|
The package was not found. |
|
Get the version string for the named package. |
|
Class representing a particular point in a (beat or measure) cycle. |
|
Represents a point on a clock's timeline. |
|
Anything that can name a point on a clock's timeline. |
|
A |
The scheduler's pluggable source of "now" and of the condition it uses for waiting. |
|
|
A subclass of |
|
Subclass of TempoEnvelope that keeps track of a current beat and time, and provides functionality for moving forward a certain number of beats or seconds, and/or setting tempo target(s) to reach in the future. |
|
A clock-agnostic point on the scheduler's timeline, projectable into any clock's beat or time axis on demand. |
|
The oriented span between two moments on the scheduler's timeline, produced by subtracting two TimeStamps ( |
|
Drive the current clock's beat length (in seconds per beat) by following a function of beats/time. |
|
Drive the current clock's rate (in beats per second) by following a function of beats/time. |
|
Append a ready-made |
|
Drive the current clock's tempo (in beats per minute) by following a function of beats/time. |
Get the |
|
|
Run |
|
Return how many beats have passed on the currently active clock (see |
Return the current beat length (in seconds per beat) of the currently active clock (see |
|
|
Return the current rate (in beats per second) of the currently active clock (see |
Return the current tempo (in beats per minute) of the currently active clock (see |
|
|
Return how much time has passed on the currently active clock (see |
|
Immediately set the beat length of the current clock (see |
|
Smoothly change the current clock's beat length to |
|
Set several beat-length targets at once, building a multi-segment tempo curve on the current clock. |
|
Immediately set the rate of the current clock (see |
|
Smoothly change the current clock's rate to |
|
Set several rate targets at once, building a multi-segment tempo curve on the current clock. |
|
Immediately set the tempo of the current clock (see |
|
Smoothly change the current clock's tempo to |
|
Set several tempo targets at once, building a multi-segment tempo curve on the current clock. |
Stop following any function or looping envelope previously started on the current clock's tempo (via |
|
Kill the child clocks of the currently active clock, returning once they have finished unwinding (see |
|
|
Block the clock currently active on this thread for |
Block on the currently active clock until its child clocks have finished (see |
|
|
Block on the currently active clock until clock has finished (see |
Block forever on the currently active clock (see |
|
|
Block the clock currently active on this thread until the absolute beat (or time, if |