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>
50 jassert (newRatio >=
static_cast<SampleType
> (1.0));
56template <
typename SampleType>
59 attackTime = newAttack;
63template <
typename SampleType>
66 releaseTime = newRelease;
71template <
typename SampleType>
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);
123template class NoiseGate<float>;
124template class NoiseGate<double>;
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.
This structure is passed into a DSP algorithm's prepare() method, and contains information about vari...
uint32 numChannels
The number of channels that the process() method will be expected to handle.
double sampleRate
The sample rate that will be used for the data that is sent to the processor.