diff --git a/Source/PS_Source/StretchSource.cpp b/Source/PS_Source/StretchSource.cpp index bf025ce..73a2280 100644 --- a/Source/PS_Source/StretchSource.cpp +++ b/Source/PS_Source/StretchSource.cpp @@ -128,35 +128,6 @@ void StretchAudioSource::setFreeFilterEnvelope(shared_envelope env) } } -ValueTree StretchAudioSource::getStateTree() -{ - ValueTree tree("stretchsourcestate"); - storeToTreeProperties(tree, nullptr, "pitch_shift", m_ppar.pitch_shift.cents, - "octaves_minus2", m_ppar.octave.om2, - "octaves_minus1",m_ppar.octave.om1, - "octave0",m_ppar.octave.o0, - "octave_plus1",m_ppar.octave.o1, - "octaves_plus15",m_ppar.octave.o15, - "octaves_plus2",m_ppar.octave.o2); - return tree; -} - -void StretchAudioSource::setStateTree(ValueTree state) -{ - ScopedLock locker(m_cs); - getFromTreeProperties(state, "pitch_shift", m_ppar.pitch_shift.cents, - "octaves_minus2", m_ppar.octave.om2, - "octaves_minus1", m_ppar.octave.om1, - "octave0", m_ppar.octave.o0, - "octave_plus1", m_ppar.octave.o1, - "octaves_plus15", m_ppar.octave.o15, - "octaves_plus2", m_ppar.octave.o2); - for (int i = 0; i < m_stretchers.size(); ++i) - { - m_stretchers[i]->set_parameters(&m_ppar); - } -} - bool StretchAudioSource::isLoopingEnabled() { if (m_inputfile == nullptr || m_inputfile->info.nsamples == 0) diff --git a/Source/PS_Source/StretchSource.h b/Source/PS_Source/StretchSource.h index 865dde4..ae01e16 100644 --- a/Source/PS_Source/StretchSource.h +++ b/Source/PS_Source/StretchSource.h @@ -89,8 +89,6 @@ public: void setFreeFilterEnvelope(shared_envelope env); - ValueTree getStateTree(); - void setStateTree(ValueTree state); void setClippingEnabled(bool b) { m_clip_output = b; } bool isLoopingEnabled(); void setLoopingEnabled(bool b); diff --git a/Source/PS_Source/globals.h b/Source/PS_Source/globals.h index 2a2291a..e36fb7c 100644 --- a/Source/PS_Source/globals.h +++ b/Source/PS_Source/globals.h @@ -85,16 +85,12 @@ inline bool hasProperties(ValueTree src, Args&&... args) return (src.hasProperty(args) && ...); } -inline void storeToTreeProperties(ValueTree dest, UndoManager* uman, juce::Identifier varname, var val) -{ - dest.setProperty(varname, val, uman); -} - template inline void storeToTreeProperties(ValueTree dest, UndoManager* uman, juce::Identifier varname, var val, Ts&&... args) { dest.setProperty(varname, val, uman); - storeToTreeProperties(dest, uman, args...); + if constexpr(sizeof...(Ts)>1) + storeToTreeProperties(dest, uman, args...); } template @@ -135,19 +131,13 @@ inline void storeToTreeProperties(ValueTree dest, UndoManager* uman, const Owned } } -template -inline void getFromTreeProperties(ValueTree src, juce::Identifier varname, T& val) -{ - if (src.hasProperty(varname)) - val = src.getProperty(varname); -} - template inline void getFromTreeProperties(ValueTree src, juce::Identifier varname, T& val, Ts&... args) { if (src.hasProperty(varname)) val = src.getProperty(varname); - getFromTreeProperties(src, args...); + if constexpr(sizeof...(Ts)>1) + getFromTreeProperties(src, args...); } template