Store and restore free filter state

This commit is contained in:
xenakios 2018-02-27 03:41:54 +02:00
parent cf9b54d19b
commit 7c61a552c2
2 changed files with 11 additions and 5 deletions

View File

@ -232,6 +232,8 @@ ValueTree PaulstretchpluginAudioProcessor::getStateTree(bool ignoreoptions, bool
paramtree.setProperty("loadfilewithstate", m_load_file_with_state, nullptr); paramtree.setProperty("loadfilewithstate", m_load_file_with_state, nullptr);
} }
storeToTreeProperties(paramtree, nullptr, "waveviewrange", m_wave_view_range); storeToTreeProperties(paramtree, nullptr, "waveviewrange", m_wave_view_range);
ValueTree freefilterstate = m_free_filter_envelope->saveState(Identifier("freefilter_envelope"));
paramtree.addChild(freefilterstate, -1, nullptr);
return paramtree; return paramtree;
} }
@ -241,6 +243,8 @@ void PaulstretchpluginAudioProcessor::setStateFromTree(ValueTree tree)
{ {
{ {
ScopedLock locker(m_cs); ScopedLock locker(m_cs);
ValueTree freefilterstate = tree.getChildWithName("freefilter_envelope");
m_free_filter_envelope->restoreState(freefilterstate);
m_load_file_with_state = tree.getProperty("loadfilewithstate", true); m_load_file_with_state = tree.getProperty("loadfilewithstate", true);
if (tree.hasProperty("numspectralstages")) if (tree.hasProperty("numspectralstages"))
{ {

View File

@ -210,9 +210,9 @@ public:
double GetDefValue() { return m_defvalue; } double GetDefValue() { return m_defvalue; }
void SetDefValue(double value) { m_defvalue=value; } void SetDefValue(double value) { m_defvalue=value; }
int GetDefShape() { return m_defshape; } 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) for (int i = 0; i < m_nodes.size(); ++i)
{ {
ValueTree pt_tree("pt"); ValueTree pt_tree("pt");
@ -224,6 +224,8 @@ public:
} }
void restoreState(ValueTree state) void restoreState(ValueTree state)
{ {
if (state.isValid()==false)
return;
int numnodes = state.getNumChildren(); int numnodes = state.getNumChildren();
if (numnodes > 0) if (numnodes > 0)
{ {