pub struct AudioBuffer<'a> {
pub samples: &'a [f32],
pub rate: SampleRate,
}Expand description
A borrowed view of a mono PCM buffer in [-1.0, 1.0].
Channel mixing is the caller’s job — every public audiofp API takes mono
f32. Multi-channel inputs must be downmixed (helpers will live in the
streaming module once it lands).
§Example
use audiofp::{AudioBuffer, SampleRate};
let samples = vec![0.0_f32; 16_000];
let buf = AudioBuffer { samples: &samples, rate: SampleRate::HZ_16000 };
assert_eq!(buf.samples.len(), 16_000);
assert_eq!(buf.rate.hz(), 16_000);Fields§
§samples: &'a [f32]Mono samples in [-1.0, 1.0]. Out-of-range values are not rejected
here; downstream code clips or normalises as needed.
rate: SampleRateSample rate the samples were captured at.
Trait Implementations§
Source§impl<'a> Clone for AudioBuffer<'a>
impl<'a> Clone for AudioBuffer<'a>
Source§fn clone(&self) -> AudioBuffer<'a>
fn clone(&self) -> AudioBuffer<'a>
Returns a duplicate 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<'a> Freeze for AudioBuffer<'a>
impl<'a> RefUnwindSafe for AudioBuffer<'a>
impl<'a> Send for AudioBuffer<'a>
impl<'a> Sync for AudioBuffer<'a>
impl<'a> Unpin for AudioBuffer<'a>
impl<'a> UnsafeUnpin for AudioBuffer<'a>
impl<'a> UnwindSafe for AudioBuffer<'a>
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