MonoBlockBuffer

Struct MonoBlockBuffer 

Source
pub struct MonoBlockBuffer<T: Default + Copy + Clone, const MAX_BLOCKSIZE: usize> {
    pub buf: [T; MAX_BLOCKSIZE],
}
Expand description

An audio buffer with a single channel.

This has a constant number of frames (MAX_BLOCKSIZE), so this can be allocated on the stack.

Fields§

§buf: [T; MAX_BLOCKSIZE]

Implementations§

Source§

impl<T: Default + Copy + Clone, const MAX_BLOCKSIZE: usize> MonoBlockBuffer<T, MAX_BLOCKSIZE>

Source

pub fn new() -> Self

Create a new buffer.

This is a constant size (MAX_BLOCKSIZE), so this can be allocated on the stack.

All samples will be cleared to 0.

Source

pub unsafe fn new_uninit() -> Self

Create a new buffer without initializing.

This is a constant size (MAX_BLOCKSIZE), so this can be allocated on the stack.

§Undefined behavior

This data will be unitialized, so undefined behavior may occur if you try to read any data without writing to it first.

Source

pub unsafe fn new_uninit_after_frames(frames: usize) -> Self

Create a new buffer that only initializes the given number of frames to 0. Any samples after frames will be uninitialized.

This is a constant size (MAX_BLOCKSIZE), so this can be allocated on the stack.

§Undefined behavior

The portion of data not in the given range will be unitialized, so undefined behavior may occur if you try to read any of that data without writing to it first.

Source

pub unsafe fn new_partially_uninit(init_range: Range<usize>) -> Self

Create a new buffer that only initializes the given range of data to 0.

This is a constant size (MAX_BLOCKSIZE), so this can be allocated on the stack.

§Undefined behavior

The portion of data not in the given range will be unitialized, so undefined behavior may occur if you try to read any of that data without writing to it first.

§Panics

This will panic if the given range lies outside the valid range [0, N).

Source

pub fn clear(&mut self)

Clear all samples in the buffer to 0.

Source

pub fn clear_frames(&mut self, frames: usize)

Clear a number of frames in the buffer to 0.

Source

pub fn clear_range(&mut self, range: Range<usize>)

Clear a range in the buffer to 0.

§Panics

This will panic if the given range lies outside the valid range [0, N).

Source

pub fn copy_from(&mut self, src: &MonoBlockBuffer<T, MAX_BLOCKSIZE>)

Copy all frames from src to this buffer.

Source

pub fn copy_frames_from( &mut self, src: &MonoBlockBuffer<T, MAX_BLOCKSIZE>, frames: usize, )

Copy the given number of frames from src to this buffer.

Trait Implementations§

Source§

impl<T: Debug + Default + Copy + Clone, const MAX_BLOCKSIZE: usize> Debug for MonoBlockBuffer<T, MAX_BLOCKSIZE>

Source§

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

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

impl<T, I, const MAX_BLOCKSIZE: usize> Index<I> for MonoBlockBuffer<T, MAX_BLOCKSIZE>
where I: SliceIndex<[T]>, T: Default + Copy + Clone,

Source§

type Output = <I as SliceIndex<[T]>>::Output

The returned type after indexing.
Source§

fn index(&self, idx: I) -> &I::Output

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

impl<T, I, const MAX_BLOCKSIZE: usize> IndexMut<I> for MonoBlockBuffer<T, MAX_BLOCKSIZE>
where I: SliceIndex<[T]>, T: Default + Copy + Clone,

Source§

fn index_mut(&mut self, idx: I) -> &mut I::Output

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

Auto Trait Implementations§

§

impl<T, const MAX_BLOCKSIZE: usize> Freeze for MonoBlockBuffer<T, MAX_BLOCKSIZE>
where T: Freeze,

§

impl<T, const MAX_BLOCKSIZE: usize> RefUnwindSafe for MonoBlockBuffer<T, MAX_BLOCKSIZE>
where T: RefUnwindSafe,

§

impl<T, const MAX_BLOCKSIZE: usize> Send for MonoBlockBuffer<T, MAX_BLOCKSIZE>
where T: Send,

§

impl<T, const MAX_BLOCKSIZE: usize> Sync for MonoBlockBuffer<T, MAX_BLOCKSIZE>
where T: Sync,

§

impl<T, const MAX_BLOCKSIZE: usize> Unpin for MonoBlockBuffer<T, MAX_BLOCKSIZE>
where T: Unpin,

§

impl<T, const MAX_BLOCKSIZE: usize> UnwindSafe for MonoBlockBuffer<T, MAX_BLOCKSIZE>
where T: 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> 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, 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.