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>
impl<T: Default + Copy + Clone, const MAX_BLOCKSIZE: usize> MonoBlockBuffer<T, MAX_BLOCKSIZE>
Sourcepub fn new() -> Self
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.
Sourcepub unsafe fn new_uninit() -> Self
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.
Sourcepub unsafe fn new_uninit_after_frames(frames: usize) -> Self
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.
Sourcepub unsafe fn new_partially_uninit(init_range: Range<usize>) -> Self
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).
Sourcepub fn clear_frames(&mut self, frames: usize)
pub fn clear_frames(&mut self, frames: usize)
Clear a number of frames in the buffer to 0.
Sourcepub fn clear_range(&mut self, range: Range<usize>)
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).
Sourcepub fn copy_from(&mut self, src: &MonoBlockBuffer<T, MAX_BLOCKSIZE>)
pub fn copy_from(&mut self, src: &MonoBlockBuffer<T, MAX_BLOCKSIZE>)
Copy all frames from src to this buffer.
Sourcepub fn copy_frames_from(
&mut self,
src: &MonoBlockBuffer<T, MAX_BLOCKSIZE>,
frames: usize,
)
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.