Trait rotary::Buf [−][src]
A trait describing an immutable audio buffer.
Required methods
pub fn frames_hint(&self) -> Option<usize>
[src]
A typical number of frames in the buffer, if known.
pub fn channels(&self) -> usize
[src]
The number of channels in the buffer.
pub fn channel(&self, channel: usize) -> Channel<'_, T>
[src]
Return a handler to the buffer associated with the channel.
Note that we don’t access the buffer for the underlying channel directly
as a linear buffer like &[T]
, because the underlying representation
might be different.
We must instead make use of the various utility functions found on Channel to copy data out of the channel.
Panics
Panics if the specified channel is out of bound as reported by Buf::channels.
Provided methods
pub fn skip(self, n: usize) -> Skip<Self>
[src]
Construct a new buffer where n
frames are skipped.
Examples
use rotary::{Buf as _, BufMut as _}; let mut from = rotary::interleaved![[0.0f32; 4]; 2]; *from.frame_mut(0, 2).unwrap() = 1.0; *from.frame_mut(0, 3).unwrap() = 1.0; let mut to = rotary::Interleaved::<f32>::with_topology(2, 4); to.channel_mut(0).copy_from((&from).skip(2).channel(0)); assert_eq!(to.as_slice(), &[1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0]);
Test with a mutable buffer.
use rotary::{Buf as _, BufMut as _}; let mut buffer = rotary::Interleaved::with_topology(2, 4); (&mut buffer).skip(2).channel_mut(0).copy_from_slice(&[1.0, 1.0]); assert_eq!(buffer.as_slice(), &[0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0])
pub fn tail(self, n: usize) -> Tail<Self>
[src]
Construct a new buffer where n
frames are skipped.
Examples
use rotary::{Buf as _, BufMut as _}; let from = rotary::interleaved![[1.0f32; 4]; 2]; let mut to = rotary::interleaved![[0.0f32; 4]; 2]; rotary::utils::copy(from, (&mut to).tail(2)); assert_eq!(to.as_slice(), &[0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0]);
pub fn limit(self, limit: usize) -> Limit<Self>
[src]
Limit the channel buffer to limit
number of frames.
Examples
use rotary::{Buf as _, BufMut as _}; let from = rotary::interleaved![[1.0f32; 4]; 2]; let mut to = rotary::Interleaved::<f32>::with_topology(2, 4); to.channel_mut(0).copy_from(from.limit(2).channel(0)); assert_eq!(to.as_slice(), &[1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0]);
pub fn chunk(self, n: usize, len: usize) -> Chunk<Self>
[src]
Construct a range of frames corresponds to the chunk with len
and
position n
.
Which is the range n * len .. n * len + len
.
Examples
use rotary::{Buf as _, BufMut as _}; let from = rotary::interleaved![[1.0f32; 4]; 2]; let mut to = rotary::interleaved![[0.0f32; 4]; 2]; (&mut to).chunk(1, 2).channel_mut(0).copy_from(from.channel(0)); assert_eq!(to.as_slice(), &[0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0]);
Implementations on Foreign Types
impl<T> Buf<T> for [Vec<T, Global>]
[src]
pub fn frames_hint(&self) -> Option<usize>
[src]
pub fn channels(&self) -> usize
[src]
pub fn channel(&self, channel: usize) -> Channel<'_, T>
[src]
impl<'_, B, T> Buf<T> for &'_ mut B where
B: Buf<T> + ?Sized,
[src]
B: Buf<T> + ?Sized,
pub fn frames_hint(&self) -> Option<usize>
[src]
pub fn channels(&self) -> usize
[src]
pub fn channel(&self, channel: usize) -> Channel<'_, T>
[src]
impl<T> Buf<T> for Vec<Vec<T, Global>, Global>
[src]
pub fn frames_hint(&self) -> Option<usize>
[src]
pub fn channels(&self) -> usize
[src]
pub fn channel(&self, channel: usize) -> Channel<'_, T>
[src]
impl<'_, B, T> Buf<T> for &'_ B where
B: Buf<T>,
[src]
B: Buf<T>,
pub fn frames_hint(&self) -> Option<usize>
[src]
pub fn channels(&self) -> usize
[src]
pub fn channel(&self, channel: usize) -> Channel<'_, T>
[src]
Implementors
impl<B, T> Buf<T> for Read<B> where
B: Buf<T>,
[src]
B: Buf<T>,
pub fn frames_hint(&self) -> Option<usize>
[src]
pub fn channels(&self) -> usize
[src]
pub fn channel(&self, channel: usize) -> Channel<'_, T>
[src]
impl<B, T> Buf<T> for ReadWrite<B> where
B: Buf<T>,
[src]
B: Buf<T>,
pub fn frames_hint(&self) -> Option<usize>
[src]
pub fn channels(&self) -> usize
[src]
pub fn channel(&self, channel: usize) -> Channel<'_, T>
[src]
impl<B, T> Buf<T> for Write<B> where
B: Buf<T>,
[src]
B: Buf<T>,