I’m saving my state:
void myplugin::getStateInformation (juce::MemoryBlock& destData)
{
juce::MemoryOutputStream mos(destData, true);
apvts.state.writeToStream(mos);
}
And then restoring:
void myplugin::setStateInformation (const void* data, int sizeInBytes)
{
auto tree = juce::ValueTree::readFromData(data, sizeInBytes);
if (tree.isValid()) //load the parameters from the previous time
{ //the plugin was used
apvts.replaceState(tree);
//here I update parameters
}
}
So, where I have //here I update parameters
I have to restore silder.setValue()
perhaps. I can change variables in my PluginProcessor but what about changing them in PluginEditor and triggering a repaint()
?
I saw this as one way of gaining access to the editor… but is it OK:
if (auto* editor = dynamic_cast<mypluginAudioProcessorEditor*>(getActiveEditor()))
{
editor->updateUIFromParameters(); //this will be my update method in PluginEditor
}
Or how about setting a flag in the PluginProcessor and have the PluginEditor pick up that flag in a timercallback()
?