Struct Audio Buffer
pub struct AudioBuffer<'channels, 'samples, S: Sample = f32> { /* private fields */ }Expand description
Borrowed planar f32/f64 samples, with separate or in-place ownership.
Constructors check that every channel contains at least frames samples.
Different backing capacities are legal; only the active prefix is exposed.
A zero-frame view never reads or writes samples. For an instrument, pass an
empty input slice to Self::separate. Format adapters must represent host
aliasing using Self::in_place or their own preallocated scratch storage.
Implementations§
§impl<'channels, 'samples, S: Sample> AudioBuffer<'channels, 'samples, S>
impl<'channels, 'samples, S: Sample> AudioBuffer<'channels, 'samples, S>
pub fn in_place( channels: &'channels mut [&'samples mut [S]], frames: usize, ) -> Result<Self, BufferError>
pub fn separate( inputs: &'channels [&'samples [S]], outputs: &'channels mut [&'samples mut [S]], frames: usize, ) -> Result<Self, BufferError>
pub fn frames(&self) -> usize
pub fn input_channels(&self) -> usize
pub fn output_channels(&self) -> usize
pub fn input(&self, channel: usize) -> Option<&[S]>
pub fn input(&self, channel: usize) -> Option<&[S]>
In-place inputs reflect any writes already made to the same channel.
pub fn output(&self, channel: usize) -> Option<&[S]>
pub fn output_mut(&mut self, channel: usize) -> Option<&mut [S]>
pub fn map_stereo_frames(
&mut self,
map: impl FnMut(usize, [S; 2]) -> [S; 2],
) -> bool
pub fn map_stereo_frames( &mut self, map: impl FnMut(usize, [S; 2]) -> [S; 2], ) -> bool
Map each active frame to stereo output, branching on storage once.
The callback receives the frame offset and two input samples. Missing inputs are zero; mono is not duplicated into the right input. Both in-place samples are read before either output is written. Backing tails are retained, and a zero-frame view invokes no callback.
Returns false without changes or callbacks unless there are exactly
two outputs and at most two inputs. This does not validate processor
preparation, events, or layout; processors must validate those first.
The callback owns the allocation-free and real-time obligations.
pub fn clear_outputs(&mut self)
pub fn clear_outputs(&mut self)
Initialize all active output frames without touching backing tails.