|
Operator SDK
Build MIDI processing and UI modes for the Operator device
|
Tells a mode when the clock has carried it into a new step. More...
#include <timing.h>
Public Member Functions | |
| StepEdge | observe (int32_t step) |
| Hand in the step the clock has reached this tick. | |
| void | reset () |
| Treat the next observe() as a fresh start. | |
| int32_t | current () const |
| The step last handed in, 0 before the first call. | |
| bool | started () const |
| Whether any step has been handed in since construction or reset(). | |
Tells a mode when the clock has carried it into a new step.
A sequencer or an arpeggiator acts at one moment, when the music reaches the next step of its grid. Work out which step the clock is on, pass that number in once per process(), and this reports whether it just changed.
Where the number comes from is the mode's own business. A fraction of a bar, a fixed count of pulses per step, and a subdivision that follows a rate parameter all arrive here as a plain step number, so the grid stays with the mode that defines it.
The first call is the one worth understanding, and it reports StepEdge::Adopted. A mode comes up at an arbitrary moment, rarely the instant a step begins, and starting inside a step is not the same as reaching one. That step is where the mode came in, so it plays nothing and waits for the next.
Give every grid its own tracker. Four sequences at four step counts run four trackers, each fed its own number.
Default-initialized throughout, so one held at file scope needs no constructor.
|
inline |
Hand in the step the clock has reached this tick.
| step | The current step index, from the mode's own division of the clock. |
|
inline |
Treat the next observe() as a fresh start.
A sequence that restarts comes in on whatever step it resumes at, the same as a mode that has just loaded, so it plays from the next one.