29enum class BallisticsFilterLevelCalculationType
42template <
typename SampleType>
47 using LevelCalculationType = BallisticsFilterLevelCalculationType;
91 void reset (SampleType initialValue);
95 template <
typename ProcessContext>
96 void process (
const ProcessContext& context)
noexcept
98 const auto& inputBlock = context.getInputBlock();
99 auto& outputBlock = context.getOutputBlock();
100 const auto numChannels = outputBlock.getNumChannels();
101 const auto numSamples = outputBlock.getNumSamples();
103 jassert (inputBlock.getNumChannels() <= yold.size());
104 jassert (inputBlock.getNumChannels() == numChannels);
105 jassert (inputBlock.getNumSamples() == numSamples);
107 if (context.isBypassed)
109 outputBlock.copyFrom (inputBlock);
113 for (
size_t channel = 0; channel < numChannels; ++channel)
115 auto* inputSamples = inputBlock .getChannelPointer (channel);
116 auto* outputSamples = outputBlock.getChannelPointer (channel);
118 for (
size_t i = 0; i < numSamples; ++i)
119 outputSamples[i] =
processSample ((
int) channel, inputSamples[i]);
122 #if JUCE_DSP_ENABLE_SNAP_TO_ZERO
128 SampleType
processSample (
int channel, SampleType inputValue);
138 SampleType calculateLimitedCte (SampleType) const noexcept;
141 std::vector<SampleType> yold;
142 double sampleRate = 44100.0, expFactor = -0.142;
143 SampleType attackTime = 1.0, releaseTime = 100.0, cteAT = 0.0, cteRL = 0.0;
144 LevelCalculationType levelType = LevelCalculationType::peak;
SampleType processSample(int channel, SampleType inputValue)
void setAttackTime(SampleType attackTimeMs)
void prepare(const ProcessSpec &spec)
void setReleaseTime(SampleType releaseTimeMs)
void process(const ProcessContext &context) noexcept
void snapToZero() noexcept
void setLevelCalculationType(LevelCalculationType newCalculationType)