I am very new to making JSFX and I have been trying to figure out how people convert decibels to amplitude and back again.
After digging around in other JSFX files, I have notice that people tend to use approximations of the two following numbers:
1. 6/ln(2) = 8.656170245 ('AMP_dB = 8.6562' seems quite common)
2. 20/ln(10) = 8.685889638
These numbers are similar but not the same, apart from the first two significant figures.
After experimenting in JSFX, I found that when converting from -6dB to amplitude and back again that the first number got me closest to a circuit without change in the dB on the way out.
1.Amp_dB = 8.6562;
0.50000119 = exp(-6dB / Amp_dB);
-6dB = Amp_dB * log(0.50000119);
1b. Amp_dB = 8.65617025;
0.5 = exp(-6dB / 8.65617025);
-5.99997938dB = 8.65617025 * log(0.5);
2. Amp_dB = 8.6858896380650365530225783783321;
0.50118723 = exp(-6dB / 8.6858896380650365530225783783321);
-6.02057922dB = 8.6858896380650365530225783783321 * log(0.50118723);
3. Random method (I just played around with digits to get -6dB to be 0.5 and 0.5 to be -6dB on the way back:
Amp_dB (way out) = 8.6561703
Amp_dB (way back) = 8.6562
0.5 = exp(-6dB / 8.6561703);
-6dB = 8.6562 * log(-6dB);
Obviously, I changed the code to make it more legible. It was all done with variables, not numbers and I added the 'dB' bits in to make it clear.
The numbers above are the numbers shown in the panel at the right hand side of the the JSFX editor (I attached the image in case I copied them incorrectly).
So my question is this, how do you convert from decibels to amplitude (and back) and why?
After doing some research online I have seen both numbers used but I do not understand why some people tend to use one over the other.
This is very much out of my wheelhouse (I do not have a mathematical background and am just learning as I go) so I would appreciate the kind of an explanation/ opinion that a layman such as myself can interpret! Thank you!
GLD
4. EDIT: found the best way (I think) :
log2db = 8.6858896380650365530225783783321; // 20 / ln(10)
db2log = 0.11512925464970228420089957273422; // ln(10) / 20
0.50118723 = exp(-6 * db2log);
-6dB = log(0.50118723) * log2db;
This gives the 0.501 that is what wikipedia says should be the amp from -6dB
and gets back to exactly -6dB
I could not change the poll so just select option 2 I guess if you use this method!
I would still really love to know why the two different constants are used though...