If I create a test VST3 plugin with an AudioProcessor
constructor like this:
TestPluginAudioProcessor::TestPluginAudioProcessor()
: AudioProcessor (BusesProperties()
.withInput ("Input", juce::AudioChannelSet::stereo(), true)
.withOutput ("Output", juce::AudioChannelSet::stereo(), true)
)
, parameters_( *this, nullptr, "PARAMETERS", {
std::make_unique< juce::AudioParameterFloat >( "FooID", "Foo", 0.0, 30.0, 15.0),
})
{
}
Where parameters_
is an AudioProcessorValueTreeState
.
And I implement getStateInformation()
as follows:
void TestPluginAudioProcessor::getStateInformation (juce::MemoryBlock& destData)
{
auto param = getParameters()[0];
param->setValue(0.0f);
const auto value = param->getValue();
DBG("FooID VALUE IS: " + String(value));
auto state = parameters_.copyState();
std::unique_ptr<juce::XmlElement> xml (state.createXml());
DBG( "STATE: " + xml->toString() );
}
Then when calling getStateInformation()
, I get the following output:
FooID VALUE IS: 0
STATE: <?xml version="1.0" encoding="UTF-8"?>
<PARAMETERS>
<PARAM id="FooID" value="15.0"/>
</PARAMETERS>
In other words, the internal ValueTree
state seems to be inconsistent with the actual parameter state. My understanding was that calling copyState()
is supposed to bring the two into sync.
If I call setValueNotifyingHost()
instead of setValue()
then it works as expected, but this isn’t going to work if hosts are calling setValue()
.
JUCE 6.1.6. macOS.