From c8f865dd4a1a916bec172abf9e76dc079b2fe294 Mon Sep 17 00:00:00 2001 From: xenakios Date: Thu, 26 Apr 2018 23:07:08 +0300 Subject: [PATCH] Almost getting there but some still is still messed up... --- Source/PS_Source/StretchSource.cpp | 17 ++++++++++++++++- Source/PS_Source/StretchSource.h | 3 ++- Source/PluginEditor.cpp | 10 ++++++++++ Source/PluginProcessor.cpp | 16 +++++++++++++++- Source/PluginProcessor.h | 5 ++++- 5 files changed, 47 insertions(+), 4 deletions(-) diff --git a/Source/PS_Source/StretchSource.cpp b/Source/PS_Source/StretchSource.cpp index 5e7f437..b235b86 100644 --- a/Source/PS_Source/StretchSource.cpp +++ b/Source/PS_Source/StretchSource.cpp @@ -78,6 +78,10 @@ void StretchAudioSource::setSpectrumProcessOrder(std::vector or for (int i = 0; i < order.size(); ++i) m_specprocmap[i] = order[i].m_index; m_specproc_order = order; + Logger::writeToLog("<**"); + for (auto& e : m_specproc_order) + Logger::writeToLog(e.m_enabled->name + " " + String(e.m_index)); + Logger::writeToLog("**>"); for (int i = 0; i < m_stretchers.size(); ++i) { m_stretchers[i]->m_spectrum_processes = order; @@ -170,6 +174,7 @@ void StretchAudioSource::setMainVolume(double decibels) } } +#ifdef OLDMODULE_ENAB void StretchAudioSource::setSpectralModulesEnabled(const std::array& params) { jassert(m_specprocmap.size() > 0); @@ -202,7 +207,17 @@ void StretchAudioSource::setSpectralModulesEnabled(const std::arraym_spectrum_processes = m_specproc_order; + } + ++m_param_change_count; +} void StretchAudioSource::setLoopXFadeLength(double lenseconds) { if (lenseconds == m_loopxfadelen) diff --git a/Source/PS_Source/StretchSource.h b/Source/PS_Source/StretchSource.h index 11374e1..0e6417c 100644 --- a/Source/PS_Source/StretchSource.h +++ b/Source/PS_Source/StretchSource.h @@ -99,7 +99,8 @@ public: void setAudioBufferAsInputSource(AudioBuffer* buf, int sr, int len); void setMainVolume(double decibels); double getMainVolume() const { return m_main_volume; } - void setSpectralModulesEnabled(const std::array& params); + //void setSpectralModulesEnabled(const std::array& params); + void setSpectralModuleEnabled(int index, bool b); void setLoopXFadeLength(double lenseconds); double getLoopXFadeLengtj() const { return m_loopxfadelen; } void setPreviewDry(bool b); diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 9cf4c78..345a892 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -995,7 +995,17 @@ void SpectralChainEditor::mouseDown(const MouseEvent & ev) juce::Rectangle r(box_w*m_cur_index, 1, 12, 12); if (r.contains(ev.x, ev.y)) { + for (int i = 0; i < m_order.size(); ++i) + { + if (m_order[i].m_index == m_cur_index) + { + //Logger::writeToLog("SpectralChainEditor::mouseDown "+m_order[i].m_enabled->name); + + //return; + } + } toggleBool(m_order[m_cur_index].m_enabled); + Logger::writeToLog("SpectralChainEditor::mouseDown " + m_order[m_cur_index].m_enabled->name); //m_src->setSpectrumProcessOrder(m_order); //if (ModuleOrderOrEnabledChangedCallback) // ModuleOrderOrEnabledChangedCallback(); diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 1052ea7..9082775 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -89,6 +89,7 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor() 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); @@ -157,6 +158,7 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor() for (int i = 0; i < 9; ++i) // 41-49 { addParameter(m_sm_enab_pars[i]); + m_sm_enab_pars[i]->addListener(this); } addParameter(make_floatpar("octavemix_extra0_0", "Ratio mix 7 level", 0.0f, 1.0f, 0.0f, 0.001, 1.0)); // 50 @@ -362,6 +364,18 @@ void PaulstretchpluginAudioProcessor::changeProgramName (int index, const String { } +void PaulstretchpluginAudioProcessor::parameterValueChanged(int parameterIndex, float newValue) +{ + if (parameterIndex >= cpi_enable_spec_module0 && parameterIndex <= cpi_enable_spec_module8) + { + m_stretch_source->setSpectralModuleEnabled(parameterIndex - cpi_enable_spec_module0, newValue >= 0.5); + } +} + +void PaulstretchpluginAudioProcessor::parameterGestureChanged(int parameterIndex, bool gestureIsStarting) +{ +} + void PaulstretchpluginAudioProcessor::setFFTSize(double size) { if (m_prebuffer_amount == 5) @@ -663,7 +677,7 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M m_free_filter_envelope->m_transform_y_random_rate = *getIntParameter(cpi_freefilter_randomy_rate); m_free_filter_envelope->m_transform_y_random_amount = *getFloatParameter(cpi_freefilter_randomy_amount); - m_stretch_source->setSpectralModulesEnabled(m_sm_enab_pars); + //m_stretch_source->setSpectralModulesEnabled(m_sm_enab_pars); m_stretch_source->setMainVolume(*getFloatParameter(cpi_main_volume)); m_stretch_source->setRate(*getFloatParameter(cpi_stretchamount)); diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index be48bc3..a332922 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -115,7 +115,7 @@ public: class PaulstretchpluginAudioProcessorEditor; class PaulstretchpluginAudioProcessor : public AudioProcessor, - public MultiTimer, public VSTCallbackHandler + public MultiTimer, public VSTCallbackHandler, public AudioProcessorParameter::Listener { public: using EditorType = PaulstretchpluginAudioProcessorEditor; @@ -152,6 +152,9 @@ public: const String getProgramName (int index) override; void changeProgramName (int index, const String& newName) override; + void parameterValueChanged(int parameterIndex, float newValue) override; + void parameterGestureChanged(int parameterIndex, bool gestureIsStarting) override; + //============================================================================== void getStateInformation (MemoryBlock& destData) override; void setStateInformation (const void* data, int sizeInBytes) override;