Expand description
PPQ (pulses-per-quarter-note) tick ↔ musical time ↔ wall-clock time.
A MIDI sequence measures time in ticks: there are ppq ticks in one
quarter note (a “beat” in 4/4). At a tempo of bpm quarter notes per
minute, one quarter note lasts 60 / bpm seconds, so
seconds = (ticks / ppq) * (60 / bpm)
ticks = seconds * (bpm / 60) * ppqBoth directions are pure functions with no allocation — safe on the hot
path. Values are validated: ppq and bpm must be strictly positive.
Functions§
- seconds_
to_ ticks - Convert seconds of wall-clock time to a fractional PPQ tick count.
- ticks_
to_ seconds - Convert a PPQ tick count to seconds of wall-clock time at a given tempo.