pub trait ClockSource:
Send
+ Sync
+ Debug {
// Required methods
fn next_tick(&mut self, block_size: usize) -> ClockTick;
fn sample_rate(&self) -> f32;
// Provided methods
fn start(&mut self) -> Result<(), TimeError> { ... }
fn stop(&mut self) -> Result<(), TimeError> { ... }
fn is_running(&self) -> bool { ... }
fn current_position(&self) -> u64 { ... }
}Expand description
A source of clock ticks for signal processing
Implementations can be hardware-based (ALSA, JACK) or software-based
(SystemClock). The clock source is responsible for providing
accurate timing information to the signal graph.
§Example
use rill_core::time::{ClockSource, SystemClock};
let mut clock = SystemClock::with_sample_rate(44100.0);
let tick = clock.next_tick(64);Required Methods§
Sourcefn sample_rate(&self) -> f32
fn sample_rate(&self) -> f32
Get the sample rate of this clock source
Provided Methods§
Sourcefn start(&mut self) -> Result<(), TimeError>
fn start(&mut self) -> Result<(), TimeError>
Start the clock
This is called when the signal graph starts processing. Default implementation does nothing.
Sourcefn stop(&mut self) -> Result<(), TimeError>
fn stop(&mut self) -> Result<(), TimeError>
Stop the clock
This is called when the signal graph stops processing. Default implementation does nothing.
Sourcefn is_running(&self) -> bool
fn is_running(&self) -> bool
Check if the clock is running
Sourcefn current_position(&self) -> u64
fn current_position(&self) -> u64
Get the current sample position
Default implementation returns the position from the last tick, but hardware clocks may provide more accurate information.