44template <
typename FloatType>
56 this->currentValue = initialValue;
57 this->target = initialValue;
71 void setLogParameters (FloatType midPointAmplitudedB,
bool rateOfChangeShouldIncrease)
noexcept
73 jassert (midPointAmplitudedB < (FloatType) 0.0);
76 increasingRateOfChange = rateOfChangeShouldIncrease;
84 void reset (
double sampleRate,
double rampLengthInSeconds)
noexcept
86 jassert (sampleRate > 0 && rampLengthInSeconds >= 0);
87 reset ((
int) std::floor (rampLengthInSeconds * sampleRate));
93 void reset (
int numSteps)
noexcept
95 stepsToTarget = numSteps;
99 updateRampParameters();
109 if (approximatelyEqual (newValue, this->target))
112 if (stepsToTarget <= 0)
118 this->target = newValue;
119 this->countdown = stepsToTarget;
120 source = this->currentValue;
122 updateRampParameters();
136 temp *= r; temp += d;
137 this->currentValue = jmap (temp, source, this->target);
139 return this->currentValue;
148 FloatType
skip (
int numSamples)
noexcept
150 if (numSamples >= this->countdown)
156 this->countdown -= numSamples;
158 auto rN = (FloatType) std::pow (r, numSamples);
160 temp += d * (rN - (FloatType) 1) / (r - (FloatType) 1);
162 this->currentValue = jmap (temp, source, this->target);
163 return this->currentValue;
168 void updateRampParameters()
170 auto D = increasingRateOfChange ? B : (FloatType) 1 - B;
171 auto base = ((FloatType) 1 / D) - (FloatType) 1;
172 r = std::pow (base, (FloatType) 2 / (FloatType) stepsToTarget);
173 auto rN = std::pow (r, (FloatType) stepsToTarget);
174 d = (r - (FloatType) 1) / (rN - (FloatType) 1);
179 bool increasingRateOfChange =
true;
182 int stepsToTarget = 0;
183 FloatType temp = 0, source = 0, r = 0, d = 1;
static Type decibelsToGain(Type decibels, Type minusInfinityDb=Type(defaultMinusInfinitydB))
bool isSmoothing() const noexcept
SmoothedValueBase()=default
void setCurrentAndTargetValue(FloatType newValue)
FloatType getNextValue() noexcept
void reset(double sampleRate, double rampLengthInSeconds) noexcept
void setLogParameters(FloatType midPointAmplitudedB, bool rateOfChangeShouldIncrease) noexcept
FloatType skip(int numSamples) noexcept
LogRampedValue(FloatType initialValue) noexcept
void reset(int numSteps) noexcept
void setTargetValue(FloatType newValue) noexcept