Messy attempt to make the spectral module enabled parameters be tied to particular modules, this needs to be seriously examined...

This commit is contained in:
xenakios 2018-04-26 21:45:37 +03:00
parent 40fcc1bdb0
commit cd15a0ea48
4 changed files with 24 additions and 17 deletions

View File

@ -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);

View File

@ -16,7 +16,10 @@ StretchAudioSource::StretchAudioSource(int initialnumoutchans,
m_resampler_outbuf.resize(1024*1024);
m_inputfile = std::make_unique<AInputS>(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<SpectrumProcess> StretchAudioSource::getSpectrumProcessOrder()
void StretchAudioSource::setSpectrumProcessOrder(std::vector<SpectrumProcess> 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<AudioParameterBool*, 9>& params)
{
jassert(m_specprocmap.size() > 0);
/*
jassert(params.size() == m_specproc_order.size());
std::set<AudioParameterBool*> 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<AudioParamet
}
if (changed == false)
return;
*/
if (m_cs.tryEnter())
{
for (int i = 0; i < m_specproc_order.size(); ++i)
{
*m_specproc_order[i].m_enabled = (bool)(*params[i]);
int index = m_specprocmap[i];
*m_specproc_order[i].m_enabled = (bool)(*params[index]);
}
for (int i = 0; i < m_stretchers.size(); ++i)
{

View File

@ -142,6 +142,7 @@ private:
std::vector<double> m_resampler_outbuf;
CriticalSection m_cs;
std::vector<SpectrumProcess> m_specproc_order;
std::unordered_map<int, int> m_specprocmap;
bool m_stop_play_requested = false;
double m_freeze_pos = 0.0;
int64_t m_output_counter = 0;

View File

@ -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<StretchAudioSource>(2, m_afm,m_sm_enab_pars);