From d42971e09f30c56307fcf8de722cd7204b3be050 Mon Sep 17 00:00:00 2001 From: xenakios Date: Tue, 1 May 2018 17:54:20 +0300 Subject: [PATCH] Added simple signal smoother class. Use that to smooth out the buffer amount component display. --- Source/PS_Source/globals.h | 32 +++++++++++++++++++++++++++++++- Source/PluginEditor.cpp | 4 ++-- Source/PluginEditor.h | 1 + readme.txt | 2 +- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/Source/PS_Source/globals.h b/Source/PS_Source/globals.h index 1d037ee..478f23c 100644 --- a/Source/PS_Source/globals.h +++ b/Source/PS_Source/globals.h @@ -339,4 +339,34 @@ inline void sanitizeTimeRange(double& t0, double& t1) t1 = t0 + 0.001; } -inline double fractpart(double x) { return x - (int)x; }; \ No newline at end of file +inline double fractpart(double x) { return x - (int)x; }; + +class SignalSmoother +{ +public: + SignalSmoother() + { + m_a = 0.5; + m_slope = m_a; + m_b = 1.0 - m_a; + m_z = 0; + } + inline double process(double in) + { + double result = in + m_a * (m_z - in); + m_z = result; + return result; + } + 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; + } + double slope() const { return m_slope; } +private: + double m_a, m_b, m_z; + double m_slope; +}; diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index e1d7091..7ab4622 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -1277,7 +1277,7 @@ 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 +1285,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_proc->getPreBufferingPercent(); + double amt = m_smoother.process(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 e2d7473..831cd82 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -113,6 +113,7 @@ public: PaulstretchpluginAudioProcessor* m_proc = nullptr; private: ColourGradient m_gradient; + SignalSmoother m_smoother; }; class MyThumbCache : public AudioThumbnailCache diff --git a/readme.txt b/readme.txt index 1f31680..6d35720 100644 --- a/readme.txt +++ b/readme.txt @@ -7,7 +7,7 @@ Copyright (C) 2017-2018 Xenakios Released under GNU General Public License v.2 license. History : -04-27-2018 1.1.3 +05-01-2018 1.1.3 -Changed "Octaves" module to "Ratios". The Ratios module has more shifters than the previous Octaves module and allows changing the pitch ratios (and the shifters mix) in a separate tabbed page in the GUI.