pub trait Writer<S>: Send + Syncwhere
S: Sample,{
// 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§
Sourcefn sample_rate(&self) -> f64
fn sample_rate(&self) -> f64
Get the sample rate of the writer.
Sourcefn num_channels(&self) -> usize
fn num_channels(&self) -> usize
Get the number of channels of the writer.
Sourcefn can_write(&self) -> bool
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.