Consolidate and clean up storing and recalling parameters. Enable storing and recalling of spectral module order again, using different state IDs. So old states will be discarded, but oh well...
This commit is contained in:
parent
fb73453723
commit
6747d20aa8
@ -172,7 +172,8 @@ inline void spectrum_copy(int nfreq, REALTYPE* freq1, REALTYPE* freq2)
|
|||||||
|
|
||||||
inline void spectrum_spread(int nfreq, double samplerate,
|
inline void spectrum_spread(int nfreq, double samplerate,
|
||||||
std::vector<REALTYPE>& tmpfreq1,
|
std::vector<REALTYPE>& tmpfreq1,
|
||||||
REALTYPE *freq1, REALTYPE *freq2, REALTYPE spread_bandwidth) {
|
REALTYPE *freq1, REALTYPE *freq2, REALTYPE spread_bandwidth)
|
||||||
|
{
|
||||||
//convert to log spectrum
|
//convert to log spectrum
|
||||||
REALTYPE minfreq = 20.0f;
|
REALTYPE minfreq = 20.0f;
|
||||||
REALTYPE maxfreq = 0.5f*samplerate;
|
REALTYPE maxfreq = 0.5f*samplerate;
|
||||||
|
@ -113,6 +113,22 @@ inline void storeToTreeProperties(ValueTree dest, UndoManager* uman, AudioParame
|
|||||||
if (par) dest.setProperty(par->paramID,(int)*par,uman);
|
if (par) dest.setProperty(par->paramID,(int)*par,uman);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void storeToTreeProperties(ValueTree dest, UndoManager* uman, const OwnedArray<AudioProcessorParameter>& pars)
|
||||||
|
{
|
||||||
|
for (auto& e : pars)
|
||||||
|
{
|
||||||
|
auto parf = dynamic_cast<AudioParameterFloat*>(e);
|
||||||
|
if (parf != nullptr)
|
||||||
|
storeToTreeProperties(dest, nullptr, parf);
|
||||||
|
auto pari = dynamic_cast<AudioParameterInt*>(e);
|
||||||
|
if (pari != nullptr)
|
||||||
|
storeToTreeProperties(dest, nullptr, pari);
|
||||||
|
auto parb = dynamic_cast<AudioParameterBool*>(e);
|
||||||
|
if (parb != nullptr)
|
||||||
|
storeToTreeProperties(dest, nullptr, parb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline void getFromTreeProperties(ValueTree src, juce::Identifier varname, T& val)
|
inline void getFromTreeProperties(ValueTree src, juce::Identifier varname, T& val)
|
||||||
{
|
{
|
||||||
@ -152,6 +168,22 @@ inline void getFromTreeProperties(ValueTree src, T par)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void getFromTreeProperties(ValueTree src, const OwnedArray<AudioProcessorParameter>& pars)
|
||||||
|
{
|
||||||
|
for (auto& e : pars)
|
||||||
|
{
|
||||||
|
auto parf = dynamic_cast<AudioParameterFloat*>(e);
|
||||||
|
if (parf != nullptr && src.hasProperty(parf->paramID))
|
||||||
|
*parf = src.getProperty(parf->paramID);
|
||||||
|
auto pari = dynamic_cast<AudioParameterInt*>(e);
|
||||||
|
if (pari != nullptr && src.hasProperty(pari->paramID))
|
||||||
|
*pari = src.getProperty(pari->paramID);
|
||||||
|
auto parb = dynamic_cast<AudioParameterBool*>(e);
|
||||||
|
if (parb != nullptr && src.hasProperty(parb->paramID))
|
||||||
|
*parb = src.getProperty(parb->paramID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
inline void timeCall(String msgprefix,F&& f)
|
inline void timeCall(String msgprefix,F&& f)
|
||||||
{
|
{
|
||||||
|
@ -88,7 +88,7 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
|
|||||||
m_sm_enab_pars[2] = new AudioParameterBool("enab_specmodule2", "Enable spectral module 3", true);
|
m_sm_enab_pars[2] = new AudioParameterBool("enab_specmodule2", "Enable spectral module 3", true);
|
||||||
m_sm_enab_pars[3] = new AudioParameterBool("enab_specmodule3", "Enable spectral module 4", true);
|
m_sm_enab_pars[3] = new AudioParameterBool("enab_specmodule3", "Enable spectral module 4", true);
|
||||||
m_sm_enab_pars[4] = new AudioParameterBool("enab_specmodule4", "Enable spectral module 5", false);
|
m_sm_enab_pars[4] = new AudioParameterBool("enab_specmodule4", "Enable spectral module 5", false);
|
||||||
m_sm_enab_pars[5] = new AudioParameterBool("enab_specmodule5", "Enable spectral module 6", true);
|
m_sm_enab_pars[5] = new AudioParameterBool("enab_specmodule5", "Enable spectral module 6", false);
|
||||||
m_sm_enab_pars[6] = new AudioParameterBool("enab_specmodule6", "Enable spectral module 7", true);
|
m_sm_enab_pars[6] = new AudioParameterBool("enab_specmodule6", "Enable spectral module 7", true);
|
||||||
m_sm_enab_pars[7] = new AudioParameterBool("enab_specmodule7", "Enable spectral module 8", true);
|
m_sm_enab_pars[7] = new AudioParameterBool("enab_specmodule7", "Enable spectral module 8", true);
|
||||||
m_sm_enab_pars[8] = new AudioParameterBool("enab_specmodule8", "Enable spectral module 9", false);
|
m_sm_enab_pars[8] = new AudioParameterBool("enab_specmodule8", "Enable spectral module 9", false);
|
||||||
@ -217,26 +217,16 @@ int PaulstretchpluginAudioProcessor::getPreBufferAmount()
|
|||||||
ValueTree PaulstretchpluginAudioProcessor::getStateTree(bool ignoreoptions, bool ignorefile)
|
ValueTree PaulstretchpluginAudioProcessor::getStateTree(bool ignoreoptions, bool ignorefile)
|
||||||
{
|
{
|
||||||
ValueTree paramtree("paulstretch3pluginstate");
|
ValueTree paramtree("paulstretch3pluginstate");
|
||||||
for (int i = 0; i<getNumParameters(); ++i)
|
storeToTreeProperties(paramtree, nullptr, getParameters());
|
||||||
{
|
|
||||||
storeToTreeProperties(paramtree, nullptr, getFloatParameter(i));
|
|
||||||
}
|
|
||||||
storeToTreeProperties(paramtree, nullptr, getIntParameter(cpi_numharmonics));
|
|
||||||
storeToTreeProperties(paramtree, nullptr, m_outchansparam);
|
|
||||||
storeToTreeProperties(paramtree, nullptr, m_inchansparam);
|
|
||||||
storeToTreeProperties(paramtree, nullptr, getIntParameter(cpi_freefilter_randomy_numbands));
|
|
||||||
storeToTreeProperties(paramtree, nullptr, getIntParameter(cpi_freefilter_randomy_rate));
|
|
||||||
storeToTreeProperties(paramtree, nullptr, getBoolParameter(cpi_bypass_stretch));
|
|
||||||
if (m_current_file != File() && ignorefile == false)
|
if (m_current_file != File() && ignorefile == false)
|
||||||
{
|
{
|
||||||
paramtree.setProperty("importedfile", m_current_file.getFullPathName(), nullptr);
|
paramtree.setProperty("importedfile", m_current_file.getFullPathName(), nullptr);
|
||||||
}
|
}
|
||||||
auto specorder = m_stretch_source->getSpectrumProcessOrder();
|
auto specorder = m_stretch_source->getSpectrumProcessOrder();
|
||||||
paramtree.setProperty("numspectralstages", (int)specorder.size(), nullptr);
|
paramtree.setProperty("numspectralstagesb", (int)specorder.size(), nullptr);
|
||||||
for (int i = 0; i < specorder.size(); ++i)
|
for (int i = 0; i < specorder.size(); ++i)
|
||||||
{
|
{
|
||||||
paramtree.setProperty("specorder" + String(i), specorder[i].m_index, nullptr);
|
paramtree.setProperty("specorderb" + String(i), specorder[i].m_index, nullptr);
|
||||||
//paramtree.setProperty("specstepenabled" + String(i), specorder[i].m_enabled, nullptr);
|
|
||||||
}
|
}
|
||||||
if (ignoreoptions == false)
|
if (ignoreoptions == false)
|
||||||
{
|
{
|
||||||
@ -261,32 +251,23 @@ void PaulstretchpluginAudioProcessor::setStateFromTree(ValueTree tree)
|
|||||||
ValueTree freefilterstate = tree.getChildWithName("freefilter_envelope");
|
ValueTree freefilterstate = tree.getChildWithName("freefilter_envelope");
|
||||||
m_free_filter_envelope->restoreState(freefilterstate);
|
m_free_filter_envelope->restoreState(freefilterstate);
|
||||||
m_load_file_with_state = tree.getProperty("loadfilewithstate", true);
|
m_load_file_with_state = tree.getProperty("loadfilewithstate", true);
|
||||||
if (tree.hasProperty("numspectralstages"))
|
if (tree.hasProperty("numspectralstagesb"))
|
||||||
{
|
{
|
||||||
/*
|
std::vector<SpectrumProcess> old_order = m_stretch_source->getSpectrumProcessOrder();
|
||||||
std::vector<SpectrumProcess> order;
|
std::vector<SpectrumProcess> new_order;
|
||||||
int ordersize = tree.getProperty("numspectralstages");
|
int ordersize = tree.getProperty("numspectralstagesb");
|
||||||
for (int i = 0; i < ordersize; ++i)
|
if (ordersize == old_order.size())
|
||||||
{
|
{
|
||||||
bool step_enabled = tree.getProperty("specstepenabled" + String(i));
|
for (int i = 0; i < ordersize; ++i)
|
||||||
//order.push_back({ (int)tree.getProperty("specorder" + String(i)), step_enabled });
|
{
|
||||||
|
new_order.push_back({ (int)tree.getProperty("specorderb" + String(i)), old_order[i].m_enabled });
|
||||||
|
}
|
||||||
|
m_stretch_source->setSpectrumProcessOrder(new_order);
|
||||||
}
|
}
|
||||||
if (ordersize<m_stretch_source->getSpectrumProcessOrder().size())
|
|
||||||
order.emplace_back(8,m_sm_enab_pars[8]);
|
|
||||||
m_stretch_source->setSpectrumProcessOrder(order);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
getFromTreeProperties(tree, "waveviewrange", m_wave_view_range);
|
getFromTreeProperties(tree, "waveviewrange", m_wave_view_range);
|
||||||
for (int i = 0; i < getNumParameters(); ++i)
|
getFromTreeProperties(tree, getParameters());
|
||||||
{
|
|
||||||
getFromTreeProperties(tree,getFloatParameter(i));
|
|
||||||
}
|
|
||||||
getFromTreeProperties(tree, getIntParameter(cpi_numharmonics));
|
|
||||||
getFromTreeProperties(tree, m_outchansparam);
|
|
||||||
getFromTreeProperties(tree, m_inchansparam);
|
|
||||||
getFromTreeProperties(tree, getBoolParameter(cpi_bypass_stretch));
|
|
||||||
getFromTreeProperties(tree, getIntParameter(cpi_freefilter_randomy_numbands));
|
|
||||||
getFromTreeProperties(tree, getIntParameter(cpi_freefilter_randomy_rate));
|
|
||||||
}
|
}
|
||||||
int prebufamt = tree.getProperty("prebufamount", 2);
|
int prebufamt = tree.getProperty("prebufamount", 2);
|
||||||
if (prebufamt == -1)
|
if (prebufamt == -1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user