go-aac

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2026 License: LGPL-3.0

README

go-aac

A pure Go implementation of an AAC (Advanced Audio Codec) decoder supporting ADTS format.

Features

  • Pure Go implementation with no external dependencies
  • Supports AAC-LC (Low Complexity) profile
  • ADTS (Audio Data Transport Stream) format parsing
  • Decodes AAC frames to PCM audio
  • Full implementation of AAC decoding pipeline including:
    • Huffman decoding
    • Inverse quantization
    • Temporal Noise Shaping (TNS)
    • Mid/Side stereo
    • Intensity stereo
    • Channel coupling
    • Modified Discrete Cosine Transform (MDCT)
    • Filterbank processing

Installation

go get github.com/skrashevich/go-aac

Command-Line Tool

The repository includes a command-line tool for converting AAC files to WAV or raw PCM:

go install github.com/skrashevich/go-aac/cmd/aac2pcm@latest
Usage
# Convert AAC to WAV
aac2pcm input.aac output.wav

# Output raw PCM to stdout
aac2pcm --raw input.aac > output.pcm

# Verbose mode with details
aac2pcm -v input.aac output.wav

See cmd/aac2pcm/main.go for a complete example of how to use the library.

Library Usage

The library provides a simple API for decoding AAC audio. See the aac2pcm implementation for a practical example demonstrating:

  1. Probing ADTS data with adts.Probe()
  2. Creating a decoder with decoder.New()
  3. Reading ADTS headers with adts.ReadHeaderFromBytes()
  4. Decoding frames with decoder.DecodeFrame()
  5. Converting float32 samples to int16 PCM
  6. Writing WAV files

Architecture

The decoder is organized into the following packages:

  • decoder: High-level AAC decoder interface
  • adts: ADTS header parsing and validation
  • ics: Individual Channel Stream processing
  • cpe: Channel Pair Element (stereo channels)
  • cce: Coupling Channel Element
  • huffman: Huffman decoding with spectral tables
  • filterbank: IMDCT filterbank processing
  • mdct: Modified Discrete Cosine Transform
  • fft: Fast Fourier Transform
  • tns: Temporal Noise Shaping
  • tables: Lookup tables for AAC decoding

Supported Profiles

  • AAC Main (partially)
  • AAC-LC (Low Complexity) - recommended
  • AAC-LTP (Long Term Prediction) (partially)

Limitations

  • SBR (Spectral Band Replication) / HE-AAC is not supported
  • AAC Main and LTP prediction features are not fully implemented
  • PCE (Program Config Element) is not implemented
  • Gain control is not implemented

License

This project is licensed under the LGPL v3 license, matching the original AAC.js implementation.

Credits

  • Author: Sergei Krashevich
  • Based on AAC.js by Devon Govett and the Audiocogs team

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

Directories

Path Synopsis
cmd
aac2pcm command
pkg
adts
Package adts implements parsing helpers for ADTS headers.
Package adts implements parsing helpers for ADTS headers.
cce
Package cce implements the AAC Channel Coupling Element.
Package cce implements the AAC Channel Coupling Element.
cpe
Package cpe implements the AAC Channel Pair Element.
Package cpe implements the AAC Channel Pair Element.
decoder
Package decoder implements an AAC decoder pipeline.
Package decoder implements an AAC decoder pipeline.
fft
Package fft implements the Fast Fourier Transform used internally by the AAC decoder's MDCT stage.
Package fft implements the Fast Fourier Transform used internally by the AAC decoder's MDCT stage.
filterbank
Package filterbank implements the AAC synthesis filter bank.
Package filterbank implements the AAC synthesis filter bank.
huffman
Package huffman implements AAC Huffman decoding for spectral data and scalefactors.
Package huffman implements AAC Huffman decoding for spectral data and scalefactors.
ics
Package ics implements the Individual Channel Stream decoding for AAC.
Package ics implements the Individual Channel Stream decoding for AAC.
mdct
Package mdct implements the Modified Discrete Cosine Transform (MDCT) used in AAC audio decoding.
Package mdct implements the Modified Discrete Cosine Transform (MDCT) used in AAC audio decoding.
tns
Package tns implements Temporal Noise Shaping for AAC decoding.
Package tns implements Temporal Noise Shaping for AAC decoding.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL