AudioBufferImpl

Trait AudioBufferImpl 

Source
pub trait AudioBufferImpl<T: FloatType>: Sized {
Show 20 methods // Required methods fn new(len: usize, layout: AudioChannelLayout) -> AudioBuffer<T>; fn new_with_layout(layout: AudioChannelLayout) -> AudioBuffer<T>; fn get_channel(&self, channel: usize) -> &[T]; fn get_channel_mut(&mut self, channel: usize) -> &mut [T]; unsafe fn get_channel_unchecked(&self, channel: usize) -> &[T]; unsafe fn get_channel_unchecked_mut(&mut self, channel: usize) -> &mut [T]; fn resize(&mut self, new_len: usize); fn copy_to_interleaved(&self, dst: &mut [T]); fn mix_with(&mut self, other: &AudioBuffer<T>); fn mix_with_gain(&mut self, other: &AudioBuffer<T>, gain: f32); fn copy_from(&mut self, other: &AudioBuffer<T>); fn copy_from_interleaved(&mut self, buffer: &[T]); fn copy_from_interleaved_range( &mut self, input: &[T], start: usize, end: usize, offset: usize, ); fn channel_layout(&self) -> AudioChannelLayout; fn set_channel_layout(&mut self, new_layout: AudioChannelLayout); fn reset(&mut self); fn len(&self) -> usize; fn len_interleaved(&self) -> usize; fn to_f32(&self) -> AudioBuffer<f32>; fn to_f64(&self) -> AudioBuffer<f64>;
}
Expand description

Trait for planar audio buffer operations, where each channel has its own separate buffer.

Required Methods§

Source

fn new(len: usize, layout: AudioChannelLayout) -> AudioBuffer<T>

Creates a new planar audio buffer with the specified length (per channel) and channel layout.

Source

fn new_with_layout(layout: AudioChannelLayout) -> AudioBuffer<T>

Creates a new planar audio buffer with default length (0) and the specified layout.

Source

fn get_channel(&self, channel: usize) -> &[T]

Returns an immutable slice for the specified channel. Panics if the channel index exceeds the layout’s channel count.

Source

fn get_channel_mut(&mut self, channel: usize) -> &mut [T]

Returns a mutable slice for the specified channel. Panics if the channel index exceeds the layout’s channel count.

Source

unsafe fn get_channel_unchecked(&self, channel: usize) -> &[T]

Returns an immutable slice for the specified channel without bounds checking.

Source

unsafe fn get_channel_unchecked_mut(&mut self, channel: usize) -> &mut [T]

Returns a mutable slice for the specified channel without bounds checking.

Source

fn resize(&mut self, new_len: usize)

Resizes all channel buffers to the new length, filling new space with zeros.

Source

fn copy_to_interleaved(&self, dst: &mut [T])

Copies all channels’ data into an interleaved destination slice. Panics if the destination length does not match self.len() * self.channel_layout() as usize.

Source

fn mix_with(&mut self, other: &AudioBuffer<T>)

Mixes another AudioBuffer into this one without applying gain. Panics if lengths or layouts do not match.

Source

fn mix_with_gain(&mut self, other: &AudioBuffer<T>, gain: f32)

Mixes another AudioBuffer into this one with the specified gain applied to the other buffer. Panics if lengths or layouts do not match.

Source

fn copy_from(&mut self, other: &AudioBuffer<T>)

Copies data from another AudioBuffer. Panics if lengths or layouts do not match.

Source

fn copy_from_interleaved(&mut self, buffer: &[T])

Copies data from an interleaved buffer. Panics if the interleaved length does not match the expected size.

Source

fn copy_from_interleaved_range( &mut self, input: &[T], start: usize, end: usize, offset: usize, )

Copies a range from an interleaved input buffer, starting at an offset.

  • start and end: Range in the input buffer.
  • offset: Starting channel offset in the planar buffer. Panics if start > end or end >= input.len().
Source

fn channel_layout(&self) -> AudioChannelLayout

Returns the current channel layout.

Source

fn set_channel_layout(&mut self, new_layout: AudioChannelLayout)

Sets a new channel layout, converting the audio signal into new layout.

Source

fn reset(&mut self)

Resets all buffers by filling them with zeros.

Source

fn len(&self) -> usize

Returns the length per channel (planar length).

Source

fn len_interleaved(&self) -> usize

Returns the total interleaved length (channels * planar length).

Source

fn to_f32(&self) -> AudioBuffer<f32>

Converts this buffer to a cloned AudioBuffer with f32 samples.

Source

fn to_f64(&self) -> AudioBuffer<f64>

Converts this buffer to a cloned AudioBuffer with f64 samples.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: FloatType> AudioBufferImpl<T> for AudioBuffer<T>