Operator SDK
Build MIDI processing and UI modes for the Operator device
Loading...
Searching...
No Matches
op::sdk::ClockInterpolator Class Reference

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.

Detailed Description

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.

Member Enumeration Documentation

◆ Status

enum class op::sdk::ClockInterpolator::Status : uint8_t
strong

Health of the interpolated position returned by now().

Enumerator
Live 

Clock active, fraction sweeping normally within a pulse.

HeldOverdue 

Clock active but the next pulse is late, fraction clamped just below unity and held until the pulse arrives.

HeldStale 

Clock active state seen but no pulse for ~4x the period, position frozen at last-known (likely a stalled clock).

NoClock 

Clock idle (NoClock) or delegated (Mode), position frozen.

Member Function Documentation

◆ now()

ClockInterpolator::Position op::sdk::ClockInterpolator::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.

◆ pulse_period_us()

uint32_t op::sdk::ClockInterpolator::pulse_period_us ( ) const
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.


The documentation for this class was generated from the following file: