# @audio/decode-aac

> Decode AAC/M4A (FAAD2 WASM) and ALAC/Apple Lossless (pure JS) to PCM samples

Latest version **1.5.0** (published 2026-08-27) · GPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install @audio/decode-aac
pnpm add @audio/decode-aac
yarn add @audio/decode-aac
bun add @audio/decode-aac
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.5.0 |
| Published | 2026-08-27 |
| First published | 2026-04-04 |
| Weekly downloads | 0 |
| License | GPL-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 393.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 208 |
| Author | audiojs |
| Maintainers | jamen, dfcreative, dy |
| Keywords | aac, m4a, mp4, audio, decode, decoder, wasm, faad2, alac, apple lossless, lossless |

## Links

- npm: https://www.npmjs.com/package/@audio/decode-aac
- Repository: https://github.com/audiojs/decode
- Homepage: https://github.com/audiojs/decode/tree/master/packages/decode-aac#readme
- Issues: https://github.com/audiojs/decode/issues
- Funding: https://github.com/sponsors/audiojs
- npm.io page: https://npm.io/package/@audio/decode-aac

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.5.0 (latest) — 2026-08-27
- 1.4.0 — 2026-08-11
- 1.3.4 — 2026-07-14
- 1.3.3 — 2026-07-14
- 1.3.2 — 2026-07-11
- 1.3.1 — 2026-07-10
- 1.3.0 — 2026-07-10
- 1.2.0 — 2026-06-22
- 1.1.3 — 2026-04-18
- 1.1.2 — 2026-04-17
- 1.1.1 — 2026-04-11
- 1.1.0 — 2026-04-05
- 1.0.2 — 2026-04-04

## README

# @audio/decode-aac

Decode AAC/M4A and ALAC audio to PCM float samples. FAAD2 WASM handles AAC; a pure-JS port of Apple's reference decoder handles ALAC. The M4A sample entry selects the codec.

## Install

```
npm i @audio/decode-aac
```

## Usage

```js
import decode from '@audio/decode-aac'

// M4A or raw ADTS; auto-detected
let { channelData, sampleRate } = await decode(uint8array)
// channelData: Float32Array[] (one per channel)
// sampleRate: number
```

### Streaming

```js
import { decoder } from '@audio/decode-aac'

let dec = await decoder()
let { channelData, sampleRate } = dec.decode(chunk)
dec.free()
```

`decoder()` is asynchronous. Its `decode()` and `flush()` methods are synchronous.

## API

### `decode(src: Uint8Array | ArrayBuffer): Promise<AudioData>`

Whole-file decode. Auto-detects M4A (MP4 container) vs raw ADTS.

### `decoder(opts?): Promise<AACDecoder>`

Creates a decoder instance for manual control.

- `dec.decode(data)`: decode a `Uint8Array` or `ArrayBuffer` chunk.
- `dec.flush()`: discard buffered partial data and return an empty result.
- `dec.free()`: release WASM memory.

Without options the byte stream is auto-detected (M4A or ADTS). Container demuxers that hold the codec config out-of-band pass it up-front and feed raw access units — one frame, or an array of frames, per `decode()` call:

```js
let dec = await decoder({ asc })   // AudioSpecificConfig (esds, Matroska CodecPrivate, WAVEFORMATEX extra bytes)
let dec = await decoder({ alac })  // ALAC magic cookie
```

This is how [@audio/decode-mp4](../decode-mp4), [@audio/decode-webm](../decode-webm) and [@audio/decode-avi](../decode-avi) decode AAC and ALAC tracks from video files.

### `AudioData`

```ts
{ channelData: Float32Array[], sampleRate: number }
```

## Formats

- M4A / MP4 / MOV with AAC audio (LC and HE-AAC v1/v2 with SBR or PS) — QuickTime sound descriptions v0, v1 and v2
- M4A / MP4 with bit-exact pure-JS ALAC decoding at 16, 20, 24, or 32 bits
- Raw ADTS streams (.aac)

## Metadata

```js
import { parseMeta } from '@audio/decode-aac/meta'

let { meta, sampleRate } = parseMeta(m4aBytes)
// meta: { title, artist, album, year, genre, track, ..., pictures }
```

## License

[ॐ](https://github.com/krishnized/license/) · AAC decoding [GPL-2.0](./LICENSE) (FAAD2), ALAC decoding Apache-2.0 (port of Apple's ALAC reference)

---
_Source: https://npm.io/package/@audio/decode-aac · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
