JUCE
Public Member Functions | List of all members
juce::LinearSmoothedValue< FloatType > Class Template Reference

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

Public Member Functions

 LinearSmoothedValue () noexcept
 Constructor. More...
 
 LinearSmoothedValue (FloatType initialValue) noexcept
 Constructor. More...
 
void reset (double sampleRate, double rampLengthInSeconds) noexcept
 Reset to a new sample rate and ramp length. More...
 
void setValue (FloatType newValue, bool force=false) noexcept
 Set a new target value. More...
 
FloatType getNextValue () noexcept
 Compute the next value. More...
 
bool isSmoothing () const noexcept
 Returns true if the current value is currently being interpolated. More...
 
FloatType getTargetValue () const noexcept
 Returns the target value towards which the smoothed value is currently moving. 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...
 

Detailed Description

template<typename FloatType>
class juce::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>
juce::LinearSmoothedValue< FloatType >::LinearSmoothedValue ( )
noexcept

Constructor.

◆ LinearSmoothedValue() [2/2]

template<typename FloatType>
juce::LinearSmoothedValue< FloatType >::LinearSmoothedValue ( FloatType  initialValue)
noexcept

Constructor.

Member Function Documentation

◆ reset()

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

Reset to a new sample rate and ramp length.

Parameters
sampleRateThe sampling rate
rampLengthInSecondsThe duration of the ramp in seconds

Referenced by juce::dsp::Bias< FloatType >::process(), and juce::dsp::Oscillator< SampleType >::reset().

◆ setValue()

template<typename FloatType>
void juce::LinearSmoothedValue< FloatType >::setValue ( FloatType  newValue,
bool  force = false 
)
noexcept

Set a new target value.

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

Referenced by juce::dsp::LadderFilter< Type >::process(), and juce::dsp::Oscillator< SampleType >::setFrequency().

◆ getNextValue()

template<typename FloatType>
FloatType juce::LinearSmoothedValue< FloatType >::getNextValue ( )
noexcept

◆ isSmoothing()

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

Returns true if the current value is currently being interpolated.

Referenced by juce::LinearSmoothedValue< Type >::applyGain(), and juce::dsp::Oscillator< SampleType >::process().

◆ getTargetValue()

template<typename FloatType>
FloatType juce::LinearSmoothedValue< FloatType >::getTargetValue ( ) const
noexcept

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

Referenced by juce::dsp::Oscillator< SampleType >::getFrequency().

◆ applyGain() [1/3]

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

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

◆ applyGain() [2/3]

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

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

◆ applyGain() [3/3]

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

Applies a linear smoothed gain to a buffer.


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