I have a Value in the editor that refers to a property Value in the processor’s AudioProcessorValueTreeState’s ValueTree (state). So any changes made to one Value is made to the other, which works fine in every case except when a new property Value has just been loaded into the ValueTree from setStateInformation. So the issue is that I’m not sure why the Value in the editor does not get updated only when the property Value of the ValueTree has been updated after setStateInformation is called.
In my processor class I have:
AudioProcessorValueTreeState parameters;
Identifier Processor::propertyType (name of property); //a static Identifier
ProcessorConstructor()
{
//.....
parameters.state = ValueTree(Identifier(name)); //initialized after adding all parameters
parameters.state.setProperty(propertyType, 0, nullptr );
}
getStateInformation (MemoryBlock& destData)
{
//just like the tutorial
auto state = parameters.copyState();
std::unique_ptr<XmlElement> xml (state.createXml());
copyXmlToBinary (*xml, destData);
}
setStateInformation (const void* data, int sizeInBytes)
{
std::unique_ptr<XmlElement> xmlState (getXmlFromBinary (data, sizeInBytes));
if (xmlState.get() != nullptr)
if (xmlState->hasTagName (parameters.state.getType()))
parameters.replaceState (ValueTree::fromXml (*xmlState));
}
In the editor, I use the Value provided by the ComboBox. I tried using ComboBoxAttachment and it didn’t work (even though it worked when I used it in a non-editor/non-component class for the same processor class). I also tried it with a separate Value member from the Editor and still got the same result.
This is what I have for it:
Processor& processor;
std::unique_ptr<ComboBox> dropDown;
editorConstructor()
{
//.....
dropDown->getSelectedIdAsValue().referTo(processor.parameters.state.getPropertyAsValue(processor.propertyType, nullptr));
}