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>>
pub fn to_channel_simd<const LANES: usize>( &self, sample_index: usize, ) -> Option<Simd<f32, LANES>>
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. IfLANES < 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>
pub unsafe fn to_channel_simd_unchecked<const LANES: usize>( &self, sample_index: usize, ) -> Simd<f32, LANES>
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>,
) -> bool
pub fn from_channel_simd<const LANES: usize>( &mut self, sample_index: usize, vector: Simd<f32, LANES>, ) -> bool
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>,
)
pub unsafe fn from_channel_simd_unchecked<const LANES: usize>( &mut self, sample_index: usize, vector: Simd<f32, LANES>, )
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().