Using applyGain to add additional gain, rather than set the gain?


#1

Hello everyone,

I wanted to check if I’m ignorant or if this is actually the case.

Does the AudioBuffer applyGain method not work if you want to apply additional gain to the general processed audio.

So, I understand that this may not be clear but as an example, in most compressors there is an option to apply make up gain after compression. Would we be able to simply use an audio parameterfloat and pass a makeup gain slider to this function as a way to apply more gain?

When I tried this in my application, the make up gain slider ended up controlling the gain of all processed audio. So, is there a way to simply apply gain on top of the current level of the sample being processed?

I appreciate any input and the time you’ve taken to read my inquiry!


#2

That is the difference between gain and level…
Gain is a factor, that multiplies the values.
If you express a gain in level, it is a logarithmic value and is adding to the existing levels.

Applying a gain of 2 (factor) will add 6 dB to the level. Applying factor 4 is adding 12 dB and applying factor 8 is adding 18 dB.

HTH


#3

… and to maybe make it even more clear: Adding 0dB to the signal will result in a gain of 1. So what you want is a slider with a range from 0dB to some positive max dB value of your choice. You can convert its values to linear gain factors with the help of Decibels::decibelToGain function - a really useful class for this purpose. You find it here. You’ll also notice that adjusting a dB value will feel a lot more “natural” then setting the linear gain factor. And in case you want to reduce your overall level, just feed a negative dB value to the converter function and it will give you back a linear gain factor in the range between 0 and 1.


#4

Thanks, that makes sense. I appreciate you clarifying what daniel said.


#5

Thank you for that. I didn’t realize this. I appreciate you taking the time to let me know whats going on.


#6

Again, thanks for your advice. I completed my plugin and I couldn’t have done it without this knowledge.