Skip to main content
Requires Python 3.9+. The wheel bundles a prebuilt librockbox_ffi for your platform — no Rust toolchain needed. From a repo checkout, the loader walks up to target/release/; override with ROCKBOX_FFI_LIB.

Quick start

Decode a file to PCM

Decoder streams an audio file to interleaved-stereo S16LE PCM one chunk at a time through the Rockbox codec engine — the same decoders that power playback, without an output device.
chunks() (or next_chunk()) yields (samples, sample_rate) and stops at None on end of track; finished() returns (done, code) where code is 0 for a clean end and negative for a codec error.
One decoder at a time. The codec state is process-wide (global) — only one Decoder can decode at once. Constructing a second one blocks until the first is closed. Always use with Decoder(...) (or call close()) so the native resource is freed; a GC finalizer is the backstop.

API

  • Handles are context managers — with Dsp(...) as dsp: frees the native resource on exit. A GC finalizer is the backstop.
  • Rich values (metadata, status) come back as plain dicts.
  • Sample buffers are array('h') of interleaved-stereo signed 16-bit samples.
Player DSP chain. Every setter applies live and is reflected back by player.dsp_settings(). The full surface: EQset_eq_enabled / is_eq_enabled, set_eq_preset(EqPreset) (21 presets: FLAT, ROCK, JAZZ, BASS_BOOST, …), set_eq_band, set_eq_precut. Toneset_tone, set_bass, set_treble, set_bass_cutoff, set_treble_cutoff. Spatialset_crossfeed(CrossfeedMode), set_surround, set_channel_mode(ChannelMode), set_stereo_width, set_balance(balance) / balance() (stereo balance, -100 full left … +100 full right, 0 = centre). Enhancersset_bass_enhancement (PBE), set_fatigue_reduction (AFR), set_compressor, set_dither, set_pitch. Shuffle / repeatset_shuffle / is_shuffle_enabled, set_repeat(RepeatMode) / repeat().For what each parameter does (and sensible ranges), see the official Rockbox manual: Sound Settings.
Dsp.set_replaygain and Player.set_replaygain take different mode integers. Always pass the named enums — DspReplayGainMode for the DSP, ReplayGainMode for the player. See the overview.

Interactive console

Drops into IPython with rb, metadata, Dsp, Player, the enums, and a FIXTURE sample track preloaded: