OpenShot Library | libopenshot-audio 0.2.0
juce::SmoothedValue< FloatType, SmoothingType > Class Template Reference

A utility class for values that need smoothing to avoid audio glitches. More...

#include <juce_SmoothedValue.h>

+ Inheritance diagram for juce::SmoothedValue< FloatType, SmoothingType >:

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.
 
- Public Types inherited from juce::SmoothedValueBase< SmoothedValueType >
using FloatType = typename FloatTypeHelper< SmoothedValueType >::Type
 

Public Member Functions

 SmoothedValue () noexcept
 Constructor.
 
 SmoothedValue (FloatType initialValue) noexcept
 Constructor.
 
void reset (double sampleRate, double rampLengthInSeconds) noexcept
 Reset to a new sample rate and ramp length.
 
void reset (int numSteps) noexcept
 Set a new ramp length directly in samples.
 
void setTargetValue (FloatType newValue) noexcept
 Set the next value to ramp towards.
 
FloatType getNextValue () noexcept
 Compute the next value.
 
FloatType skip (int numSamples) noexcept
 Skip the next numSamples samples.
 
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 juce::SmoothedValueBase< SmoothedValueType >
 SmoothedValueBase ()=default
 Constructor.
 
bool isSmoothing () const noexcept
 Returns true if the current value is currently being interpolated.
 
FloatType getCurrentValue () const noexcept
 Returns the current value of the ramp.
 
FloatType getTargetValue () const noexcept
 Returns the target value towards which the smoothed value is currently moving.
 
void setCurrentAndTargetValue (FloatType newValue)
 Sets the current value and the target value.
 
void applyGain (FloatType *samples, int numSamples) noexcept
 Applies a smoothed gain to a stream of samples S[i] *= gain.
 
void applyGain (FloatType *samplesOut, const FloatType *samplesIn, int numSamples) noexcept
 Computes output as a smoothed gain applied to a stream of samples.
 
void applyGain (AudioBuffer< FloatType > &buffer, int numSamples) noexcept
 Applies a smoothed gain to a buffer.
 

Public Attributes

FloatType step = FloatType()
 
int stepsToTarget = 0
 

Additional Inherited Members

- Protected Attributes inherited from juce::SmoothedValueBase< SmoothedValueType >
FloatType currentValue = 0
 
FloatType target = currentValue
 
int countdown = 0
 

Detailed Description

template<typename FloatType, typename SmoothingType = ValueSmoothingTypes::Linear>
class juce::SmoothedValue< FloatType, SmoothingType >

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 utility class for values that need smoothing to avoid audio glitches.

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!

Definition at line 224 of file juce_SmoothedValue.h.

Member Typedef Documentation

◆ MultiplicativeVoid

template<typename FloatType , typename SmoothingType = ValueSmoothingTypes::Linear>
template<typename T >
using juce::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);

Parameters
newValueThe new target value
forceIf true, the value will be set immediately, bypassing the ramp

Definition at line 356 of file juce_SmoothedValue.h.

Constructor & Destructor Documentation

◆ SmoothedValue() [1/2]

template<typename FloatType , typename SmoothingType = ValueSmoothingTypes::Linear>
juce::SmoothedValue< FloatType, SmoothingType >::SmoothedValue ( )
inlinenoexcept

Constructor.

Definition at line 229 of file juce_SmoothedValue.h.

◆ SmoothedValue() [2/2]

template<typename FloatType , typename SmoothingType = ValueSmoothingTypes::Linear>
juce::SmoothedValue< FloatType, SmoothingType >::SmoothedValue ( FloatType  initialValue)
inlinenoexcept

Constructor.

Definition at line 235 of file juce_SmoothedValue.h.

Member Function Documentation

◆ reset() [1/2]

template<typename FloatType , typename SmoothingType = ValueSmoothingTypes::Linear>
void juce::SmoothedValue< FloatType, SmoothingType >::reset ( double  sampleRate,
double  rampLengthInSeconds 
)
inlinenoexcept

Reset to a new sample rate and ramp length.

Parameters
sampleRateThe sample rate
rampLengthInSecondsThe duration of the ramp in seconds

Definition at line 250 of file juce_SmoothedValue.h.

References juce::SmoothedValue< FloatType, SmoothingType >::reset().

Referenced by juce::SmoothedValue< FloatType, SmoothingType >::reset(), and juce::Reverb::setSampleRate().

◆ reset() [2/2]

template<typename FloatType , typename SmoothingType = ValueSmoothingTypes::Linear>
void juce::SmoothedValue< FloatType, SmoothingType >::reset ( int  numSteps)
inlinenoexcept

