Expand description
24-PPQN MIDI clock — generation and consumption.
MIDI transmits 24 timing-clock bytes (0xF8) per quarter note. One clock
therefore lasts (60 / bpm) / 24 seconds. This module both generates the
stream (how many clock pulses fall inside a wall-clock time slice) and
consumes it (estimate BPM from the interval between received pulses,
smoothed over a small fixed window so jitter on a single interval does not
throw the tempo). No allocation; all state lives on the stack.
Structs§
- Clock
Sync - A 24-PPQN clock that both emits pulses over time and estimates incoming BPM.
Constants§
- CLOCKS_
PER_ QUARTER - Clock pulses per quarter note, per the MIDI spec.
- CONTINUE
- MIDI System Real-Time: Continue.
- START
- MIDI System Real-Time: Start.
- STOP
- MIDI System Real-Time: Stop.
- TIMING_
CLOCK - MIDI System Real-Time: Timing Clock (24 per quarter note).
Functions§
- bpm_
from_ clock_ period - Recover BPM from the interval (seconds) between two clock pulses.
- clock_
period_ seconds - Seconds between consecutive clock pulses at a given tempo.