pub struct AudioClip { /* private fields */ }Expand description
Decoded PCM held in memory, ready to play with no further work.
Samples are interleaved f32 in -1.0..=1.0, one or two channels. The
buffer sits behind an Arc so handing a clip to the audio thread is a
refcount bump rather than a copy.
Implementations§
Source§impl AudioClip
impl AudioClip
Sourcepub const MAX_FRAMES: usize
pub const MAX_FRAMES: usize
The largest clip the framework accepts, guarding a malformed header from turning into a multi-gigabyte allocation.
Sourcepub fn from_samples(
samples: Vec<f32>,
channels: u16,
sample_rate: u32,
) -> Result<AudioClip, AudioError>
pub fn from_samples( samples: Vec<f32>, channels: u16, sample_rate: u32, ) -> Result<AudioClip, AudioError>
Wraps already-decoded interleaved samples.
Sourcepub fn decode(bytes: &[u8]) -> Result<AudioClip, AudioError>
pub fn decode(bytes: &[u8]) -> Result<AudioClip, AudioError>
Decodes an encoded clip. RIFF/WAVE is understood everywhere; anything
else reports AudioError::UnsupportedFormat.
Run this wherever the bytes arrive — including a worker thread — and
hand the result to AudioPlayer::load_clip when it is ready.
The shared sample buffer, for a backend that keeps its own reference.
Sourcepub fn sample_rate(&self) -> u32
pub fn sample_rate(&self) -> u32
The clip’s recorded sample rate in Hz.
Sourcepub fn duration_secs(&self) -> f32
pub fn duration_secs(&self) -> f32
Playing length in seconds at unity rate.