pub struct Timeline { /* private fields */ }Expand description
A sample-accurate musical timeline driving MIDI clips and automation lanes into a plugin.
Implementations§
Source§impl Timeline
impl Timeline
Sourcepub fn new(sample_rate: f64, bpm: f64) -> Self
pub fn new(sample_rate: f64, bpm: f64) -> Self
A timeline at sample_rate and constant tempo bpm. bpm must be finite and > 0;
an invalid value falls back to 120.0 so beat↔sample conversion can’t produce NaN.
Sourcepub fn with_lane(self, lane: AutomationLane) -> Self
pub fn with_lane(self, lane: AutomationLane) -> Self
Add an automation lane (fluent).
Sourcepub fn add_lane(&mut self, lane: AutomationLane)
pub fn add_lane(&mut self, lane: AutomationLane)
Add an automation lane.
Sourcepub fn sample_clock(&self) -> u64
pub fn sample_clock(&self) -> u64
The current playhead position in frames since the start.
Sourcepub fn seek_frame(&mut self, frame: u64)
pub fn seek_frame(&mut self, frame: u64)
Move the playhead to frame (e.g. to loop or seek). Does not emit events.
Sourcepub fn samples_per_beat(&self) -> f64
pub fn samples_per_beat(&self) -> f64
Samples per beat at the current constant tempo.
Sourcepub fn beat_to_frame(&self, beat: f64) -> u64
pub fn beat_to_frame(&self, beat: f64) -> u64
Convert a beat position to an absolute frame index.
Sourcepub fn frame_to_beat(&self, frame: u64) -> f64
pub fn frame_to_beat(&self, frame: u64) -> f64
Convert an absolute frame index to a beat position.
Sourcepub fn advance_block(&mut self, frames: usize) -> BlockEvents
pub fn advance_block(&mut self, frames: usize) -> BlockEvents
Collect the events that fall in the next frames-sample block as sample offsets, then
advance the playhead by frames. Clip events are windowed by frame index against the
half-open block [clock, clock + frames); automation lanes emit their per-block points
(evaluated in the beat domain) tagged with the lane’s parameter id.
Sourcepub fn drive_block(
&mut self,
plugin: &mut Plugin,
buffers: &mut AudioBuffers,
) -> Result<()>
pub fn drive_block( &mut self, plugin: &mut Plugin, buffers: &mut AudioBuffers, ) -> Result<()>
Advance one block and drive it into plugin: schedule its MIDI and parameter changes at
their sample offsets, then render buffers.
The block length is the number of frames Plugin::process_audio will actually render
— the length of buffers’ first channel buffer, not its block_size field. The two are
independent (both are public), and windowing by a different count than the plugin renders
would slip the timeline clock against the plugin’s transport by the difference every block.