18 #ifndef DISTRHO_VALUE_SMOOTHER_HPP_INCLUDED
19 #define DISTRHO_VALUE_SMOOTHER_HPP_INCLUDED
21 #include "../DistrhoUtils.hpp"
54 void setSampleRate(
const float newSampleRate) noexcept
58 sampleRate = newSampleRate;
63 void setTimeConstant(
const float newT60) noexcept
65 const float newTau = newT60 * (float)(1.0 / 6.91);
74 float getCurrentValue()
const noexcept
79 float getTargetValue()
const noexcept
84 void setTargetValue(
const float newTarget) noexcept
89 void clearToTargetValue() noexcept
94 inline float peek()
const noexcept
96 return mem * coef + target * (1.f - coef);
99 inline float next() noexcept
101 return (mem = mem * coef + target * (1.f - coef));
105 void updateCoef() noexcept
107 coef = std::exp(-1.f / (tau * sampleRate));
138 void setSampleRate(
const float newSampleRate) noexcept
142 sampleRate = newSampleRate;
147 void setTimeConstant(
const float newTau) noexcept
156 float getCurrentValue()
const noexcept
161 float getTargetValue()
const noexcept
166 void setTargetValue(
const float newTarget) noexcept
175 void clearToTargetValue() noexcept
180 inline float peek()
const noexcept
182 const float dy = target - mem;
183 return mem + std::copysign(std::fmin(std::abs(dy), std::abs(step)), dy);
186 inline float next() noexcept
188 const float y0 = mem;
189 const float dy = target - y0;
190 return (mem = y0 + std::copysign(std::fmin(std::abs(dy), std::abs(step)), dy));
194 void updateStep() noexcept
196 step = (target - mem) / (tau * sampleRate);
An exponential smoother for control values.
Definition: ValueSmoother.hpp:39
A linear smoother for control values.
Definition: ValueSmoother.hpp:123
static constexpr bool d_isNotEqual(const T &v1, const T &v2)
Definition: DistrhoUtils.hpp:279
#define END_NAMESPACE_DISTRHO
Definition: DistrhoInfo.hpp:949
#define START_NAMESPACE_DISTRHO
Definition: DistrhoInfo.hpp:943