Skip to main content

Transport

Struct Transport 

Source
pub struct Transport {
Show 16 fields pub tempo: Option<f64>, pub time_sig_numerator: Option<i32>, pub time_sig_denominator: Option<i32>, pub project_time_samples: Option<i64>, pub project_time_beats: Option<f64>, pub bar_position_beats: Option<f64>, pub cycle_start_beats: Option<f64>, pub cycle_end_beats: Option<f64>, pub is_playing: bool, pub is_recording: bool, pub is_cycle_active: bool, pub system_time_ns: Option<i64>, pub continuous_time_samples: Option<i64>, pub samples_to_next_clock: Option<i32>, pub smpte_offset_subframes: Option<i32>, pub frame_rate: Option<FrameRate>,
}
Expand description

Host transport and timing information.

Contains tempo, time signature, playback position, and transport state. All timing fields are Option<T> because not all hosts provide all data. Playback state fields (is_playing, etc.) are always valid.

§Field Availability

Different DAWs provide different subsets of transport information:

  • Tempo/time signature: Most DAWs provide these
  • Musical position: Common but not universal
  • SMPTE/timecode: Only in video-oriented DAWs
  • System time: Rarely provided

Always check Option fields before use and provide sensible fallbacks.

§Example

// Safe tempo access with fallback
let tempo = context.transport.tempo.unwrap_or(120.0);

// Check if we have valid musical position
if let Some(beats) = context.transport.project_time_beats {
    // Sync effect to beat position
}

// Transport state is always valid
if context.transport.is_playing {
    // Process audio
} else {
    // Maybe bypass or fade out
}

Fields§

§tempo: Option<f64>

Current tempo in BPM (beats per minute).

Typically 20-300, but can be any positive value.

§time_sig_numerator: Option<i32>

Time signature numerator (e.g., 4 in 4/4, 3 in 3/4, 6 in 6/8).

§time_sig_denominator: Option<i32>

Time signature denominator (e.g., 4 in 4/4, 4 in 3/4, 8 in 6/8).

§project_time_samples: Option<i64>

Project time in samples from the start of the timeline.

This is the primary sample-accurate position. Always increments during playback, may jump on loop or locate.

§project_time_beats: Option<f64>

Project time in quarter notes (musical time).

Takes tempo changes into account. 1.0 = one quarter note.

§bar_position_beats: Option<f64>

Position of the last bar start in quarter notes.

Useful for bar-synchronized effects (e.g., 4-bar delay).

§cycle_start_beats: Option<f64>

Loop/cycle start position in quarter notes.

§cycle_end_beats: Option<f64>

Loop/cycle end position in quarter notes.

§is_playing: bool

True if transport is currently playing.

This is always valid (not an Option) because VST3 always provides it.

§is_recording: bool

True if recording is active.

§is_cycle_active: bool

True if loop/cycle mode is enabled.

§system_time_ns: Option<i64>

System time in nanoseconds.

Can be used to sync to wall-clock time. Rarely provided by hosts.

§continuous_time_samples: Option<i64>

Continuous time in samples (doesn’t reset on loop).

Unlike project_time_samples, this never jumps during cycle playback - it always increments monotonically.

§samples_to_next_clock: Option<i32>

Samples until next MIDI beat clock (24 ppqn).

Used for generating MIDI clock messages or syncing to external gear.

§smpte_offset_subframes: Option<i32>

SMPTE offset in subframes (1/80th of a frame).

For video synchronization. Divide by 80 to get frame offset.

§frame_rate: Option<FrameRate>

SMPTE frame rate.

Implementations§

Source§

impl Transport

Source

pub fn time_signature(&self) -> Option<(i32, i32)>

Returns the time signature as a tuple (numerator, denominator).

Returns None if either component is unavailable.

§Example
if let Some((num, denom)) = transport.time_signature() {
    println!("Playing in {}/{} time", num, denom);
}
Source

pub fn cycle_range(&self) -> Option<(f64, f64)>

Returns the loop/cycle range in quarter notes as (start, end).

Returns None if either endpoint is unavailable.

§Example
if let Some((start, end)) = transport.cycle_range() {
    let loop_length_beats = end - start;
}
Source

pub fn is_looping(&self) -> bool

Returns true if loop is active and has valid range.

Source

pub fn has_timing_info(&self) -> bool

Returns true if any timing info is available.

Source

pub fn has_time_signature(&self) -> bool

Returns true if time signature info is complete.

Source

pub fn smpte_frames(&self) -> Option<(i32, i32)>

Converts SMPTE subframes to (frames, subframes) tuple.

Subframes are 0-79 within each frame. Uses Euclidean division to correctly handle negative offsets.

Trait Implementations§

Source§

impl Clone for Transport

Source§

fn clone(&self) -> Transport

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Transport

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Transport

Source§

fn default() -> Transport

Returns the “default value” for a type. Read more
Source§

impl Copy for Transport

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 = 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.