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, Error>;
    fn decode_file(
        &self,
        in_compressed: &Path,
        out_wav: &Path,
    ) -> Result<(), Error>;

    // Provided method
    fn roundtrip_file(
        &self,
        in_audio: &Path,
        out_wav: &Path,
    ) -> Result<CompressStats, Error> { ... }
}
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, Error>

Compress in_audioout_compressed, returning size + timing.

Source

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

Decompress in_compressedout_wav.

Provided Methods§

Source

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

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§

Source§

impl FileCodec for TsacCodec

Unified rlx_core::FileCodec view of TSAC (file-bitstream compressor). TSAC has no RVQ codes, so it implements FileCodec rather than the frame/quantizer rlx_core::AudioCodec trait used by mimi/dac.