#[repr(align(64))]pub struct OwnedAudioBuffer { /* private fields */ }
Expand description
An audio buffer that owns its audio data
Create an OwnedAudioBuffer
will allocate a vector with enough space to hold the audio data
Implementations§
Source§impl OwnedAudioBuffer
impl OwnedAudioBuffer
Sourcepub fn new(frame_count: usize, channel_count: usize, sample_rate: usize) -> Self
pub fn new(frame_count: usize, channel_count: usize, sample_rate: usize) -> Self
Create an audio buffer with specified number of frames, channels, and at the specified sample rate
Sourcepub fn from_slice(
data: &[f32],
channel_count: usize,
sample_rate: usize,
) -> Self
pub fn from_slice( data: &[f32], channel_count: usize, sample_rate: usize, ) -> Self
Create an audio buffer with audio from the specified slice
The audio from data
represents a single channel and will be copied to all channels
Sourcepub fn from_buffer(buffer: &dyn AudioBuffer) -> Self
pub fn from_buffer(buffer: &dyn AudioBuffer) -> Self
Create a buffer by copying the data from another buffer
Sourcepub fn extended_with_buffer(&self, buffer: &dyn AudioBuffer) -> Self
pub fn extended_with_buffer(&self, buffer: &dyn AudioBuffer) -> Self
Create a new buffer with the existing audio data, and copying in the data from buffer
buffer
should have the same number of channels and be at the same sample rate
Sourcepub fn white_noise(
frame_count: usize,
channel_count: usize,
sample_rate: usize,
) -> Self
pub fn white_noise( frame_count: usize, channel_count: usize, sample_rate: usize, ) -> Self
Create a buffer with random audio samples
Sourcepub fn padded_to_length(&self, frame_count: usize) -> Self
pub fn padded_to_length(&self, frame_count: usize) -> Self
Create a new buffer that has been padded to the specified length
Trait Implementations§
Source§impl AudioBuffer for OwnedAudioBuffer
impl AudioBuffer for OwnedAudioBuffer
Source§fn channel_count(&self) -> usize
fn channel_count(&self) -> usize
Get the number of channels in this buffer
Source§fn frame_count(&self) -> usize
fn frame_count(&self) -> usize
Get the number of frames in this buffer
Source§fn sample_rate(&self) -> usize
fn sample_rate(&self) -> usize
Get the sample rate of this buffer
Source§fn get_channel_data(&self, sample_location: SampleLocation) -> &[f32]
fn get_channel_data(&self, sample_location: SampleLocation) -> &[f32]
Get a slice representing the audio data of a particular channel
Source§fn get_channel_data_mut(
&mut self,
sample_location: SampleLocation,
) -> &mut [f32]
fn get_channel_data_mut( &mut self, sample_location: SampleLocation, ) -> &mut [f32]
Get a mutable slice representing the audio data of a particular channel
Source§fn duplicate_channel(
&mut self,
source: SampleLocation,
to_channel: usize,
frame_count: usize,
)
fn duplicate_channel( &mut self, source: SampleLocation, to_channel: usize, frame_count: usize, )
Duplicate the audio data from one channel to a different channel
Source§fn fill_from_interleaved(
&mut self,
interleaved_data: &[f32],
channel_count: usize,
frame_count: usize,
)
fn fill_from_interleaved( &mut self, interleaved_data: &[f32], channel_count: usize, frame_count: usize, )
Fill the buffer with interleaved audio Read more
Source§fn copy_to_interleaved(
&self,
interleaved_data: &mut [f32],
channel_count: usize,
frame_count: usize,
)
fn copy_to_interleaved( &self, interleaved_data: &mut [f32], channel_count: usize, frame_count: usize, )
Copy the data to an interleaved buffer Read more
Source§fn length_in_seconds(&self) -> f64
fn length_in_seconds(&self) -> f64
Get the length represented by this buffer in seconds
Source§fn range_is_valid(&self, range: &SampleRange) -> bool
fn range_is_valid(&self, range: &SampleRange) -> bool
Verify that a sample range is valid
Source§fn clear_range(&mut self, range: &SampleRange)
fn clear_range(&mut self, range: &SampleRange)
Clear the audio in a range of samples
Source§fn fill_channel_with_value(&mut self, channel: usize, value: f32)
fn fill_channel_with_value(&mut self, channel: usize, value: f32)
Fill a channel with a value
Source§fn fill_with_value(&mut self, value: f32)
fn fill_with_value(&mut self, value: f32)
Fill the entire buffer with a value
Source§fn set_sample(&mut self, sample_location: SampleLocation, value: f32)
fn set_sample(&mut self, sample_location: SampleLocation, value: f32)
Set a sample in the buffer
Source§fn add_sample(&mut self, sample_location: SampleLocation, value: f32)
fn add_sample(&mut self, sample_location: SampleLocation, value: f32)
Add a sample into the buffer
Source§fn get_sample(&self, sample_location: SampleLocation) -> f32
fn get_sample(&self, sample_location: SampleLocation) -> f32
Get a sample from the buffer
Source§fn add_from(
&mut self,
source_buffer: &dyn AudioBuffer,
source_location: SampleLocation,
destination_location: SampleLocation,
channel_count: usize,
frame_count: usize,
)
fn add_from( &mut self, source_buffer: &dyn AudioBuffer, source_location: SampleLocation, destination_location: SampleLocation, channel_count: usize, frame_count: usize, )
Mix audio from one buffer into another buffer
Source§fn add_from_with_gain(
&mut self,
source_buffer: &dyn AudioBuffer,
source_location: SampleLocation,
destination_location: SampleLocation,
channel_count: usize,
frame_count: usize,
gain: f32,
)
fn add_from_with_gain( &mut self, source_buffer: &dyn AudioBuffer, source_location: SampleLocation, destination_location: SampleLocation, channel_count: usize, frame_count: usize, gain: f32, )
Mix audio from one buffer into another buffer, apply a constant gain to each sample
Source§fn copy_from(
&mut self,
source_buffer: &dyn AudioBuffer,
source_location: SampleLocation,
destination_location: SampleLocation,
channel_count: usize,
frame_count: usize,
)
fn copy_from( &mut self, source_buffer: &dyn AudioBuffer, source_location: SampleLocation, destination_location: SampleLocation, channel_count: usize, frame_count: usize, )
Copy audio from one buffer into another Read more
Source§fn copy_within(&mut self, source_range: &SampleRange, destination_frame: usize)
fn copy_within(&mut self, source_range: &SampleRange, destination_frame: usize)
Copy audio data within the buffer
Source§fn apply_gain(&mut self, gain: &[f32])
fn apply_gain(&mut self, gain: &[f32])
Apply gain to all channels the buffer Read more
Source§fn apply_gain_value(&mut self, range: &SampleRange, gain: f32)
fn apply_gain_value(&mut self, range: &SampleRange, gain: f32)
Apply a single gain value to a whole channel
Source§fn frame_iter(&self) -> FrameIterator
fn frame_iter(&self) -> FrameIterator
Get an iterator to iteraotr over every sample in the buffer Read more
Source§fn sample_rate_convert_from(
&mut self,
audio_buffer: &dyn AudioBuffer,
source_location: SampleLocation,
destination_location: SampleLocation,
channel_count: usize,
)
fn sample_rate_convert_from( &mut self, audio_buffer: &dyn AudioBuffer, source_location: SampleLocation, destination_location: SampleLocation, channel_count: usize, )
Copy audio from a different audio buffer at a different sample rate Read more
Source§fn fill_from_slice(&mut self, audio_data: &[f32], location: SampleLocation)
fn fill_from_slice(&mut self, audio_data: &[f32], location: SampleLocation)
Fill a channel from a slice
Source§impl Clone for OwnedAudioBuffer
impl Clone for OwnedAudioBuffer
Source§fn clone(&self) -> OwnedAudioBuffer
fn clone(&self) -> OwnedAudioBuffer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for OwnedAudioBuffer
impl RefUnwindSafe for OwnedAudioBuffer
impl Send for OwnedAudioBuffer
impl Sync for OwnedAudioBuffer
impl Unpin for OwnedAudioBuffer
impl UnwindSafe for OwnedAudioBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
Source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Performs the conversion.
Source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
Source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Performs the conversion.
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
Source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
Source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.