pub struct AudioFrame { /* private fields */ }Expand description
Owned, tightly packed planar floating-point audio with a validated layout.
Channel samples are contiguous, with channels stored one after another. Conversion from borrowed SDK audio omits inter-channel padding.
Implementations§
Source§impl AudioFrame
impl AudioFrame
Sourcepub fn builder() -> AudioFrameBuilder
pub fn builder() -> AudioFrameBuilder
Create a builder for configuring an audio frame
Sourcepub fn sample_rate(&self) -> i32
pub fn sample_rate(&self) -> i32
Get the sample rate in Hz.
Sourcepub fn num_channels(&self) -> i32
pub fn num_channels(&self) -> i32
Get the number of audio channels.
Sourcepub fn num_samples(&self) -> i32
pub fn num_samples(&self) -> i32
Get the number of samples per channel.
Sourcepub fn timecode(&self) -> i64
pub fn timecode(&self) -> i64
Get the timecode in 100 ns units.
Defaults to the SDK’s synthesized-timecode sentinel. An explicit zero is passed through as a literal timecode.
Sourcepub fn timestamp(&self) -> i64
pub fn timestamp(&self) -> i64
Get the receive timestamp in 100 ns units since the Unix epoch.
On receive the SDK supplies this value, or its undefined-timestamp sentinel when unavailable. Outbound values are passed through unchanged; the SDK defines this field for receiving.
Sourcepub fn format(&self) -> AudioFormat
pub fn format(&self) -> AudioFormat
Get the audio format.
Sourcepub fn channel_stride_in_bytes(&self) -> i32
pub fn channel_stride_in_bytes(&self) -> i32
Get the channel stride in bytes.
Sourcepub fn data(&self) -> &[f32]
pub fn data(&self) -> &[f32]
Get tightly packed planar audio as 32-bit floats. Each channel’s samples are contiguous; channels follow one another.
Sourcepub fn data_mut(&mut self) -> &mut [f32]
pub fn data_mut(&mut self) -> &mut [f32]
Get mutable audio sample data without changing the validated layout.
Sourcepub fn replace_data(&mut self, data: Vec<f32>) -> Result<()>
pub fn replace_data(&mut self, data: Vec<f32>) -> Result<()>
Replace the owned audio data while preserving the validated layout.
§Errors
Returns Error::InvalidFrame if data is not exactly the validated
sample count.
Sourcepub fn set_metadata<S: Into<String>>(
&mut self,
metadata: Option<S>,
) -> Result<()>
pub fn set_metadata<S: Into<String>>( &mut self, metadata: Option<S>, ) -> Result<()>
Replace frame metadata.
§Errors
Returns Error::InvalidCString if metadata contains an interior NUL
byte, or Error::InvalidFrame if the emitted C string would exceed
the metadata size cap.
Sourcepub fn channel_data(&self, channel: usize) -> Option<&[f32]>
pub fn channel_data(&self, channel: usize) -> Option<&[f32]>
Get audio data for a specific channel
Data is always stored in planar format internally. If AudioLayout::Interleaved
was specified at build time, the data was converted to planar during construction.
Sourcepub fn channel_data_mut(&mut self, channel: usize) -> Option<&mut [f32]>
pub fn channel_data_mut(&mut self, channel: usize) -> Option<&mut [f32]>
Get mutable samples for one channel without allocating.