From 7c61a552c286bd43b053824bf2e6ca8df907c790 Mon Sep 17 00:00:00 2001 From: xenakios Date: Tue, 27 Feb 2018 03:41:54 +0200 Subject: [PATCH] Store and restore free filter state --- Source/PluginProcessor.cpp | 8 ++++++-- Source/jcdp_envelope.h | 8 +++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 7f9d79e..b00b8fc 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -232,7 +232,9 @@ ValueTree PaulstretchpluginAudioProcessor::getStateTree(bool ignoreoptions, bool paramtree.setProperty("loadfilewithstate", m_load_file_with_state, nullptr); } storeToTreeProperties(paramtree, nullptr, "waveviewrange", m_wave_view_range); - return paramtree; + ValueTree freefilterstate = m_free_filter_envelope->saveState(Identifier("freefilter_envelope")); + paramtree.addChild(freefilterstate, -1, nullptr); + return paramtree; } void PaulstretchpluginAudioProcessor::setStateFromTree(ValueTree tree) @@ -241,7 +243,9 @@ void PaulstretchpluginAudioProcessor::setStateFromTree(ValueTree tree) { { ScopedLock locker(m_cs); - m_load_file_with_state = tree.getProperty("loadfilewithstate", true); + ValueTree freefilterstate = tree.getChildWithName("freefilter_envelope"); + m_free_filter_envelope->restoreState(freefilterstate); + m_load_file_with_state = tree.getProperty("loadfilewithstate", true); if (tree.hasProperty("numspectralstages")) { std::vector order; diff --git a/Source/jcdp_envelope.h b/Source/jcdp_envelope.h index 454db0a..e131b5f 100644 --- a/Source/jcdp_envelope.h +++ b/Source/jcdp_envelope.h @@ -210,9 +210,9 @@ public: double GetDefValue() { return m_defvalue; } void SetDefValue(double value) { m_defvalue=value; } int GetDefShape() { return m_defshape; } - ValueTree saveState() + ValueTree saveState(Identifier id) { - ValueTree result("envelope"); + ValueTree result(id); for (int i = 0; i < m_nodes.size(); ++i) { ValueTree pt_tree("pt"); @@ -224,7 +224,9 @@ public: } void restoreState(ValueTree state) { - int numnodes = state.getNumChildren(); + if (state.isValid()==false) + return; + int numnodes = state.getNumChildren(); if (numnodes > 0) { m_nodes.clear();