|
Operator SDK
Build MIDI processing and UI modes for the Operator device
|
Converts the firmware's integer 24 PPQ pulse counter into a smooth fractional position by interpolating between pulse edges. More...
#include <timing.h>
Classes | |
| struct | Position |
| Interpolated clock position. More... | |
Public Types | |
| enum class | Status : uint8_t { Live , HeldOverdue , HeldStale , NoClock } |
| Health of the interpolated position returned by now(). More... | |
Public Member Functions | |
| Position | now () |
| Sample the current interpolated clock position. | |
| uint32_t | pulse_period_us () const |
| Smoothed microseconds between consecutive 24 PPQ pulse edges. | |
Converts the firmware's integer 24 PPQ pulse counter into a smooth fractional position by interpolating between pulse edges.
Header-only, per-instance. Hold one ClockInterpolator as a plain member of your mode struct. Call now() exactly once per process() call.
|
strong |
Health of the interpolated position returned by now().
|
inline |
Sample the current interpolated clock position.
Consume-only: reads op::api (get_pulse_count / get_tick / get_clock_state), updates internal interpolation state, and returns the position. Call once per process(). Units are 24 PPQ pulses, so divide by your own modulus for beats. Never resets to zero on clock loss: a stalled or absent clock freezes the last-known position.
|
inline |
Smoothed microseconds between consecutive 24 PPQ pulse edges.
Returns the median of the last three inter-pulse intervals, or 0 until three have been observed at cold start. After that it holds the last period across a clock stop, the same freeze now() applies to the position. One quarter note spans 24 pulses, so multiply by 24 for microseconds-per-quarter-note and divide 60'000'000 by that for BPM. Reflects whatever now() last sampled, so call now() once per process() tick to keep it current.