pub struct TimeBase { /* private fields */ }Expand description
The clock of a framed sequence: one frame per stride samples at rate.
Kept exact as the pair rather than a frames-per-second float, so
samples is integer arithmetic and two values that must
share sample arithmetic can be checked for representational equality
(see the module doc for why representational, not numeric).
Implementations§
Source§impl TimeBase
impl TimeBase
Sourcepub const fn new(rate: SampleRate, stride: NonZeroU32) -> Self
pub const fn new(rate: SampleRate, stride: NonZeroU32) -> Self
A latent clock ticking once per stride samples at rate.
Sourcepub const fn of_samples(rate: SampleRate) -> Self
pub const fn of_samples(rate: SampleRate) -> Self
The PCM clock itself: one frame per sample.
Sourcepub const fn sample_rate(self) -> SampleRate
pub const fn sample_rate(self) -> SampleRate
The underlying sample rate.
Sourcepub const fn stride(self) -> NonZeroU32
pub const fn stride(self) -> NonZeroU32
Samples per frame.
Sourcepub fn frames_per_second(self) -> f64
pub fn frames_per_second(self) -> f64
Frames per second, for display and budget arithmetic. The exact value lives in the pair; this projection is lossy and never drives layout.
Sourcepub fn samples(self, frames: Frames) -> Option<Samples>
pub fn samples(self, frames: Frames) -> Option<Samples>
Exact sample count covered by frames, or None on u64 overflow.
Sourcepub fn frames_exact(self, samples: Samples) -> Option<Frames>
pub fn frames_exact(self, samples: Samples) -> Option<Frames>
Frame count that exactly covers samples, or None if samples is
not a whole number of frames. Partial frames are a caller decision
(pad or reject), never a silent truncation.
Trait Implementations§
impl Copy for TimeBase
Source§impl<'de> Deserialize<'de> for TimeBase
impl<'de> Deserialize<'de> for TimeBase
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for TimeBase
impl StructuralPartialEq for TimeBase
Auto Trait Implementations§
impl Freeze for TimeBase
impl RefUnwindSafe for TimeBase
impl Send for TimeBase
impl Sync for TimeBase
impl Unpin for TimeBase
impl UnsafeUnpin for TimeBase
impl UnwindSafe for TimeBase
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.