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: boolTrue if transport is currently playing.
This is always valid (not an Option) because VST3 always provides it.
is_recording: boolTrue if recording is active.
is_cycle_active: boolTrue 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
impl Transport
Sourcepub fn time_signature(&self) -> Option<(i32, i32)>
pub fn time_signature(&self) -> Option<(i32, i32)>
Sourcepub fn cycle_range(&self) -> Option<(f64, f64)>
pub fn cycle_range(&self) -> Option<(f64, f64)>
Sourcepub fn is_looping(&self) -> bool
pub fn is_looping(&self) -> bool
Returns true if loop is active and has valid range.
Sourcepub fn has_timing_info(&self) -> bool
pub fn has_timing_info(&self) -> bool
Returns true if any timing info is available.
Sourcepub fn has_time_signature(&self) -> bool
pub fn has_time_signature(&self) -> bool
Returns true if time signature info is complete.
Sourcepub fn smpte_frames(&self) -> Option<(i32, i32)>
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.