pub struct Chunk { /* private fields */ }Expand description
A buffer of audio samples with associated metadata.
Chunk is the unit of data that flows between DspNodes
in a pipeline. It owns its sample buffer so that nodes can process in-place
without extra allocations.
Samples are stored interleaved when channels > 1:
[L0, R0, L1, R1, ...] for stereo.
§Examples
use resonant_stream::Chunk;
let chunk = Chunk::new(vec![0.0_f32; 1024], 44100, 1);
assert_eq!(chunk.frames(), 1024);
assert_eq!(chunk.sample_rate(), 44100);Implementations§
Source§impl Chunk
impl Chunk
Sourcepub fn new(data: Vec<f32>, sample_rate: u32, channels: u16) -> Self
pub fn new(data: Vec<f32>, sample_rate: u32, channels: u16) -> Self
Creates a new chunk from interleaved sample data.
§Panics
Panics if channels is zero or sample_rate is zero.
Sourcepub fn empty(sample_rate: u32, channels: u16) -> Self
pub fn empty(sample_rate: u32, channels: u16) -> Self
Creates an empty chunk with the given format.
§Panics
Panics if channels is zero or sample_rate is zero.
Sourcepub fn data_mut(&mut self) -> &mut [f32]
pub fn data_mut(&mut self) -> &mut [f32]
Returns a mutable reference to the interleaved sample data.
Sourcepub fn sample_rate(&self) -> u32
pub fn sample_rate(&self) -> u32
The sample rate in Hz.
Trait Implementations§
impl StructuralPartialEq for Chunk
Auto Trait Implementations§
impl Freeze for Chunk
impl RefUnwindSafe for Chunk
impl Send for Chunk
impl Sync for Chunk
impl Unpin for Chunk
impl UnsafeUnpin for Chunk
impl UnwindSafe for Chunk
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