49 using Mode = LadderFilterMode;
56 void setEnabled (
bool isEnabled)
noexcept { enabled = isEnabled; }
68 void reset() noexcept;
92 const auto& inputBlock = context.getInputBlock();
93 auto& outputBlock = context.getOutputBlock();
94 const auto numChannels = outputBlock.getNumChannels();
95 const auto numSamples = outputBlock.getNumSamples();
98 jassert (inputBlock.getNumChannels() == numChannels);
99 jassert (inputBlock.getNumSamples() == numSamples);
101 if (! enabled || context.isBypassed)
103 outputBlock.copyFrom (inputBlock);
107 for (
size_t n = 0; n < numSamples; ++n)
111 for (
size_t ch = 0;
ch < numChannels; ++
ch)
112 outputBlock.getChannelPointer (
ch)[n] = processSample (inputBlock.getChannelPointer (
ch)[n],
ch);
119 void updateSmoothers() noexcept;
123 void setSampleRate (SampleType newValue) noexcept;
124 void setNumChannels (
size_t newValue) { state.
resize (newValue); }
125 void updateCutoffFreq() noexcept { cutoffTransformSmoother.
setTargetValue (
std::exp (cutoffFreqHz * cutoffFreqScaler)); }
126 void updateResonance() noexcept { scaledResonanceSmoother.
setTargetValue (
jmap (resonance, SampleType (0.1), SampleType (1.0))); }
129 SampleType drive, drive2, gain, gain2, comp;
131 static constexpr size_t numStates = 5;
135 SmoothedValue<SampleType> cutoffTransformSmoother, scaledResonanceSmoother;
136 SampleType cutoffTransformValue, scaledResonanceValue;
138 LookupTableTransform<SampleType> saturationLUT { [] (SampleType x) {
return std::tanh (x); },
139 SampleType (-5), SampleType (5), 128 };
141 SampleType cutoffFreqHz { SampleType (200) };
142 SampleType resonance;
144 SampleType cutoffFreqScaler;
constexpr Type jmap(Type value0To1, Type targetRangeMin, Type targetRangeMax)
Remaps a normalised value (between 0 and 1) to a target range.