pub struct AudioChunk {
format: AudioFormat,
samples: Vec<f32>,
pts: MediaTime,
duration: MediaDuration,
}Expand description
One timestamped chunk of normalized f32 audio.
Sample buffer is interleaved (planar-per-frame): [L₀, R₀, L₁, R₁, …] for stereo. Mono is [s₀, s₁, …]. Duration is derived from
samples.len() / channels / sample_rate.
Fields§
§format: AudioFormat§samples: Vec<f32>§pts: MediaTime§duration: MediaDurationImplementations§
Source§impl AudioChunk
impl AudioChunk
Sourcepub fn new(
format: AudioFormat,
samples: Vec<f32>,
pts: MediaTime,
) -> Result<Self, AudioChunkError>
pub fn new( format: AudioFormat, samples: Vec<f32>, pts: MediaTime, ) -> Result<Self, AudioChunkError>
Validate + construct. Fails when channel count is zero, sample
rate is zero, or samples.len() isn’t a multiple of channels.
Sourcepub fn format(&self) -> AudioFormat
pub fn format(&self) -> AudioFormat
Format of the carried samples.
Sourcepub fn frame_count(&self) -> usize
pub fn frame_count(&self) -> usize
Number of frames (samples-per-channel) in the buffer.
Sourcepub fn pts(&self) -> MediaTime
pub fn pts(&self) -> MediaTime
Presentation timestamp — when this chunk’s first sample occurs on the media timeline.
Sourcepub fn duration(&self) -> MediaDuration
pub fn duration(&self) -> MediaDuration
Derived duration of the chunk.
Trait Implementations§
Source§impl Clone for AudioChunk
impl Clone for AudioChunk
Source§fn clone(&self) -> AudioChunk
fn clone(&self) -> AudioChunk
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 moreSource§impl Debug for AudioChunk
impl Debug for AudioChunk
Source§impl PartialEq for AudioChunk
impl PartialEq for AudioChunk
Source§fn eq(&self, other: &AudioChunk) -> bool
fn eq(&self, other: &AudioChunk) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for AudioChunk
Auto Trait Implementations§
impl Freeze for AudioChunk
impl RefUnwindSafe for AudioChunk
impl Send for AudioChunk
impl Sync for AudioChunk
impl Unpin for AudioChunk
impl UnsafeUnpin for AudioChunk
impl UnwindSafe for AudioChunk
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