Convert midi value to db

Maybe this is not the correct forum but I try anyway…

I’m desperately searching for the mathematical formula for converting the linear 14 bit fader value sent by Cubase in Mackie Control emulation to the corresponding logarithmic db value shown in Cubase.

If anyone has a clue, please help me.

14bit max value is 16383 (assuming unsigned integer values), so
db(x) = 10*log(x/16383)
db(16383) = 0
db(0) = -infinity
of course any generic calculator will tell you that db(0) is not defined, so for conversion I’d either catch this with an if/else clause or clamp x to 1-16383:
db(x) = 10*log(max(1, x)/16383)

Fixed formula from Bel to dB, my bad. Also:
db(1) = -42,143934312552058279471034783116
would be the lowest you can go with the “max” adjusted formula

Thanks…but that formula doesn’t work. I know it is a standard formula for calculating db, but it will not even come close to giving the same results as in Cubase I am afraid.

The min value I can see in Cubase is -111.1db and max value is +6db. Also, for some reason Cubase never goes above 15281 when the fader is at max.

db(0) = -infinity
db(1) = -111.1 (…or actually: db(39)=-111.1, it’s the lowest value I’ve managed to get before Cubase shows -infinity)
db(12864) = 0
db(15281) = +6

Well, looks like the 14 bit value is not linear. If it were then you’d expect 10*log(12864/15281) to be -6db, which it isn’t.
In that case you can only guess. I know it’s pain staking but what I would do if I were really desperate is to just create a midi part with multiple values and then note the db values Cubase spits out. You can then use these value pairs and try to fit a curve against it using least mean squares, something like 10*log(a*x + b) +c.

If you try like this?

db(x) = 10*log(x/12864)

That makes the 0db position correct but everything else is way off…

Instead of spanning -111=>+6db it spans about -21 =>+0.75db

Long shot and I might be getting in way over my head, but if this is just a way of combining two CCs (MSB and LSB) into one, give this a shot:

(MSB * 128) + LSB

I.E. When converting bank change messages (combination of CC0 and CC32) into the 14bit format this is what we do.

Yes getting the 14 bit value is no problem. The problem is that this value defines the physical position of the fader in x/16383 physical steps calculated from the total physical length of the fader. To actually get the db value this represents requires some calculation that seems to be quite impossible :thinking: