audioJS

@audio/decode-dts

Status calibrated

npm1.0.0licenseGPL-2.0-or-later

Decode DTS (DTS Coherent Acoustics core) audio with libdca WASM

Overview

Install
Updated
Family
decode, 25 packages under it

Decode DTS (DTS Coherent Acoustics) to PCM float samples.
libdca compiled to a single-file WASM ES module — no side files, loads from any CDN, Node, workers and AudioWorklets.

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

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

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

Input is a raw DTS core frame stream (.dts, or the frames a container demuxer extracts — @audio/decode-mp4, @audio/decode-webm and @audio/decode-avi route their DTS 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,

DTS-HD Master Audio and High Resolution streams decode through their lossy core; the extension substreams are skipped. 14-bit and little-endian sync variants are handled.

API

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

Decode a complete stream.

decoder(): Promise<DTSDecoder>

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

{ channelData: Float32Array[], sampleRate: number }

License

ॐ · GPL-2.0-or-later, inherited from the bundled libdca.