Skip to main content

AudioBuffer

Struct AudioBuffer 

Source
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>

Source

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.

Source

pub fn num_frames(&self) -> usize

Block length in samples (frames). Every channel slice is exactly this long.

Source

pub fn num_input_buses(&self) -> usize

Number of input buses (including main + sidechains).

Source

pub fn num_output_buses(&self) -> usize

Number of output buses.

Source

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.

Source

pub fn total_output_channels(&self) -> usize

Total output channels across every bus.

Source

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().

Source

pub fn bus_outputs(&mut self, bus_index: usize) -> &mut [&'a mut [S]]

Mutable output channels for one bus.

§Panics

Panics if bus_index >= num_output_buses().

Source

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.

Source

pub fn main_outputs(&mut self) -> &mut [&'a mut [S]]

Shortcut: mutable output channels of the main bus.

Auto Trait Implementations§

§

impl<'a, S> !UnwindSafe for AudioBuffer<'a, S>

§

impl<'a, S> Freeze for AudioBuffer<'a, S>

§

impl<'a, S> RefUnwindSafe for AudioBuffer<'a, S>
where S: RefUnwindSafe,

§

impl<'a, S> Send for AudioBuffer<'a, S>

§

impl<'a, S> Sync for AudioBuffer<'a, S>

§

impl<'a, S> Unpin for AudioBuffer<'a, S>

§

impl<'a, S> UnsafeUnpin for AudioBuffer<'a, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.