33 template <
typename Type>
36 setSampleRate (Type (1000));
44 template <
typename Type>
49 case Mode::LPF12: A = {{ Type (0), Type (0), Type (1), Type (0), Type (0) }}; comp = Type (0.5);
break;
50 case Mode::HPF12: A = {{ Type (1), Type (-2), Type (1), Type (0), Type (0) }}; comp = Type (0);
break;
51 case Mode::LPF24: A = {{ Type (0), Type (0), Type (0), Type (0), Type (1) }}; comp = Type (0.5);
break;
52 case Mode::HPF24: A = {{ Type (1), Type (-4), Type (6), Type (-4), Type (1) }}; comp = Type (0);
break;
53 default: jassertfalse;
break;
56 static constexpr
auto outputGain = Type (1.2);
66 template <
typename Type>
75 template <
typename Type>
86 template <
typename Type>
89 jassert (newValue > Type (0));
90 cutoffFreqHz = newValue;
95 template <
typename Type>
98 jassert (newValue >= Type (0) && newValue <= Type (1));
104 template <
typename Type>
107 jassert (newValue >= Type (1));
110 gain = std::pow (drive, Type (-2.642)) * Type (0.6103) + Type (0.3903);
111 drive2 = drive * Type (0.04) + Type (0.96);
112 gain2 = std::pow (drive2, Type (-2.642)) * Type (0.6103) + Type (0.3903);
116 template <
typename Type>
119 auto& s = state[channelToUse];
121 const auto a1 = cutoffTransformValue;
122 const auto g = a1 * Type (-1) + Type (1);
123 const auto b0 = g * Type (0.76923076923);
124 const auto b1 = g * Type (0.23076923076);
126 const auto dx = gain * saturationLUT (drive * inputValue);
127 const auto a = dx + scaledResonanceValue * Type (-4) * (gain2 * saturationLUT (drive2 * s[4]) - dx * comp);
129 const auto b = b1 * s[0] + a1 * s[1] + b0 * a;
130 const auto c = b1 * s[1] + a1 * s[2] + b0 * b;
131 const auto d = b1 * s[2] + a1 * s[3] + b0 * c;
132 const auto e = b1 * s[3] + a1 * s[4] + b0 * d;
140 return a * A[0] + b * A[1] + c * A[2] + d * A[3] + e * A[4];
144 template <
typename Type>
147 cutoffTransformValue = cutoffTransformSmoother.
getNextValue();
148 scaledResonanceValue = scaledResonanceSmoother.
getNextValue();
152 template <
typename Type>
155 jassert (newValue > Type (0));
158 static constexpr Type smootherRampTimeSec = Type (0.05);
159 cutoffTransformSmoother.
reset (newValue, smootherRampTimeSec);
160 scaledResonanceSmoother.
reset (newValue, smootherRampTimeSec);
FloatType getNextValue() noexcept
Compute the next value.
void setCutoffFrequencyHz(Type newValue) noexcept
Sets the cutoff frequency of the filter.
FloatType getTargetValue() const noexcept
Returns the target value towards which the smoothed value is currently moving.
void prepare(const juce::dsp::ProcessSpec &spec)
Initialises the filter.
uint32 numChannels
The number of channels that the process() method will be expected to handle.
Multi-mode filter based on the Moog ladder filter.
double sampleRate
The sample rate that will be used for the data that is sent to the processor.
LadderFilter()
Creates an uninitialised filter.
void reset(double sampleRate, double rampLengthInSeconds) noexcept
Reset to a new sample rate and ramp length.
void setDrive(Type newValue) noexcept
Sets the amount of saturation in the filter.
void setMode(Mode newValue) noexcept
Sets filter mode.
This structure is passed into a DSP algorithm's prepare() method, and contains information about vari...
void setCurrentAndTargetValue(FloatType newValue)
Sets the current value and the target value.
void setResonance(Type newValue) noexcept
Sets the resonance of the filter.
Commonly used mathematical constants.
void reset() noexcept
Resets the internal state variables of the filter.