Skip to main content
TypeScript bindings for metadata parsing (40+ formats), the DSP pipeline (EQ, tone, surround, compressor, ReplayGain, resampler), and a queue-based player with crossfade, shuffle/repeat, and the full Rockbox DSP chain (EQ presets, tone, crossfeed, surround, compressor, …). One typed API, three runtimes.
Import the entry point for your runtime — all three expose the identical API:
Prefer one import that resolves the right backend at runtime? Use import { load } from "rockbox-ffi" — it returns a promise for the correct runtime backend.
The published package bundles a prebuilt native library per platform. From a repo checkout, point at your own build with ROCKBOX_FFI_LIB.

Quick start

Decode a file to PCM

Decoder streams one audio file through the Rockbox codec engine, yielding interleaved-stereo S16LE PCM (Int16Array) one chunk at a time — no output device required. Same Metadata shape as metadata.read.
Seek with dec.seekMs(ms) and read the codec’s position with dec.elapsedMs().
Codec state is process-wide — only one Decoder decodes at a time. Constructing a second Decoder blocks until the first is closed (via close(), or automatically at the end of a using scope).

API

Everything is fully typed — your editor has the details. metadata Dsp — interleaved-S16LE-stereo processor. Construct with a sample rate, feed it Int16Arrays, and close() (or using) when done. Decoder — streaming file decoder. Construct with a path, pull PCM with nextChunk(), and close() (or using) when done. Only one may decode at a time (see Decode a file to PCM). Player — queue, transport, crossfade, shuffle/repeat, the full DSP chain, and status(). Every mutating method returns this, so calls chain fluently (see the quick start); getters and close() return their own values. Enums Exported constant objects to pass to the setters above: DspReplayGainMode, ReplayGainMode, CrossfadeMode, MixMode, CrossfeedMode, InsertPosition, ChannelConfig, ChannelMode, EqPreset, and RepeatMode.
The EqPreset presets, tone/crossfeed/surround/compressor controls, and their value ranges mirror Rockbox’s own sound-settings menu — see the official Rockbox manual for what each effect does.
Dsp.setReplaygain and Player.setReplaygain use different mode integers. Pass the exported enums — DspReplayGainMode for the DSP, ReplayGainMode for the player. See the overview.