Expand description
SMPTE timecode arithmetic with exact drop-frame handling, and a MIDI Time Code decoder and encoder.
Timecodeis a frame position within one 24-hour day at aFrameRate. It parses and formats labels, wraps at midnight, and converts to and from exact seconds and samples.RatioandPullkeep NTSC rates, pulled sample rates and seconds exact.MtcDecoderturns quarter-frame and full-frame messages into checked positions with their direction and lock state.MtcEncoderproduces 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.
- Frame
Rate - 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.
- Lock
State - 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.
- Timecode
Error - An error from building, parsing or converting a timecode.