mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-11 23:54:18 +00:00
LinearSmoothedValue: Changed the new interface
This commit is contained in:
parent
1dee28660e
commit
6f2f9afb06
3 changed files with 25 additions and 16 deletions
|
|
@ -60,7 +60,7 @@ public:
|
|||
void reset (int numSteps) noexcept
|
||||
{
|
||||
stepsToTarget = numSteps;
|
||||
setCurrentValueToTargetValue();
|
||||
setCurrentAndTargetValue (target);
|
||||
}
|
||||
|
||||
/** Set the next value to ramp towards.
|
||||
|
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
if (stepsToTarget <= 0)
|
||||
{
|
||||
setCurrentValueToTargetValue();
|
||||
setCurrentAndTargetValue (target);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -83,10 +83,12 @@ public:
|
|||
step = (target - currentValue) / static_cast<FloatType> (countdown);
|
||||
}
|
||||
|
||||
/** Sets the current value to the target value. */
|
||||
void setCurrentValueToTargetValue() noexcept
|
||||
/** Sets the current value and the target value.
|
||||
@param newValue the new value to take
|
||||
*/
|
||||
void setCurrentAndTargetValue (FloatType newValue)
|
||||
{
|
||||
currentValue = target;
|
||||
target = currentValue = newValue;
|
||||
countdown = 0;
|
||||
}
|
||||
|
||||
|
|
@ -198,7 +200,7 @@ public:
|
|||
{
|
||||
if (numSamples >= countdown)
|
||||
{
|
||||
setCurrentValueToTargetValue();
|
||||
setCurrentAndTargetValue (target);
|
||||
return target;
|
||||
}
|
||||
|
||||
|
|
@ -210,20 +212,24 @@ public:
|
|||
//==============================================================================
|
||||
/** THIS FUNCTION IS DEPRECATED.
|
||||
|
||||
Use `setTargetValue (float)` and `setCurrentValueToTargetValue()` instead:
|
||||
Use `setTargetValue (float)` and `setCurrentAndTargetValue()` instead:
|
||||
|
||||
lsv.setValue (x, false); -> lsv.setTargetValue (x);
|
||||
lsv.setValue (x, true); -> lsv.setTargetValue (x); lsv.setCurrentValueToTargetValue();
|
||||
lsv.setValue (x, true); -> lsv.setCurrentAndTargetValue (x);
|
||||
|
||||
@param newValue The new target value
|
||||
@param force If true, the value will be set immediately, bypassing the ramp
|
||||
*/
|
||||
JUCE_DEPRECATED_WITH_BODY (void setValue (FloatType newValue, bool force = false) noexcept,
|
||||
{
|
||||
setTargetValue (newValue);
|
||||
|
||||
if (force)
|
||||
setCurrentValueToTargetValue();
|
||||
{
|
||||
target = newValue;
|
||||
setCurrentAndTargetValue (target);
|
||||
return;
|
||||
}
|
||||
|
||||
setTargetValue (newValue);
|
||||
})
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -78,8 +78,8 @@ void LadderFilter<Type>::reset() noexcept
|
|||
for (auto& s : state)
|
||||
s.fill (Type (0));
|
||||
|
||||
cutoffTransformSmoother.setCurrentValueToTargetValue();
|
||||
scaledResonanceSmoother.setCurrentValueToTargetValue();
|
||||
cutoffTransformSmoother.setCurrentAndTargetValue (cutoffTransformSmoother.getTargetValue());
|
||||
scaledResonanceSmoother.setCurrentAndTargetValue (scaledResonanceSmoother.getTargetValue());
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -84,10 +84,13 @@ public:
|
|||
/** Sets the frequency of the oscillator. */
|
||||
void setFrequency (NumericType newFrequency, bool force = false) noexcept
|
||||
{
|
||||
frequency.setTargetValue (newFrequency);
|
||||
|
||||
if (force)
|
||||
frequency.setCurrentValueToTargetValue();
|
||||
{
|
||||
frequency.setCurrentAndTargetValue (newFrequency);
|
||||
return;
|
||||
}
|
||||
|
||||
frequency.setTargetValue (newFrequency);
|
||||
}
|
||||
|
||||
/** Returns the current frequency of the oscillator. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue