A processor to apply standard attack / release ballistics to an input signal. More...
#include <juce_BallisticsFilter.h>
Public Types | |
using | LevelCalculationType = BallisticsFilterLevelCalculationType |
Public Member Functions | |
BallisticsFilter () | |
Constructor. More... | |
void | prepare (const ProcessSpec &spec) |
Initialises the filter. More... | |
template<typename ProcessContext > | |
void | process (const ProcessContext &context) noexcept |
Processes the input and output samples supplied in the processing context. More... | |
SampleType | processSample (int channel, SampleType inputValue) |
Processes one sample at a time on a given channel. More... | |
void | reset () |
Resets the internal state variables of the filter. More... | |
void | reset (SampleType initialValue) |
Resets the internal state variables of the filter to the given initial value. More... | |
void | setAttackTime (SampleType attackTimeMs) |
Sets the attack time in ms. More... | |
void | setLevelCalculationType (LevelCalculationType newCalculationType) |
Sets how the filter levels are calculated. More... | |
void | setReleaseTime (SampleType releaseTimeMs) |
Sets the release time in ms. More... | |
void | snapToZero () noexcept |
Ensure that the state variables are rounded to zero if the state variables are denormals. More... | |
Private Member Functions | |
SampleType | calculateLimitedCte (SampleType) const noexcept |
Private Attributes | |
SampleType | attackTime = 1.0 |
SampleType | cteAT = 0.0 |
SampleType | cteRL = 0.0 |
double | expFactor = -0.142 |
LevelCalculationType | levelType = LevelCalculationType::peak |
SampleType | releaseTime = 100.0 |
double | sampleRate = 44100.0 |
std::vector< SampleType > | yold |
A processor to apply standard attack / release ballistics to an input signal.
This is useful in dynamics processors, envelope followers, modulated audio effects and for smoothing animation in data visualisation.
@tags{DSP}
using juce::dsp::BallisticsFilter< SampleType >::LevelCalculationType = BallisticsFilterLevelCalculationType |
juce::dsp::BallisticsFilter< SampleType >::BallisticsFilter | ( | ) |
Constructor.
|
privatenoexcept |
void juce::dsp::BallisticsFilter< SampleType >::prepare | ( | const ProcessSpec & | spec | ) |
Initialises the filter.
|
inlinenoexcept |
Processes the input and output samples supplied in the processing context.
References jassert, juce::dsp::BallisticsFilter< SampleType >::processSample(), juce::dsp::BallisticsFilter< SampleType >::snapToZero(), and juce::dsp::BallisticsFilter< SampleType >::yold.
SampleType juce::dsp::BallisticsFilter< SampleType >::processSample | ( | int | channel, |
SampleType | inputValue | ||
) |
Processes one sample at a time on a given channel.
Referenced by juce::dsp::BallisticsFilter< SampleType >::process().
void juce::dsp::BallisticsFilter< SampleType >::reset | ( | ) |
Resets the internal state variables of the filter.
void juce::dsp::BallisticsFilter< SampleType >::reset | ( | SampleType | initialValue | ) |
Resets the internal state variables of the filter to the given initial value.
void juce::dsp::BallisticsFilter< SampleType >::setAttackTime | ( | SampleType | attackTimeMs | ) |
Sets the attack time in ms.
Attack times less than 0.001 ms will be snapped to zero and very long attack times will eventually saturate depending on the numerical precision used.
void juce::dsp::BallisticsFilter< SampleType >::setLevelCalculationType | ( | LevelCalculationType | newCalculationType | ) |
Sets how the filter levels are calculated.
Level calculation in digital envelope followers is usually performed using peak detection with a rectifier function (like std::abs) and filtering, which returns an envelope dependant on the peak or maximum values of the signal amplitude.
To perform an estimation of the average value of the signal you can use an RMS (root mean squared) implementation of the ballistics filter instead. This is useful in some compressor and noise-gate designs, or in specific types of volume meters.
void juce::dsp::BallisticsFilter< SampleType >::setReleaseTime | ( | SampleType | releaseTimeMs | ) |
Sets the release time in ms.
Release times less than 0.001 ms will be snapped to zero and very long release times will eventually saturate depending on the numerical precision used.
|
noexcept |
Ensure that the state variables are rounded to zero if the state variables are denormals.
This is only needed if you are doing sample by sample processing.
Referenced by juce::dsp::BallisticsFilter< SampleType >::process().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Referenced by juce::dsp::BallisticsFilter< SampleType >::process().