Skip to main content

ChannelSamples

Struct ChannelSamples 

Source
pub struct ChannelSamples<'slice, 'sample: 'slice> { /* private fields */ }
Expand description

Can construct iterators over actual iterator over the channel data for a sample, yielded by SamplesIter. Can be turned into an iterator, or ChannelSamples::iter_mut() can be used to iterate over the channel data multiple times, or more efficiently you can use ChannelSamples::get_unchecked_mut() to do the same thing.

Implementations§

Source§

impl<'slice, 'sample> ChannelSamples<'slice, 'sample>

Source

pub fn len(&self) -> usize

Get the number of channels.

Source

pub fn iter_mut(&mut self) -> ChannelSamplesIter<'slice, 'sample>

A resetting iterator. This lets you iterate over the same channels multiple times. Otherwise you don’t need to use this function as ChannelSamples already implements IntoIterator.

Source

pub fn get_mut(&mut self, channel_index: usize) -> Option<&mut f32>

Access a sample by index. Useful when you would otherwise iterate over this ‘Channels’ iterator multiple times.

Source

pub unsafe fn get_unchecked_mut(&mut self, channel_index: usize) -> &mut f32

The same as get_mut(), but without any bounds checking.

§Safety

channel_index must be in the range 0..Self::len().

Source

pub fn to_simd<const LANES: usize>(&self) -> Simd<f32, LANES>

Get a SIMD vector containing the channel data for this buffer. If LANES > channels.len() then this will be padded with zeroes. If LANES < channels.len() then this won’t contain all values.

Source

pub unsafe fn to_simd_unchecked<const LANES: usize>(&self) -> Simd<f32, LANES>

Get a SIMD vector containing the channel data for this buffer. Will always read exactly LANES channels.

§Safety

Undefined behavior if LANES > channels.len().

Source

pub fn from_simd<const LANES: usize>(&mut self, vector: Simd<f32, LANES>)

Write data from a SIMD vector to this sample’s channel data. This takes the padding added by to_simd() into account.

Source

pub unsafe fn from_simd_unchecked<const LANES: usize>( &mut self, vector: Simd<f32, LANES>, )

Write data from a SIMD vector to this sample’s channel data. This assumes LANES matches exactly with the number of channels in the buffer.

§Safety

Undefined behavior if LANES > channels.len().

Trait Implementations§

Source§

impl<'slice, 'sample> IntoIterator for ChannelSamples<'slice, 'sample>

Source§

type Item = &'sample mut f32

The type of the elements being iterated over.
Source§

type IntoIter = ChannelSamplesIter<'slice, 'sample>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'slice, 'sample> Freeze for ChannelSamples<'slice, 'sample>

§

impl<'slice, 'sample> RefUnwindSafe for ChannelSamples<'slice, 'sample>

§

impl<'slice, 'sample> !Send for ChannelSamples<'slice, 'sample>

§

impl<'slice, 'sample> !Sync for ChannelSamples<'slice, 'sample>

§

impl<'slice, 'sample> Unpin for ChannelSamples<'slice, 'sample>

§

impl<'slice, 'sample> UnsafeUnpin for ChannelSamples<'slice, 'sample>

§

impl<'slice, 'sample> !UnwindSafe for ChannelSamples<'slice, 'sample>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.