Operator SDK
Build MIDI processing and UI modes for the Operator device
Loading...
Searching...
No Matches
timing.h File Reference

Musical subdivision helpers + clock interpolation (opt-in, header-only). More...

#include <cstdint>
#include <operator_sdk/abi/mode_api.h>

Classes

class  op::sdk::ClockInterpolator
 Converts the firmware's integer 24 PPQ pulse counter into a smooth fractional position by interpolating between pulse edges. More...
struct  op::sdk::ClockInterpolator::Position
 Interpolated clock position. More...
class  op::sdk::StepTracker
 Tells a mode when the clock has carried it into a new step. More...

Namespaces

namespace  op
 Root namespace for the Operator SDK.
namespace  op::sdk::timing
 Musical subdivision constants and clock/timing helpers.
namespace  op::sdk
 Core SDK helpers for modes (timing, text, MIDI, and math).

Enumerations

enum class  op::sdk::StepEdge : uint8_t { op::sdk::Unchanged , op::sdk::Adopted , op::sdk::Crossed }
 What a step observation means. More...

Functions

uint32_t op::sdk::timing::beats_to_ticks (float beats, uint32_t bpm)
 Convert musical beats at a given tempo into microseconds.
uint32_t op::sdk::timing::subdivision_us (uint8_t subdiv, uint32_t bpm)
 Microseconds per single subdivision at the given tempo.
uint32_t op::sdk::timing::quantize_to_grid (uint32_t tick_us, uint32_t subdiv_us)
 Round a tick value down to the nearest grid boundary.
int32_t op::sdk::timing::swing_offset (uint32_t tick_us, uint8_t swing_percent, uint32_t subdiv_us)
 Microsecond offset to apply to "every other" subdivision to create swing feel.

Variables

constexpr uint8_t op::sdk::timing::kSubdiv1 = 0
 Whole note subdivision (4 beats in 4/4).
constexpr uint8_t op::sdk::timing::kSubdiv_2 = 1
 Half note subdivision.
constexpr uint8_t op::sdk::timing::kSubdiv_4 = 2
 Quarter note subdivision (one beat).
constexpr uint8_t op::sdk::timing::kSubdiv_8 = 3
 Eighth note subdivision.
constexpr uint8_t op::sdk::timing::kSubdiv_16 = 4
 Sixteenth note subdivision.
constexpr uint8_t op::sdk::timing::kSubdiv_32 = 5
 Thirty-second note subdivision.
constexpr uint8_t op::sdk::timing::kSubdivTripletQuarter = 6
 Quarter-note triplet (three notes per half-note).
constexpr uint8_t op::sdk::timing::kSubdivTripletEighth = 7
 Eighth-note triplet (three notes per quarter-note).
constexpr uint8_t op::sdk::timing::kSubdivTripletSixteenth = 8
 Sixteenth-note triplet (three notes per eighth-note).

Detailed Description

Musical subdivision helpers + clock interpolation (opt-in, header-only).

Three groups of facilities live here:

  • op::sdk::timing::*, the pure integer/float subdivision math (beats to microseconds, grid quantization, swing). These do not call the ABI themselves. They translate between microseconds, beats, and musical grid subdivisions.
  • op::sdk::ClockInterpolator, which converts the device's integer 24 PPQ api->get_pulse_count() counter into a smooth fractional position by interpolating between pulse edges using api->get_tick() microseconds. (The ABI exposes no fractional-beat call, so the interpolator is the mode-side way to get a continuous position.)
  • op::sdk::StepTracker, which tells a mode running on a musical grid when the clock has carried it into a new step.

Include on demand. This header is deliberately not pulled in by operator_sdk.h.