The spectral module enabled parameters still not doing so great...

This commit is contained in:
xenakios 2018-03-09 18:05:33 +02:00
parent 828c9e1479
commit 6d7671e8cf
6 changed files with 40 additions and 24 deletions

View File

@ -104,23 +104,23 @@ void ProcessedStretch::process_spectrum(REALTYPE *freq)
for (auto& e : m_spectrum_processes)
{
spectrum_copy(nfreq, freq, m_infreq.data());
if (e.m_index == 0 && e.m_enabled == true)
if (e.m_index == 0 && *e.m_enabled == true)
spectrum_do_harmonics(pars, m_tmpfreq1, nfreq, samplerate, m_infreq.data(), freq);
if (e.m_index == 1 && e.m_enabled == true)
if (e.m_index == 1 && *e.m_enabled == true)
spectrum_do_tonal_vs_noise(pars,nfreq,samplerate,m_tmpfreq1, m_infreq.data(), freq);
if (e.m_index == 2 && e.m_enabled == true)
if (e.m_index == 2 && *e.m_enabled == true)
spectrum_do_freq_shift(pars,nfreq,samplerate,m_infreq.data(), freq);
if (e.m_index == 3 && e.m_enabled == true)
if (e.m_index == 3 && *e.m_enabled == true)
spectrum_do_pitch_shift(pars,nfreq,m_infreq.data(), freq, pow(2.0f, pars.pitch_shift.cents / 1200.0f));
if (e.m_index == 4 && e.m_enabled == true)
if (e.m_index == 4 && *e.m_enabled == true)
spectrum_do_octave(pars,nfreq,samplerate, m_sumfreq, m_tmpfreq1, m_infreq.data(), freq);
if (e.m_index == 5 && e.m_enabled == true)
if (e.m_index == 5 && *e.m_enabled == true)
spectrum_spread(nfreq,samplerate,m_tmpfreq1,m_infreq.data(), freq, pars.spread.bandwidth);
if (e.m_index == 6 && e.m_enabled == true)
if (e.m_index == 6 && *e.m_enabled == true)
spectrum_do_filter(pars,nfreq,samplerate,m_infreq.data(), freq);
if (e.m_index == 7 && e.m_enabled == true)
if (e.m_index == 7 && *e.m_enabled == true)
spectrum_do_compressor(pars,nfreq, m_infreq.data(), freq);
if (e.m_index == 8 && e.m_enabled == true)
if (e.m_index == 8 && *e.m_enabled == true)
spectrum_do_free_filter(m_free_filter_envelope, nfreq, samplerate, m_infreq.data(), freq);
}
};

View File

@ -438,9 +438,9 @@ class SpectrumProcess
{
public:
SpectrumProcess() {}
SpectrumProcess(int index, bool enabled) : m_index(index), m_enabled(enabled) {}
SpectrumProcess(int index, AudioParameterBool* enabled) : m_index(index), m_enabled(enabled) {}
int m_index = -1;
bool m_enabled = true;
AudioParameterBool* m_enabled = nullptr;
};
class ProcessedStretch final : public Stretch

View File

