Rockbox DSP, metadata, and playback in Go via purego over the librockbox_ffi C ABI — no cgo.
go get github.com/tsirysndr/rockboxd/bindings/go
Requires Go 1.22+. Calls the native engine through
purego — no cgo and no C
toolchain; the package dlopens a prebuilt librockbox_ffi at process
start. From a repo checkout the loader walks up to target/release/; override
with ROCKBOX_FFI_LIB.
OpenDecoder runs a file through the Rockbox codec engine and hands back
interleaved-stereo S16LE PCM one chunk at a time — decode without an output
device.
The codec engine is process-wide: only one Decoder may decode at a
time, and always from a single goroutine. A second OpenDecoder blocks until
the first is closed.
Stream-decode a file to interleaved-stereo S16LE PCM via the Rockbox codec engine: Metadata(), NextChunk() ([]int16, uint32, bool), SeekMs / ElapsedMs, Finished() (bool, int32). Codec state is process-wide — only one Decoder decodes at a time, from one goroutine.
Rich values (metadata, status) decode into typed structs (Meta,
Status); optional tags are nil-able pointer fields.
Sample buffers are []int16 of interleaved-stereo signed 16-bit samples.
DSP semantics (EQ bands, tone, crossfeed, compressor, …) mirror Rockbox’s own settings — see the official Rockbox manual for what each control does.
Dsp.SetReplaygain and Player.SetReplaygain take different mode
integers. Always pass the named constants — DspReplayGain* for the DSP,
ReplayGain* for the player. See the overview.