pub struct PipeBuffer<T: Transcendental, const N: usize> { /* 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: Transcendental, const N: usize> PipeBuffer<T, N>
impl<T: Transcendental, const N: usize> PipeBuffer<T, N>
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)