@ -1,4 +1,5 @@
#include "StretchSource.h"
#include <set>
#ifdef WIN32
#include <ppl.h>
@ -7,12 +8,16 @@
#undef max
#endif
StretchAudioSource::StretchAudioSource(int initialnumoutchans, AudioFormatManager* afm) : m_afm(afm)
StretchAudioSource::StretchAudioSource(int initialnumoutchans,
AudioFormatManager* afm,
std::array<AudioParameterBool*,9>& enab_pars) : m_afm(afm)
{
m_resampler = std::make_unique<WDL_Resampler>();
m_resampler_outbuf.resize(1024*1024);
m_inputfile = std::make_unique<AInputS>(m_afm);
m_specproc_order = { {0,false} , { 1, false} ,{2,true},{3,true},{4,true},{5,false},{6,true},{7,true},{8,false} };
for (int i = 0; i < enab_pars.size(); ++i)
m_specproc_order.emplace_back(i, enab_pars[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);
m_xfadetask.buffer.clear();
@ -162,10 +167,14 @@ void StretchAudioSource::setMainVolume(double decibels)
void StretchAudioSource::setSpectralModulesEnabled(const std::array<AudioParameterBool*, 9>& params)
{
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)
if (*params[i] != *m_specproc_order[i].m_enabled)
{
changed = true;
break;
@ -177,7 +186,7 @@ void StretchAudioSource::setSpectralModulesEnabled(const std::array<AudioParamet
{
for (int i = 0; i < m_specproc_order.size(); ++i)
{
m_specproc_order[i].m_enabled = *params[i];
*m_specproc_order[i].m_enabled = (bool)(*params[i]);
}
for (int i = 0; i < m_stretchers.size(); ++i)
{

View File

@ -31,7 +31,7 @@ class StretchAudioSource final : public PositionableAudioSource
{
public:
StretchAudioSource() {}
StretchAudioSource(int initialnumoutchans, AudioFormatManager* afm);
StretchAudioSource(int initialnumoutchans, AudioFormatManager* afm, std::array<AudioParameterBool*, 9>& enab_pars);
~StretchAudioSource();
// Inherited via PositionableAudioSource
void prepareToPlay(int samplesPerBlockExpected, double sampleRate) override;

View File

@ -925,7 +925,7 @@ void SpectralChainEditor::mouseDown(const MouseEvent & ev)
juce::Rectangle<int> r(box_w*m_cur_index, 1, 12, 12);
if (r.contains(ev.x, ev.y))
{
m_order[m_cur_index].m_enabled = !m_order[m_cur_index].m_enabled;
toggleBool(m_order[m_cur_index].m_enabled);
m_src->setSpectrumProcessOrder(m_order);
if (ModuleOrderOrEnabledChangedCallback)
ModuleOrderOrEnabledChangedCallback();
@ -993,6 +993,7 @@ void SpectralChainEditor::moveModule(int old_id, int new_id)
void SpectralChainEditor::drawBox(Graphics & g, int index, int x, int y, int w, int h)
{
jassert(m_order[index].m_enabled != nullptr);
String txt;
if (m_order[index].m_index == 0)
txt = "Harmonics";
@ -1021,9 +1022,10 @@ void SpectralChainEditor::drawBox(Graphics & g, int index, int x, int y, int w,
g.setColour(Colours::white);
g.drawRect(x, y, w, h);
g.drawFittedText(txt, x,y,w,h, Justification::centred, 3);
//g.drawFittedText(m_order[index].m_enabled->name, x, y, w, h, Justification::centred, 3);
g.setColour(Colours::gold);
g.drawRect(x + 2, y + 2, 12, 12);
if (m_order[index].m_enabled == true)
if (*m_order[index].m_enabled == true)
{
g.drawLine(x+2, y+2, x+14, y+14);
g.drawLine(x+2, y+14, x+14, y+2);

View File

@ -93,7 +93,11 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
m_thumb = std::make_unique<AudioThumbnail>(512, *m_afm, *m_thumbcache);
// The default priority of 2 is a bit too low in some cases, it seems...
m_thumbcache->getTimeSliceThread().setPriority(3);
m_stretch_source = std::make_unique<StretchAudioSource>(2, m_afm);
for (int i = 0; i < 9; ++i) // 41-49
{
m_sm_enab_pars[i] = new AudioParameterBool("enab_specmodule" + String(i), "Enable spectral module " + String(i + 1), false);
}
m_stretch_source = std::make_unique<StretchAudioSource>(2, m_afm,m_sm_enab_pars);
m_stretch_source->setOnsetDetection(0.0);
m_stretch_source->setLoopingEnabled(true);
@ -159,7 +163,6 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
addParameter(new AudioParameterFloat("freefilter_randomyamount0", "Random amount", 0.0, 1.0, 0.0)); // 40
for (int i = 0; i < 9; ++i) // 41-49
{
m_sm_enab_pars[i] = new AudioParameterBool("enab_specmodule"+String(i), "Enable spectral module "+String(i+1), false);
addParameter(m_sm_enab_pars[i]);
}
auto& pars = getParameters();
@ -237,7 +240,7 @@ ValueTree PaulstretchpluginAudioProcessor::getStateTree(bool ignoreoptions, bool
for (int i = 0; i < specorder.size(); ++i)
{
paramtree.setProperty("specorder" + String(i), specorder[i].m_index, nullptr);
paramtree.setProperty("specstepenabled" + String(i), specorder[i].m_enabled, nullptr);
//paramtree.setProperty("specstepenabled" + String(i), specorder[i].m_enabled, nullptr);
}
if (ignoreoptions == false)
{
@ -264,16 +267,18 @@ void PaulstretchpluginAudioProcessor::setStateFromTree(ValueTree tree)
m_load_file_with_state = tree.getProperty("loadfilewithstate", true);
if (tree.hasProperty("numspectralstages"))
{
/*
std::vector<SpectrumProcess> order;
int ordersize = tree.getProperty("numspectralstages");
for (int i = 0; i < ordersize; ++i)
{
bool step_enabled = tree.getProperty("specstepenabled" + String(i));
order.push_back({ (int)tree.getProperty("specorder" + String(i)), step_enabled });
//order.push_back({ (int)tree.getProperty("specorder" + String(i)), step_enabled });
}
if (ordersize<m_stretch_source->getSpectrumProcessOrder().size())
order.emplace_back(8,false);
order.emplace_back(8,m_sm_enab_pars[8]);
m_stretch_source->setSpectrumProcessOrder(order);
*/
}
getFromTreeProperties(tree, "waveviewrange", m_wave_view_range);
for (int i = 0; i < getNumParameters(); ++i)
@ -445,7 +450,7 @@ String PaulstretchpluginAudioProcessor::offlineRender(File outputfile)
{
File outputfiletouse = outputfile.getNonexistentSibling();
int numoutchans = *getIntParameter(cpi_num_outchans);
auto ss = std::make_shared<StretchAudioSource>(numoutchans,m_afm);
auto ss = std::make_shared<StretchAudioSource>(numoutchans,m_afm,m_sm_enab_pars);
int blocksize = 2048;
ss->setAudioFile(m_current_file);