pub struct InstanceBuffer<T: Clone + Copy + Default> { /* private fields */ }Expand description
A memory-efficient buffer of samples with a given number of instances each with a given
number of channels. Each channel has a length of frames.
T is the backing type of the storage, typically f32.
This is like a collection of num_instances SequentialBuffers but contiguous in memory.
The number of instances, channels, and frames cannot be changed once constructed.
Implementations§
Source§impl<T: Clone + Copy + Default> InstanceBuffer<T>
impl<T: Clone + Copy + Default> InstanceBuffer<T>
pub fn new(instances: usize, channels: NonZeroUsize, frames: usize) -> Self
pub fn frames(&self) -> usize
pub fn num_channels(&self) -> NonZeroUsize
pub fn num_instances(&self) -> usize
Sourcepub fn instance<const MAX_CHANNELS: usize>(
&self,
instance_index: usize,
channels: usize,
frames: usize,
) -> Option<ArrayVec<&[T], MAX_CHANNELS>>
pub fn instance<const MAX_CHANNELS: usize>( &self, instance_index: usize, channels: usize, frames: usize, ) -> Option<ArrayVec<&[T], MAX_CHANNELS>>
Returns an array of slices to the first frames frames of the backing buffers
for the first num_channels channels present of the instance at instance_index.
Clamps num_channels and frames to the available data.
Returns None if there is no instance at instance_index.
Sourcepub fn instance_mut<const MAX_CHANNELS: usize>(
&mut self,
instance_index: usize,
channels: usize,
frames: usize,
) -> Option<ArrayVec<&mut [T], MAX_CHANNELS>>
pub fn instance_mut<const MAX_CHANNELS: usize>( &mut self, instance_index: usize, channels: usize, frames: usize, ) -> Option<ArrayVec<&mut [T], MAX_CHANNELS>>
Returns an array of mutable slices to the first frames frames of the backing buffers
for the first num_channels channels present of the instance at instance_index.
Clamps num_channels and frames to the available data.
Returns None if there is no instance at instance_index.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for InstanceBuffer<T>
impl<T> RefUnwindSafe for InstanceBuffer<T>where
T: RefUnwindSafe,
impl<T> Send for InstanceBuffer<T>where
T: Send,
impl<T> Sync for InstanceBuffer<T>where
T: Sync,
impl<T> Unpin for InstanceBuffer<T>where
T: Unpin,
impl<T> UnsafeUnpin for InstanceBuffer<T>
impl<T> UnwindSafe for InstanceBuffer<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.