pub struct InterleavedChannelMut<'a, T> { /* private fields */ }
Expand description

Read-write access to a single channel of audio within an interleaved, multichannel audio buffer. This struct does not own the audio data; it provides an API for accessing data owned by something else.

See also crate::buf::Interleaved.

Implementations§

source§

impl<'a, T> InterleavedChannelMut<'a, T>

source

pub unsafe fn new_unchecked( ptr: NonNull<T>, len: usize, channel: usize, channels: usize ) -> Self

Construct an interleaved channel buffer.

The provided buffer must be the complete buffer, which includes all other channels. The provided channels argument is the total number of channels in this buffer, and channel indicates which specific channel this buffer belongs to.

Note that this is typically not used directly, but instead through an abstraction which makes sure to provide the correct parameters.

Safety

Caller must ensure that the provided base pointer, length, and channel configuration is in bounds with the buffer pointed to by ptr.

source§

impl<'a, T> InterleavedChannelMut<'a, T>
where T: Copy,

source

pub fn get(&self, frame: usize) -> Option<T>

Get the given frame if it’s in bound.

source

pub fn iter(&self) -> Iter<'_, T>

Construct an iterator over the interleaved channel.

source§

impl<'a, T> InterleavedChannelMut<'a, T>

source

pub fn from_slice( data: &'a mut [T], channel: usize, channels: usize ) -> Option<Self>

Construct an interleaved channel buffer from a slice.

This is a safe function since the data being referenced is both bounds checked and is associated with the lifetime of the structure.

Returns None if the channel configuration is not valid. That is either true if the given number of channels cannot fit within it or if the selected channel does not fit within the specified channels.

use audio::channel::InterleavedChannelMut;

let buf: &mut [u32] = &mut [1, 2];
assert!(InterleavedChannelMut::from_slice(buf, 1, 4).is_none());
Examples
use audio::channel::InterleavedChannelMut;

let buf: &mut [u32] = &mut [1, 2, 3, 4, 5, 6, 7, 8];
let channel = InterleavedChannelMut::from_slice(buf, 1, 2).unwrap();

assert_eq!(channel.get(1), Some(4));
assert_eq!(channel.get(2), Some(6));
source

pub fn into_mut(self, frame: usize) -> Option<&'a mut T>

Get the given frame if it’s in bound.

source

pub fn get_mut(&mut self, n: usize) -> Option<&mut T>

Get the given frame mutably if it’s in bound.

source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

Construct a mutable iterator over the channel.

Trait Implementations§

source§

impl<'a, T> Channel for InterleavedChannelMut<'a, T>
where T: Copy,

§

type Sample = T

The sample of a channel.
§

type Channel<'this> = InterleavedChannelMut<'this, <InterleavedChannelMut<'a, T> as Channel>::Sample> where Self: 'this

The type the channel assumes when coerced into a reference.
§

type Iter<'this> = Iter<'this, <InterleavedChannelMut<'a, T> as Channel>::Sample> where Self: 'this

A borrowing iterator over the channel.
source§

fn as_channel(&self) -> InterleavedChannelMut<'_, T>

Reborrow the current channel as a reference.
source§

fn len(&self) -> usize

Get the length which indicates number of frames in the current channel. Read more
source§

fn get(&self, n: usize) -> Option<Self::Sample>

Get the frame at the given offset in the channel. Read more
source§

fn iter(&self) -> Self::Iter<'_>

Construct an iterator over the channel. Read more
source§

fn skip(self, n: usize) -> Self

Construct a channel buffer where the first n frames are skipped. Read more
source§

fn tail(self, n: usize) -> Self

Construct a channel buffer where the last n frames are included. Read more
source§

fn limit(self, limit: usize) -> Self

Limit the channel bufferto limit number of frames. Read more
source§

fn try_as_linear(&self) -> Option<&[T]>

Try to access the current channel as a linear buffer. Read more
source§

fn is_empty(&self) -> bool

Test if the current channel is empty. Read more
source§

impl<'a, T> ChannelMut for InterleavedChannelMut<'a, T>
where T: Copy,

§

type ChannelMut<'this> = InterleavedChannelMut<'this, <InterleavedChannelMut<'a, T> as Channel>::Sample> where Self: 'this

A reborrowed mutable channel.
§

type IterMut<'this> = IterMut<'this, <InterleavedChannelMut<'a, T> as Channel>::Sample> where Self: 'this

A mutable iterator over a channel.
source§

fn as_channel_mut(&mut self) -> Self::ChannelMut<'_>

Reborrow the channel mutably.
source§

fn get_mut(&mut self, n: usize) -> Option<&mut T>

Get the frame at the given offset in the channel. Read more
source§

fn iter_mut(&mut self) -> Self::IterMut<'_>

Construct a mutable iterator over the channel
source§

fn try_as_linear_mut(&mut self) -> Option<&mut [T]>

Try to access the current channel as a mutable linear buffer. Read more
source§

fn fill(&mut self, value: Self::Sample)

Replace all samples in the channel with the specified value Read more
source§

impl<'a, T> Debug for InterleavedChannelMut<'a, T>
where T: Copy + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, T> Ord for InterleavedChannelMut<'a, T>
where T: Copy + Ord,

source§

fn cmp(&self, other: &InterleavedChannelMut<'a, T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<'a, T> PartialEq<&[T]> for InterleavedChannelMut<'a, T>
where T: Copy + PartialEq,

source§

fn eq(&self, b: &&[T]) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, T> PartialEq<[T]> for InterleavedChannelMut<'a, T>
where T: Copy + PartialEq,

source§

fn eq(&self, b: &[T]) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, T, const N: usize> PartialEq<[T; N]> for InterleavedChannelMut<'a, T>
where T: Copy + PartialEq,

source§

fn eq(&self, b: &[T; N]) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, T> PartialEq<InterleavedChannel<'a, T>> for InterleavedChannelMut<'a, T>
where T: Copy + PartialEq,

source§

fn eq(&self, other: &InterleavedChannel<'a, T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, T> PartialEq<InterleavedChannelMut<'a, T>> for InterleavedChannel<'a, T>
where T: Copy + PartialEq,

source§

fn eq(&self, other: &InterleavedChannelMut<'a, T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, T> PartialEq<Vec<T>> for InterleavedChannelMut<'a, T>
where T: Copy + PartialEq,

source§

fn eq(&self, b: &Vec<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, T> PartialEq for InterleavedChannelMut<'a, T>
where T: Copy + PartialEq,

source§

fn eq(&self, other: &InterleavedChannelMut<'a, T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, T> PartialOrd<&[T]> for InterleavedChannelMut<'a, T>
where T: Copy + PartialOrd,

source§

fn partial_cmp(&self, b: &&[T]) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, T> PartialOrd<[T]> for InterleavedChannelMut<'a, T>
where T: Copy + PartialOrd,

source§

fn partial_cmp(&self, b: &[T]) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, T, const N: usize> PartialOrd<[T; N]> for InterleavedChannelMut<'a, T>
where T: Copy + PartialOrd,

source§

fn partial_cmp(&self, b: &[T; N]) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, T> PartialOrd<InterleavedChannel<'a, T>> for InterleavedChannelMut<'a, T>
where T: Copy + PartialOrd,

source§

fn partial_cmp(&self, other: &InterleavedChannel<'a, T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, T> PartialOrd<InterleavedChannelMut<'a, T>> for InterleavedChannel<'a, T>
where T: Copy + PartialOrd,

source§

fn partial_cmp(&self, other: &InterleavedChannelMut<'a, T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, T> PartialOrd<Vec<T>> for InterleavedChannelMut<'a, T>
where T: Copy + PartialOrd,

source§

fn partial_cmp(&self, b: &Vec<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, T> PartialOrd for InterleavedChannelMut<'a, T>
where T: Copy + PartialOrd,

source§

fn partial_cmp(&self, other: &InterleavedChannelMut<'a, T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, T> Eq for InterleavedChannelMut<'a, T>
where T: Copy + Eq,

Auto Trait Implementations§

§

impl<'a, T> RefUnwindSafe for InterleavedChannelMut<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> !Send for InterleavedChannelMut<'a, T>

§

impl<'a, T> !Sync for InterleavedChannelMut<'a, T>

§

impl<'a, T> Unpin for InterleavedChannelMut<'a, T>

§

impl<'a, T> !UnwindSafe for InterleavedChannelMut<'a, T>

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>,

§

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>,

§

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.