AUDIO
Source snapshot · 12 October 2026

API reference / ravet_foundation::AudioBuffer

Struct AudioBuffer 

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>

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

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

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)

Initialize all active output frames without touching backing tails.

Trait Implementations§

§

impl<'channels, 'samples, S: Debug + Sample> Debug for AudioBuffer<'channels, 'samples, S>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'channels, 'samples, S = f32> !UnwindSafe for AudioBuffer<'channels, 'samples, S>

§

impl<'channels, 'samples, S> Freeze for AudioBuffer<'channels, 'samples, S>

§

impl<'channels, 'samples, S> RefUnwindSafe for AudioBuffer<'channels, 'samples, S>
where S: RefUnwindSafe,

§

impl<'channels, 'samples, S> Send for AudioBuffer<'channels, 'samples, S>
where S: Send + Sync,

§

impl<'channels, 'samples, S> Sync for AudioBuffer<'channels, 'samples, S>
where S: Sync,

§

impl<'channels, 'samples, S> Unpin for AudioBuffer<'channels, 'samples, S>

§

impl<'channels, 'samples, S> UnsafeUnpin for AudioBuffer<'channels, 'samples, S>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.