Set a new ramp length directly in samples.

Parameters
numStepsThe number of samples over which the ramp should be active

Definition at line 259 of file juce_SmoothedValue.h.

References juce::SmoothedValueBase< SmoothedValueType >::setCurrentAndTargetValue().

◆ setTargetValue()

template<typename FloatType , typename SmoothingType = ValueSmoothingTypes::Linear>
void juce::SmoothedValue< FloatType, SmoothingType >::setTargetValue ( FloatType  newValue)
inlinenoexcept

Set the next value to ramp towards.

Parameters
newValueThe new target value

Definition at line 269 of file juce_SmoothedValue.h.

References juce::SmoothedValueBase< SmoothedValueType >::setCurrentAndTargetValue().

Referenced by juce::Reverb::setParameters().

◆ getNextValue()

template<typename FloatType , typename SmoothingType = ValueSmoothingTypes::Linear>
FloatType juce::SmoothedValue< FloatType, SmoothingType >::getNextValue ( )
inlinenoexcept

Compute the next value.

Returns
Smoothed value

Definition at line 293 of file juce_SmoothedValue.h.

References juce::SmoothedValueBase< SmoothedValueType >::isSmoothing().

Referenced by juce::Reverb::processMono(), and juce::Reverb::processStereo().

◆ skip()

template<typename FloatType , typename SmoothingType = ValueSmoothingTypes::Linear>
FloatType juce::SmoothedValue< FloatType, SmoothingType >::skip ( int  numSamples)
inlinenoexcept

Skip the next numSamples samples.

This is identical to calling getNextValue numSamples times. It returns the new current value.

See also
getNextValue

Definition at line 314 of file juce_SmoothedValue.h.

References juce::SmoothedValueBase< SmoothedValueType >::setCurrentAndTargetValue().

◆ setStepSize() [1/2]

template<typename FloatType , typename SmoothingType = ValueSmoothingTypes::Linear>
template<typename T = SmoothingType>
LinearVoid< T > juce::SmoothedValue< FloatType, SmoothingType >::setStepSize ( )
inlinenoexcept

Definition at line 360 of file juce_SmoothedValue.h.

◆ setStepSize() [2/2]

template<typename FloatType , typename SmoothingType = ValueSmoothingTypes::Linear>
template<typename T = SmoothingType>
MultiplicativeVoid< T > juce::SmoothedValue< FloatType, SmoothingType >::setStepSize ( )
inline

Definition at line 366 of file juce_SmoothedValue.h.

◆ setNextValue() [1/2]

template<typename FloatType , typename SmoothingType = ValueSmoothingTypes::Linear>
template<typename T = SmoothingType>
LinearVoid< T > juce::SmoothedValue< FloatType, SmoothingType >::setNextValue ( )
inlinenoexcept

Definition at line 373 of file juce_SmoothedValue.h.

◆ setNextValue() [2/2]

template<typename FloatType , typename SmoothingType = ValueSmoothingTypes::Linear>
template<typename T = SmoothingType>
MultiplicativeVoid< T > juce::SmoothedValue< FloatType, SmoothingType >::setNextValue ( )
inlinenoexcept

Definition at line 379 of file juce_SmoothedValue.h.

◆ skipCurrentValue() [1/2]

template<typename FloatType , typename SmoothingType = ValueSmoothingTypes::Linear>
template<typename T = SmoothingType>
LinearVoid< T > juce::SmoothedValue< FloatType, SmoothingType >::skipCurrentValue ( int  numSamples)
inlinenoexcept

Definition at line 386 of file juce_SmoothedValue.h.

◆ skipCurrentValue() [2/2]

template<typename FloatType , typename SmoothingType = ValueSmoothingTypes::Linear>
template<typename T = SmoothingType>
MultiplicativeVoid< T > juce::SmoothedValue< FloatType, SmoothingType >::skipCurrentValue ( int  numSamples)
inline

Definition at line 392 of file juce_SmoothedValue.h.

Member Data Documentation

◆ step

template<typename FloatType , typename SmoothingType = ValueSmoothingTypes::Linear>
FloatType juce::SmoothedValue< FloatType, SmoothingType >::step = FloatType()

Definition at line 398 of file juce_SmoothedValue.h.

◆ stepsToTarget

template<typename FloatType , typename SmoothingType = ValueSmoothingTypes::Linear>
int juce::SmoothedValue< FloatType, SmoothingType >::stepsToTarget = 0

Definition at line 399 of file juce_SmoothedValue.h.


The documentation for this class was generated from the following file: