Skip to main content

Crate smpte_timecode

Crate smpte_timecode 

Source
Expand description

SMPTE timecode arithmetic with exact drop-frame handling, and a MIDI Time Code decoder and encoder.

  • Timecode is a frame position within one 24-hour day at a FrameRate. It parses and formats labels, wraps at midnight, and converts to and from exact seconds and samples.
  • Ratio and Pull keep NTSC rates, pulled sample rates and seconds exact.
  • MtcDecoder turns quarter-frame and full-frame messages into checked positions with their direction and lock state. MtcEncoder produces the messages.

The crate is no_std, does not allocate and has no dependencies. It does not open MIDI ports or keep time: callers pass complete MIDI messages and the time each arrived.

use smpte_timecode::{FrameRate, Ratio, Rounding, Timecode};

let tc = Timecode::parse("00:10:00;00", FrameRate::FPS_29_97_DF)?;
assert_eq!(tc.frames(), 17_982);
assert_eq!(tc.to_samples(Ratio::from_integer(48_000), Rounding::Nearest)?, 28_799_971);

Structs§

Fields
The four fields of a timecode label.
FrameRate
A timecode frame rate: a nominal frame count, whether frames run 1000/1001 slower (the NTSC family), and whether labels use drop-frame counting.
MtcDecoder
Turns MIDI Time Code messages into checked positions.
MtcEncoder
Produces the quarter-frame messages of a running MIDI Time Code stream.
MtcEvent
A position decoded from MIDI Time Code.
Pull
An exact pull-up or pull-down factor for a frame rate or a sample rate.
Ratio
An exact non-negative rational number, always stored in lowest terms.
Timecode
A position within one 24-hour timecode day at a FrameRate.

Enums§

Direction
Which way quarter frames run.
LockState
Whether a decoder is following a timecode source.
Motion
How a decoded position was reached.
MtcError
An error from decoding or encoding MIDI Time Code.
Rounding
How a conversion picks a whole number when the exact result falls between two.
TimecodeError
An error from building, parsing or converting a timecode.