pub struct AudioFrame {
pub format: SampleFormat,
pub sample_rate: u32,
pub channels: u16,
pub data: Vec<f32>,
}Expand description
A block of interleaved PCM audio — std/media/v1/AudioFrame[sample=…].
Samples are interleaved across channels (frame 0 ch 0, frame 0 ch 1, …),
which is the layout a capture ring buffer already holds.
Fields§
§format: SampleFormatThe sample format, which selects the sample column’s type.
sample_rate: u32Frames per second.
channels: u16How many channels are interleaved.
data: Vec<f32>The interleaved samples, as 32-bit floats regardless of the wire format — the one shape every audio pipeline can consume, converted on encode.
Implementations§
Source§impl AudioFrame
impl AudioFrame
Sourcepub fn new(
format: SampleFormat,
sample_rate: u32,
channels: u16,
data: Vec<f32>,
) -> Result<Self>
pub fn new( format: SampleFormat, sample_rate: u32, channels: u16, data: Vec<f32>, ) -> Result<Self>
A frame of interleaved f32 samples.
§Errors
DataError::ChildLengthMismatch when the sample count is not a
whole number of interleaved frames.
Sourcepub fn frame_count(&self) -> usize
pub fn frame_count(&self) -> usize
How many interleaved frames the block holds.
Sourcepub fn to_record_batch(&self) -> Result<RecordBatch>
pub fn to_record_batch(&self) -> Result<RecordBatch>
Encodes the frame as a one-row payload batch, converting the samples into the format’s own column type.
§Errors
As AudioFrame::check, plus DataError when the columns cannot be
assembled.