I am programming a LUA script so that I can control audio EQ on two audio tracks at same time, such that when one goes up, the other goes down.
In the EQ interface, a user sees 0dB to 36 dB of positive gain, and 0dB down to -inf of negative gain.
The plugin itself internally handles the positive values as floating point numbers from 0.25 - 16.0. This range maps to the 0dB - 36dB range that a user sees in the EQ interface.
Negative values are handled internally as 0.2499999 down to 0.0000002, which covers range in the EQ interface of 0 dB down to -inf dB.
Most people when using an EQ, don't add or reduce more than 16dB or so. So I need a range mapping, such that 0.25 to 1.5773934 (which in the EQ app is 0 dB to 16 dB) in one EQ mirrors/maps to 0.2499999 to .044457 in the other (which is 0 down to -16dB).
This way, when one EQ is 4 dB, the other is -4dB. When one is 12 dB, the other is -12 dB, so on til +-16 dB. Beyond that they will inevitably diverge due to asymmetry of the positive and negative EQ ranges.
After that (beyond the +-16 dB point) I just need a mapping so that the 36dB extreme on one EQ mirrors to -inf on the other (that is, internally, 16.0 on one EQ mirrors to 0.0000002 on the other). I know this mapping won't be linear.
Does this make sense how I explained it?
Initially, I just used a simple linear mapping:
function map(x, in_min, in_max, out_min, out_max)
return out_min + (x - in_min)*(out_max - out_min)/(in_max - in_min)
end
which I saw at
Mapping a numeric range onto another
and then when I receive an internal EQ gain value on the EQ that is being adjusted, I calculate the value to be mirrored on the other EQ as
if val >= 0.25 then
mappedval = map(val, nogain, maxgain, nogain, mingain)
else
mappedval = map(val, nogain, mingain, nogain, maxgain)
end
This doesn't work well at all, because large changes on one EQ can map to very small changes on the other.
So that is why I am trying to get this working in a way where the two EQs are moving opposite to one another in very similar amounts in the +-16dB range.
Ideas?
thanks!
Edit: Looked into this more, and the values are mapped to dB on some sort of log scale, just that it isn't a typical scale. Usually with dB, a decimal value of 1 maps to 0 dB.
In my case, going from decimal to dB has domain [0 1], range [-120 12].
So just trying to work out the equations... This way I can precisely do the mapping across all values