Rack development blog

What is the formula for scaling parameter values for display using configParam(..., displayBase, displayMultiplier, displayOffset)?

Where v is the parameter value:

  • Linear displayBase = 0: v * displayMultiplier + displayOffset
  • Logarithmic displayBase < 0: log(v) / log(-displayBase) * displayMultiplier + displayOffset
  • Exponential displayBase > 0: pow(displayBase, v) * displayMultiplier + displayOffset

Useful examples:

  • configParam(PW_PARAM, 0, 1, 0.5f, "Pulse width", "%", 0, 100) displays as “Pulse width 50%” at the default value
  • configParam(FREQ_PARAM, -54, 54, 0, "Frequency", " Hz", dsp::FREQ_SEMITONE, dsp::FREQ_C4) displays as “Frequency 261.6 Hz”
  • Or, configParam(FREQ_PARAM, -4, 4, 0, "Frequency", " Hz", 2, dsp::FREQ_C4) since octaves are easier to work with than semitones.
  • configParam(LVL_PARAM, 0, M_SQRT2, 1, "Ch 1 level", " dB", -10, 40) displays as “Ch 1 level 0 dB” and scales with gain = pow(v, 2) in the DSP kernel.
2 Likes