# [Ardour-Dev] gain-mapping - was Re: OSC next

Fons Adriaensen fons at linuxaudio.org
Sun May 15 03:39:30 PDT 2016

On Sat, May 14, 2016 at 02:40:44PM +0200, Robin Gareus wrote:

> With fader position 0 <= p <= 1.0, Ardour calculates the gain as follows:
>
>   $g = 2^{\frac{1}{6}(-192 + 198 \sqrt{p})}$ 

An alternative (within 1dB over the range 0.05...1.00) is

g(dB) = sqrt(x) / (sqrt(0.5) + sqrt(x)) * 180 - 99.44

which requires only one sqrt() and is easy to invert.

The upper half is so close to linear that it could as well
be exactly linear:

g(dB) = sqrt(x) / (sqrt(0.5) + sqrt(x)) * 180 - 100,   (x < 0.5)
g(dB) = 32 * x - 26,                                   (x >= 0.5)

With 320 steps for the full range, this produces steps
of exactly 0.1 dB in the upper range. There is a small
discontinuity of the derivative at x = 0.5, but I doubt
if anyone will notice that.

Or have 400 steps and an upper limit of +10 dB:

g(dB) = 40 * x - 30,   (x >= 0.5)

which also reduces the discontinuity of the derivative.

Etc.

Ciao,

--
FA

A world of exhaustive, reliable metadata would be an utopia.
It's also a pipe-dream, founded on self-delusion, nerd hubris
and hysterically inflated market opportunities. (Cory Doctorow)