# @audio/decode-ac3

> Decode AC-3 (Dolby Digital) audio with liba52 WASM

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

## Install

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

## 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.0.0 |
| Published | 2026-08-27 |
| First published | 2026-08-27 |
| Weekly downloads | 0 |
| License | GPL-2.0-or-later |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 69.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 208 |
| Author | audiojs |
| Maintainers | jamen, dfcreative, dy |
| Keywords | ac3, ac-3, dolby, a52, surround, 5.1, audio, decode, decoder, wasm, liba52 |

## Links

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

## 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.0.0 (latest) — 2026-08-27

## README

# @audio/decode-ac3

Decode AC-3 (Dolby Digital) to PCM float samples.<br>
[liba52](https://code.videolan.org/videolan/liba52) compiled to a single-file WASM ES module — no side files, loads from any CDN, Node, workers and AudioWorklets.

[![npm install @audio/decode-ac3](https://nodei.co/npm/@audio/decode-ac3.png?mini=true)](https://npmjs.org/package/@audio/decode-ac3/)

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

let { channelData, sampleRate } = await decode(ac3Bytes)

let dec = await decoder()
let head = dec.decode(chunk1)   // synchronous; partial frames carry over
let tail = dec.flush()
dec.free()
```

Input is a raw AC-3 frame stream (`.ac3`, or the frames a container demuxer extracts — [@audio/decode-mp4](../decode-mp4), [@audio/decode-webm](../decode-webm) and [@audio/decode-avi](../decode-avi) route their AC-3 tracks here). The stream's own layout is kept, up to 5.1; channels come out in WAV order: FL, FR, FC, LFE, BL, BR (surround-only or mono as present). Output level is full scale, no dialnorm applied.

E-AC-3 (Dolby Digital Plus) is a different codec and is not decoded.

## API

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

Decode a complete stream.

### `decoder(): Promise<AC3Decoder>`

Synchronous streaming decoder: `decode(chunk)` returns the samples of every complete frame in the data so far, `flush()` drops a trailing partial frame, `free()` releases WASM memory. `errors` counts frames that failed to decode.

### `AudioData`

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

## License

[ॐ](https://github.com/krishnized/license/) · [GPL-2.0-or-later](./LICENSE), inherited from the bundled [liba52](./LICENSE.liba52).

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