Skip to main content

SystemClock

Struct SystemClock 

Source
pub struct SystemClock {
    pub sample_rate: f32,
    /* private fields */
}
Expand description

High-precision system clock for sample-accurate timing.

Provides sample-accurate timing for signal processing. Uses atomic operations for thread safety without locks.

Fields§

§sample_rate: f32

Sample rate of the audio system (Hz).

Implementations§

Source§

impl SystemClock

Source

pub fn new(sample_rate: f32, initial_bpm: f64) -> SystemClock

Create a new system clock at the given sample rate and initial BPM.

Source

pub fn with_sample_rate(sample_rate: f32) -> SystemClock

Create a new system clock with a default BPM of 120.

Source

pub fn next_tick(&mut self, block_size: usize) -> ClockTick

Advance the clock by block_size samples and return the clock tick.

Source

pub fn bpm(&self) -> f64

Return the current BPM value.

Source

pub fn set_bpm(&self, bpm: f64)

Set the BPM value atomically.

Source

pub fn position(&self) -> u64

Return the current sample position.

Source

pub fn reset(&self)

Reset the sample position to zero.

Trait Implementations§

Source§

impl ClockSource for SystemClock

Source§

fn next_tick(&mut self, block_size: usize) -> ClockTick

Get the next clock tick Read more
Source§

fn sample_rate(&self) -> f32

Get the sample rate of this clock source
Source§

fn start(&mut self) -> Result<(), TimeError>

Start the clock Read more
Source§

fn stop(&mut self) -> Result<(), TimeError>

Stop the clock Read more
Source§

fn is_running(&self) -> bool

Check if the clock is running
Source§

fn current_position(&self) -> u64

Get the current sample position Read more
Source§

impl Debug for SystemClock

Source§

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

Formats the value using the given formatter. Read more

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> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert to &dyn std::any::Any
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert to &mut dyn std::any::Any
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> 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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V