[ardour-dev] slider_postion2gain analysis
gerard van dongen
gml at xs4all.nl
Wed Jul 14 16:28:41 PDT 2004
My math hobby strikes again :)
Hope somebody finds this useful, otherwise I had fun figuring it out
anyway.
The slider_postion_to_gain function used in ardour =
pow (2.0,(sqrt(sqrt(sqrt(pos)))*198.0-192.0)/6.0)
which is really (ascii math)
1/8
(198 * p - 192)/6
2
equals
1/8
((32+1) n * p - 32* n) / n
2
where n = 6
hmm, divide out n
this is actually just pow(2,sqrt(sqrt(sqrt(pos)))*33 - 32)
well there is one little bit of code optimization anyway.
and this gives unity gain at 0.78178675, 2 at p=1 and pow(2, -32) at 0
which is nice because we work with 32 bits
So the problem is I want my midi controller to give me gain G at position
P (where G is allready translated to [0,2] and P to [0,1]
so now the formula is
1/8
(x+1)*P - x
G = 2
solve for x gives:
1/8 1/8
x= ( (logG/log2) - P ) / ( P - 1)
_and_ we want x >= 32 (or can it be smaller ? , say 24, I don't know)
which constrains the possibilities
f.e. I want at P=0.6 G to be 0.8 that requires x to be 20.37061 so that is
not good enough.
Obviously (or I should have seen it before starting this mail) you can
only adjust downwards then, if you want 0 to remain 0
What that means is that if you want your controller to behave similarly to
ardour's faders, and you can only set G at a lower value than the current
slider_position_to_gain function returns.
Practically that means CC value 99 is about the lowest controller value
for unity gain, and clearly 127 will give you division by zero.
More information about the Ardour-Dev
mailing list