mod decoder;
mod encoder;
mod errors;
pub use decoder::{LockState, MtcDecoder, MtcEvent};
pub use encoder::MtcEncoder;
pub use errors::MtcError;
use crate::FrameRate;
const QUARTER_FRAME: u8 = 0xF1;
const SYSEX_START: u8 = 0xF0;
const SYSEX_END: u8 = 0xF7;
const UNIVERSAL_REAL_TIME: u8 = 0x7F;
const ALL_DEVICES: u8 = 0x7F;
const SUB_ID_TIME_CODE: u8 = 0x01;
const SUB_ID_FULL_FRAME: u8 = 0x01;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Direction {
Forward,
Reverse,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Motion {
Forward,
Reverse,
Located,
}
const fn stream_rate(code: u8) -> FrameRate {
match code {
0 => FrameRate::FPS_24,
1 => FrameRate::FPS_25,
2 => FrameRate::FPS_29_97_DF,
_ => FrameRate::FPS_30,
}
}
const fn rate_code(rate: FrameRate) -> Result<u8, MtcError> {
match (rate.nominal(), rate.is_drop_frame()) {
(24, _) => Ok(0),
(25, _) => Ok(1),
(30, true) => Ok(2),
(30, false) => Ok(3),
_ => Err(MtcError::NoRateCode),
}
}