30template <
typename SampleType>
35 RMSFilter.setLevelCalculationType (BallisticsFilterLevelCalculationType::RMS);
36 RMSFilter.setAttackTime (
static_cast<SampleType
> (0.0));
37 RMSFilter.setReleaseTime (
static_cast<SampleType
> (50.0));
40template <
typename SampleType>
43 thresholddB = newValue;
47template <
typename SampleType>
56template <
typename SampleType>
63template <
typename SampleType>
71template <
typename SampleType>
77 sampleRate =
spec.sampleRate;
79 RMSFilter.prepare (
spec);
80 envelopeFilter.prepare (
spec);
86template <
typename SampleType>
90 envelopeFilter.reset();
94template <
typename SampleType>
98 auto env = RMSFilter.processSample (channel, sample);
101 env = envelopeFilter.processSample (channel,
env);
104 auto gain = (
env > threshold) ?
static_cast<SampleType
> (1.0)
105 :
std::pow (
env * thresholdInverse, currentRatio -
static_cast<SampleType
> (1.0));
108 return gain * sample;
111template <
typename SampleType>
115 thresholdInverse =
static_cast<SampleType
> (1.0) / threshold;
116 currentRatio = ratio;
118 envelopeFilter.setAttackTime (attackTime);
119 envelopeFilter.setReleaseTime (releaseTime);
static Type decibelsToGain(Type decibels, Type minusInfinityDb=Type(defaultMinusInfinitydB))
Converts a dBFS value to its equivalent gain level.
A simple noise gate with standard threshold, ratio, attack time and release time controls.
void prepare(const ProcessSpec &spec)
Initialises the processor.
SampleType processSample(int channel, SampleType inputValue)
Performs the processing operation on a single sample at a time.
void setRelease(SampleType newRelease)
Sets the release time in milliseconds of the noise-gate.
void setRatio(SampleType newRatio)
Sets the ratio of the noise-gate (must be higher or equal to 1).
void setAttack(SampleType newAttack)
Sets the attack time in milliseconds of the noise-gate.
void setThreshold(SampleType newThreshold)
Sets the threshold in dB of the noise-gate.
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...