30template <
typename SampleType>
37template <
typename SampleType>
40 thresholddB = newThreshold;
44template <
typename SampleType>
47 jassert (newRatio >=
static_cast<SampleType
> (1.0));
53template <
typename SampleType>
56 attackTime = newAttack;
60template <
typename SampleType>
63 releaseTime = newRelease;
68template <
typename SampleType>
76 envelopeFilter.prepare (spec);
82template <
typename SampleType>
85 envelopeFilter.reset();
89template <
typename SampleType>
93 auto env = envelopeFilter.processSample (channel, inputValue);
96 auto gain = (env < threshold) ? static_cast<SampleType> (1.0)
97 :
std::pow (env * thresholdInverse, ratioInverse -
static_cast<SampleType
> (1.0));
100 return gain * inputValue;
103template <
typename SampleType>
107 thresholdInverse =
static_cast<SampleType
> (1.0) / threshold;
108 ratioInverse =
static_cast<SampleType
> (1.0) / ratio;
110 envelopeFilter.setAttackTime (attackTime);
111 envelopeFilter.setReleaseTime (releaseTime);
115template class Compressor<float>;
116template class Compressor<double>;
static Type decibelsToGain(Type decibels, Type minusInfinityDb=Type(defaultMinusInfinitydB))
Converts a dBFS value to its equivalent gain level.
A simple compressor with standard threshold, ratio, attack time and release time controls.
void reset()
Resets the internal state variables of the processor.
void setThreshold(SampleType newThreshold)
Sets the threshold in dB of the compressor.
SampleType processSample(int channel, SampleType inputValue)
Performs the processing operation on a single sample at a time.
void prepare(const ProcessSpec &spec)
Initialises the processor.
void setAttack(SampleType newAttack)
Sets the attack time in milliseconds of the compressor.
void setRelease(SampleType newRelease)
Sets the release time in milliseconds of the compressor.
void setRatio(SampleType newRatio)
Sets the ratio of the compressor (must be higher or equal to 1).
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.