From 6aa514f52b2b1662401b98f7a4749cf629ace748 Mon Sep 17 00:00:00 2001 From: xenakios Date: Fri, 17 Nov 2017 16:41:33 +0200 Subject: [PATCH] Finally support changing FFT size. This however doesn't now use the double stretch source thing, so glitches will probably happen... Parameter component was changed to support changing the parameter value only on mouse releasee etc --- Source/PS_Source/StretchSource.cpp | 5 +++-- Source/PluginEditor.cpp | 17 ++++++++++++----- Source/PluginEditor.h | 21 +++++++++++++++++++-- Source/PluginProcessor.cpp | 2 +- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/Source/PS_Source/StretchSource.cpp b/Source/PS_Source/StretchSource.cpp index 94e32a3..ffbeda6 100644 --- a/Source/PS_Source/StretchSource.cpp +++ b/Source/PS_Source/StretchSource.cpp @@ -437,10 +437,11 @@ void StretchAudioSource::setFFTWindowingType(int windowtype) void StretchAudioSource::setFFTSize(int size) { jassert(size>0); - if (size != m_process_fftsize) + if (m_process_fftsize == 0 || size != m_process_fftsize) { m_process_fftsize = size; - + initObjects(); + ++m_param_change_count; } } diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 3bf6cb7..0306233 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -28,8 +28,16 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor (Pa const auto& pars = processor.getParameters(); for (int i=0;i(pars[i])); - addAndMakeVisible(m_parcomps.back().get()); + AudioProcessorParameterWithID* parid = dynamic_cast(pars[i]); + jassert(parid); + if (parid) + { + bool notifyonlyonrelease = false; + if (parid->paramID.startsWith("fftsize")) + notifyonlyonrelease = true; + m_parcomps.push_back(std::make_shared(pars[i],notifyonlyonrelease)); + addAndMakeVisible(m_parcomps.back().get()); + } } addAndMakeVisible(&m_rec_enable); m_rec_enable.setButtonText("Capture"); @@ -90,9 +98,8 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id) m_wavecomponent.setRecordingPosition(processor.getRecordingPositionPercent()); } else m_wavecomponent.setRecordingPosition(-1.0); - //m_info_label.setText(String(processor.m_control->getStretchAudioSource()->m_param_change_count), dontSendNotification); - double prebufavail=processor.m_control->getPreBufferingPercent(); - m_info_label.setText(String(prebufavail,1), dontSendNotification); + String infotext = String(processor.m_control->getPreBufferingPercent(), 1) + " " + String(processor.m_control->getStretchAudioSource()->m_param_change_count); + m_info_label.setText(infotext, dontSendNotification); } if (id == 2) { diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 7292cf5..8e68216 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -47,7 +47,7 @@ class ParameterComponent : public Component, public Slider::Listener, public Button::Listener { public: - ParameterComponent(AudioProcessorParameter* par) : m_par(par) + ParameterComponent(AudioProcessorParameter* par, bool notifyOnlyOnRelease) : m_par(par) { addAndMakeVisible(&m_label); m_label.setText(par->getName(50),dontSendNotification); @@ -55,6 +55,7 @@ public: if (floatpar) { m_slider = std::make_unique(); + m_notify_only_on_release = notifyOnlyOnRelease; m_slider->setRange(floatpar->range.start, floatpar->range.end, floatpar->range.interval); m_slider->setValue(*floatpar, dontSendNotification); m_slider->addListener(this); @@ -84,6 +85,20 @@ public: } void sliderValueChanged(Slider* slid) override { + if (m_notify_only_on_release == true) + return; + AudioParameterFloat* floatpar = dynamic_cast(m_par); + *floatpar = slid->getValue(); + } + void sliderDragStarted(Slider* slid) override + { + m_dragging = true; + } + void sliderDragEnded(Slider* slid) override + { + m_dragging = false; + if (m_notify_only_on_release == false) + return; AudioParameterFloat* floatpar = dynamic_cast(m_par); *floatpar = slid->getValue(); } @@ -98,7 +113,7 @@ public: void updateComponent() { AudioParameterFloat* floatpar = dynamic_cast(m_par); - if (m_slider != nullptr && (float)m_slider->getValue() != *floatpar) + if (m_slider != nullptr && m_dragging == false && (float)m_slider->getValue() != *floatpar) { m_slider->setValue(*floatpar, dontSendNotification); } @@ -114,6 +129,8 @@ private: std::unique_ptr m_slider; std::unique_ptr m_combobox; std::unique_ptr m_togglebut; + bool m_notify_only_on_release = false; + bool m_dragging = false; }; class WaveformComponent : public Component, public ChangeListener, public Timer diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index aa6238b..04dfb83 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -235,7 +235,7 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M m_control->getStretchAudioSource()->val_MainVolume = (float)*getFloatParameter(0); m_control->getStretchAudioSource()->setRate(*getFloatParameter(1)); m_control->getStretchAudioSource()->val_XFadeLen = 0.1; - //m_control->setFFTSize(*getFloatParameter(2)); + m_control->setFFTSize(*getFloatParameter(2)); m_control->ppar.pitch_shift.cents = *getFloatParameter(3) * 100.0; m_control->ppar.freq_shift.Hz = *getFloatParameter(4); double t0 = *getFloatParameter(5);