Skip to main content

FileCodec

Trait FileCodec 

Source
pub trait FileCodec {
    // Required methods
    fn device(&self) -> Device;
    fn sample_rate(&self) -> u32;
    fn encode_file(
        &self,
        in_audio: &Path,
        out_compressed: &Path,
    ) -> Result<CompressStats>;
    fn decode_file(&self, in_compressed: &Path, out_wav: &Path) -> Result<()>;

    // Provided method
    fn roundtrip_file(
        &self,
        in_audio: &Path,
        out_wav: &Path,
    ) -> Result<CompressStats> { ... }
}
Expand description

A file-level audio compressor: an audio file ⇄ an opaque compressed bitstream on disk. Unlike AudioCodec, there are no in-memory PCM buffers or discrete RVQ codes — the compressed form is a self-contained file (e.g. TSAC’s transformer-entropy-coded .tsac). This is the home for codecs that don’t expose a frame/quantizer structure.

Required Methods§

Source

fn device(&self) -> Device

Backend this codec executes on.

Source

fn sample_rate(&self) -> u32

Native sample rate the codec targets.

Source

fn encode_file( &self, in_audio: &Path, out_compressed: &Path, ) -> Result<CompressStats>

Compress in_audioout_compressed, returning size + timing.

Source

fn decode_file(&self, in_compressed: &Path, out_wav: &Path) -> Result<()>

Decompress in_compressedout_wav.

Provided Methods§

Source

fn roundtrip_file( &self, in_audio: &Path, out_wav: &Path, ) -> Result<CompressStats>

Encode then decode through a temporary compressed file. Codecs with a cheaper native roundtrip may override this.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§