41 template <
typename Type>
58 void setEnabled (
bool newValue) noexcept { enabled = newValue; }
61 void setMode (Mode newValue) noexcept;
70 void reset() noexcept;
82 void setDrive (Type newValue) noexcept;
85 template <
typename ProcessContext>
86 void process (
const ProcessContext& context) noexcept
88 const auto& inputBlock = context.getInputBlock();
89 auto& outputBlock = context.getOutputBlock();
90 const auto numChannels = outputBlock.getNumChannels();
91 const auto numSamples = outputBlock.getNumSamples();
94 jassert (inputBlock.getNumChannels() == numChannels);
95 jassert (inputBlock.getNumSamples() == numSamples);
97 if (! enabled || context.isBypassed)
99 outputBlock.copyFrom (inputBlock);
103 for (
size_t n = 0; n < numSamples; ++n)
107 for (
size_t ch = 0; ch < numChannels; ++ch)
108 outputBlock.getChannelPointer (ch)[n] = processSample (inputBlock.getChannelPointer (ch)[n], ch);
114 Type processSample (Type inputValue,
size_t channelToUse) noexcept;
115 void updateSmoothers() noexcept;
119 Type drive, drive2, gain, gain2, comp;
121 static constexpr
size_t numStates = 5;
122 std::vector<std::array<Type, numStates>> state;
123 std::array<Type, numStates> A;
126 Type cutoffTransformValue, scaledResonanceValue;
130 Type cutoffFreqHz { Type (200) };
133 Type cutoffFreqScaler;
139 void setSampleRate (Type newValue) noexcept;
140 void setNumChannels (
size_t newValue) { state.resize (newValue); }
141 void updateCutoffFreq() noexcept { cutoffTransformSmoother.
setTargetValue (std::exp (cutoffFreqHz * cutoffFreqScaler)); }
142 void updateResonance() noexcept { scaledResonanceSmoother.
setTargetValue (jmap (resonance, Type (0.1), Type (1.0))); }
void setCutoffFrequencyHz(Type newValue) noexcept
Sets the cutoff frequency of the filter.
void prepare(const juce::dsp::ProcessSpec &spec)
Initialises the filter.
Multi-mode filter based on the Moog ladder filter.
LadderFilter()
Creates an uninitialised filter.
void setDrive(Type newValue) noexcept
Sets the amount of saturation in the filter.
void setMode(Mode newValue) noexcept
Sets filter mode.
size_t getNumChannels() const noexcept
Returns the current number of channels.
void setEnabled(bool newValue) noexcept
Enables or disables the filter.
void setTargetValue(FloatType newValue) noexcept
Set the next value to ramp towards.
This structure is passed into a DSP algorithm's prepare() method, and contains information about vari...
void setResonance(Type newValue) noexcept
Sets the resonance of the filter.
void reset() noexcept
Resets the internal state variables of the filter.