Skip to main content

ConversionBuffers

Struct ConversionBuffers 

Source
pub struct ConversionBuffers {
    pub main_input_f32: Vec<Vec<f32>>,
    pub main_output_f32: Vec<Vec<f32>>,
    pub aux_input_f32: Vec<Vec<Vec<f32>>>,
    pub aux_output_f32: Vec<Vec<Vec<f32>>>,
}
Expand description

Pre-allocated buffers for f64↔f32 conversion.

Avoids heap allocation during audio processing when the processor only supports f32 but the host provides f64 buffers.

Fields are public for direct iteration access in format wrappers.

Fields§

§main_input_f32: Vec<Vec<f32>>

Main input bus conversion buffers: [channel][samples]

§main_output_f32: Vec<Vec<f32>>

Main output bus conversion buffers: [channel][samples]

§aux_input_f32: Vec<Vec<Vec<f32>>>

Auxiliary input buses: [bus_index][channel_index][samples]

§aux_output_f32: Vec<Vec<Vec<f32>>>

Auxiliary output buses: [bus_index][channel_index][samples]

Implementations§

Source§

impl ConversionBuffers

Source

pub fn new() -> Self

Create empty conversion buffers (no capacity reserved).

Use this when you don’t know the configuration yet. Call allocate() or allocate_from_buses() later.

Source

pub fn allocate_from_buses( input_buses: &[BusInfo], output_buses: &[BusInfo], max_frames: usize, ) -> Self

Pre-allocate buffers from bus information.

This is the preferred allocation method when you have access to BusInfo. Extracts channel counts from main bus (index 0) and auxiliary buses (index 1+).

§Arguments
  • input_buses - Slice of input bus information
  • output_buses - Slice of output bus information
  • max_frames - Maximum number of samples per buffer
Source

pub fn allocate( main_input_channels: usize, main_output_channels: usize, aux_input_channels: &[usize], aux_output_channels: &[usize], max_frames: usize, ) -> Self

Pre-allocate buffers with explicit channel counts.

Use this when you have channel counts directly rather than BusInfo.

§Arguments
  • main_input_channels - Number of main input channels
  • main_output_channels - Number of main output channels
  • aux_input_channels - Channel count for each auxiliary input bus
  • aux_output_channels - Channel count for each auxiliary output bus
  • max_frames - Maximum number of samples per buffer
Source

pub fn main_input_mut(&mut self, channel: usize) -> Option<&mut [f32]>

Get mutable reference to a main input channel buffer.

Returns None if the channel index is out of bounds.

Source

pub fn main_input(&self, channel: usize) -> Option<&[f32]>

Get reference to a main input channel buffer.

Source

pub fn main_output_mut(&mut self, channel: usize) -> Option<&mut [f32]>

Get mutable reference to a main output channel buffer.

Source

pub fn main_output(&self, channel: usize) -> Option<&[f32]>

Get reference to a main output channel buffer.

Source

pub fn main_input_channel_count(&self) -> usize

Get number of main input channels.

Source

pub fn main_output_channel_count(&self) -> usize

Get number of main output channels.

Source

pub fn aux_input_mut( &mut self, bus: usize, channel: usize, len: usize, ) -> Option<&mut [f32]>

Get mutable slice of an auxiliary input channel buffer.

§Arguments
  • bus - Auxiliary bus index (0 = first aux bus, not main bus)
  • channel - Channel index within the bus
  • len - Number of samples to access
Source

pub fn aux_input( &self, bus: usize, channel: usize, len: usize, ) -> Option<&[f32]>

Get slice of an auxiliary input channel buffer.

Source

pub fn aux_output_mut( &mut self, bus: usize, channel: usize, len: usize, ) -> Option<&mut [f32]>

Get mutable slice of an auxiliary output channel buffer.

Source

pub fn aux_output( &self, bus: usize, channel: usize, len: usize, ) -> Option<&[f32]>

Get slice of an auxiliary output channel buffer.

Source

pub fn aux_input_bus_count(&self) -> usize

Get number of auxiliary input buses.

Source

pub fn aux_output_bus_count(&self) -> usize

Get number of auxiliary output buses.

Source

pub fn aux_input_channel_count(&self, bus: usize) -> usize

Get number of channels in an auxiliary input bus.

Source

pub fn aux_output_channel_count(&self, bus: usize) -> usize

Get number of channels in an auxiliary output bus.

Trait Implementations§

Source§

impl Default for ConversionBuffers

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.