Skip to content

Commit 139f29e

Browse files
committed
ensure that plugin state for all parameters is persisted on save/get
1 parent 1a626e2 commit 139f29e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/PluginProcessor.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,18 @@ void SetekhAudioProcessor::changeProgramName(int, const juce::String &) {
101101
}
102102

103103
void SetekhAudioProcessor::getStateInformation(juce::MemoryBlock &destData) {
104-
// Save plugin state here
105-
juce::MemoryOutputStream stream(destData, true);
106-
// stream.writeFloat(someValue);
104+
auto state = apvts.copyState();
105+
std::unique_ptr<juce::XmlElement> xml(state.createXml());
106+
copyXmlToBinary(*xml, destData);
107107
}
108108

109109
void SetekhAudioProcessor::setStateInformation(const void *data, int sizeInBytes) {
110-
// Restore plugin state here
111-
juce::MemoryInputStream stream(data, static_cast<size_t>(sizeInBytes), false);
112-
// someValue = stream.readFloat();
110+
std::unique_ptr<juce::XmlElement> xmlState(getXmlFromBinary(data, sizeInBytes));
111+
112+
if (xmlState != nullptr)
113+
{
114+
apvts.replaceState(juce::ValueTree::fromXml(*xmlState));
115+
}
113116
}
114117

115118
// Required factory function

0 commit comments

Comments
 (0)