pub struct AudioRingBuffer { /* private fields */ }Expand description
A ring buffer for accumulating audio samples with a fixed capacity.
Useful for buffering streaming audio before processing (e.g., accumulating enough audio for a STT inference pass).
Implementations§
Source§impl AudioRingBuffer
impl AudioRingBuffer
Sourcepub fn new(config: AudioConfig, duration_secs: f64) -> Self
pub fn new(config: AudioConfig, duration_secs: f64) -> Self
Create a new ring buffer with capacity for duration_secs of audio.
Sourcepub fn push(&mut self, bytes: &[u8])
pub fn push(&mut self, bytes: &[u8])
Push raw PCM bytes into the buffer, overwriting oldest data if full.
Sourcepub fn read_all(&self) -> Vec<u8> ⓘ
pub fn read_all(&self) -> Vec<u8> ⓘ
Read all available data as a contiguous byte slice.
Returns data in chronological order (oldest first).
Sourcepub fn duration_secs(&self) -> f64
pub fn duration_secs(&self) -> f64
Duration of buffered audio in seconds.
Sourcepub fn config(&self) -> &AudioConfig
pub fn config(&self) -> &AudioConfig
Get the audio config for this buffer.
Auto Trait Implementations§
impl Freeze for AudioRingBuffer
impl RefUnwindSafe for AudioRingBuffer
impl Send for AudioRingBuffer
impl Sync for AudioRingBuffer
impl Unpin for AudioRingBuffer
impl UnsafeUnpin for AudioRingBuffer
impl UnwindSafe for AudioRingBuffer
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
Mutably borrows from an owned value. Read more