Allow getting state tree without imported file and options. Update spectral order component from timer.

This commit is contained in:
xenakios 2017-12-27 22:43:07 +02:00
parent 843af8a8f9
commit 7d8ba0c15f
3 changed files with 20 additions and 11 deletions

View File

@ -217,7 +217,11 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id)
processor.getSampleRateChecked(), bufptr->getNumSamples()); processor.getSampleRateChecked(), bufptr->getNumSamples());
} }
m_wavecomponent.setTimeSelection(processor.getTimeSelection()); 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) if (id == 3)
{ {
@ -362,7 +366,7 @@ String juceversiontxt = String("JUCE ") + String(JUCE_MAJOR_VERSION) + "." + Str
} }
if (r == 6) if (r == 6)
{ {
ValueTree tree = processor.getStateTree(); ValueTree tree = processor.getStateTree(true,true);
MemoryBlock destData; MemoryBlock destData;
MemoryOutputStream stream(destData, true); MemoryOutputStream stream(destData, true);
tree.writeToStream(stream); tree.writeToStream(stream);

View File

@ -223,7 +223,7 @@ int PaulstretchpluginAudioProcessor::getPreBufferAmount()
return m_prebuffer_amount; return m_prebuffer_amount;
} }
ValueTree PaulstretchpluginAudioProcessor::getStateTree() ValueTree PaulstretchpluginAudioProcessor::getStateTree(bool ignoreoptions, bool ignorefile)
{ {
ValueTree paramtree("paulstretch3pluginstate"); ValueTree paramtree("paulstretch3pluginstate");
for (int i = 0; i<getNumParameters(); ++i) for (int i = 0; i<getNumParameters(); ++i)
@ -235,7 +235,7 @@ ValueTree PaulstretchpluginAudioProcessor::getStateTree()
} }
} }
paramtree.setProperty(m_outchansparam->paramID, (int)*m_outchansparam, nullptr); paramtree.setProperty(m_outchansparam->paramID, (int)*m_outchansparam, nullptr);
if (m_current_file != File()) if (m_current_file != File() && ignorefile == false)
{ {
paramtree.setProperty("importedfile", m_current_file.getFullPathName(), nullptr); paramtree.setProperty("importedfile", m_current_file.getFullPathName(), nullptr);
} }
@ -245,11 +245,14 @@ ValueTree PaulstretchpluginAudioProcessor::getStateTree()
{ {
paramtree.setProperty("specorder" + String(i), specorder[i], nullptr); paramtree.setProperty("specorder" + String(i), specorder[i], nullptr);
} }
if (m_use_backgroundbuffering) if (ignoreoptions == false)
paramtree.setProperty("prebufamount", m_prebuffer_amount, nullptr); {
else if (m_use_backgroundbuffering)
paramtree.setProperty("prebufamount", -1, nullptr); paramtree.setProperty("prebufamount", m_prebuffer_amount, nullptr);
paramtree.setProperty("loadfilewithstate", m_load_file_with_state, nullptr); else
paramtree.setProperty("prebufamount", -1, nullptr);
paramtree.setProperty("loadfilewithstate", m_load_file_with_state, nullptr);
}
return paramtree; return paramtree;
} }
@ -297,6 +300,7 @@ void PaulstretchpluginAudioProcessor::setStateFromTree(ValueTree tree)
setAudioFile(f); setAudioFile(f);
} }
} }
m_state_dirty = true;
} }
} }
@ -639,7 +643,7 @@ AudioProcessorEditor* PaulstretchpluginAudioProcessor::createEditor()
//============================================================================== //==============================================================================
void PaulstretchpluginAudioProcessor::getStateInformation (MemoryBlock& destData) void PaulstretchpluginAudioProcessor::getStateInformation (MemoryBlock& destData)
{ {
ValueTree paramtree = getStateTree(); ValueTree paramtree = getStateTree(false,false);
MemoryOutputStream stream(destData,true); MemoryOutputStream stream(destData,true);
paramtree.writeToStream(stream); paramtree.writeToStream(stream);
} }

View File

@ -145,8 +145,9 @@ public:
void setPreBufferAmount(int x); void setPreBufferAmount(int x);
int getPreBufferAmount(); int getPreBufferAmount();
bool m_load_file_with_state = true; bool m_load_file_with_state = true;
ValueTree getStateTree(); ValueTree getStateTree(bool ignoreoptions, bool ignorefile);
void setStateFromTree(ValueTree tree); void setStateFromTree(ValueTree tree);
bool m_state_dirty = false;
private: private: