Hi all,
I am using the function textFromValueFunction
to modify the text of a label associated to a slider. I can indeed change that text but only when the slider is actually moved, whereas I would like to have it changed already when the GUI is created. I am using this code:
class PanelFilter
{
public:
PanelFilter (AudioProcessorValueTreeState& valueTreeState)
{
filterSystemDecayLabel.setText ("System Decay", dontSendNotification);
filterSystemDecayLabel.attachToComponent (&filterSystemDecaySlider, true);
addAndMakeVisible (filterSystemDecayLabel);
addAndMakeVisible (filterSystemDecaySlider);
filterSystemDecayAttachment.reset (new SliderAttachment (valueTreeState, "system_decay_panel_filter", filterSystemDecaySlider));
filterSystemDecaySlider.textFromValueFunction = [](float value)
{
float systemDecay = value / PluginConstants::scaleFactor;
return juce::String(systemDecay);
};
filterSystemDecaySlider.valueFromTextFunction = [](const String &text)
{
float systemDecay = text.getFloatValue();
return systemDecay * PluginConstants::scaleFactor;
};
}
Note that the value that is displayed at the start of the GUI is the one I set here
AudioProcessorValueTreeState::ParameterLayout FilterSynthesizerAudioProcessor::createParameterLayoutPanelFilter1()
{
auto SystemDecayFilter1Param = std::make_unique<AudioParameterFloat> ("system_decay_panel_filter1",// parameterID
"System Decay Filter1", // parameter name
0.0f * PluginConstants::scaleFactor, // minimum value
0.99999f * PluginConstants::scaleFactor, // maximum value
0.9965f * PluginConstants::scaleFactor); // default value
that is called in
FilterSynthesizerAudioProcessor::FilterSynthesizerAudioProcessor()
: AudioProcessor (BusesProperties().withOutput ("Output", AudioChannelSet::stereo(), true)),
parametersPanelFilter1 (*this, nullptr, Identifier ("ParametersPanelFilter1"), createParameterLayoutPanelFilter1())
{
systemDecayParameterPanelFilter1 = parametersPanelFilter1.getRawParameterValue ("system_decay_panel_filter1");
}