Expand description
Audio codec framework.
Squad-24 (2026-04-17 PM5): adds the decoder/encoder traits + the wire types Squad-23 (audio mux pipeline) consumes. Decoders cover MP3 and Vorbis (mux already handles AAC/Opus/AC-3 passthrough — no decode needed for those). The encoder side currently exposes Opus only; the user decision on the audio expansion in TODO.md picked Opus over AAC because the libopus binding is BSD/Apache, modern browsers all play Opus-in-MP4, and the iOS-13-and-older floor is acceptable.
§Wire model
AudioFrameis the canonical PCM exchange type: f32 in [-1.0, 1.0], interleaved planar layout (LRLRLR for stereo), with the source sample rate and channel count carried alongside the samples and a microsecond-domain PTS.EncodedAudioPacketcarries one encoder output packet plus PTS/duration in encoder timescale (Opus = 48000 ticks per second per RFC 7845 §4.1).AudioDecoder/AudioEncodertraits are object-safe so pipeline code can hand outBox<dyn AudioEncoder>.
§Pre-skip + extra_data contract (Opus-specific)
AudioEncoder::pre_skip returns the number of 48 kHz samples of
lookahead the libopus encoder injects (queried via
OPUS_GET_LOOKAHEAD and reported in 48 kHz ticks no matter the
configured rate). Squad-23’s mux side writes this into the dOps
body so a conformant decoder discards the lookahead at the start of
the file.
AudioEncoder::extra_data returns the dOps body bytes per RFC
7845 §4.5: 11 bytes minimum, channel-mapping family 0 (mono/stereo).
Multistream (>2 channels) is out of scope for this sprint and
returns AudioError::Unsupported.
Modules§
- decode
- Audio decoder implementations.
- encode
- Audio encoder implementations.
- resample
- Sample-rate conversion using rubato’s
SincFixedIn(high-quality windowed-sinc with band-limited interpolation).
Structs§
- Audio
Encoder Config - Audio
Frame - One decoded audio frame.
- Encoded
Audio Packet - One encoded audio packet leaving the encoder.
Enums§
Traits§
Functions§
- create_
decoder - Construct an audio decoder for the given codec name.
- create_
encoder - Construct an audio encoder.