Hey y’all!
Sharing a little helper today. When controlling gain parameters from inside scripts, one has to specify a linear float value which GP will internally convert to a logarithmic dB scale.
So let’s say you want to set a GP gain control to 0 dB, you first have to look up the linear value for that which is about 0.71.
I was tired of it, so I figured out the math and wrote utility functions for converting between “param” value and dB. So instead of setting a gain slider to 0db, connecting a widget and checking out the linear param equivalent, this scripts it as dbToFloat(0.0).
Function floatToDb( val:Double ) Returns Double
result = ((Log(val)+0.3) * 40.0) - 6.0
End
Function dbToFloat( val:Double ) Returns Double
result = Power(10.0, (((val + 6)/40) - 0.3))
End
Happy scripting!