Struct audio::channel::interleaved::InterleavedChannelMut
source · 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>
impl<'a, T> InterleavedChannelMut<'a, T>
sourcepub unsafe fn new_unchecked(
ptr: NonNull<T>,
len: usize,
channel: usize,
channels: usize
) -> Self
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,
impl<'a, T> InterleavedChannelMut<'a, T>where
T: Copy,
source§impl<'a, T> InterleavedChannelMut<'a, T>
impl<'a, T> InterleavedChannelMut<'a, T>
sourcepub fn from_slice(
data: &'a mut [T],
channel: usize,
channels: usize
) -> Option<Self>
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));
Trait Implementations§
source§impl<'a, T> Channel for InterleavedChannelMut<'a, T>where
T: Copy,
impl<'a, T> Channel for InterleavedChannelMut<'a, T>where
T: Copy,
§type Channel<'this> = InterleavedChannelMut<'this, <InterleavedChannelMut<'a, T> as Channel>::Sample>
where
Self: 'this
type Channel<'this> = InterleavedChannelMut<'this, <InterleavedChannelMut<'a, T> as Channel>::Sample> where Self: 'this
§type Iter<'this> = Iter<'this, <InterleavedChannelMut<'a, T> as Channel>::Sample>
where
Self: 'this
type Iter<'this> = Iter<'this, <InterleavedChannelMut<'a, T> as Channel>::Sample> where Self: 'this
source§fn as_channel(&self) -> InterleavedChannelMut<'_, T>
fn as_channel(&self) -> InterleavedChannelMut<'_, T>
source§fn len(&self) -> usize
fn len(&self) -> usize
source§fn get(&self, n: usize) -> Option<Self::Sample>
fn get(&self, n: usize) -> Option<Self::Sample>
source§fn skip(self, n: usize) -> Self
fn skip(self, n: usize) -> Self
n
frames are skipped. Read moresource§fn tail(self, n: usize) -> Self
fn tail(self, n: usize) -> Self
n
frames are included. Read moresource§fn limit(self, limit: usize) -> Self
fn limit(self, limit: usize) -> Self
limit
number of frames. Read moresource§impl<'a, T> ChannelMut for InterleavedChannelMut<'a, T>where
T: Copy,
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
type ChannelMut<'this> = InterleavedChannelMut<'this, <InterleavedChannelMut<'a, T> as Channel>::Sample> where Self: 'this
§type IterMut<'this> = IterMut<'this, <InterleavedChannelMut<'a, T> as Channel>::Sample>
where
Self: 'this
type IterMut<'this> = IterMut<'this, <InterleavedChannelMut<'a, T> as Channel>::Sample> where Self: 'this
source§fn as_channel_mut(&mut self) -> Self::ChannelMut<'_>
fn as_channel_mut(&mut self) -> Self::ChannelMut<'_>
source§fn get_mut(&mut self, n: usize) -> Option<&mut T>
fn get_mut(&mut self, n: usize) -> Option<&mut T>
source§impl<'a, T> Debug for InterleavedChannelMut<'a, T>
impl<'a, T> Debug for InterleavedChannelMut<'a, T>
source§impl<'a, T> Ord for InterleavedChannelMut<'a, T>
impl<'a, T> Ord for InterleavedChannelMut<'a, T>
source§fn cmp(&self, other: &InterleavedChannelMut<'a, T>) -> Ordering
fn cmp(&self, other: &InterleavedChannelMut<'a, T>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<'a, T> PartialEq<&[T]> for InterleavedChannelMut<'a, T>
impl<'a, T> PartialEq<&[T]> for InterleavedChannelMut<'a, T>
source§impl<'a, T> PartialEq<[T]> for InterleavedChannelMut<'a, T>
impl<'a, T> PartialEq<[T]> for InterleavedChannelMut<'a, T>
source§impl<'a, T> PartialEq<InterleavedChannel<'a, T>> for InterleavedChannelMut<'a, T>
impl<'a, T> PartialEq<InterleavedChannel<'a, T>> for InterleavedChannelMut<'a, T>
source§fn eq(&self, other: &InterleavedChannel<'a, T>) -> bool
fn eq(&self, other: &InterleavedChannel<'a, T>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, T> PartialEq<InterleavedChannelMut<'a, T>> for InterleavedChannel<'a, T>
impl<'a, T> PartialEq<InterleavedChannelMut<'a, T>> for InterleavedChannel<'a, T>
source§fn eq(&self, other: &InterleavedChannelMut<'a, T>) -> bool
fn eq(&self, other: &InterleavedChannelMut<'a, T>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, T> PartialEq<Vec<T>> for InterleavedChannelMut<'a, T>
impl<'a, T> PartialEq<Vec<T>> for InterleavedChannelMut<'a, T>
source§impl<'a, T> PartialEq for InterleavedChannelMut<'a, T>
impl<'a, T> PartialEq for InterleavedChannelMut<'a, T>
source§fn eq(&self, other: &InterleavedChannelMut<'a, T>) -> bool
fn eq(&self, other: &InterleavedChannelMut<'a, T>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, T> PartialOrd<&[T]> for InterleavedChannelMut<'a, T>where
T: Copy + PartialOrd,
impl<'a, T> PartialOrd<&[T]> for InterleavedChannelMut<'a, T>where
T: Copy + PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, T> PartialOrd<[T]> for InterleavedChannelMut<'a, T>where
T: Copy + PartialOrd,
impl<'a, T> PartialOrd<[T]> for InterleavedChannelMut<'a, T>where
T: Copy + PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, T, const N: usize> PartialOrd<[T; N]> for InterleavedChannelMut<'a, T>where
T: Copy + PartialOrd,
impl<'a, T, const N: usize> PartialOrd<[T; N]> for InterleavedChannelMut<'a, T>where
T: Copy + PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, T> PartialOrd<InterleavedChannel<'a, T>> for InterleavedChannelMut<'a, T>where
T: Copy + PartialOrd,
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>
fn partial_cmp(&self, other: &InterleavedChannel<'a, T>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, T> PartialOrd<InterleavedChannelMut<'a, T>> for InterleavedChannel<'a, T>where
T: Copy + PartialOrd,
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>
fn partial_cmp(&self, other: &InterleavedChannelMut<'a, T>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, T> PartialOrd<Vec<T>> for InterleavedChannelMut<'a, T>where
T: Copy + PartialOrd,
impl<'a, T> PartialOrd<Vec<T>> for InterleavedChannelMut<'a, T>where
T: Copy + PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, T> PartialOrd for InterleavedChannelMut<'a, T>where
T: Copy + PartialOrd,
impl<'a, T> PartialOrd for InterleavedChannelMut<'a, T>where
T: Copy + PartialOrd,
source§fn partial_cmp(&self, other: &InterleavedChannelMut<'a, T>) -> Option<Ordering>
fn partial_cmp(&self, other: &InterleavedChannelMut<'a, T>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more