gdjacobs wrote:Yes, mixing up dBV and dB SPL, but the ratio given by dBV does not measure volume. It is used for waveform amplitude. The actual sound volume is proportional to power. The actual loudness of -3 dB will be the same, but the ratio will be different depending on whether you're interested in PCM amplitude or SPL.
For the same load, if you double the voltage, you get quadruple the power, right?
For power, 10*log(4)=6dB. For voltage, 20*log(2)=6dB.
So the decibel ratio is same. You need 3dB more power to double the power so it sounds double as loud (doubles the SPL).
You also need 3dB more voltage to sound double as loud (double the SPL), even though that only requires 1.414 times more voltage amplitude to double the power.
Either way, we are working with PCM sample values that are about voltages, not powers, So yes, I could have been more clear that by volume here it really means amplitudes of PCM values or voltages they represent, not the actual sound pressure level, but also considering the context... Anyway, for those PCM values, doubling/halving is +/- 6dB which is what matters, and for making it twice/half as loud it is +/- 3dB.
gdjacobs wrote:
The Adlib board can do this because it's essentially using the 6 bit register as an enumeration. In your case, go ahead and use 0 to 1 as the PCM envelope and convert to/from dB as needed. If you want to avoid some compute cost in conversion, precompute dB and create lookup tables.
It's not used as an enumeration. It really uses everything related to amplitude (volumes, envelopes, even the waveforms) in log domain, so it can just sum together the attenuations, and finally convert this to linear PCM domain. If each operator would require just one multiplication per sample, it would have to perform about 900000 multiplications per second, which was just not possible to do cheaply.
But yes, it is completely weird to use 1 as the decibel offset. And completely weird to use a range of 0 to 1 in decibels for volume, even if it meant -1 to 0 decibels. 0 to 1 as linear is good.
Now, what could be useful is to convert some volume variable that is between 0 and 1 into decibels in between -100 to -0 dB , so where 0 is -100dB and 1 is -0dB.
In Superfury's code, that would be 0 to 100 dB amplification with 100 as the maxDB to have the 100dB attenuation there as well. And 1.03 would be twice as loud, and 1.06 would be twice the voltage.
The only problem is what he wants to avoid, 2 equals then 200dB, meaning +100dB gain or times 100000 linear, so even PCM values of +/- 1 with 100dB gain goes through the roof not fitting into 16-bit PCM values any more.
Perhaps a 100dB range, from -80 to +20, is good? -80dB divides by 10000, +20dB multiplies by 10.