audio-decode
v3.5.0
Published
Decode audio data in node or browser
Readme
audio-decode 
Decode any audio format to raw samples. JS / WASM – no ffmpeg, no native bindings, works in both node and browser. Small API, minimal size, near-native performance, lazy-loading, chunked decoding.
import decode from 'audio-decode';
const { channelData, sampleRate } = await decode(anyAudioBuffer);Supported formats:
| Format | Package | Engine | |--------|---------|--------| | MP3 | mpg123-decoder | WASM | | WAV | node-wav | JS | | OGG Vorbis | @wasm-audio-decoders/ogg-vorbis | WASM | | FLAC | @wasm-audio-decoders/flac | WASM | | Opus | ogg-opus-decoder | WASM | | M4A / AAC | @audio/aac-decode | WASM | | QOA | qoa-format | JS | | AIFF | @audio/aiff-decode | JS | | CAF | @audio/caf-decode | JS | | WebM | @audio/webm-decode | JS + WASM | | AMR | @audio/amr-decode | WASM | | WMA | @audio/wma-decode | WASM |
Whole-file
Auto-detects format. Input can be ArrayBuffer, Uint8Array, or Buffer.
import decode from 'audio-decode'
let { channelData, sampleRate } = await decode(buf)Chunked
let dec = await decode.mp3()
let a = await dec(chunk1) // { channelData, sampleRate }
let b = await dec(chunk2)
await dec() // closeStreaming
With ReadableStream, fetch, or Node stream:
import decodeStream from 'audio-decode/stream'
for await (let { channelData, sampleRate } of decodeStream(response.body, 'mp3')) {
// process chunks
}Formats: mp3, flac, opus, oga, m4a, wav, qoa, aac, aiff, caf, webm, amr, wma.
See also
- audio-type – detect audio format from buffer.
- wasm-audio-decoders – compact & fast WASM audio decoders.
- AudioDecoder – native WebCodecs decoder API.
- decodeAudioData – built-in browser decoding method.
- ffmpeg.wasm – full encoding/decoding library.
License
ॐ

