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>,
pub source: String,
pub speed_ratio: f64,
pub is_final: bool,
}Expand description
A tick of the system 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)source- Which backend produced this tick (e.g. “alsa:default”)
I/O access is handled directly through IoCapture
and IoPlayback traits — the tick carries
only timing metadata.
§Example
use rill_core::time::ClockTick;
let tick = ClockTick::new(44100, 64, 44100.0, "test".into());
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)
source: StringWhich backend produced this tick (e.g. “alsa:default”, “pipewire:0”).
speed_ratio: f64Hardware clock correction factor: configured_rate / actual_rate.
1.0 = nominal (rates match). < 1.0 = hardware runs faster.
> 1.0 = hardware runs slower. Set by the backend when the
negotiated hardware rate differs from the graph’s configured rate.
is_final: boolWhether this tick should trigger a ClockTick dispatch to modules.
true by default. Chunking backends (PipeWire) set this to false
for intermediate chunks and true only for the final chunk of the
DMA buffer — avoiding 48 ClockTick dispatches per PW callback.
Implementations§
Source§impl ClockTick
impl ClockTick
Sourcepub fn new(
sample_pos: u64,
samples_since_last: u32,
sample_rate: f32,
source: String,
) -> ClockTick
pub fn new( sample_pos: u64, samples_since_last: u32, sample_rate: f32, source: String, ) -> ClockTick
Sourcepub fn with_tempo(
sample_pos: u64,
samples_since_last: u32,
sample_rate: f32,
tempo: f32,
source: String,
) -> ClockTick
pub fn with_tempo( sample_pos: u64, samples_since_last: u32, sample_rate: f32, tempo: f32, source: String, ) -> 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 BPMsource- Backend source name
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