pub struct ConstSequentialBuffer<T: Clone + Copy + Default, const CHANNELS: usize> { /* private fields */ }Expand description
A memory-efficient buffer of samples with CHANNELS channels. Each channel
has a length of frames.
T is the backing type of the storage, typically f32.
This is like a SequentialBuffer but guarantees all MAX_CHANNELS are present.
The number of frames and number of channels cannot be changed once constructed.
Implementations§
Source§impl<T: Clone + Copy + Default, const CHANNELS: usize> ConstSequentialBuffer<T, CHANNELS>
impl<T: Clone + Copy + Default, const CHANNELS: usize> ConstSequentialBuffer<T, CHANNELS>
pub const fn empty() -> Self
pub fn new(frames: usize) -> Self
pub fn frames(&self) -> usize
Sourcepub fn first_with_frames(&self, frames: usize) -> &[T]
pub fn first_with_frames(&self, frames: usize) -> &[T]
Get an immutable reference to the first channel with the given number of frames.
The length of the returned slice will be either frames or the number of
frames in this buffer, whichever is smaller.
Sourcepub fn first_with_frames_mut(&mut self, frames: usize) -> &mut [T]
pub fn first_with_frames_mut(&mut self, frames: usize) -> &mut [T]
Get a mutable reference to the first channel with the given number of frames.
The length of the returned slice will be either frames or the number of
frames in this buffer, whichever is smaller.
Sourcepub fn channels<const NUM_CHANNELS: usize>(&self) -> [&[T]; NUM_CHANNELS]
pub fn channels<const NUM_CHANNELS: usize>(&self) -> [&[T]; NUM_CHANNELS]
Get an immutable reference to the first given number of channels in this buffer.
§Panics
Panics if NUM_CHANNELS > Self::CHANNELS
Sourcepub fn channels_mut<const NUM_CHANNELS: usize>(
&mut self,
) -> [&mut [T]; NUM_CHANNELS]
pub fn channels_mut<const NUM_CHANNELS: usize>( &mut self, ) -> [&mut [T]; NUM_CHANNELS]
Get a mutable reference to the first given number of channels in this buffer.
§Panics
Panics if NUM_CHANNELS > Self::CHANNELS
Sourcepub fn channels_with_frames<const NUM_CHANNELS: usize>(
&self,
frames: usize,
) -> [&[T]; NUM_CHANNELS]
pub fn channels_with_frames<const NUM_CHANNELS: usize>( &self, frames: usize, ) -> [&[T]; NUM_CHANNELS]
Get an immutable reference to the first given number of channels with the given number of frames.
The length of the returned slices will be either frames or the number of
frames in this buffer, whichever is smaller.
§Panics
Panics if NUM_CHANNELS > Self::CHANNELS
Sourcepub fn channels_with_frames_mut<const NUM_CHANNELS: usize>(
&mut self,
frames: usize,
) -> [&mut [T]; NUM_CHANNELS]
pub fn channels_with_frames_mut<const NUM_CHANNELS: usize>( &mut self, frames: usize, ) -> [&mut [T]; NUM_CHANNELS]
Get a mutable reference to the first given number of channels with the given number of frames.
The length of the returned slices will be either frames or the number of
frames in this buffer, whichever is smaller.
§Panics
Panics if NUM_CHANNELS > Self::CHANNELS
Sourcepub fn all(&self) -> [&[T]; CHANNELS]
pub fn all(&self) -> [&[T]; CHANNELS]
Get an immutable reference to all channels in this buffer.
Sourcepub fn all_mut(&mut self) -> [&mut [T]; CHANNELS]
pub fn all_mut(&mut self) -> [&mut [T]; CHANNELS]
Get a mutable reference to all channels in this buffer.
Sourcepub fn all_with_frames(&self, frames: usize) -> [&[T]; CHANNELS]
pub fn all_with_frames(&self, frames: usize) -> [&[T]; CHANNELS]
Get an immutable reference to all channels with the given number of frames.
The length of the returned slices will be either frames or the number of
frames in this buffer, whichever is smaller.
Sourcepub fn all_with_frames_mut(&mut self, frames: usize) -> [&mut [T]; CHANNELS]
pub fn all_with_frames_mut(&mut self, frames: usize) -> [&mut [T]; CHANNELS]
Get a mutable reference to all channels with the given number of frames.
The length of the returned slices will be either frames or the number of
frames in this buffer, whichever is smaller.
Sourcepub fn iter_channels(&self) -> impl Iterator<Item = &[T]>
pub fn iter_channels(&self) -> impl Iterator<Item = &[T]>
Iterate over all the channels immutably. Each channel slice will have a length
of self.frames().
Sourcepub fn iter_channels_mut(&mut self) -> impl Iterator<Item = &mut [T]>
pub fn iter_channels_mut(&mut self) -> impl Iterator<Item = &mut [T]>
Iterate over all the channels mutably. Each channel slice will have a length
of self.frames().
Trait Implementations§
Auto Trait Implementations§
impl<T, const CHANNELS: usize> Freeze for ConstSequentialBuffer<T, CHANNELS>
impl<T, const CHANNELS: usize> RefUnwindSafe for ConstSequentialBuffer<T, CHANNELS>where
T: RefUnwindSafe,
impl<T, const CHANNELS: usize> Send for ConstSequentialBuffer<T, CHANNELS>where
T: Send,
impl<T, const CHANNELS: usize> Sync for ConstSequentialBuffer<T, CHANNELS>where
T: Sync,
impl<T, const CHANNELS: usize> Unpin for ConstSequentialBuffer<T, CHANNELS>where
T: Unpin,
impl<T, const CHANNELS: usize> UnsafeUnpin for ConstSequentialBuffer<T, CHANNELS>
impl<T, const CHANNELS: usize> UnwindSafe for ConstSequentialBuffer<T, CHANNELS>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.