Skip to main content

Module song_position

Module song_position 

Source
Expand description

Song Position Pointer (SPP) — 14-bit MIDI-beat position codec.

SPP is the System Common message 0xF2 LSB MSB: two 7-bit data bytes form a 14-bit value counting MIDI beats from the start of the song, where one MIDI beat = 6 MIDI clocks = a sixteenth note. The value range is 0 ..= 16383. This module encodes a beat count into the two data bytes (least-significant 7 bits first) and decodes them back, validating that the data bytes have their high bit clear. Allocation-free.

Constants§

MAX_BEATS
Maximum representable MIDI-beat position (14 bits).
SONG_POSITION
Song Position Pointer status byte (System Common).

Functions§

decode_song_position
Decode the two SPP data bytes back into a MIDI-beat position.
encode_song_position
Encode a MIDI-beat position into the two SPP data bytes [LSB, MSB].