<div dir="ltr"><div><div><br></div>1260 is doable that´s no problem. Problematic it get´s when floating point needs to be done but that is the problem with all micro controllers.<br><br></div> <br><div class="gmail_extra"><br><div class="gmail_quote">2016-05-14 14:40 GMT+02:00 Robin Gareus <span dir="ltr"><<a href="mailto:robin@gareus.org" target="_blank">robin@gareus.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 05/13/2016 08:53 PM, Len Ovens wrote:<br>
> On Fri, 13 May 2016, Melanie Bernkopf wrote:<br>
><br>
>> yes I can only give a full ack to this it is just mimic of the<br>
>> position and not about gain or DB.<br>
<br>
At first thought, I think this is not a good idea.<br>
<br>
It would limit the control surface to the same fader-deflection which<br>
Ardour chose and does not expose any actual relevant numerics.<br>
<br>
But the lack of a well defined "no gain" 0dB point is the most obvious flaw.<br>
<br>
<br>
<br>
Internally Ardour uses a floating point gain-factor (coefficient) for<br>
both: state and processing. Resetting a fader sets it exactly to 1.f and<br>
the control has a detent (in the GUI) because it is impossible to<br>
otherwise reach this point (With integer ratios 41 bits of precision are<br>
required for the power law to result in exactly 1.f).<br>
<br>
> Yes and no. With either gain or dB I can remotely say I want x amount of<br>
> gain. It is easy to put a button in that zeros a fader with either dB<br>
> (send 0) or gain (send 1.0). It is impossible to do that with 1023 INT.<br>
> 800 comes closest at 0.006990539841353893 dB. (Using two surfaces one<br>
> with int1024 and the other with dB, setting position to 799, 800 or 801<br>
> and seeing what Ardour sends to the other surface)<br>
<br>
+1 for testing the whole system. That's very good practice and pretty<br>
much the simplest way to find out how rounding (and float<br>
parsing/precision) behaves.<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Here's the math for completeness:<br>
<br>
With fader position 0 <= p <= 1.0, Ardour calculates the gain as follows:<br>
<br>
  $g = 2^{\frac{1}{6}(-192 + 198 \sqrt[8]{p})}$ [1]<br>
<br>
The inverse of which is<br>
<br>
  $p = (\frac{1}{198} (6 \log_2(g) + 192))^8$ [2]<br>
<br>
<br>
At unity gain, [2] evaluates to (192/198)^8 = (32/33)^8<br>
<br>
You'll need to add a factor much much larger factor than 1024 to<br>
represent unity gain with an exact integer.<br>
<br>
<details><br>
As you can read in the source [3], the gain/fader-position relation is<br>
derived from measuring a console fader. The intended range is 0..2<br>
(-inf, +6. dB) which is reflected in the base of the logarithm, but the<br>
actual range is configurable(!).<br>
<br>
The initial polynomial fit (old gain math) had a problem that inverse<br>
function had a large error and  f(f^{-1}(x)) was off by a few dB for<br>
smaller values of x. The power-function is a close approximation of it<br>
though.<br>
<br>
$ gnuplot<br>
set key horizontal top left<br>
set ylabel "dB"<br>
set xlabel "% fader"<br>
set samples 250<br>
plot[0:100][-200:6] 20 * log10 (2**((198 * (x / 100)**(.125) - 192) /<br>
6)) t "Ardour fader"<br>
<br>
<br>
Also note that granularity of the fader position p is not fixed in<br>
Ardour. Fader length scales with the GUI, and the fine-grained mode is<br>
constrained by a gtk adjustment. Default GUI granularity is  250 *<br>
ui_scale (rounded to px),  hence "set samples 250" in the plot, With<br>
"Keyboard::GainExtraFineScaleModifier" Ardour increases granularity by<br>
a factor of 200 to a total of 50K steps with default GUI scaling.<br>
</details><br>
<br>
<br>
> So with dB, I can on<br>
> the surface enter as text an exact gain in dB. Also, the text value on<br>
> the surface shows the value in dB which is much more useful to the user<br>
> than some number from 0 to 1023.<br>
<br>
exactly.<br>
<br>
<br>
However, are there any OSC controllers out there that can provide a<br>
power-law fader?<br>
<br>
As far as I know the answer is no. Furthermore neither log-scale (dB)<br>
nor linear (coefficient) are appropriate for a fader.<br>
<br>
<br>
One way would be to add a *new* interface specifically for OSC with the<br>
following properties:<br>
<br>
 - power-scale - similar to Ardour's Fader<br>
 - 0dB can be represented by an integer fraction with small denominator.<br>
 - the range is independent of Ardour's max_gain configuration<br>
 - relatively simple relation to dB.<br>
<br>
One candidate that fulfills these criteria is<br>
<br>
 $g = (1.26 p)^3 ; 0 \leq p \leq 126; p \in \mathbb{Z}_{\geq 0}$<br>
<br>
with x = 100 / 126 this results in a gain = 0dB<br>
and x = 126/126; gain ~= +6dB<br>
<br>
This could also be mapped to MIDI 0..127 with a small overshoot (1.26 *<br>
127 / 126)^3 = 6.23 dB  and OSC could use 0 .. 1260  with unity at 1000.<br>
<br>
<br>
This interface would be available in *addition* to a dB interface (two<br>
in total).<br>
<br>
ciao,<br>
robin<br>
<br>
<br>
<br>
The equations in text (non LaTeX) are:<br>
<br>
[1] g = 2 ^ ((198 * p ^ (1/8) - 192) / 6)<br>
<br>
[2] p = ((6 * log(g) / log(2) + 192) / 198) ^ 8<br>
<br>
[3] <a href="https://github.com/Ardour/ardour/blob/master/libs/ardour/ardour/utils.h" rel="noreferrer" target="_blank">https://github.com/Ardour/ardour/blob/master/libs/ardour/ardour/utils.h</a><br>
_______________________________________________<br>
ardour-dev mailing list<br>
<a href="mailto:ardour-dev@lists.ardour.org">ardour-dev@lists.ardour.org</a><br>
<a href="http://lists.ardour.org/listinfo.cgi/ardour-dev-ardour.org" rel="noreferrer" target="_blank">http://lists.ardour.org/listinfo.cgi/ardour-dev-ardour.org</a><br>
</blockquote></div><br></div></div>