OwnedAudioBuffer

Struct OwnedAudioBuffer 

Source
#[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

Source

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

Source

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

Source

pub fn from_buffer(buffer: &dyn AudioBuffer) -> Self

Create a buffer by copying the data from another buffer

Source

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

Source

pub fn white_noise( frame_count: usize, channel_count: usize, sample_rate: usize, ) -> Self

Create a buffer with random audio samples

Source

pub fn padded_to_length(&self, frame_count: usize) -> Self

Create a new buffer that has been padded to the specified length

Source

pub fn sine( frame_count: usize, channel_count: usize, sample_rate: usize, frequency: f64, amplitude: f64, ) -> Self

Create an audio buffer filled with a sine wave at the specified frequency

Source

pub fn step( frame_count: usize, channel_count: usize, sample_rate: usize, step_range: Range<usize>, ) -> Self

Create an audio buffer that is value 0.0 until frame_count, then 1.0

Trait Implementations§

Source§

impl AudioBuffer for OwnedAudioBuffer

Source§

fn channel_count(&self) -> usize

Get the number of channels in this buffer
Source§

fn frame_count(&self) -> usize

Get the number of frames in this buffer
Source§

fn sample_rate(&self) -> usize

Get the sample rate of this buffer
Source§

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]

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, )

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, )

Fill the buffer with interleaved audio Read more
Source§

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

Get the length represented by this buffer in seconds
Source§

fn duration(&self) -> Duration

Get the duration of this buffer in seconds
Source§

fn clear(&mut self)

Clear the audio in this buffer
Source§

fn range_is_valid(&self, range: &SampleRange) -> bool

Verify that a sample range is valid
Source§

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)

Fill a channel with a value
Source§

fn fill_with_value(&mut self, value: f32)

Fill the entire buffer with a value
Source§

fn channel_is_silent(&self, channel: usize) -> bool

Check if a channel is silent Read more
Source§

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)

Add a sample into the buffer
Source§

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, )

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, )

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, )

Copy audio from one buffer into another Read more
Source§

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

Apply gain to all channels the buffer Read more
Source§

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

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, )

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)

Fill a channel from a slice
Source§

impl Clone for OwnedAudioBuffer

Source§

fn clone(&self) -> OwnedAudioBuffer

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.