Skip to main content

Transport

Struct Transport 

Source
pub struct Transport { /* private fields */ }
Expand description

A sequencer transport: position, tempo, run-state, and an optional loop.

Implementations§

Source§

impl Transport

Source

pub fn new(ppq: u32, bpm: f64) -> Result<Self, AudioError>

A stopped transport at position 0 with the given resolution and tempo.

Errors if ppq == 0 or bpm is not a positive finite number.

Source

pub fn state(&self) -> TransportState

Current run-state.

Source

pub fn position_ticks(&self) -> u64

Current integer tick position (floor of the fractional position).

Source

pub fn position_ticks_f64(&self) -> f64

Current fractional tick position.

Source

pub fn bpm(&self) -> f64

Current tempo in BPM.

Source

pub fn ppq(&self) -> u32

Ticks per quarter note.

Source

pub fn play(&mut self)

Begin playback from the current position.

Source

pub fn pause(&mut self)

Pause, holding the current position.

Source

pub fn stop(&mut self)

Stop and rewind the position to 0.

Source

pub fn seek(&mut self, tick: u64)

Jump to an absolute tick position (does not change run-state).

Source

pub fn set_tempo(&mut self, bpm: f64) -> Result<(), AudioError>

Set the tempo. Errors if bpm is not positive/finite.

Source

pub fn set_loop(&mut self, start: u64, end: u64) -> Result<(), AudioError>

Enable a loop over [start, end) ticks. Errors if end <= start.

Source

pub fn clear_loop(&mut self)

Disable looping.

Source

pub fn advance(&mut self, delta_seconds: f64) -> Result<(), AudioError>

Advance the position by delta_seconds of wall-clock time. Only moves while TransportState::Playing. Honors the loop if enabled.

Errors if delta_seconds is negative or not finite.

Trait Implementations§

Source§

impl Clone for Transport

Source§

fn clone(&self) -> Self

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 Copy for Transport

Source§

impl Debug for Transport

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.