I'm not a coder by any means but have studied maths and engineering a bit.
I think you are treating it as a linear function with the quick example given but dB is a logarithmic expression so all the calulations have to be dealt with in a non-linear way. dB measurements are measured using a logarithmic system against a reference which changes depending on which system is being used.
eg. SPL - sound pressure level is caluculated using:
SPL = 20* log (Prms/Pref)
log is base 10, Prms is the pressure (Pa) of the measured sound & Pref is the reference pressure (Pa) which is 20 uPa
This is only an example, there are other systems of expression, like sound power level where powers are replaced by Watts. The *20 is replaced by *10 and the reference is 10E-12 W.
Sound power level = 10 * log (Prms/Pref)
using the above mentioned power reference, Prms is again the measured power of the signal.
If you convert from dB to a power or pressure type linear value, you can then add and subtract them together/from each other.
This is because human hearing does not work in a linear way. A sound that is played twice as loud in terms of power is not perceived to be twice as loud. This would limit our dynamic range of hearing, loud sounds would be crippling and we wouldn't hear quiet sounds well. Instead dBs are used as they closer repsresent how our ear/brain system compares sound levels.
It's been a few years since I studied all this, treat it as a guide and not as gospel.
Hope it helps and good luck.
Originally Posted by GhostAddict
The math behind compressors/limiters.
I want to make a multiband compressor like the one in FLstudio for use in my plugins.
Does anyone have any idea the math behind compressors.
I understand the basic function of threshold,compression, gain, and the standard knobs on a compressor. but im interested in the math.
like thershold at -6db with compression of 3/1 and gain of 2 times would look like
Is this close to how it should look like?