pub struct Transport { /* private fields */ }Expand description
A sample-accurate musical clock. All arithmetic before the single frame-boundary crossings is the exact rational/f64 segment walk shared with the compiler (ADR 0002), so the transport and the offline render can never disagree about where a beat lands.
Implementations§
Source§impl Transport
impl Transport
Sourcepub fn for_program(meta: &ProgramMeta) -> Self
pub fn for_program(meta: &ProgramMeta) -> Self
A transport for a compiled program, stopped at frame 0.
Sourcepub fn sample_rate(&self) -> u32
pub fn sample_rate(&self) -> u32
The clock’s sample rate.
Sourcepub fn state(&self) -> TransportState
pub fn state(&self) -> TransportState
The current state.
Sourcepub fn is_playing(&self) -> bool
pub fn is_playing(&self) -> bool
Whether the transport is advancing.
Sourcepub fn frame_at_beat(&self, beat: f64) -> u64
pub fn frame_at_beat(&self, beat: f64) -> u64
The frame a beat lands on (rounds halves away from zero, ADR 0002).
Sourcepub fn beat_at_frame(&self, frame: u64) -> f64
pub fn beat_at_frame(&self, frame: u64) -> f64
The beat at a frame (the inverse conversion).
Sourcepub fn frame_at_bar(&self, bar: u32) -> u64
pub fn frame_at_bar(&self, bar: u32) -> u64
The frame a bar starts on (through the meter map and pickup).
Sourcepub fn position_frames(&self) -> u64
pub fn position_frames(&self) -> u64
The position in frames.
Sourcepub fn position_beats(&self) -> f64
pub fn position_beats(&self) -> f64
The position in beats.
Sourcepub fn position_bars(&self) -> f64
pub fn position_bars(&self) -> f64
The position in bars (bar index plus intra-bar fraction).
Sourcepub fn length_frames(&self) -> u64
pub fn length_frames(&self) -> u64
The program length in frames.
Sourcepub fn seek_frame(&mut self, frame: u64)
pub fn seek_frame(&mut self, frame: u64)
Seek to a frame (clamped to the program length).
Sourcepub fn set_loop_frames(&mut self, start: u64, end: u64) -> bool
pub fn set_loop_frames(&mut self, start: u64, end: u64) -> bool
Loop a frame range [start, end). At end the playhead wraps to
start; seeking outside the range is allowed (the loop engages when
the playhead reaches end). Invalid ranges (empty, past the end) are
rejected with false and leave the old range.
Sourcepub fn set_loop_bars(&mut self, start_bar: u32, end_bar: u32) -> bool
pub fn set_loop_bars(&mut self, start_bar: u32, end_bar: u32) -> bool
Loop a bar range (through the meter map), or report an invalid range.
Sourcepub fn clear_loop(&mut self)
pub fn clear_loop(&mut self)
Clear the loop range.
Sourcepub fn loop_range(&self) -> Option<(u64, u64)>
pub fn loop_range(&self) -> Option<(u64, u64)>
The loop range in frames, if set.