We use dBvalue = 20 * log10( volumeAsPercent )
where volumeAsPercent
is in the range of [0.001 .. 1]. dbValue
will be in the range of [-60 .. 0].
(That's a bit annoying because the actual engine - OpenAL - uses 0..1 for its gain, so we have to convert that back using volumeAsPercent = 2^(dBvalue/6)
. It will not exactly give the same result as the input but will give an approximation to volumeAsPercent = 10^(dBvalue/20)
which is close enough (I don't know why we use that formula, and we can't change it at this point).)
I'm not a sound engineer, I don't play music and I don't have a sound studio to test this, but testing this formula with increments of 10%, seems to give a nice progression in making the sound louder (from completely muted at 0, up to what is in the original wav file at 1).
Here are the plotted curves.