pub struct AudioBuffer {
pub sample_rate: u32,
pub data: Vec<Vec<f32>>,
}Expand description
Planar f32 audio: one Vec<f32> per channel, all the same length.
Fields§
§sample_rate: u32§data: Vec<Vec<f32>>Implementations§
Source§impl AudioBuffer
impl AudioBuffer
Sourcepub fn from_planar(sample_rate: u32, data: Vec<Vec<f32>>) -> Self
pub fn from_planar(sample_rate: u32, data: Vec<Vec<f32>>) -> Self
Build from planar channels. Shorter channels are zero-padded to the longest.
pub fn from_mono(sample_rate: u32, samples: Vec<f32>) -> Self
pub fn from_interleaved( sample_rate: u32, channels: usize, samples: &[f32], ) -> Self
pub fn to_interleaved(&self) -> Vec<f32>
pub fn channels(&self) -> usize
pub fn frames(&self) -> usize
pub fn duration_s(&self) -> f64
pub fn is_empty(&self) -> bool
Sourcepub fn slice(&self, start: usize, end: usize) -> AudioBuffer
pub fn slice(&self, start: usize, end: usize) -> AudioBuffer
Frames [start, end), clamped to the buffer.
Sourcepub fn append(&mut self, other: &AudioBuffer)
pub fn append(&mut self, other: &AudioBuffer)
Append another buffer with the same channel count (extra channels are dropped, missing ones are filled from the last channel).
pub fn peak(&self) -> f32
pub fn rms(&self) -> f32
Sourcepub fn with_channels(&self, n: usize) -> AudioBuffer
pub fn with_channels(&self, n: usize) -> AudioBuffer
Change the channel count: mono→N duplicates, N→mono averages, otherwise truncates or repeats the last channel.
pub fn info(&self) -> BufferInfo
Trait Implementations§
Source§impl Clone for AudioBuffer
impl Clone for AudioBuffer
Source§impl Debug for AudioBuffer
impl Debug for AudioBuffer
Source§impl PartialEq for AudioBuffer
impl PartialEq for AudioBuffer
impl StructuralPartialEq for AudioBuffer
Auto Trait Implementations§
impl Freeze for AudioBuffer
impl RefUnwindSafe for AudioBuffer
impl Send for AudioBuffer
impl Sync for AudioBuffer
impl Unpin for AudioBuffer
impl UnsafeUnpin for AudioBuffer
impl UnwindSafe for AudioBuffer
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