pub struct SampleWindow { /* private fields */ }Expand description
The newest capacity audio samples, oldest first.
Stored samples are already sanitized: non-finite values are 0.0 and finite values lie in [-1, 1]. Capacity 0 is allowed and holds nothing.
Implementations§
Source§impl SampleWindow
impl SampleWindow
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create an empty window holding at most capacity samples.
Capacity 0 is allowed: such a window ignores every push and stays
empty. The only allocation this type ever makes is here (and in
Self::samples / Self::copy_into for the caller’s copy).
Sourcepub fn push(&mut self, frame: &[f32])
pub fn push(&mut self, frame: &[f32])
Append a frame, keeping the newest samples and dropping the oldest.
A frame longer than the capacity keeps its tail. Non-finite samples are stored as 0.0 and finite ones are clamped to [-1, 1]. Never allocates.
Sourcepub fn samples(&self) -> Vec<f32>
pub fn samples(&self) -> Vec<f32>
The window, oldest sample first. Allocates; see Self::copy_into.
Trait Implementations§
Source§impl Clone for SampleWindow
impl Clone for SampleWindow
Source§impl Debug for SampleWindow
impl Debug for SampleWindow
Source§impl PartialEq for SampleWindow
Two windows are equal when they have the same capacity and hold the same
samples in the same order; the rotation of the ring storage is irrelevant.
Stored samples are never NaN, so this is a true equivalence.
impl PartialEq for SampleWindow
Two windows are equal when they have the same capacity and hold the same samples in the same order; the rotation of the ring storage is irrelevant. Stored samples are never NaN, so this is a true equivalence.