Skip to main content

AudioSource

Trait AudioSource 

Source
pub trait AudioSource: Send + Sync {
    // Required methods
    fn sample_rate(&self) -> u32;
    fn channels(&self) -> u16;
    fn read(&self, start_frame: u64, output: &mut [f32]) -> usize;
    fn duration(&self) -> Option<Duration>;

    // Provided methods
    fn composition(&self) -> Option<&Timeline> { ... }
    fn file_path(&self) -> Option<&Path> { ... }
    fn try_read(&self, start_frame: u64, output: &mut [f32]) -> Result<usize> { ... }
}
Expand description

A pure, concurrent random-access interleaved PCM source. Repeated reads must not depend on prior requests. Implementations return frames, never samples; EOF/short reads leave the rest of the caller’s buffer silent.

Required Methods§

Source

fn sample_rate(&self) -> u32

Native PCM sampling frequency, in frames per second.

Source

fn channels(&self) -> u16

Interleaved channel count; mixing supports mono and stereo.

Source

fn read(&self, start_frame: u64, output: &mut [f32]) -> usize

Reads complete frames at an absolute source offset. The return value must not exceed output.len()/channels; all returned samples must be finite.

Source

fn duration(&self) -> Option<Duration>

Finite source duration, or None for a procedurally unbounded source.

Provided Methods§

Source

fn composition(&self) -> Option<&Timeline>

Deferred child mix, resolved by the encoding boundary before PCM queries.

Source

fn file_path(&self) -> Option<&Path>

Optional local file identity, used by execution boundaries for lazy decoding.

Source

fn try_read(&self, start_frame: u64, output: &mut [f32]) -> Result<usize>

Checked reads let file-backed sources propagate decoding failures.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<Source: AudioSource + ?Sized> AudioSource for Arc<Source>

Source§

fn composition(&self) -> Option<&Timeline>

Source§

fn file_path(&self) -> Option<&Path>

Source§

fn try_read(&self, start: u64, output: &mut [f32]) -> Result<usize>

Source§

fn sample_rate(&self) -> u32

Source§

fn channels(&self) -> u16

Source§

fn read(&self, start: u64, output: &mut [f32]) -> usize

Source§

fn duration(&self) -> Option<Duration>

Implementors§