pub struct Block<'slice, 'sample: 'slice> { /* private fields */ }
Expand description
A block yielded by BlocksIter
. Can be iterated over once or multiple times, and also
supports direct access to the block’s samples if needed.
Implementations§
source§impl<'slice, 'sample> Block<'slice, 'sample>
impl<'slice, 'sample> Block<'slice, 'sample>
sourcepub fn iter_mut(&mut self) -> BlockChannelsIter<'slice, 'sample> ⓘ
pub fn iter_mut(&mut self) -> BlockChannelsIter<'slice, 'sample> ⓘ
sourcepub fn iter_samples(&mut self) -> SamplesIter<'slice, 'sample> ⓘ
pub fn iter_samples(&mut self) -> SamplesIter<'slice, 'sample> ⓘ
Iterate over this block on a per-sample per-channel basis. This is identical to
Buffer::iter_samples()
but for a smaller block instead of
the entire buffer
sourcepub fn get(&self, channel_index: usize) -> Option<&[f32]>
pub fn get(&self, channel_index: usize) -> Option<&[f32]>
Access a channel by index. Useful when you would otherwise iterate over this Block
multiple times.
sourcepub unsafe fn get_unchecked(&self, channel_index: usize) -> &[f32]
pub unsafe fn get_unchecked(&self, channel_index: usize) -> &[f32]
sourcepub fn get_mut(&mut self, channel_index: usize) -> Option<&mut [f32]>
pub fn get_mut(&mut self, channel_index: usize) -> Option<&mut [f32]>
Access a mutable channel by index. Useful when you would otherwise iterate over this
Block
multiple times.
sourcepub unsafe fn get_unchecked_mut(&mut self, channel_index: usize) -> &mut [f32]
pub unsafe fn get_unchecked_mut(&mut self, channel_index: usize) -> &mut [f32]
sourcepub fn to_channel_simd<const LANES: usize>(
&self,
sample_index: usize
) -> Option<Simd<f32, LANES>>where
LaneCount<LANES>: SupportedLaneCount,
Available on crate feature simd
only.
pub fn to_channel_simd<const LANES: usize>( &self, sample_index: usize ) -> Option<Simd<f32, LANES>>where LaneCount<LANES>: SupportedLaneCount,
simd
only.Get a SIMD vector containing the channel data for a specific sample in this block. If `LANES
channels.len()
then this will be padded with zeroes. If
LANES < channels.len()` then this won’t contain all values.
Returns a None
value if sample_index
is out of bounds.
sourcepub unsafe fn to_channel_simd_unchecked<const LANES: usize>(
&self,
sample_index: usize
) -> Simd<f32, LANES>where
LaneCount<LANES>: SupportedLaneCount,
Available on crate feature simd
only.
pub unsafe fn to_channel_simd_unchecked<const LANES: usize>( &self, sample_index: usize ) -> Simd<f32, LANES>where LaneCount<LANES>: SupportedLaneCount,
simd
only.Get a SIMD vector containing the channel data for a specific sample in this block. Will
always read exactly LANES
channels, and does not perform bounds checks on sample_index
.
Safety
Undefined behavior if LANES > block.len()
or if sample_index > block.len()
.
sourcepub fn from_channel_simd<const LANES: usize>(
&mut self,
sample_index: usize,
vector: Simd<f32, LANES>
) -> boolwhere
LaneCount<LANES>: SupportedLaneCount,
Available on crate feature simd
only.
pub fn from_channel_simd<const LANES: usize>( &mut self, sample_index: usize, vector: Simd<f32, LANES> ) -> boolwhere LaneCount<LANES>: SupportedLaneCount,
simd
only.Write data from a SIMD vector to this sample’s channel data for a specific sample in this
block. This takes the padding added by to_channel_simd()
into
account.
Returns false
if sample_index
is out of bounds.
sourcepub unsafe fn from_channel_simd_unchecked<const LANES: usize>(
&mut self,
sample_index: usize,
vector: Simd<f32, LANES>
)where
LaneCount<LANES>: SupportedLaneCount,
Available on crate feature simd
only.
pub unsafe fn from_channel_simd_unchecked<const LANES: usize>( &mut self, sample_index: usize, vector: Simd<f32, LANES> )where LaneCount<LANES>: SupportedLaneCount,
simd
only.Write data from a SIMD vector to this sample’s channel data for a specific sample in this
block.. This assumes LANES
matches exactly with the number of channels in the buffer, and
does not perform bounds checks on sample_index
.
Safety
Undefined behavior if LANES > block.len()
or if sample_index > block.len()
.