JUCE
|
A utility class for values that need smoothing to avoid audio glitches. More...
Public Types | |
template<typename T > | |
using | MultiplicativeVoid = (void setValue(FloatType newValue, bool force=false) noexcept, { if(force) { this->setCurrentAndTargetValue(newValue);return;} setTargetValue(newValue);}) private typename std::enable_if< std::is_same< T, ValueSmoothingTypes::Multiplicative >::value, void >::type |
THIS FUNCTION IS DEPRECATED. More... | |
Public Types inherited from SmoothedValueBase< SmoothedValue< FloatType, SmoothingType > > | |
using | FloatType = typename FloatTypeHelper< SmoothedValue< FloatType, SmoothingType > >::Type |
Public Member Functions | |
SmoothedValue () noexcept | |
Constructor. More... | |
SmoothedValue (FloatType initialValue) noexcept | |
Constructor. More... | |
void | reset (double sampleRate, double rampLengthInSeconds) noexcept |
Reset to a new sample rate and ramp length. More... | |
void | reset (int numSteps) noexcept |
Set a new ramp length directly in samples. More... | |
void | setTargetValue (FloatType newValue) noexcept |
Set the next value to ramp towards. More... | |
FloatType | getNextValue () noexcept |
Compute the next value. More... | |
FloatType | skip (int numSamples) noexcept |
Skip the next numSamples samples. More... | |
template<typename T = SmoothingType> | |
LinearVoid< T > | setStepSize () noexcept |
template<typename T = SmoothingType> | |
MultiplicativeVoid< T > | setStepSize () |
template<typename T = SmoothingType> | |
LinearVoid< T > | setNextValue () noexcept |
template<typename T = SmoothingType> | |
MultiplicativeVoid< T > | setNextValue () noexcept |
template<typename T = SmoothingType> | |
LinearVoid< T > | skipCurrentValue (int numSamples) noexcept |
template<typename T = SmoothingType> | |
MultiplicativeVoid< T > | skipCurrentValue (int numSamples) |
Public Member Functions inherited from SmoothedValueBase< SmoothedValue< FloatType, SmoothingType > > | |
SmoothedValueBase ()=default | |
Constructor. More... | |
virtual | ~SmoothedValueBase () |
bool | isSmoothing () const noexcept |
Returns true if the current value is currently being interpolated. More... | |
FloatType | getCurrentValue () const noexcept |
Returns the current value of the ramp. More... | |
FloatType | getTargetValue () const noexcept |
Returns the target value towards which the smoothed value is currently moving. More... | |
void | setCurrentAndTargetValue (FloatType newValue) |
Sets the current value and the target value. More... | |
void | applyGain (FloatType *samples, int numSamples) noexcept |
Applies a smoothed gain to a stream of samples S[i] *= gain. More... | |
void | applyGain (FloatType *samplesOut, const FloatType *samplesIn, int numSamples) noexcept |
Computes output as a smoothed gain applied to a stream of samples. More... | |
void | applyGain (AudioBuffer< FloatType > &buffer, int numSamples) noexcept |
Applies a smoothed gain to a buffer. More... | |
Public Attributes | |
FloatType | step = FloatType() |
int | stepsToTarget = 0 |
Additional Inherited Members | |
Protected Attributes inherited from SmoothedValueBase< SmoothedValue< FloatType, SmoothingType > > | |
FloatType | currentValue |
FloatType | target |
int | countdown |
A utility class for values that need smoothing to avoid audio glitches.
A ValueSmoothingTypes::Linear template parameter selects linear smoothing, which increments the SmoothedValue linearly towards its target value.
A ValueSmoothingTypes::Multiplicative template parameter selects multiplicative smoothing increments towards the target value.
Multiplicative smoothing is useful when you are dealing with exponential/logarithmic values like volume in dB or frequency in Hz. For example a 12 step ramp from 440.0 Hz (A4) to 880.0 Hz (A5) will increase the frequency with an equal temperament tuning across the octave. A 10 step smoothing from 1.0 (0 dB) to 3.16228 (10 dB) will increase the value in increments of 1 dB.
Note that when you are using multiplicative smoothing you cannot ever reach a target value of zero!
using SmoothedValue< FloatType, SmoothingType >::MultiplicativeVoid = (void setValue (FloatType newValue, bool force = false) noexcept, { if (force) { this->setCurrentAndTargetValue (newValue); return; } setTargetValue (newValue); }) private typename std::enable_if <std::is_same <T, ValueSmoothingTypes::Multiplicative>::value, void>::type |
THIS FUNCTION IS DEPRECATED.
Use setTargetValue (float)
and setCurrentAndTargetValue()
instead:
lsv.setValue (x, false); -> lsv.setTargetValue (x); lsv.setValue (x, true); -> lsv.setCurrentAndTargetValue (x);
newValue | The new target value |
force | If true, the value will be set immediately, bypassing the ramp |
|
noexcept |
Constructor.
|
noexcept |
Constructor.
|
noexcept |
Reset to a new sample rate and ramp length.
sampleRate | The sample rate |
rampLengthInSeconds | The duration of the ramp in seconds |
Referenced by dsp::Bias< FloatType >::process(), dsp::Gain< FloatType >::reset(), dsp::Bias< FloatType >::reset(), and dsp::Oscillator< SampleType >::reset().
|
noexcept |
Set a new ramp length directly in samples.
numSteps | The number of samples over which the ramp should be active |
|
noexcept |
Set the next value to ramp towards.
newValue | The new target value |
Referenced by dsp::LadderFilter< Type >::process(), dsp::Bias< FloatType >::setBias(), dsp::Oscillator< SampleType >::setFrequency(), and dsp::Gain< FloatType >::setGainLinear().
|
noexcept |
Compute the next value.
Referenced by dsp::Gain< FloatType >::process(), dsp::Bias< FloatType >::process(), dsp::Oscillator< SampleType >::process(), dsp::AudioBlock< const SampleType >::process(), dsp::Gain< FloatType >::processSample(), dsp::Bias< FloatType >::processSample(), and dsp::Oscillator< SampleType >::processSample().
|
noexcept |
Skip the next numSamples samples.
This is identical to calling getNextValue numSamples times. It returns the new current value.
Referenced by dsp::Gain< FloatType >::process(), dsp::Bias< FloatType >::process(), and dsp::Oscillator< SampleType >::process().
|
noexcept |
MultiplicativeVoid<T> SmoothedValue< FloatType, SmoothingType >::setStepSize | ( | ) |
|
noexcept |
|
noexcept |
|
noexcept |
MultiplicativeVoid<T> SmoothedValue< FloatType, SmoothingType >::skipCurrentValue | ( | int | numSamples | ) |
FloatType SmoothedValue< FloatType, SmoothingType >::step = FloatType() |
int SmoothedValue< FloatType, SmoothingType >::stepsToTarget = 0 |