Trait Writer

Source
pub trait Writer<S: Sample>: Send + Sync {
    // Required methods
    fn sample_rate(&self) -> f64;
    fn num_channels(&self) -> usize;
    fn can_write(&self) -> bool;
    fn write_channel(
        &mut self,
        channel_index: usize,
        samples: &[S],
    ) -> Result<(), Box<dyn Error>>;
    fn finalize(&mut self) -> Result<(), Box<dyn Error>>;
}
Expand description

Trait for writing audio data to files.

Implementations handle encoding and file format specifics. Call finalize when done to ensure proper file closure.

Required Methods§

Source

fn sample_rate(&self) -> f64

Get the sample rate of the writer.

Source

fn num_channels(&self) -> usize

Get the number of channels of the writer.

Source

fn can_write(&self) -> bool

Check whether the writer can write to audio an audio file. This is useful for particular audio files that use closing byte signatures, unlike WAV files which can usually be appended with more audio data at any time.

Source

fn write_channel( &mut self, channel_index: usize, samples: &[S], ) -> Result<(), Box<dyn Error>>

Write samples to a specified channel.

Source

fn finalize(&mut self) -> Result<(), Box<dyn Error>>

Finalize the writing of an audio file.

Implementors§