Decibel AudioParameterFloat

Hi!
I’m trying to set the range of an AudioParameterFloat to decibels.
This seems like a trivial question, but how do I initialize such NormalisableRange and how I use it?

I have tried different approaches, but without success. How do you deal with this?

Thank you!

You can pass a decibel range for the NormalisableRange, for instance with juce::NormalisableRange <float> (-100.0f, 12.0f).

To visualize the decibels unit after the value in the DAW and plugin UI, pass juce::String ("dB") as the label to the AudioParameterFloat constructor.

To apply volume in the audio block, use juce::Decibels::decibelToGain (paramDecibel->get()).

Thank you Jelle! I overcomplicated things; your tips helped a lot!

In the last step, Decibels::decibelsToGain(rawParameter->load()) did the trick for me. Getting the rawParameter with parameters.getRawParameterValue ("paramID") of course.

I’m leaving this here in case someone else needs it. :slight_smile:
Thank you Jelle