pub struct SampleBuffer {
pub samples: Vec<f32>,
pub channels: u16,
pub sample_rate: u32,
pub frames: usize,
pub path: String,
}Expand description
A decoded audio buffer stored as interleaved f32 samples.
Fields§
§samples: Vec<f32>Interleaved samples (mono or stereo).
channels: u16Number of channels (1=mono, 2=stereo).
sample_rate: u32Original sample rate in Hz.
frames: usizeTotal number of frames (samples / channels).
path: StringFile path this was loaded from.
Implementations§
Source§impl SampleBuffer
impl SampleBuffer
Sourcepub fn load_wav(path: &Path) -> Result<Self, BufferError>
pub fn load_wav(path: &Path) -> Result<Self, BufferError>
Load a WAV file into memory as f32 samples.
Sourcepub fn sample_at(&self, frame: f64) -> f32
pub fn sample_at(&self, frame: f64) -> f32
Get a mono sample at a given frame position (linear interpolation). If stereo, returns the average of both channels.
Sourcepub fn load_wav_reader<R: Read + Seek>(reader: R) -> Result<Self, BufferError>
pub fn load_wav_reader<R: Read + Seek>(reader: R) -> Result<Self, BufferError>
Load a WAV from any Read + Seek source (e.g. an in-memory Cursor<&[u8]>).
This is used by the CLAP plugin to decode audio that was embedded at build time.
Sourcepub fn duration_secs(&self) -> f32
pub fn duration_secs(&self) -> f32
Duration in seconds.
Trait Implementations§
Source§impl Clone for SampleBuffer
impl Clone for SampleBuffer
Source§fn clone(&self) -> SampleBuffer
fn clone(&self) -> SampleBuffer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 SampleBuffer
impl RefUnwindSafe for SampleBuffer
impl Send for SampleBuffer
impl Sync for SampleBuffer
impl Unpin for SampleBuffer
impl UnsafeUnpin for SampleBuffer
impl UnwindSafe for SampleBuffer
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