pub struct AudioBlockSequentialViewMut<'a, S>where
S: Sample,{ /* private fields */ }Expand description
A mutable view of sequential audio data.
- Layout:
[ch0, ch0, ch0, ch1, ch1, ch1] - Interpretation: All samples from
ch0are stored first, followed by all fromch1, etc. - Terminology: Described as “channels first” in the sense that all data for one channel appears before any data for the next.
- Usage: Used in DSP pipelines where per-channel processing is easier and more efficient.
§Example
use audio_blocks::*;
let mut data = vec![0.0, 0.0, 0.0, 1.0, 1.0, 1.0];
let block = AudioBlockSequentialViewMut::from_slice(&mut data, 2, 3);
assert_eq!(block.channel(0), &[0.0, 0.0, 0.0]);
assert_eq!(block.channel(1), &[1.0, 1.0, 1.0]);Implementations§
Source§impl<'a, S> AudioBlockSequentialViewMut<'a, S>where
S: Sample,
impl<'a, S> AudioBlockSequentialViewMut<'a, S>where
S: Sample,
Sourcepub fn from_slice(
data: &'a mut [S],
num_channels: u16,
num_frames: usize,
) -> AudioBlockSequentialViewMut<'a, S>
pub fn from_slice( data: &'a mut [S], num_channels: u16, num_frames: usize, ) -> AudioBlockSequentialViewMut<'a, S>
Creates a new audio block from a mutable slice of sequential audio data.
§Parameters
data- The mutable slice containing sequential audio samplesnum_channels- Number of audio channels in the datanum_frames- Number of audio frames in the data
§Panics
Panics if the length of data doesn’t equal num_channels * num_frames.
Sourcepub fn from_slice_limited(
data: &'a mut [S],
num_channels_visible: u16,
num_frames_visible: usize,
num_channels_available: u16,
num_frames_available: usize,
) -> AudioBlockSequentialViewMut<'a, S>
pub fn from_slice_limited( data: &'a mut [S], num_channels_visible: u16, num_frames_visible: usize, num_channels_available: u16, num_frames_available: usize, ) -> AudioBlockSequentialViewMut<'a, S>
Creates a new audio block from a mutable slice with limited visibility.
This function allows creating a view that exposes only a subset of the allocated channels and frames, which is useful for working with a logical section of a larger buffer.
§Parameters
data- The mutable slice containing sequential audio samplesnum_channels_visible- Number of audio channels to expose in the viewnum_frames_visible- Number of audio frames to expose in the viewnum_channels_allocated- Total number of channels allocated in the data buffernum_frames_allocated- Total number of frames allocated in the data buffer
§Panics
- Panics if the length of
datadoesn’t equalnum_channels_allocated * num_frames_allocated - Panics if
num_channels_visibleexceedsnum_channels_allocated - Panics if
num_frames_visibleexceedsnum_frames_allocated
Sourcepub unsafe fn from_ptr(
ptr: *mut S,
num_channels: u16,
num_frames: usize,
) -> AudioBlockSequentialViewMut<'a, S>
pub unsafe fn from_ptr( ptr: *mut S, num_channels: u16, num_frames: usize, ) -> AudioBlockSequentialViewMut<'a, S>
Creates a new audio block from a pointer.
§Safety
The caller must ensure that:
ptrpoints to valid memory containing at leastnum_channels_available * num_frames_availableelements- The memory referenced by
ptrmust be valid for the lifetime of the returnedSequentialView - The memory must not be mutated through other pointers while this view exists
Sourcepub unsafe fn from_ptr_limited(
ptr: *mut S,
num_channels_visible: u16,
num_frames_visible: usize,
num_channels_allocated: u16,
num_frames_allocated: usize,
) -> AudioBlockSequentialViewMut<'a, S>
pub unsafe fn from_ptr_limited( ptr: *mut S, num_channels_visible: u16, num_frames_visible: usize, num_channels_allocated: u16, num_frames_allocated: usize, ) -> AudioBlockSequentialViewMut<'a, S>
Creates a new audio block from a pointer with a limited amount of channels and/or frames.
§Safety
The caller must ensure that:
ptrpoints to valid memory containing at leastnum_channels_available * num_frames_availableelements- The memory referenced by
ptrmust be valid for the lifetime of the returnedSequentialView - The memory must not be mutated through other pointers while this view exists
Sourcepub fn channel_mut(&mut self, channel: u16) -> &mut [S]
pub fn channel_mut(&mut self, channel: u16) -> &mut [S]
Sourcepub fn channels(&self) -> impl Iterator<Item = &[S]>
pub fn channels(&self) -> impl Iterator<Item = &[S]>
Returns an iterator over all channels in the block.
Each channel is represented as a slice of samples.
Sourcepub fn channels_mut(&mut self) -> impl Iterator<Item = &mut [S]>
pub fn channels_mut(&mut self) -> impl Iterator<Item = &mut [S]>
Returns a mutable iterator over all channels in the block.
Each channel is represented as a mutable slice of samples.
Sourcepub fn raw_data(&self) -> &[S]
pub fn raw_data(&self) -> &[S]
Provides direct access to the underlying memory as an interleaved slice.
This function gives access to all allocated data, including any reserved capacity beyond the active range.
Sourcepub fn raw_data_mut(&mut self) -> &mut [S]
pub fn raw_data_mut(&mut self) -> &mut [S]
Provides direct mutable access to the underlying memory as an interleaved slice.
This function gives mutable access to all allocated data, including any reserved capacity beyond the active range.
pub fn view(&self) -> AudioBlockSequentialView<'_, S>
pub fn view_mut(&mut self) -> AudioBlockSequentialViewMut<'_, S>
Trait Implementations§
Source§impl<S> AudioBlock<S> for AudioBlockSequentialViewMut<'_, S>where
S: Sample,
impl<S> AudioBlock<S> for AudioBlockSequentialViewMut<'_, S>where
S: Sample,
type PlanarView = [S; 0]
Source§fn num_channels(&self) -> u16
fn num_channels(&self) -> u16
Source§fn num_frames(&self) -> usize
fn num_frames(&self) -> usize
Source§fn num_channels_allocated(&self) -> u16
fn num_channels_allocated(&self) -> u16
Source§fn num_frames_allocated(&self) -> usize
fn num_frames_allocated(&self) -> usize
Source§fn layout(&self) -> BlockLayout
fn layout(&self) -> BlockLayout
Source§fn sample(&self, channel: u16, frame: usize) -> S
fn sample(&self, channel: u16, frame: usize) -> S
Source§fn channel_iter(&self, channel: u16) -> impl Iterator<Item = &S>
fn channel_iter(&self, channel: u16) -> impl Iterator<Item = &S>
Source§fn channels_iter(&self) -> impl Iterator<Item = impl Iterator<Item = &S>>
fn channels_iter(&self) -> impl Iterator<Item = impl Iterator<Item = &S>>
Source§fn frame_iter(&self, frame: usize) -> impl Iterator<Item = &S>
fn frame_iter(&self, frame: usize) -> impl Iterator<Item = &S>
Source§fn frame_iters(&self) -> impl Iterator<Item = impl Iterator<Item = &S>>
fn frame_iters(&self) -> impl Iterator<Item = impl Iterator<Item = &S>>
Source§fn as_view(&self) -> impl AudioBlock<S>
fn as_view(&self) -> impl AudioBlock<S>
Source§fn as_sequential_view(&self) -> Option<AudioBlockSequentialView<'_, S>>
fn as_sequential_view(&self) -> Option<AudioBlockSequentialView<'_, S>>
Source§fn as_interleaved_view(&self) -> Option<AudioBlockInterleavedView<'_, S>>
fn as_interleaved_view(&self) -> Option<AudioBlockInterleavedView<'_, S>>
Source§fn as_planar_view(
&self,
) -> Option<AudioBlockPlanarView<'_, S, Self::PlanarView>>
fn as_planar_view( &self, ) -> Option<AudioBlockPlanarView<'_, S, Self::PlanarView>>
Source§impl<S> AudioBlockMut<S> for AudioBlockSequentialViewMut<'_, S>where
S: Sample,
impl<S> AudioBlockMut<S> for AudioBlockSequentialViewMut<'_, S>where
S: Sample,
type PlanarViewMut = [S; 0]
Source§fn set_active_num_channels(&mut self, num_channels: u16)
fn set_active_num_channels(&mut self, num_channels: u16)
Source§fn set_active_num_frames(&mut self, num_frames: usize)
fn set_active_num_frames(&mut self, num_frames: usize)
Source§fn sample_mut(&mut self, channel: u16, frame: usize) -> &mut S
fn sample_mut(&mut self, channel: u16, frame: usize) -> &mut S
Source§fn channel_iter_mut(&mut self, channel: u16) -> impl Iterator<Item = &mut S>
fn channel_iter_mut(&mut self, channel: u16) -> impl Iterator<Item = &mut S>
Source§fn channels_iter_mut(
&mut self,
) -> impl Iterator<Item = impl Iterator<Item = &mut S>>
fn channels_iter_mut( &mut self, ) -> impl Iterator<Item = impl Iterator<Item = &mut S>>
Source§fn frame_iter_mut(&mut self, frame: usize) -> impl Iterator<Item = &mut S>
fn frame_iter_mut(&mut self, frame: usize) -> impl Iterator<Item = &mut S>
Source§fn frames_iter_mut(
&mut self,
) -> impl Iterator<Item = impl Iterator<Item = &mut S>>
fn frames_iter_mut( &mut self, ) -> impl Iterator<Item = impl Iterator<Item = &mut S>>
Source§fn as_view_mut(&mut self) -> impl AudioBlockMut<S>
fn as_view_mut(&mut self) -> impl AudioBlockMut<S>
Source§fn as_sequential_view_mut(
&mut self,
) -> Option<AudioBlockSequentialViewMut<'_, S>>
fn as_sequential_view_mut( &mut self, ) -> Option<AudioBlockSequentialViewMut<'_, S>>
Source§fn set_active_size(&mut self, num_channels: u16, num_frames: usize)
fn set_active_size(&mut self, num_channels: u16, num_frames: usize)
Source§fn as_interleaved_view_mut(
&mut self,
) -> Option<AudioBlockInterleavedViewMut<'_, S>>
fn as_interleaved_view_mut( &mut self, ) -> Option<AudioBlockInterleavedViewMut<'_, S>>
Source§fn as_planar_view_mut(
&mut self,
) -> Option<AudioBlockPlanarViewMut<'_, S, Self::PlanarViewMut>>
fn as_planar_view_mut( &mut self, ) -> Option<AudioBlockPlanarViewMut<'_, S, Self::PlanarViewMut>>
Auto Trait Implementations§
impl<'a, S> Freeze for AudioBlockSequentialViewMut<'a, S>
impl<'a, S> RefUnwindSafe for AudioBlockSequentialViewMut<'a, S>where
S: RefUnwindSafe,
impl<'a, S> Send for AudioBlockSequentialViewMut<'a, S>where
S: Send,
impl<'a, S> Sync for AudioBlockSequentialViewMut<'a, S>where
S: Sync,
impl<'a, S> Unpin for AudioBlockSequentialViewMut<'a, S>
impl<'a, S> !UnwindSafe for AudioBlockSequentialViewMut<'a, S>
Blanket Implementations§
Source§impl<S, B> AudioBlockOps<S> for Bwhere
S: Sample,
B: AudioBlockMut<S>,
impl<S, B> AudioBlockOps<S> for Bwhere
S: Sample,
B: AudioBlockMut<S>,
Source§fn copy_from_block(&mut self, block: &impl AudioBlock<S>)
fn copy_from_block(&mut self, block: &impl AudioBlock<S>)
Source§fn copy_from_block_resize(&mut self, block: &impl AudioBlock<S>)
fn copy_from_block_resize(&mut self, block: &impl AudioBlock<S>)
Source§fn for_each_including_non_visible(&mut self, f: impl FnMut(&mut S))
fn for_each_including_non_visible(&mut self, f: impl FnMut(&mut S))
for_each by not checking bounds of the block.
It can be used if your algorithm does not change if wrong samples are accessed.
For example this is the case for gain, clear, etc.