From 7d8ba0c15f08c5a25897d4cc78d5efe4d9766e77 Mon Sep 17 00:00:00 2001 From: xenakios Date: Wed, 27 Dec 2017 22:43:07 +0200 Subject: [PATCH] Allow getting state tree without imported file and options. Update spectral order component from timer. --- Source/PluginEditor.cpp | 8 ++++++-- Source/PluginProcessor.cpp | 20 ++++++++++++-------- Source/PluginProcessor.h | 3 ++- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 73bb023..70f22dd 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -217,7 +217,11 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id) processor.getSampleRateChecked(), bufptr->getNumSamples()); } m_wavecomponent.setTimeSelection(processor.getTimeSelection()); - + if (processor.m_state_dirty) + { + m_spec_order_ed.setSource(processor.getStretchSource()); + processor.m_state_dirty = false; + } } if (id == 3) { @@ -362,7 +366,7 @@ String juceversiontxt = String("JUCE ") + String(JUCE_MAJOR_VERSION) + "." + Str } if (r == 6) { - ValueTree tree = processor.getStateTree(); + ValueTree tree = processor.getStateTree(true,true); MemoryBlock destData; MemoryOutputStream stream(destData, true); tree.writeToStream(stream); diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 51e470a..ce8d256 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -223,7 +223,7 @@ int PaulstretchpluginAudioProcessor::getPreBufferAmount() return m_prebuffer_amount; } -ValueTree PaulstretchpluginAudioProcessor::getStateTree() +ValueTree PaulstretchpluginAudioProcessor::getStateTree(bool ignoreoptions, bool ignorefile) { ValueTree paramtree("paulstretch3pluginstate"); for (int i = 0; iparamID, (int)*m_outchansparam, nullptr); - if (m_current_file != File()) + if (m_current_file != File() && ignorefile == false) { paramtree.setProperty("importedfile", m_current_file.getFullPathName(), nullptr); } @@ -245,11 +245,14 @@ ValueTree PaulstretchpluginAudioProcessor::getStateTree() { paramtree.setProperty("specorder" + String(i), specorder[i], nullptr); } - if (m_use_backgroundbuffering) - paramtree.setProperty("prebufamount", m_prebuffer_amount, nullptr); - else - paramtree.setProperty("prebufamount", -1, nullptr); - paramtree.setProperty("loadfilewithstate", m_load_file_with_state, nullptr); + if (ignoreoptions == false) + { + if (m_use_backgroundbuffering) + paramtree.setProperty("prebufamount", m_prebuffer_amount, nullptr); + else + paramtree.setProperty("prebufamount", -1, nullptr); + paramtree.setProperty("loadfilewithstate", m_load_file_with_state, nullptr); + } return paramtree; } @@ -297,6 +300,7 @@ void PaulstretchpluginAudioProcessor::setStateFromTree(ValueTree tree) setAudioFile(f); } } + m_state_dirty = true; } } @@ -639,7 +643,7 @@ AudioProcessorEditor* PaulstretchpluginAudioProcessor::createEditor() //============================================================================== void PaulstretchpluginAudioProcessor::getStateInformation (MemoryBlock& destData) { - ValueTree paramtree = getStateTree(); + ValueTree paramtree = getStateTree(false,false); MemoryOutputStream stream(destData,true); paramtree.writeToStream(stream); } diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index cb7b5a3..139c649 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -145,8 +145,9 @@ public: void setPreBufferAmount(int x); int getPreBufferAmount(); bool m_load_file_with_state = true; - ValueTree getStateTree(); + ValueTree getStateTree(bool ignoreoptions, bool ignorefile); void setStateFromTree(ValueTree tree); + bool m_state_dirty = false; private: