rockbox/dsp

The DSP pipeline: EQ, tone, surround, compressor, ReplayGain, resampler.

A Dsp wraps the process-wide audio DSP singleton (only one should be alive at a time). It is a NIF resource, freed by the BEAM garbage collector — no explicit close.

ReplayGain mode here uses the DSP-native values: 0 track, 1 album, 2 shuffle, 3 off.

Types

Opaque DSP handle (a NIF resource).

pub type Dsp

Values

pub fn eq_enable(dsp: Dsp, enable: Bool) -> Nil
pub fn flush(dsp: Dsp) -> Nil
pub fn new(sample_rate: Int) -> Dsp

Create a DSP for interleaved S16LE stereo at sample_rate Hz.

pub fn process(dsp: Dsp, pcm: BitArray) -> BitArray

Run interleaved stereo S16 samples through the pipeline. Both the input and the result are little-endian int16 sample buffers.

pub fn set_channel_config(dsp: Dsp, mode: Int) -> Nil
pub fn set_compressor(
  dsp: Dsp,
  threshold: Int,
  makeup_gain: Int,
  ratio: Int,
  knee: Int,
  release_time: Int,
  attack_time: Int,
) -> Nil
pub fn set_eq_band(
  dsp: Dsp,
  band: Int,
  cutoff_hz: Int,
  q: Float,
  gain_db: Float,
) -> Nil

Configure one EQ band (0..9). Band 0 low shelf, 9 high shelf.

pub fn set_eq_precut(dsp: Dsp, db: Float) -> Nil
pub fn set_input_frequency(dsp: Dsp, hz: Int) -> Nil
pub fn set_replaygain(
  dsp: Dsp,
  mode: Int,
  noclip: Bool,
  preamp_db: Float,
) -> Nil

ReplayGain mode (0 track, 1 album, 2 shuffle, 3 off), clipping prevention, preamp in dB.

pub fn set_replaygain_gains(
  dsp: Dsp,
  track_gain_db: option.Option(Float),
  album_gain_db: option.Option(Float),
  track_peak: option.Option(Float),
  album_peak: option.Option(Float),
) -> Nil

Per-track gains in plain dB / peaks as linear amplitude. None = absent.

pub fn set_replaygain_gains_raw(
  dsp: Dsp,
  track_gain: Int,
  album_gain: Int,
  track_peak: Int,
  album_peak: Int,
) -> Nil

Native Q7.24 factors (the raw_* metadata fields); 0 = not tagged.

pub fn set_stereo_width(dsp: Dsp, percent: Int) -> Nil
pub fn set_surround(
  dsp: Dsp,
  delay_ms: Int,
  balance: Int,
  fx1: Int,
  fx2: Int,
) -> Nil
pub fn set_tone(dsp: Dsp, bass_db: Int, treble_db: Int) -> Nil
pub fn set_tone_cutoffs(
  dsp: Dsp,
  bass_hz: Int,
  treble_hz: Int,
) -> Nil
Search Document