mathematical expression of Fader.x to db range [solved]

Discuss Lemur and share techniques.
Post Reply
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

mathematical expression of Fader.x to db range [solved]

Post by Softcore »

Apparently, Im not that good at mathematics.

I cant for the life of me figure out the equation so that the position of a fader is displayed as dB in a monitor object. Inside the software (Ableton Live) when Fader.x =1, db=6, and when Fader.x=0, db = -inf. The first next value after -inf is -69 so I guess I could make a script for the lowest "-inf" indication but I can't figure out the how to map the rest of the range from -69 to +6 in relation to Fader.x
Of course the range is not linearly mapped throughout the fader so Monitor.value=Fader.x*75-69 is not an option - the range is correct but the values do not correspond to the actual values in the software.
This must be some log function but thats just where Im stuck.

I was pretty sure someone would have already asked for this on the forums and searched but found nothing in particular. Anyone?
Last edited by Softcore on 04 Dec 2012 23:06, edited 1 time in total.
Macciza
Regular
Posts: 1315
Joined: 07 Dec 2011 04:57
Location: Sydney, Australia.

Re: mathematical expression of Fader.x to db range

Post by Macciza »

Hi
This did get discussed at length at one time
Here a few threads to look at http://liine.net/forum/viewtopic.php?f= ... mula#p6261 and http://liine.net/forum/viewtopic.php?f= ... mula#p3286
They may ofcourse be using just mapped values and not an equation . . .

Cheers
MM
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: mathematical expression of Fader.x to db range

Post by Softcore »

Thank you very much for the info and links!

Here's how it all turned out:

At first I tried the formula
20*(log(x*127/108))*6/3.241
Can't say I was happy as far as accuracy goes!
Then I thought, ah well, lets just use that equation that maps velocity to an amplitude range - frankly? I started replacing the data to the main formula and I ....I got scared by the monster.

Talking about this one...
a = (m * x + b) ^ 2,

a = amplitude,
x = MIDI velocity,
r = 10 ^ (R / 20),
b = 127 / (126 * sqrt( r )) - 1 / 126
m = (1 - (127 / (126 * sqrt( r )) - 1 / 126)) / 127
R = specified dynamic range in decibels.

So then I turned my attention to the last solution, allbeit not a very mathematic one...the mappings to a vector.
Surprisingly I 've managed to get good results with:
decl fDB; fDB={-68, -48, -34, -24, -18, -14, -10, -6, -2, 2, 6};
Monitor.value=fDB[x*10];
By good results I mean a slight deviation of 0.1 at some points out of the faders' total possible values - not too bad (with one decimal precision anyway)

Also, in case anyone maps a fader to Ableton Live and limits its range to 0dB (I think many would do so to be sure not to clip commecrial audio being played) natively in the software (i.e. the Lemur fader is 0 to 127 but inside Live you limit the mapping to 0dB) then you can use this:
decl aDB; aDB={-68, -50, -36, -24.6, -19, -15, -12, -8, -4, 0};
Monitor.value=aDB[x*9];
of course you could just limit the x range inside Lemur but not if you also have faders from other controllers mapped to the same parameters ;)

Lastly I used an

if (Monitor.value==-68) Monitor.value='';

to replace the -68 value shown when the fader is all the way down and represent the -inf point.

Now only a last question to see if Im thinking this correctly: since these functions will be appearing at a total of 24 faders in my project, aren't I correct in thinking I'm better defining aDB and fDB ggolbally in the project level and then just proceed in eacn fader to set the monitor value?

Thanks!!!
Stephmo
Newbie
Posts: 24
Joined: 22 May 2012 16:09

Re: mathematical expression of Fader.x to db range [solved]

Post by Stephmo »

Hi Softcore Could you please post an example of your last post ? I can't figure out how to use those vectors. Thanks
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: mathematical expression of Fader.x to db range [solved]

Post by Softcore »

Here's an example....
dBfader.jzml
(3.02 KiB) Downloaded 12228 times
Stephmo
Newbie
Posts: 24
Joined: 22 May 2012 16:09

Re: mathematical expression of Fader.x to db range [solved]

Post by Stephmo »

Thanks a lot Softcore. I've been fighting with this for a while now to find the right expression. Even contacted the ableton support but, to my surprise, got no answer. Now you can can bring it to them :D
http://liine.net/forum/viewtopic.php?f=26&t=536
https://forum.ableton.com/viewtopic.php ... ader+lemur
https://forum.ableton.com/viewtopic.php ... emur+fader
ErikG
Newbie
Posts: 49
Joined: 06 Oct 2013 10:10

Re: mathematical expression of Fader.x to db range [solved]

Post by ErikG »

YAY!
Great, thank you!
I had to modify your numbers a bit though to get decent values.

And as I am not a math giant...
How and why did you come up with that series of numbers?
Why 12 steps?

Im sure theres something clever here somewhere, but I just don't get it (yet)...
Sound post production to feature film & TV.
Nuendo and ProTools. Dubstage with Euphonix S5MC 32 fader.
8 editing rooms without hardware controllers.
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: mathematical expression of Fader.x to db range [solved]

Post by Softcore »

Nothing genious mathematecally I swear lol... I was just trying and testing with less values and when the numbers were starting to have a big deviation I was inserting a new value....you can think of the values as "anchors" to the mathematical curve of an equation I didnt have the time to discover....its like sampling really! Lol and 12 points is not exactly high sampling rate but it did the job! ;)
Post Reply