audio

@audio/decode-flac2.0.0

Decode FLAC audio with libFLAC WASM

Status
calibrated
Updated
Family
decode, 24 packages under it
Category
codecs
Licence
MIT AND BSD-3-Clause AND LGPL-3.0-or-later AND Zlib
Bundles
codec-parser, gpl-3.0, libflac, simple-yenc, wasm-audio-decoders
Dependencies
none
Downloads
737,242 last month
Tests
at least 88 in audiojs/decode's CI, passed at 58c36d8,

Decode raw FLAC and Ogg FLAC audio with @wasm-audio-decoders/flac.

import decode, { decoder } from '@audio/decode-flac'

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

let dec = await decoder() // initialize WASM
let a = dec.decode(chunk1)
let b = dec.decode(chunk2)
let tail = dec.flush()
dec.free()

decoder() initializes asynchronously. decode() and flush() are synchronous. decode() accepts consecutive raw FLAC and complete Ogg FLAC files. Raw FLAC may omit the STREAMINFO sample total. For chunked input, flush() ends the decoder.

License

ॐ · MIT. decode-flac.js bundles libFLAC, BSD-3-Clause (LICENSE.libflac); codec-parser, LGPL-3.0-or-later (LICENSE.codec-parser); @wasm-audio-decoders, MIT, with puff, zlib (LICENSE.wasm-audio-decoders); simple-yenc, MIT (LICENSE.simple-yenc). The bundled codec-parser is version 2.5.0, and this repository's build.sh builds decode-flac.js from src/decode-flac.src.js with esbuild, so it can be rebuilt with a modified codec-parser; the GNU GPL that the LGPL-3.0 supplements is in LICENSE.gpl-3.0.