Skip to main content
Requires Elixir 1.15+ and OTP 27+ (uses the built-in :json module — no jason dependency). The NIF links the Rust static archive (target/release/librockbox_ffi.a); mix compile builds it automatically through elixir_make (running cargo build --release -p rockbox-ffi first if the archive is missing).

Quick start

Decode a file to PCM

Rockbox.Decoder runs the Rockbox codec engine directly, yielding interleaved stereo S16LE PCM one chunk at a time — no output device required.
Codec state is process-wide — only one Rockbox.Decoder decodes at a time. Opening a second decoder blocks until the first is freed by the GC.

API

Rockbox.Player — every mutating function returns the handle (pipe-friendly), so setup chains with |>; getters/queries return their values:
  • Transport: play/1, pause/1, toggle/1, stop/1, next/1, previous/1, skip_to/2, seek_ms/2, set_volume/2 / volume/1, set_balance/2 / balance/1 (stereo balance, -100 full left … +100 full right, 0 = centre), sample_rate/1, status/1.
  • Sources / queue: set_queue/2 and enqueue/2 accept local file paths, http(s):// URLs, and live-radio / streaming URLs; plus insert/4, queue/1, import_m3u/4, load_m3u/2, export_m3u/2, and resume via resume/1 / save_resume/1 / clear_resume/1.
  • Shuffle & repeat: set_shuffle/2 / shuffle_enabled?/1; set_repeat/2 / repeat/1 (Rockbox.RepeatMode).
  • DSP chain: set_eq_enabled/2 / eq_enabled?/1, set_eq_preset/2 (21 Rockbox.EqPreset presets), set_eq_band/5, set_eq_precut/2, set_tone/5 / set_bass/2 / set_treble/2 / set_bass_cutoff/2 / set_treble_cutoff/2, set_crossfeed/6 (Rockbox.CrossfeedMode), set_surround/5, set_channel_mode/2 (Rockbox.ChannelMode) / set_stereo_width/2, set_bass_enhancement/3, set_fatigue_reduction/2, set_compressor/7, set_dither/2, set_pitch/2, and dsp_settings/1 (full DSP state as a map).
  • Crossfade / ReplayGain: set_crossfade/7, set_replaygain/4.
Enum helper modules (each takes an atom or the raw integer):
  • Handles (Rockbox.Dsp / Rockbox.Player) are NIF resources freed by the BEAM garbage collector — no explicit close.
  • PCM crosses the boundary as an int16 LE binary.
  • Rich values come back as maps with atom keys.
  • The DSP chain mirrors Rockbox’s own; see the official Rockbox sound-settings manual for what each control does.
The DSP and player use different mode integers: Rockbox.Dsp.set_replaygain/40 track, 1 album, 2 shuffle, 3 off; Rockbox.Player.set_replaygain/40 off, 1 track, 2 album. See the overview.

Docs

Generate API docs locally with mix docs (→ doc/index.html), or read the published ones at hexdocs.pm/rockbox_ex_ffi.
The Elixir and Gleam bindings share the exact same rockbox_ffi_nif.{c,erl} NIF, vendored into each project.