There are built-in functions to do this - you probably want CCToGain which converts a CC value 0-127 to a gain value using the same mapping as MIDI bindings.
See here: Velocity and Control Curve Functions
That will give you a scalar value - to convert dB, you can use formatGain()
See here: Decibel Functions