Requires Ruby 2.6+. The binding uses fiddle
(Ruby stdlib) to dlopen the shared library — no native extension is
compiled. The published gem bundles a prebuilt librockbox_ffi; from a repo
checkout the loader walks up to target/release/ (override with
ROCKBOX_FFI_LIB).
Quick start
The Rockbox codec engine is process-wide — only one Decoder decodes at a
time. A second Decoder.open blocks until the first is freed (via #close
or the block form). Drive a decoder from a single thread.
API
- Rich values (metadata, status,
dsp_settings) come back as Hashes with
symbol keys.
- Sample buffers are
Array<Integer> of interleaved-stereo signed 16-bit
samples.
Dsp and Player own native resources. Use the block form (.open) to
close them automatically, or call #close; a GC finalizer is the backstop.
- The
Player DSP chain mirrors Rockbox’s own sound settings — see the
official Rockbox manual
for what each control does.
Dsp#set_replaygain and Player#set_replaygain take different mode
integers. Use the named constants — DspReplayGainMode for the DSP,
ReplayGainMode for the player. See the overview.
Interactive console
Drops into IRB with RockboxFFI loaded and FIXTURE pointing at a sample
track — Tab autocompletion and syntax highlighting are on by default: