Set normal values to gain sliders

Hi all!
I`m using AudioProcessorValueTreeState and trying to set my gain slider to to values between -48 and 10 dB. I need the slider to initialize to 0. That is, when the value is 0, the original volume should not change.

I have AudioProcessorValueTreeState::createParameter() method, where I should initialize my sliders. Am I doing the right thing to set the slider values in the range from 0 to 1, and initialize 1?


std::vector<std::unique_ptr<RangedAudioParameter>> params;

    auto overallGainParam = std::make_unique<AudioParameterFloat>(OVERALL_GAIN_ID, 
    OVERALL_GAIN_NAME, 0.0f, 1.0f, 1.0f);

Initialize gain parameter in constructor:

std::atomic* overallGain = parameters.getRawParameterValue(OVERALL_GAIN_ID);

And setting range in Editor:

slOverallGain.setTextBoxStyle(Slider::TextBoxAbove, false, 100, 25);
*slOverallGain.setRange(-48.0f, 10.0f);*

I tried to setting range with NormalisableRange, but nothing successed. Only a small area of the slider from 0 to 1 works normally. Above one, the volume increases, but the value of 1 remains on the slider. Below 0, there is no sound at all, the value of 0 remains to the very bottom.

Tell me, please. Сan i make the slider show values from -48 to 10 dB and the initial value is 0? Is it possible in this case to adequately recalculate these values into the gain?

Ok, I made it with NormalisableRange and lambda in createParameter() method.

auto value = [](float value, int) { return String(std::log10(value) * 20.0f); };
auto userValue = [](const String& string)
    if (string.getFloatValue() >= -48.0f)
        return juce::jlimit(0.0f, 2.0f, std::powf(10, string.getFloatValue() * 0.05));
    if (string.getFloatValue() < -48.0f)
        return 0.0f / 20.0f;
auto overallGainParam = std::make_unique<AudioParameterFloat>(OVERALL_GAIN_ID, OVERALL_GAIN_NAME, NormalisableRange<float>(0.0f, 2.0f, 0.1f), 1.0f, "", AudioProcessorParameter::inputGain, value, userValue);

But now I can not normally save parameters in XML. I noticed that when I build the code and run the plugin for the first time, a file is created in my Users folder with the extension .settings . When I call the plugin a second time, my previous settings are returned in a slightly modified form. Each subsequent time the plugin restores the state that was saved after the first call. .settings file is not updated.
Has anyone had this problem? Does anyone know how to deal with this?