diff --git a/Source/PS_Source/globals.h b/Source/PS_Source/globals.h index 478f23c..e3956eb 100644 --- a/Source/PS_Source/globals.h +++ b/Source/PS_Source/globals.h @@ -359,14 +359,20 @@ public: } void setSlope(double x, double sr) { - m_slope = x; - double srCompensate = srCompensate = sr / 100.0; - double compensated_a = powf(x, (1.0 / srCompensate)); - m_a = compensated_a; - m_b = 1.0 - m_a; + if (x != m_slope || sr != m_sr) + { + m_slope = x; + m_sr = sr; + double srCompensate = srCompensate = sr / 100.0; + double compensated_a = powf(x, (1.0 / srCompensate)); + m_a = compensated_a; + m_b = 1.0 - m_a; + } } - double slope() const { return m_slope; } + double getSlope() const { return m_slope; } + double getSamplerate() const { return m_sr; } private: double m_a, m_b, m_z; double m_slope; + double m_sr = 0.0; }; diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 7ab4622..8608b20 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -1277,7 +1277,6 @@ PerfMeterComponent::PerfMeterComponent(PaulstretchpluginAudioProcessor * p) m_gradient.addColour(0.0, Colours::red); m_gradient.addColour(0.25, Colours::yellow); m_gradient.addColour(1.0, Colours::green); - m_smoother.setSlope(0.9, 10.0); } void PerfMeterComponent::paint(Graphics & g) @@ -1285,7 +1284,7 @@ void PerfMeterComponent::paint(Graphics & g) m_gradient.point1 = {0.0f,0.0f}; m_gradient.point2 = {(float)getWidth(),0.0f}; g.fillAll(Colours::grey); - double amt = m_smoother.process(m_proc->getPreBufferingPercent()); + double amt = m_proc->getPreBufferingPercent(); g.setColour(Colours::green); int w = amt * getWidth(); //g.setGradientFill(m_gradient); diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 831cd82..e2d7473 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -113,7 +113,6 @@ public: PaulstretchpluginAudioProcessor* m_proc = nullptr; private: ColourGradient m_gradient; - SignalSmoother m_smoother; }; class MyThumbCache : public AudioThumbnailCache diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index a02dd87..978e4b2 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -639,7 +639,9 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M double srtemp = getSampleRate(); if (srtemp != m_cur_sr) m_cur_sr = srtemp; - const int totalNumInputChannels = getTotalNumInputChannels(); + m_prebufsmoother.setSlope(0.9, srtemp / buffer.getNumSamples()); + m_smoothed_prebuffer_ready = m_prebufsmoother.process(m_buffering_source->getPercentReady()); + const int totalNumInputChannels = getTotalNumInputChannels(); const int totalNumOutputChannels = getTotalNumOutputChannels(); for (int i = 0; i < totalNumInputChannels; ++i) m_input_buffer.copyFrom(i, 0, buffer, i, 0, buffer.getNumSamples()); @@ -822,7 +824,7 @@ double PaulstretchpluginAudioProcessor::getPreBufferingPercent() { if (m_buffering_source==nullptr) return 0.0; - return m_buffering_source->getPercentReady(); + return m_smoothed_prebuffer_ready; } void PaulstretchpluginAudioProcessor::timerCallback(int id) diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index a332922..eec9874 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -235,7 +235,8 @@ private: std::unique_ptr m_buffering_source; int m_prebuffer_amount = 1; bool m_recreate_buffering_source = true; - + double m_smoothed_prebuffer_ready = 0.0; + SignalSmoother m_prebufsmoother; int m_fft_size_to_use = 1024; double m_last_outpos_pos = 0.0; double m_last_in_pos = 0.0;