pub struct LtcAudioEncoder { /* private fields */ }Expand description
Generates biphase-mark modulated audio samples from LTC bit words.
Biphase-mark encoding: every bit cell starts with a transition. A ‘1’ bit has an additional mid-cell transition; a ‘0’ bit does not.
§Example
use oximedia_timecode::ltc_encoder::{LtcAudioEncoder, LtcSignalParams, LtcBitEncoder};
use oximedia_timecode::{Timecode, FrameRate, FrameRateInfo};
let params = LtcSignalParams::default_25fps();
let mut encoder = LtcAudioEncoder::new(params);
let tc = Timecode {
hours: 1, minutes: 0, seconds: 0, frames: 0,
frame_rate: FrameRateInfo { fps: 25, drop_frame: false },
user_bits: 0,
};
let bits = LtcBitEncoder::encode(&tc);
let samples = encoder.encode_frame(&bits);
assert!(!samples.is_empty());Implementations§
Source§impl LtcAudioEncoder
impl LtcAudioEncoder
Sourcepub fn new(params: LtcSignalParams) -> Self
pub fn new(params: LtcSignalParams) -> Self
Create a new audio encoder.
Sourcepub fn encode_frame(&mut self, bits: &[u8; 80]) -> Vec<f32>
pub fn encode_frame(&mut self, bits: &[u8; 80]) -> Vec<f32>
Encode a single 80-bit LTC word into audio samples.
Returns a Vec<f32> of biphase-mark modulated audio.
Sourcepub fn encode_sequence(&mut self, timecodes: &[Timecode]) -> Vec<f32>
pub fn encode_sequence(&mut self, timecodes: &[Timecode]) -> Vec<f32>
Encode multiple consecutive timecodes into a continuous audio stream.
Sourcepub fn reset_polarity(&mut self)
pub fn reset_polarity(&mut self)
Reset the polarity to +1.
Sourcepub fn params(&self) -> &LtcSignalParams
pub fn params(&self) -> &LtcSignalParams
Return the signal parameters.
Trait Implementations§
Source§impl Clone for LtcAudioEncoder
impl Clone for LtcAudioEncoder
Source§fn clone(&self) -> LtcAudioEncoder
fn clone(&self) -> LtcAudioEncoder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for LtcAudioEncoder
impl RefUnwindSafe for LtcAudioEncoder
impl Send for LtcAudioEncoder
impl Sync for LtcAudioEncoder
impl Unpin for LtcAudioEncoder
impl UnsafeUnpin for LtcAudioEncoder
impl UnwindSafe for LtcAudioEncoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more