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?
AudioProcessorValueTreeState::createParameter() {
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); params.push_back(std::move(overallGainParam)); }
Initialize gain parameter in constructor:
std::atomic* overallGain = parameters.getRawParameterValue(OVERALL_GAIN_ID);
And setting range in Editor:
addAndMakeVisible(&slOverallGain); slOverallGain.setTextBoxStyle(Slider::TextBoxAbove, false, 100, 25); slOverallGain.setTextValueSuffix("dB"); slOverallGain.setSliderStyle(Slider::SliderStyle::LinearVertical); *slOverallGain.setRange(-48.0f, 10.0f);* slOverallGain.addListener(this);
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?