30template <
typename SampleType>
37template <
typename SampleType>
45template <
typename SampleType>
51 sampleRate =
spec.sampleRate;
53 firstStageCompressor.prepare (
spec);
54 secondStageCompressor.prepare (
spec);
60template <
typename SampleType>
63 firstStageCompressor.reset();
64 secondStageCompressor.reset();
66 outputVolume.reset (sampleRate, 0.001);
70template <
typename SampleType>
74 firstStageCompressor.setRatio ((SampleType) 4.0);
75 firstStageCompressor.setAttack ((SampleType) 2.0);
76 firstStageCompressor.setRelease ((SampleType) 200.0);
78 secondStageCompressor.setThreshold (thresholddB);
79 secondStageCompressor.setRatio ((SampleType) 1000.0);
80 secondStageCompressor.setAttack ((SampleType) 0.001);
81 secondStageCompressor.setRelease (releaseTime);
83 auto ratioInverse = (SampleType) (1.0 / 4.0);
85 auto gain = (SampleType)
std::pow (10.0, 10.0 * (1.0 - ratioInverse) / 40.0);
88 outputVolume.setTargetValue (gain);
static Type decibelsToGain(Type decibels, Type minusInfinityDb=Type(defaultMinusInfinitydB))
Converts a dBFS value to its equivalent gain level.
A simple limiter with standard threshold and release time controls, featuring two compressors and a h...
void setThreshold(SampleType newThreshold)
Sets the threshold in dB of the limiter.
void prepare(const ProcessSpec &spec)
Initialises the processor.
void setRelease(SampleType newRelease)
Sets the release time in milliseconds of the limiter.
void reset()
Resets the internal state variables of the processor.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
This structure is passed into a DSP algorithm's prepare() method, and contains information about vari...