From 8a1db5f2f5b7fe34d9360cc1fc3cc1178f626373 Mon Sep 17 00:00:00 2001 From: Legaeli Date: Thu, 27 Nov 2025 14:12:30 +0100 Subject: [PATCH] Fixed bug, where the parameters are not saved on DAW restart. --- CrystalizerEQ/PluginProcessor.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/CrystalizerEQ/PluginProcessor.cpp b/CrystalizerEQ/PluginProcessor.cpp index f473670..d91e824 100644 --- a/CrystalizerEQ/PluginProcessor.cpp +++ b/CrystalizerEQ/PluginProcessor.cpp @@ -806,14 +806,19 @@ juce::AudioProcessorEditor *CrystalizerEQAudioProcessor::createEditor() { //============================================================================== void CrystalizerEQAudioProcessor::getStateInformation(juce::MemoryBlock &destData) { - // You should use this method to store your parameters in the memory block. - // You could do that either as raw data, or use the XML or ValueTree classes - // as intermediaries to make it easy to save and load complex data. + auto state = apvts.copyState(); + std::unique_ptr xml(state.createXml()); + copyXmlToBinary(*xml, destData); } void CrystalizerEQAudioProcessor::setStateInformation(const void *data, int sizeInBytes) { - // You should use this method to restore your parameters from this memory block, - // whose contents will have been created by the getStateInformation() call. + std::unique_ptr xmlState(getXmlFromBinary(data, sizeInBytes)); + + if (xmlState != nullptr) { + if (xmlState->hasTagName(apvts.state.getType())) { + apvts.replaceState(juce::ValueTree::fromXml(*xmlState)); + } + } } //==============================================================================