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§
Sourcefn sample_rate(&self) -> u32
fn sample_rate(&self) -> u32
Native sample rate the codec targets.
Sourcefn encode_file(
&self,
in_audio: &Path,
out_compressed: &Path,
) -> Result<CompressStats, Error>
fn encode_file( &self, in_audio: &Path, out_compressed: &Path, ) -> Result<CompressStats, Error>
Compress in_audio → out_compressed, returning size + timing.
Provided Methods§
Sourcefn roundtrip_file(
&self,
in_audio: &Path,
out_wav: &Path,
) -> Result<CompressStats, Error>
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§
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.