npm.io
1.3.1 • Published 4d ago

@audio/decode-opus

Licence
MIT
Version
1.3.1
Deps
1
Size
179 kB
Vulns
0
Weekly
0
Stars
208

@audio/decode-opus

Decode Ogg Opus audio to PCM samples with libopus WASM.

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

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

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

decoder() is asynchronous. Its decode() and flush() methods are synchronous. flush() ends the stream.

Metadata

Read OpusTags metadata and cover art without decoding audio:

import { parseMeta } from '@audio/decode-opus/meta'

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

License

· MIT. Bundled libopus is BSD 3-Clause.

Keywords