pub struct PipeBuffer<T, const N: usize>where
T: Transcendental,{ /* private fields */ }Expand description
Single-producer, single-consumer buffer for node connections
This buffer provides wait-free operations and minimal overhead. It is ideal for point-to-point connections between audio nodes.
§Type Parameters
T: Audio sample type (f32 or f64) implementingTranscendentalN: Buffer size (number of samples per block)
Implementations§
Source§impl<T, const N: usize> PipeBuffer<T, N>where
T: Transcendental,
impl<T, const N: usize> PipeBuffer<T, N>where
T: Transcendental,
Sourcepub fn new() -> PipeBuffer<T, N>
pub fn new() -> PipeBuffer<T, N>
Create a new pipe buffer
The buffer starts empty with no data available.
Sourcepub fn write(&self, data: &[T; N])
pub fn write(&self, data: &[T; N])
Write a block of data to the buffer
This operation is wait-free and will overwrite any existing data. The buffer holds at most one block at a time - new writes always overwrite the previous block, regardless of whether it was read.
§Arguments
data- Array of samples to write (must be exactlyNsamples)
Sourcepub fn read(&self) -> Option<[T; N]>
pub fn read(&self) -> Option<[T; N]>
Read a block without consuming (multiple consumers can read the same data)
Unlike try_read, this does not mark the buffer as empty.
Multiple callers can read the same data before the next write.
Sourcepub fn try_read(&self) -> Option<[T; N]>
pub fn try_read(&self) -> Option<[T; N]>
Try to read a block of data from the buffer
Returns Some(data) if data is available, None otherwise.
This operation is wait-free and non-blocking. This call consumes
the data — subsequent readers will get None until the next write.
Sourcepub fn read_blocking(&self) -> [T; N]
pub fn read_blocking(&self) -> [T; N]
Read data, blocking until available (for non-real-time use)
This is a convenience method for non-real-time contexts like testing or offline processing. It spins until data is available.
Sourcepub fn is_caught_up(&self) -> bool
pub fn is_caught_up(&self) -> bool
Check if reader is caught up with writer
Sourcepub fn overwrites(&self) -> usize
pub fn overwrites(&self) -> usize
Get the number of overwritten blocks (for debugging)
Trait Implementations§
Source§impl<T, const N: usize> Clone for PipeBuffer<T, N>where
T: Transcendental + Copy,
impl<T, const N: usize> Clone for PipeBuffer<T, N>where
T: Transcendental + Copy,
Source§fn clone(&self) -> PipeBuffer<T, N>
fn clone(&self) -> PipeBuffer<T, N>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more