pub struct SequentialBuffer<T: Clone + Copy + Default> { /* private fields */ }Expand description
A buffer of samples where each channel is stored sequentially in memory.
T is the backing type of the storage, typically f32.
The number of frames and number of channels cannot be changed once constructed.
Implementations§
Source§impl<T: Clone + Copy + Default> SequentialBuffer<T>
impl<T: Clone + Copy + Default> SequentialBuffer<T>
pub fn new(channels: NonZeroUsize, frames: usize) -> Self
pub fn frames(&self) -> usize
pub fn num_channels(&self) -> NonZeroUsize
Sourcepub fn channel_slice(&self, channel: usize) -> Option<&[T]>
pub fn channel_slice(&self, channel: usize) -> Option<&[T]>
Returns an immutable slice of the given channel. This slice will have a length of
self.frames().
Returns None if channel >= self.num_channels().
Sourcepub fn channel_slice_mut(&mut self, channel: usize) -> Option<&mut [T]>
pub fn channel_slice_mut(&mut self, channel: usize) -> Option<&mut [T]>
Returns a mutable slice to the given channel. This slice will have a length of
self.frames().
Returns None if channel >= self.num_channels().
Sourcepub fn stereo(&self, frames: usize) -> Option<(&[T], &[T])>
pub fn stereo(&self, frames: usize) -> Option<(&[T], &[T])>
Returns two immutable slices to the first two channels in this buffer with length
frames.
Clamps frames to the available data.
If the number of channels in this buffer is less than 2, then this will return
None.
Sourcepub fn stereo_mut(&mut self, frames: usize) -> Option<(&mut [T], &mut [T])>
pub fn stereo_mut(&mut self, frames: usize) -> Option<(&mut [T], &mut [T])>
Returns two mutable slices to the first two channels in this buffer with length
frames.
Clamps frames to the available data.
If the number of channels in this buffer is less than 2, then this will return
None.
Sourcepub fn channels<const MAX_CHANNELS: usize>(
&self,
num_channels: usize,
frames: usize,
) -> ArrayVec<&[T], MAX_CHANNELS>
pub fn channels<const MAX_CHANNELS: usize>( &self, num_channels: usize, frames: usize, ) -> ArrayVec<&[T], MAX_CHANNELS>
Returns a vec of slices to the first frames frames of the backing buffers
for the first num_channels channels present.
Clamps num_channels and frames to the available data.
Sourcepub fn channels_mut<const MAX_CHANNELS: usize>(
&mut self,
num_channels: usize,
frames: usize,
) -> ArrayVec<&mut [T], MAX_CHANNELS>
pub fn channels_mut<const MAX_CHANNELS: usize>( &mut self, num_channels: usize, frames: usize, ) -> ArrayVec<&mut [T], MAX_CHANNELS>
Returns a vec of mutable slices to the first frames frames of the backing buffers
for the first num_channels channels present.
Clamps num_channels and frames to the available data.
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> Freeze for SequentialBuffer<T>
impl<T> RefUnwindSafe for SequentialBuffer<T>where
T: RefUnwindSafe,
impl<T> Send for SequentialBuffer<T>where
T: Send,
impl<T> Sync for SequentialBuffer<T>where
T: Sync,
impl<T> Unpin for SequentialBuffer<T>where
T: Unpin,
impl<T> UnsafeUnpin for SequentialBuffer<T>
impl<T> UnwindSafe for SequentialBuffer<T>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.