Skip to main content

Timeline

Struct Timeline 

Source
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

Source

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.

Source

pub fn with_clip(self, clip: MidiClip) -> Self

Add a MIDI clip (fluent).

Source

pub fn with_lane(self, lane: AutomationLane) -> Self

Add an automation lane (fluent).

Source

pub fn add_clip(&mut self, clip: MidiClip)

Add a MIDI clip.

Source

pub fn add_lane(&mut self, lane: AutomationLane)

Add an automation lane.

Source

pub fn sample_clock(&self) -> u64

The current playhead position in frames since the start.

Source

pub fn seek_frame(&mut self, frame: u64)

Move the playhead to frame (e.g. to loop or seek). Does not emit events.

Source

pub fn samples_per_beat(&self) -> f64

Samples per beat at the current constant tempo.

Source

pub fn beat_to_frame(&self, beat: f64) -> u64

Convert a beat position to an absolute frame index.

Source

pub fn frame_to_beat(&self, frame: u64) -> f64

Convert an absolute frame index to a beat position.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Timeline

Source§

fn clone(&self) -> Timeline

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Timeline

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.