pub struct AudioBuffer<'a, S: Sample> { /* private fields */ }Expand description
Mutable, planar audio buffer for one process block.
Channels are flat across buses internally; bus_inputs(0) /
bus_outputs(0) slice into the main bus, higher indices into
sidechains and auxiliaries. The flat-then-sliced shape matches
host SDK conventions (CLAP’s clap_audio_buffer, VST3’s
ProcessData, AU’s AudioBufferList).
S is the sample precision — f32 for CLAP / VST2 / LV2 /
AAX, f32 or f64 for VST3 / AU at the host’s choice.
Implementations§
Source§impl<'a, S: Sample> AudioBuffer<'a, S>
impl<'a, S: Sample> AudioBuffer<'a, S>
Sourcepub fn new(
inputs: &'a [&'a [S]],
outputs: &'a mut [&'a mut [S]],
num_frames: usize,
bus_inputs: &'a [BusRange],
bus_outputs: &'a [BusRange],
) -> Self
pub fn new( inputs: &'a [&'a [S]], outputs: &'a mut [&'a mut [S]], num_frames: usize, bus_inputs: &'a [BusRange], bus_outputs: &'a [BusRange], ) -> Self
Build a buffer from raw slices.
Format wrappers call this once per block from their
process callback. Plugin code receives the buffer; only
wrappers construct one.
§Panics
Panics in debug builds if any channel slice is shorter
than num_frames or the bus ranges don’t cover the
channel arrays exactly. Release builds elide the checks —
wrappers are expected to maintain the invariants.
Sourcepub fn num_frames(&self) -> usize
pub fn num_frames(&self) -> usize
Block length in samples (frames). Every channel slice is exactly this long.
Sourcepub fn num_input_buses(&self) -> usize
pub fn num_input_buses(&self) -> usize
Number of input buses (including main + sidechains).
Sourcepub fn num_output_buses(&self) -> usize
pub fn num_output_buses(&self) -> usize
Number of output buses.
Sourcepub fn total_input_channels(&self) -> usize
pub fn total_input_channels(&self) -> usize
Total input channels across every bus. Useful for the “loop over flat channels” pattern when bus layout doesn’t matter for the operation.
Sourcepub fn total_output_channels(&self) -> usize
pub fn total_output_channels(&self) -> usize
Total output channels across every bus.
Sourcepub fn bus_inputs(&self, bus_index: usize) -> &[InputChannel<'a, S>] ⓘ
pub fn bus_inputs(&self, bus_index: usize) -> &[InputChannel<'a, S>] ⓘ
Input channels for one bus. bus_index is 0 for the main
input; higher indices for sidechains / auxiliaries.
§Panics
Panics if bus_index >= num_input_buses().
Sourcepub fn bus_outputs(&mut self, bus_index: usize) -> &mut [&'a mut [S]]
pub fn bus_outputs(&mut self, bus_index: usize) -> &mut [&'a mut [S]]
Sourcepub fn main_inputs(&self) -> &[InputChannel<'a, S>] ⓘ
pub fn main_inputs(&self) -> &[InputChannel<'a, S>] ⓘ
Shortcut: input channels of the main bus (index 0). Most
effects use this; reach for Self::bus_inputs when you
need sidechains too.
Sourcepub fn main_outputs(&mut self) -> &mut [&'a mut [S]]
pub fn main_outputs(&mut self) -> &mut [&'a mut [S]]
Shortcut: mutable output channels of the main bus.