diff --git a/Source/PS_Source/ProcessedStretch.h b/Source/PS_Source/ProcessedStretch.h index 3e73b6d..3110c7f 100644 --- a/Source/PS_Source/ProcessedStretch.h +++ b/Source/PS_Source/ProcessedStretch.h @@ -486,6 +486,8 @@ public: inline void swapSpectrumProcesses(SpectrumProcess& a, SpectrumProcess& b) { + std::swap(a, b); + return; bool aenab = *b.m_enabled; bool benab = *a.m_enabled; std::swap(a.m_index, b.m_index); diff --git a/Source/PS_Source/StretchSource.cpp b/Source/PS_Source/StretchSource.cpp index 2685e2b..5e7f437 100644 --- a/Source/PS_Source/StretchSource.cpp +++ b/Source/PS_Source/StretchSource.cpp @@ -16,7 +16,10 @@ StretchAudioSource::StretchAudioSource(int initialnumoutchans, m_resampler_outbuf.resize(1024*1024); m_inputfile = std::make_unique(m_afm); for (int i = 0; i < enab_pars.size(); ++i) + { m_specproc_order.emplace_back(i, enab_pars[i]); + m_specprocmap[i] = i; + } //m_specproc_order = { {0,false} , { 1, false} ,{2,true},{3,true},{4,true},{5,false},{6,true},{7,true},{8,false} }; setNumOutChannels(initialnumoutchans); m_xfadetask.buffer.setSize(8, 65536); @@ -71,6 +74,9 @@ std::vector StretchAudioSource::getSpectrumProcessOrder() void StretchAudioSource::setSpectrumProcessOrder(std::vector order) { ScopedLock locker(m_cs); + m_specprocmap.clear(); + for (int i = 0; i < order.size(); ++i) + m_specprocmap[i] = order[i].m_index; m_specproc_order = order; for (int i = 0; i < m_stretchers.size(); ++i) { @@ -166,17 +172,13 @@ void StretchAudioSource::setMainVolume(double decibels) void StretchAudioSource::setSpectralModulesEnabled(const std::array& params) { + jassert(m_specprocmap.size() > 0); /* - jassert(params.size() == m_specproc_order.size()); - std::set foo; - for (auto& e : params) - foo.insert(e); - jassert(foo.size() == params.size()); - */ bool changed = false; for (int i = 0; i < m_specproc_order.size(); ++i) { - if (*params[i] != *m_specproc_order[i].m_enabled) + int index = m_specprocmap[i]; + if (*params[index] != *m_specproc_order[i].m_enabled) { changed = true; break; @@ -184,11 +186,13 @@ void StretchAudioSource::setSpectralModulesEnabled(const std::array m_resampler_outbuf; CriticalSection m_cs; std::vector m_specproc_order; + std::unordered_map m_specprocmap; bool m_stop_play_requested = false; double m_freeze_pos = 0.0; int64_t m_output_counter = 0; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 67a4299..1052ea7 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -80,15 +80,15 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor() // The default priority of 2 is a bit too low in some cases, it seems... m_thumbcache->getTimeSliceThread().setPriority(3); - m_sm_enab_pars[0] = new AudioParameterBool("enab_specmodule0", "Enable spectral module 1", false); - m_sm_enab_pars[1] = new AudioParameterBool("enab_specmodule1", "Enable spectral module 2", false); - 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[4] = new AudioParameterBool("enab_specmodule4", "Enable spectral module 5", false); - 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[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[0] = new AudioParameterBool("enab_specmodule0", "Enable harmonics", false); + m_sm_enab_pars[1] = new AudioParameterBool("enab_specmodule1", "Enable tonal vs noise", false); + m_sm_enab_pars[2] = new AudioParameterBool("enab_specmodule2", "Enable frequency shift", true); + m_sm_enab_pars[3] = new AudioParameterBool("enab_specmodule3", "Enable pitch shift", true); + m_sm_enab_pars[4] = new AudioParameterBool("enab_specmodule4", "Enable ratios", false); + m_sm_enab_pars[5] = new AudioParameterBool("enab_specmodule5", "Enable spread", false); + m_sm_enab_pars[6] = new AudioParameterBool("enab_specmodule6", "Enable filter", true); + m_sm_enab_pars[7] = new AudioParameterBool("enab_specmodule7", "Enable free filter", true); + m_sm_enab_pars[8] = new AudioParameterBool("enab_specmodule8", "Enable compressor", false); m_stretch_source = std::make_unique(2, m_afm,m_sm_enab_pars);