Skip to main content

Module mtc

Module mtc 

Source
Expand description

MIDI Time Code (MTC) — quarter-frame encode/decode of an hh:mm:ss:ff timecode.

A full SMPTE timecode is streamed as eight quarter-frame messages, each a 0xF1 status byte followed by one data byte of the form 0iiidddd: the upper three bits iii select which of the eight nibbles (piece 0..=7) is carried in the lower four bits dddd. Reassembling all eight pieces yields the frame; the top piece also carries the high hour bit and a 2-bit frame-rate code. This module encodes a Timecode to the eight data bytes and decodes them back, allocation-free.

Structs§

Timecode
An SMPTE / MTC timecode: hours:minutes:seconds:frames at a FrameRate.

Enums§

FrameRate
SMPTE frame rate, encoded in the 2-bit rate field of MTC piece 7.

Functions§

decode_quarter_frames
Decode eight MTC quarter-frame data bytes back into a Timecode.
encode_quarter_frames
Encode a timecode into the eight MTC quarter-frame data bytes (the byte that follows each 0xF1 status). Element i has the form (i << 4) | nibble.