glint_audio library

Dart FFI bindings for the glint MP3 encoder.

Classes

GlintAacConfig
Mirror of struct glint_aac_config (zero-init the reserved tail).
GlintAacDecoder
ADTS AAC-LC decoder.
GlintAacEncoder
AAC-LC encoder (ADTS output). Same interleaved-PCM conventions as GlintEncoder; one encode call consumes samplesPerFrame (1024) samples per channel and returns one ADTS frame. flush returns the two tail frames and must be called at end of stream (encoder delay: 2048 samples; the first frame is a silence priming frame).
GlintConfig
GlintDecFrameInfo
GlintDecodedAudio
Decoded audio: interleaved float PCM plus its stream parameters.
GlintDecodedAudioI16
Decode a whole encoded stream (MP3 / AAC-LC / Ogg-Opus, format auto- detected from the header) to interleaved float PCM. Throws StateError on unrecognized or corrupt input. Decoded int16 audio.
GlintEncoder
A safe wrapper around the glint MP3 encoder for use via Dart FFI.
GlintMp3Decoder
MPEG-1/2 Layer III decoder.
GlintOpusDecoder
Opus decoder (SILK/CELT/hybrid, PLC, SILK in-band FEC). Output rates 48000/24000/16000/12000/8000; interleaved float32 PCM out.
GlintOpusEncoder
CELT-only Opus encoder: 48 kHz interleaved float32 PCM in, complete Opus packets out. Frame sizes 120/240/480/960 samples per channel.

Enums

GlintCodec
Output codec for glintEncodeAudio.

Functions

glintDecodeAudio(Uint8List data, {int rate = 0}) GlintDecodedAudio
Decode a whole encoded stream (MP3 / AAC-LC / Ogg-Opus, format auto- detected, Opus surround included) to interleaved float PCM. rate resamples the output (0 = keep native). Throws on unrecognized input.
glintDecodeAudioI16(Uint8List data, {int rate = 0}) GlintDecodedAudioI16
Like glintDecodeAudio but returns interleaved int16 PCM.
glintEncodeAudio(Float32List pcm, int channels, int sampleRate, GlintCodec codec, {int bitrate = 128, int? vbrQuality, int quality = 1}) Uint8List
One-call encode: interleaved float 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 in kbps; vbrQuality 0..9 selects VBR.
glintEncodeOpus(Float32List pcm, int channels, {int bitrate = 96000, bool vbr = false}) Uint8List
Encode interleaved 48 kHz float PCM (±1.0, channels = 1 or 2) to a complete Ogg-Opus file (CELT-only, 20 ms frames). vbr selects unconstrained VBR. Input MUST be 48 kHz — resample first with glintResample. Returns the .opus file bytes.
glintReadWav(Uint8List data) GlintDecodedAudio
Read a WAV buffer (PCM 8/16/24/32, IEEE float 32/64, A-law, mu-law, EXTENSIBLE) into interleaved float PCM. Throws StateError on malformed or unsupported input.
glintResample(Float32List pcm, int channels, int srIn, int srOut) Float32List
Resample interleaved float PCM (±1.0) from srIn to srOut with a Kaiser-windowed sinc kernel (anti-aliased, unity passband). pcm is frames * channels interleaved samples. Pass-through (a copy) when the rates match.
glintWriteWav(Float32List pcm, int channels, int sampleRate, {int bits = 16, bool floatFmt = false}) Uint8List
Encode interleaved float PCM (±1.0) to a WAV file buffer. bits: 8/16/24/32 integer PCM, or 32/64 with floatFmt for IEEE float (invalid combos fall back to 16-bit).

Typedefs

GlintAacCreate = Pointer<Void> Function(Pointer<GlintAacConfig> cfg)
GlintAacCreateNative = Pointer<Void> Function(Pointer<GlintAacConfig> cfg)
GlintCheckConfig = int Function(int sampleRate, int bitrate)
GlintCheckConfigNative = Int32 Function(Int32 sampleRate, Int32 bitrate)
GlintCreate = Pointer<Void> Function(Pointer<GlintConfig> cfg)
GlintCreateNative = Pointer<Void> Function(Pointer<GlintConfig> cfg)
GlintDestroy = void Function(Pointer<Void> enc)
GlintDestroyNative = Void Function(Pointer<Void> enc)
GlintEncode = Pointer<Uint8> Function(Pointer<Void> enc, Pointer<Pointer<Int16>> channelData, Pointer<Int32> outSize)
GlintEncodeFloat = Pointer<Uint8> Function(Pointer<Void> enc, Pointer<Pointer<Float>> channelData, Pointer<Int32> outSize)
GlintEncodeFloatNative = Pointer<Uint8> Function(Pointer<Void> enc, Pointer<Pointer<Float>> channelData, Pointer<Int32> outSize)
GlintEncodeNative = Pointer<Uint8> Function(Pointer<Void> enc, Pointer<Pointer<Int16>> channelData, Pointer<Int32> outSize)
GlintFlush = Pointer<Uint8> Function(Pointer<Void> enc, Pointer<Int32> outSize)
GlintFlushNative = Pointer<Uint8> Function(Pointer<Void> enc, Pointer<Int32> outSize)
GlintSamplesPerFrame = int Function(Pointer<Void> enc)
GlintSamplesPerFrameNative = Int32 Function(Pointer<Void> enc)