Struct AudioBuffer

Source
pub struct AudioBuffer<S: Sample> { /* private fields */ }
Expand description

A buffer for storing audio sample data.

Used internally by the DSP graph for block input/output buffers. Wraps a Vec<S> with convenience methods for audio processing.

Implementations§

Source§

impl<S: Sample> AudioBuffer<S>

Source

pub fn new(capacity: usize) -> Self

Create an AudioBuffer of a particular capacity, automatically filled with zeroes.

Source

pub fn with_data(data: Vec<S>) -> Self

Create an AudioBuffer initialized with a given set of values.

Source

pub fn capacity(&self) -> usize

Get the capacity of the AudioBuffer.

Source

pub fn fill(&mut self, value: S)

Fill the AudioBuffer with a particular value.

Source

pub fn copy_from_slice(&mut self, source: &[S])

Copy the values from a given source to the AudioBuffer.

Source

pub fn copy_to_slice(&self, target: &mut [S])

Copy the AudioBuffer’s values to a given slice.

Source

pub fn as_ptr(&self) -> *const S

Get the AudioBuffer as a pointer to its contents.

Source

pub fn as_mut_ptr(&mut self) -> *mut S

Get the AudioBuffer as a mutable pointer to its contents.

Source

pub fn extend_from_slice(&mut self, slice: &[S])

Append the AudioBuffer with data from a given slice.

Source

pub fn drain_front(&mut self, count: usize) -> Drain<'_, S>

Drain the first count values from the AudioBuffer.

Trait Implementations§

Source§

impl<S: Sample> Buffer<S> for AudioBuffer<S>

Source§

fn len(&self) -> usize

Get the length of the Buffer.
Source§

fn is_empty(&self) -> bool

Check if the Buffer is empty.
Source§

fn as_slice(&self) -> &[S]

Get the Buffer as a data slice.
Source§

fn as_mut_slice(&mut self) -> &mut [S]

Get the Buffer as a mutable data slice.
Source§

fn clear(&mut self)

Remove all values from the Buffer
Source§

fn zeroize(&mut self)

Set all values in the Buffer to zero.
Source§

impl<S: Clone + Sample> Clone for AudioBuffer<S>

Source§

fn clone(&self) -> AudioBuffer<S>

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

impl<S: Debug + Sample> Debug for AudioBuffer<S>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<S: Sample> Extend<S> for AudioBuffer<S>

Source§

fn extend<I: IntoIterator<Item = S>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<S: Sample> Index<usize> for AudioBuffer<S>

Source§

type Output = S

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<S: Sample> IndexMut<usize> for AudioBuffer<S>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<S> Freeze for AudioBuffer<S>

§

impl<S> RefUnwindSafe for AudioBuffer<S>
where S: RefUnwindSafe,

§

impl<S> Send for AudioBuffer<S>

§

impl<S> Sync for AudioBuffer<S>

§

impl<S> Unpin for AudioBuffer<S>
where S: Unpin,

§

impl<S> UnwindSafe for AudioBuffer<S>
where S: UnwindSafe,

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