47template <
typename FloatType>
102 updateRampParameters();
112 if (newValue == this->target)
115 if (stepsToTarget <= 0)
121 this->target = newValue;
122 this->countdown = stepsToTarget;
123 source = this->currentValue;
125 updateRampParameters();
139 temp *= r; temp += d;
140 this->currentValue = jmap (temp, source, this->target);
142 return this->currentValue;
151 FloatType
skip (
int numSamples)
noexcept
153 if (numSamples >= this->countdown)
159 this->countdown -= numSamples;
161 auto rN = (FloatType) std::pow (r, numSamples);
163 temp += d * (
rN - (FloatType) 1) / (r - (FloatType) 1);
165 this->currentValue = jmap (temp, source, this->target);
166 return this->currentValue;
171 void updateRampParameters()
173 auto D = increasingRateOfChange ? B : (FloatType) 1 - B;
174 auto base = ((FloatType) 1 /
D) - (FloatType) 1;
175 r = std::pow (
base, (FloatType) 2 / (FloatType) stepsToTarget);
176 auto rN = std::pow (r, (FloatType) stepsToTarget);
177 d = (r - (FloatType) 1) / (
rN - (FloatType) 1);
182 bool increasingRateOfChange =
true;
185 int stepsToTarget = 0;
186 FloatType temp = 0, source = 0, r = 0, d = 1;
static Type decibelsToGain(Type decibels, Type minusInfinityDb=Type(defaultMinusInfinitydB))
bool isSmoothing() const noexcept
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