Added convenience functions to deal with storing and getting audio parameters and use them
This commit is contained in:
parent
73c58f6067
commit
1a8bddeb9b
@ -90,6 +90,16 @@ inline void storeToTreeProperties(ValueTree dest, UndoManager* uman, juce::Ident
|
||||
dest.setProperty(varname+"_end", x.getEnd(), uman);
|
||||
}
|
||||
|
||||
inline void storeToTreeProperties(ValueTree dest, UndoManager* uman, AudioParameterBool* par)
|
||||
{
|
||||
if (par) dest.setProperty(par->paramID,(bool)*par,uman);
|
||||
}
|
||||
|
||||
inline void storeToTreeProperties(ValueTree dest, UndoManager* uman, AudioParameterInt* par)
|
||||
{
|
||||
if (par) dest.setProperty(par->paramID,(int)*par,uman);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void getFromTreeProperties(ValueTree src, juce::Identifier varname, T& val)
|
||||
{
|
||||
@ -115,6 +125,15 @@ 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))
|
||||
{
|
||||
*par = src.getProperty(par->paramID);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
inline void timeCall(String msgprefix,F&& f)
|
||||
{
|
||||
|
@ -210,10 +210,10 @@ ValueTree PaulstretchpluginAudioProcessor::getStateTree(bool ignoreoptions, bool
|
||||
paramtree.setProperty(par->paramID, (double)*par, nullptr);
|
||||
}
|
||||
}
|
||||
paramtree.setProperty(m_outchansparam->paramID, (int)*m_outchansparam, nullptr);
|
||||
paramtree.setProperty(m_inchansparam->paramID, (int)*m_inchansparam, nullptr);
|
||||
paramtree.setProperty(getBoolParameter(cpi_bypass_stretch)->paramID, (bool)*getBoolParameter(cpi_bypass_stretch), nullptr);
|
||||
if (m_current_file != File() && ignorefile == false)
|
||||
storeToTreeProperties(paramtree, nullptr, m_outchansparam);
|
||||
storeToTreeProperties(paramtree, nullptr, m_inchansparam);
|
||||
storeToTreeProperties(paramtree, nullptr, getBoolParameter(cpi_bypass_stretch));
|
||||
if (m_current_file != File() && ignorefile == false)
|
||||
{
|
||||
paramtree.setProperty("importedfile", m_current_file.getFullPathName(), nullptr);
|
||||
}
|
||||
@ -264,13 +264,10 @@ void PaulstretchpluginAudioProcessor::setStateFromTree(ValueTree tree)
|
||||
*par = parval;
|
||||
}
|
||||
}
|
||||
if (tree.hasProperty(m_outchansparam->paramID))
|
||||
*m_outchansparam = tree.getProperty(m_outchansparam->paramID, 2);
|
||||
if (tree.hasProperty(m_inchansparam->paramID))
|
||||
*m_inchansparam = tree.getProperty(m_inchansparam->paramID, 2);
|
||||
if (tree.hasProperty(getBoolParameter(cpi_bypass_stretch)->paramID))
|
||||
*getBoolParameter(cpi_bypass_stretch) = tree.getProperty(getBoolParameter(cpi_bypass_stretch)->paramID, false);
|
||||
}
|
||||
getFromTreeProperties(tree, m_outchansparam);
|
||||
getFromTreeProperties(tree, m_inchansparam);
|
||||
getFromTreeProperties(tree, getBoolParameter(cpi_bypass_stretch));
|
||||
}
|
||||
int prebufamt = tree.getProperty("prebufamount", 2);
|
||||
if (prebufamt == -1)
|
||||
m_use_backgroundbuffering = false;
|
||||
|
Loading…
Reference in New Issue
Block a user