very usefull, I can compare to exact values
The live.gain do the job even simplier and better( I put it also in the patch to compare )
any differences oddities advantages with the live object en general ?
or they are just msp objects ?
Yes I know this thread is a year old, but I was trying to do the same thing and did not find anything else in the forum that seemed clear to me.
The formula I came up with for dB for gain~ from the slider value is:
dB gain of the slider = 20*log(2^(( x-128)/10)) "dB"
Where x is the gain~ slider value and the settings are the default.
158 steps or 0 to 157 on the slider
128 is 0dB (no gain or loss)
10 slider value steps = 6 dB (probably 6.02)
157 is roughly +18dB
1 is roughly -76 dB
0 is off. It should say -infinity, but the meter reads -120 dB. (effectively the same thing)
I would love to know more about these values.
base value (7.94231)
Zero is a separate case - I imagine there is a more elegant way to handle it than what I did in the patch. I am relatively new to Max, but an old hand at audio.
Generating the slider value should be the reverse of this process. Feel free to do that or I'll pursue that another time.
If you decide to look at the patch, the left side is individual steps and the right is my attempt to pack it into one expr. The results at the very end of the scale are different. Miniscule, but may highlight differences in algorithms.
There is a cycle~ connected to the meter so that you can compare the meter out with the calculation. How that value correlates with real VU ballistics or an RMS value is anyone's guess. It does seem to show the calc to be pretty close for a sine wave.
Please feel free to comment and let me know if I just calculated something that's already an object. LOL
so, i refused to give that answer to the other guy one year ago, but i will do it now for you:
it is misleading and makes it only extra complicated to look at the gainslider MSP object in order to find out how it is calculated.
for a valid formula for "dB/A to linear" i am posting my solution for the 4th time now:
where the input and the output range will also work with this formula when you exceed +0. db/A:
the "158" of the gainslider GUI object is set by will, it is only releated to the slider resolution and has nothing to do with gaining up a digital audio signal.
you shouldn´t deal at all with "step value" and these things. ignore this object and build your own.
dB/A (float) – [expr (pow(10.,$f1*0.05))*($f1!=-90.)] – [*~ 0.] is all you need.
for displaying the result with a GUI object you might need to scale the "linear" value.
the "live" objects might be an alternative for the GUI, multislider is another one.
i find my vesion of "dealing with the 0" the most elegant possible, just to answer that question, too. :)
or did you mean the "0" of the dB/A result? that should be 100% at "0.0" if you use a correct expression.