JUCE  v5.1.1-3-g1a0b28c73
JUCE API
LinearSmoothedValue< FloatType > Class Template Reference

Utility class for linearly smoothed values like volume etc. More...

#include <juce_LinearSmoothedValue.h>

Collaboration diagram for LinearSmoothedValue< FloatType >:

Public Member Functions

 LinearSmoothedValue () noexcept
 Constructor. More...
 
 LinearSmoothedValue (FloatType initialValue) noexcept
 Constructor. More...
 
void applyGain (FloatType *samples, int numSamples) noexcept
 Applies a linear smoothed gain to a stream of samples S[i] *= gain. More...
 
void applyGain (FloatType *samplesOut, const FloatType *samplesIn, int numSamples) noexcept
 Computes output as linear smoothed gain applied to a stream of samples. More...
 
void applyGain (AudioBuffer< FloatType > &buffer, int numSamples) noexcept
 Applies a linear smoothed gain to a buffer. More...
 
FloatType getNextValue () noexcept
 Compute the next value. More...
 
FloatType getTargetValue () const noexcept
 Returns the target value towards which the smoothed value is currently moving. More...
 
bool isSmoothing () const noexcept
 Returns true if the current value is currently being interpolated. More...
 
void reset (double sampleRate, double rampLengthInSeconds) noexcept
 Reset to a new sample rate and ramp length. More...
 
void setValue (FloatType newValue) noexcept
 Set a new target value. More...
 

Private Attributes

int countdown = 0
 
FloatType currentValue = 0
 
FloatType step = 0
 
int stepsToTarget = 0
 
FloatType target = 0
 

Detailed Description

template<typename FloatType>
class LinearSmoothedValue< FloatType >

Utility class for linearly smoothed values like volume etc.

that should not change abruptly but as a linear ramp, to avoid audio glitches.

Constructor & Destructor Documentation

◆ LinearSmoothedValue() [1/2]

template<typename FloatType>
LinearSmoothedValue< FloatType >::LinearSmoothedValue ( )
inlinenoexcept

Constructor.

◆ LinearSmoothedValue() [2/2]

template<typename FloatType>
LinearSmoothedValue< FloatType >::LinearSmoothedValue ( FloatType  initialValue)
inlinenoexcept

Constructor.

Member Function Documentation

◆ applyGain() [1/3]

template<typename FloatType>
void LinearSmoothedValue< FloatType >::applyGain ( FloatType *  samples,
int  numSamples 
)
inlinenoexcept

Applies a linear smoothed gain to a stream of samples S[i] *= gain.

Parameters
samplesPointer to a raw array of samples
numSamplesLength of array of samples

References LinearSmoothedValue< FloatType >::getNextValue(), LinearSmoothedValue< FloatType >::isSmoothing(), jassert, FloatVectorOperations::multiply(), and LinearSmoothedValue< FloatType >::target.

◆ applyGain() [2/3]

template<typename FloatType>
void LinearSmoothedValue< FloatType >::applyGain ( FloatType *  samplesOut,
const FloatType *  samplesIn,
int  numSamples 
)
inlinenoexcept

Computes output as linear smoothed gain applied to a stream of samples.

Sout[i] = Sin[i] * gain

Parameters
samplesOutA pointer to a raw array of output samples
samplesInA pointer to a raw array of input samples
numSamplesThe length of the array of samples

References LinearSmoothedValue< FloatType >::getNextValue(), LinearSmoothedValue< FloatType >::isSmoothing(), jassert, FloatVectorOperations::multiply(), and LinearSmoothedValue< FloatType >::target.

◆ applyGain() [3/3]

template<typename FloatType>
void LinearSmoothedValue< FloatType >::applyGain ( AudioBuffer< FloatType > &  buffer,
int  numSamples 
)
inlinenoexcept

◆ getNextValue()

template<typename FloatType>
FloatType LinearSmoothedValue< FloatType >::getNextValue ( )
inlinenoexcept

◆ getTargetValue()

template<typename FloatType>
FloatType LinearSmoothedValue< FloatType >::getTargetValue ( ) const
inlinenoexcept

Returns the target value towards which the smoothed value is currently moving.

References LinearSmoothedValue< FloatType >::target.

◆ isSmoothing()

template<typename FloatType>
bool LinearSmoothedValue< FloatType >::isSmoothing ( ) const
inlinenoexcept

Returns true if the current value is currently being interpolated.

References LinearSmoothedValue< FloatType >::countdown.

Referenced by LinearSmoothedValue< FloatType >::applyGain().

◆ reset()

template<typename FloatType>
void LinearSmoothedValue< FloatType >::reset ( double  sampleRate,
double  rampLengthInSeconds 
)
inlinenoexcept

Reset to a new sample rate and ramp length.

Parameters
sampleRateThe sampling rate
rampLengthInSecondsThe duration of the ramp in seconds

References LinearSmoothedValue< FloatType >::countdown, LinearSmoothedValue< FloatType >::currentValue, jassert, LinearSmoothedValue< FloatType >::stepsToTarget, and LinearSmoothedValue< FloatType >::target.

Referenced by Bias< FloatType >::updateRamp().

◆ setValue()

template<typename FloatType>
void LinearSmoothedValue< FloatType >::setValue ( FloatType  newValue)
inlinenoexcept

Member Data Documentation

◆ countdown

◆ currentValue

template<typename FloatType>
FloatType LinearSmoothedValue< FloatType >::currentValue = 0
private

◆ step

template<typename FloatType>
FloatType LinearSmoothedValue< FloatType >::step = 0
private

◆ stepsToTarget

template<typename FloatType>
int LinearSmoothedValue< FloatType >::stepsToTarget = 0
private

◆ target


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