pub struct BufferData { /* private fields */ }
Expand description
Implementations§
Source§impl BufferData
impl BufferData
Sourcepub fn new(channel_layout: ChannelLayout, num_frames: usize) -> Self
pub fn new(channel_layout: ChannelLayout, num_frames: usize) -> Self
Create a new buffer with the given channel layout and number of frames.
The buffer will be filled with zeros.
§Examples
let buffer = BufferData::new(ChannelLayout::Mono, 3);
assert_eq!(buffer.channel_layout(), ChannelLayout::Mono);
assert_eq!(buffer.channel(0), [0.0, 0.0, 0.0]);
Sourcepub fn new_mono(data: Vec<f32>) -> BufferData
pub fn new_mono(data: Vec<f32>) -> BufferData
Create a new mono buffer with the given data.
§Examples
let buffer = BufferData::new_mono(vec![1.0, 2.0, 3.0]);
assert_eq!(buffer.channel_layout(), ChannelLayout::Mono);
assert_eq!(buffer.channel(0), [1.0, 2.0, 3.0]);
Sourcepub fn new_stereo<L: IntoIterator<Item = f32>, R: IntoIterator<Item = f32>>(
left: L,
right: R,
) -> BufferData
pub fn new_stereo<L: IntoIterator<Item = f32>, R: IntoIterator<Item = f32>>( left: L, right: R, ) -> BufferData
Create a new stereo buffer with the given data.
§Examples
let buffer = BufferData::new_stereo([1.0, 2.0], [3.0, 4.0]);
assert_eq!(buffer.channel_layout(), ChannelLayout::Stereo);
assert!(channels(&buffer).eq([[1.0, 2.0], [3.0, 4.0]]));
§Panics
Panics if the length of left
and right
are not equal.
ⓘ
let buffer = BufferData::new_stereo([1.0, 2.0], [3.0]);
Trait Implementations§
Source§impl Buffer for BufferData
impl Buffer for BufferData
Source§fn channel_layout(&self) -> ChannelLayout
fn channel_layout(&self) -> ChannelLayout
The layout of the channels in the buffer.
Source§fn num_frames(&self) -> usize
fn num_frames(&self) -> usize
The number of frames in the buffer. Read more
Source§fn num_channels(&self) -> usize
fn num_channels(&self) -> usize
The number of channels in the buffer.
Source§impl BufferMut for BufferData
impl BufferMut for BufferData
Source§fn channel_mut(&mut self, channel: usize) -> &mut [f32]
fn channel_mut(&mut self, channel: usize) -> &mut [f32]
Get a channel from the buffer as a mutable slice
Source§impl Clone for BufferData
impl Clone for BufferData
Source§fn clone(&self) -> BufferData
fn clone(&self) -> BufferData
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for BufferData
impl RefUnwindSafe for BufferData
impl Send for BufferData
impl Sync for BufferData
impl Unpin for BufferData
impl UnwindSafe for BufferData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more