mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-13 07:06:41 +01:00
invoke timebase callback, persists state but doesn't seem to do anything
This commit is contained in:
parent
ae69e87dc9
commit
003329aa1b
10 changed files with 350 additions and 329 deletions
|
|
@ -1,39 +0,0 @@
|
|||
use crate::*;
|
||||
|
||||
/// Timestamp in microseconds
|
||||
#[derive(Debug, Default)] pub struct Microsecond(AtomicF64);
|
||||
impl_time_unit!(Microsecond);
|
||||
impl Microsecond {
|
||||
#[inline] pub fn format_msu (&self) -> String {
|
||||
let usecs = self.get() as usize;
|
||||
let (seconds, msecs) = (usecs / 1000000, usecs / 1000 % 1000);
|
||||
let (minutes, seconds) = (seconds / 60, seconds % 60);
|
||||
format!("{minutes}:{seconds:02}:{msecs:03}")
|
||||
}
|
||||
}
|
||||
|
||||
/// Audio sample rate in Hz (samples per second)
|
||||
#[derive(Debug, Default)] pub struct SampleRate(AtomicF64);
|
||||
impl_time_unit!(SampleRate);
|
||||
impl SampleRate {
|
||||
/// Return the duration of a sample in microseconds (floating)
|
||||
#[inline] pub fn usec_per_sample (&self) -> f64 {
|
||||
1_000_000f64 / self.get()
|
||||
}
|
||||
/// Return the duration of a sample in microseconds (floating)
|
||||
#[inline] pub fn sample_per_usec (&self) -> f64 {
|
||||
self.get() / 1_000_000f64
|
||||
}
|
||||
/// Convert a number of samples to microseconds (floating)
|
||||
#[inline] pub fn samples_to_usec (&self, samples: f64) -> f64 {
|
||||
self.usec_per_sample() * samples
|
||||
}
|
||||
/// Convert a number of microseconds to samples (floating)
|
||||
#[inline] pub fn usecs_to_sample (&self, usecs: f64) -> f64 {
|
||||
self.sample_per_usec() * usecs
|
||||
}
|
||||
}
|
||||
|
||||
/// Timestamp in audio samples
|
||||
#[derive(Debug, Default)] pub struct SampleCount(AtomicF64);
|
||||
impl_time_unit!(SampleCount);
|
||||
Loading…
Add table
Add a link
Reference in a new issue