Parameter store and recall stuff

This commit is contained in:
xenakios 2018-02-23 18:09:01 +02:00
parent 1f24ffb1b6
commit 6f6670b2d4
2 changed files with 10 additions and 12 deletions

View File

@ -90,6 +90,11 @@ inline void storeToTreeProperties(ValueTree dest, UndoManager* uman, juce::Ident
dest.setProperty(varname+"_end", x.getEnd(), uman);
}
inline void storeToTreeProperties(ValueTree dest, UndoManager* uman, AudioParameterFloat* par)
{
if (par) dest.setProperty(par->paramID, (float)*par, uman);
}
inline void storeToTreeProperties(ValueTree dest, UndoManager* uman, AudioParameterBool* par)
{
if (par) dest.setProperty(par->paramID,(bool)*par,uman);
@ -128,7 +133,9 @@ inline void getFromTreeProperties(ValueTree src, juce::Identifier varname, Range
template<typename T>
inline void getFromTreeProperties(ValueTree src, T par)
{
if (par!=nullptr && src.hasProperty(par->paramID))
static_assert(std::is_base_of<AudioProcessorParameterWithID,std::remove_pointer<T>::type>::value,
"T must inherit from AudioProcessorParameterWithID");
if (par!=nullptr && src.hasProperty(par->paramID))
{
*par = src.getProperty(par->paramID);
}

View File

@ -204,11 +204,7 @@ ValueTree PaulstretchpluginAudioProcessor::getStateTree(bool ignoreoptions, bool
ValueTree paramtree("paulstretch3pluginstate");
for (int i = 0; i<getNumParameters(); ++i)
{
auto par = getFloatParameter(i);
if (par != nullptr)
{
paramtree.setProperty(par->paramID, (double)*par, nullptr);
}
storeToTreeProperties(paramtree, nullptr, getFloatParameter(i));
}
storeToTreeProperties(paramtree, nullptr, m_outchansparam);
storeToTreeProperties(paramtree, nullptr, m_inchansparam);
@ -257,12 +253,7 @@ void PaulstretchpluginAudioProcessor::setStateFromTree(ValueTree tree)
getFromTreeProperties(tree, "waveviewrange", m_wave_view_range);
for (int i = 0; i < getNumParameters(); ++i)
{
auto par = getFloatParameter(i);
if (par != nullptr)
{
double parval = tree.getProperty(par->paramID, (double)*par);
*par = parval;
}
getFromTreeProperties(tree,getFloatParameter(i));
}
getFromTreeProperties(tree, m_outchansparam);
getFromTreeProperties(tree, m_inchansparam);