Expand description
Safe Rust wrapper for the glint MP3 encoder.
Structs§
- AacDecoder
- ADTS AAC-LC decoder.
- AacEncoder
- AAC-LC encoder (ADTS output). Same interleaved-PCM conventions as
Encoder; oneencodecall consumessamples_per_frame()(1024) samples per channel and returns one ADTS frame.flushreturns the two tail frames and must be called at end of stream (encoder delay: 2048 samples; the first frame is a silence priming frame). - DecFrame
Info - A decoded frame’s stream parameters.
- Decoded
Audio - Decoded audio: interleaved f32 PCM plus its stream parameters.
- Encoder
- A safe wrapper around the glint MP3 encoder.
- Mp3Decoder
- MPEG-1/2 Layer III decoder (keeps a bit reservoir across frames).
- Opus
Decoder - Opus decoder (SILK/CELT/hybrid, PLC, SILK in-band FEC), output rates 8/12/16/24/48 kHz, interleaved f32 PCM out.
- Opus
Encoder - CELT-only Opus encoder: 48 kHz interleaved f32 PCM in, complete Opus packets out. Frame sizes 120/240/480/960 samples per channel.
Enums§
- Codec
- Output codec for
encode_audio.
Functions§
- decode_
audio - Decode a whole encoded stream (MP3 / AAC-LC / Ogg-Opus / Ogg-Vorbis /
FLAC, format auto-detected from the header) to interleaved f32 PCM.
Returns
Noneon unrecognized or corrupt input. - decode_
audio_ i16 - Decode a whole stream to interleaved i16 PCM, resampled to
out_rate(0 = keep native). Returns (pcm, sample_rate, channels). - decode_
audio_ rate - Decode a whole stream to interleaved f32 PCM, resampled to
out_rate(0 = keep native). Auto-detects MP3/AAC/Opus/Vorbis/FLAC (incl. Opus surround). - decode_
flac - Decode a complete in-memory native FLAC stream to interleaved f32 PCM at
its native rate.
decode_audioalso decodes FLAC transparently. - decode_
vorbis - Decode a complete in-memory Ogg-Vorbis I stream (identification +
comment + setup headers followed by audio packets) to interleaved f32
PCM at its native rate — the shape the
.sf3soundfont sample path needs. MirrorsOpusDecoder;decode_audioalso decodes Vorbis transparently. ReturnsNoneon a non-Vorbis or corrupt buffer. - encode_
audio - One-call encode: interleaved f32 PCM (±1.0) at any rate / 1-2 channels
-> a complete MP3 / AAC-LC / Ogg-Opus stream. The input is auto-
resampled to a codec-valid rate (Opus->48k, MP3/AAC->nearest
supported).
bitrate_kbpsis the CBR/target rate;vbr_qualitySome(0..9) selects VBR. ReturnsNoneon error. - encode_
opus_ file - Encode interleaved 48 kHz f32 PCM (±1.0,
framesper channel, 1-2 channels) to a complete Ogg-Opus file (CELT-only, 20 ms frames).vbrselects unconstrained VBR. Input MUST be 48 kHz — resample first withresample. ReturnsNoneon error. - encode_
pcm - Convenience function: encode an entire buffer of interleaved 16-bit PCM to MP3 in one call.
- encode_
pcm_ aac - Convenience function: encode an entire buffer of interleaved 16-bit PCM to AAC (ADTS) in one call. quality: 0 speed / 1 normal / 2 best.
- read_
wav - Read a WAV buffer (PCM 8/16/24/32, IEEE float 32/64, A-law, mu-law,
EXTENSIBLE) into interleaved f32 PCM. Returns
Noneon malformed or unsupported input. - resample
- Resample interleaved f32 PCM (±1.0) from
sr_intosr_outwith a Kaiser-windowed sinc kernel (anti-aliased, unity passband).pcmisframes * channelsinterleaved samples; returns the resampled buffer. Pass-through (a clone) when the rates match. - write_
wav - Encode interleaved f32 PCM (±1.0) to a WAV file buffer.
bits: 8/16/24/32 integer PCM, or 32/64 withfloat_fmtfor IEEE float (invalid combos fall back to 16-bit). ReturnsNoneon error.