35template <
typename SampleType>
65 template <
typename ProcessContext>
68 const auto& inputBlock = context.getInputBlock();
69 auto& outputBlock = context.getOutputBlock();
70 const auto numChannels = outputBlock.getNumChannels();
71 const auto numSamples = outputBlock.getNumSamples();
73 jassert (inputBlock.getNumChannels() == numChannels);
74 jassert (inputBlock.getNumSamples() == numSamples);
76 if (context.isBypassed)
78 outputBlock.copyFrom (inputBlock);
82 for (
size_t channel = 0; channel < numChannels; ++channel)
84 auto*
inputSamples = inputBlock .getChannelPointer (channel);
85 auto*
outputSamples = outputBlock.getChannelPointer (channel);
87 for (
size_t i = 0; i < numSamples; ++i)
100 SampleType threshold, thresholdInverse, ratioInverse;
103 double sampleRate = 44100.0;
104 SampleType thresholddB = 0.0, ratio = 1.0, attackTime = 1.0, releaseTime = 100.0;
A processor to apply standard attack / release ballistics to an input signal.
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 process(const ProcessContext &context) noexcept
Processes the input and output samples supplied in the processing context.
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).
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...