Hello,
I’m fairly new to this, so forgive me if this is a stupid question!
I’m trying to create a plugin. I have used the Juce GUI Component, that creates a plugineditor template for you. I have also implemented the Value Tree system.
I’m not sure of the best way of handling changes to variable through slider movements…
So. I’ve created a public variable called Gain, in my pluginprocessor.h. I want to change this value.
When I add a slider for Gain using the subcomponents tab in the GUI Component, the template adds the following to plugineditor.cpp
if (sliderThatWasMoved == GainSlider)
{
//[UserSliderCode_GainSlider] – add your slider handling code here…
//[/UserSliderCode_GainSlider]
}
Which of the following is the best way of handling changes.
- Ignoring the attachment and simply putting the following in the [UserSliderCode_GainSlider] section in plugineditor.cpp
i.e. processor.Gain = GainSlider->getvalue();
I guess this makes setting up the Valuetree pointless and misses the point?
- Putting the following in the [UserSliderCode_GainSlider] section in plugineditor.cpp
processor.Gain = myValueTree.getRawParameterValue (“gain”);
Or some variation of this, because I currently can’t this to work because myValueTree is stored as private in the processor cpp. So I’m not sure how to make that work unless I make myValueTree public? Which is inadvisable right?
- Handling any changes to gain in processor.cpp with code like
Gain = myValueTree.getRawParameterValue (“gain”);
But then there the whole sliderthatwasmoved section from the editor.cpp is redundant, and this seems inefficient?
Please let me know your thoughts or if there is a better of doing this that I haven’t managed to grasp.