Added simple signal smoother class. Use that to smooth out the buffer amount component display.
This commit is contained in:
		@@ -339,4 +339,34 @@ inline void sanitizeTimeRange(double& t0, double& t1)
 | 
			
		||||
		t1 = t0 + 0.001;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline double fractpart(double x) { return x - (int)x; };
 | 
			
		||||
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;
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -113,6 +113,7 @@ public:
 | 
			
		||||
	PaulstretchpluginAudioProcessor* m_proc = nullptr;
 | 
			
		||||
private:
 | 
			
		||||
    ColourGradient m_gradient;
 | 
			
		||||
	SignalSmoother m_smoother;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class MyThumbCache : public AudioThumbnailCache
 | 
			
		||||
 
 | 
			
		||||
@@ -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.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user