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§
Sourcefn new(len: usize, layout: AudioChannelLayout) -> AudioBuffer<T>
fn new(len: usize, layout: AudioChannelLayout) -> AudioBuffer<T>
Creates a new planar audio buffer with the specified length (per channel) and channel layout.
Sourcefn new_with_layout(layout: AudioChannelLayout) -> AudioBuffer<T>
fn new_with_layout(layout: AudioChannelLayout) -> AudioBuffer<T>
Creates a new planar audio buffer with default length (0) and the specified layout.
Sourcefn get_channel(&self, channel: usize) -> &[T]
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.
Sourcefn get_channel_mut(&mut self, channel: usize) -> &mut [T]
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.
Sourceunsafe fn get_channel_unchecked(&self, channel: usize) -> &[T]
unsafe fn get_channel_unchecked(&self, channel: usize) -> &[T]
Returns an immutable slice for the specified channel without bounds checking.
Sourceunsafe fn get_channel_unchecked_mut(&mut self, channel: usize) -> &mut [T]
unsafe fn get_channel_unchecked_mut(&mut self, channel: usize) -> &mut [T]
Returns a mutable slice for the specified channel without bounds checking.
Sourcefn resize(&mut self, new_len: usize)
fn resize(&mut self, new_len: usize)
Resizes all channel buffers to the new length, filling new space with zeros.
Sourcefn copy_to_interleaved(&self, dst: &mut [T])
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.
Sourcefn mix_with(&mut self, other: &AudioBuffer<T>)
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.
Sourcefn mix_with_gain(&mut self, other: &AudioBuffer<T>, gain: f32)
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.
Sourcefn copy_from(&mut self, other: &AudioBuffer<T>)
fn copy_from(&mut self, other: &AudioBuffer<T>)
Copies data from another AudioBuffer. Panics if lengths or layouts do not match.
Sourcefn copy_from_interleaved(&mut self, buffer: &[T])
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.
Sourcefn copy_from_interleaved_range(
&mut self,
input: &[T],
start: usize,
end: usize,
offset: usize,
)
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.
startandend: Range in the input buffer.offset: Starting channel offset in the planar buffer. Panics ifstart > endorend >= input.len().
Sourcefn channel_layout(&self) -> AudioChannelLayout
fn channel_layout(&self) -> AudioChannelLayout
Returns the current channel layout.
Sourcefn set_channel_layout(&mut self, new_layout: AudioChannelLayout)
fn set_channel_layout(&mut self, new_layout: AudioChannelLayout)
Sets a new channel layout, converting the audio signal into new layout.
Sourcefn len_interleaved(&self) -> usize
fn len_interleaved(&self) -> usize
Returns the total interleaved length (channels * planar length).
Sourcefn to_f32(&self) -> AudioBuffer<f32>
fn to_f32(&self) -> AudioBuffer<f32>
Converts this buffer to a cloned AudioBuffer with f32 samples.
Sourcefn to_f64(&self) -> AudioBuffer<f64>
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.