59 this->currentValue = initialValue;
60 this->target = initialValue;
74 void setLogParameters (FloatType midPointAmplitudedB,
bool rateOfChangeShouldIncrease)
noexcept
76 jassert (midPointAmplitudedB < (FloatType) 0.0);
79 increasingRateOfChange = rateOfChangeShouldIncrease;
87 void reset (
double sampleRate,
double rampLengthInSeconds)
noexcept
89 jassert (sampleRate > 0 && rampLengthInSeconds >= 0);
90 reset ((
int) std::floor (rampLengthInSeconds * sampleRate));
96 void reset (
int numSteps)
noexcept
98 stepsToTarget = numSteps;
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;