pub struct ClockTick {
pub sample_pos: u64,
pub samples_since_last: u32,
pub is_new_block: bool,
pub sample_rate: f32,
pub tempo: Option<f32>,
}Expand description
A tick of the audio clock
Sent to nodes on every signal block to provide timing information and synchronize processing. This is the fundamental timing primitive in Rill.
§Fields
sample_pos- Absolute sample position since startsamples_since_last- Number of samples since the last tickis_new_block- Whether this is the start of a new blocksample_rate- Current sample rate in Hztempo- Current tempo in BPM (if available)
§Example
use rill_core::time::ClockTick;
let tick = ClockTick::new(44100, 64, 44100.0);
assert_eq!(tick.absolute_seconds(), 1.0);
assert_eq!(tick.delta_seconds(), 64.0 / 44100.0);Fields§
§sample_pos: u64Absolute sample position since start
samples_since_last: u32Number of samples since the last tick
is_new_block: boolWhether this is the start of a new block
sample_rate: f32Current sample rate in Hz
tempo: Option<f32>Current tempo in BPM (if available)
Implementations§
Source§impl ClockTick
impl ClockTick
Sourcepub const fn with_tempo(
sample_pos: u64,
samples_since_last: u32,
sample_rate: f32,
tempo: f32,
) -> ClockTick
pub const fn with_tempo( sample_pos: u64, samples_since_last: u32, sample_rate: f32, tempo: f32, ) -> ClockTick
Create a new clock tick with tempo information
§Arguments
sample_pos- Absolute sample positionsamples_since_last- Samples since last ticksample_rate- Sample rate in Hztempo- Tempo in BPM
Sourcepub fn delta_seconds(&self) -> f32
pub fn delta_seconds(&self) -> f32
Sourcepub fn absolute_seconds(&self) -> f64
pub fn absolute_seconds(&self) -> f64
Sourcepub fn beat_position(&self) -> Option<f64>
pub fn beat_position(&self) -> Option<f64>
Get the current beat position (if tempo is available)
§Returns
Some(beat)- Current beat position (fractional)None- No tempo information available
Sourcepub fn musical_position(&self) -> Option<(u32, u8, u8)>
pub fn musical_position(&self) -> Option<(u32, u8, u8)>
Get the current bar-beat-sixteenth position (if tempo is available)
§Returns
Some((bar, beat, sixteenth))- Musical positionNone- No tempo information available
Sourcepub fn is_new_bar(&self) -> bool
pub fn is_new_bar(&self) -> bool
Sourcepub fn is_new_beat(&self) -> bool
pub fn is_new_beat(&self) -> bool
Trait Implementations§
impl Copy for ClockTick
impl StructuralPartialEq for ClockTick
Auto Trait Implementations§
impl Freeze for ClockTick
impl RefUnwindSafe for ClockTick
impl Send for ClockTick
impl Sync for ClockTick
impl Unpin for ClockTick
impl UnsafeUnpin for ClockTick
impl UnwindSafe for ClockTick
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more