33template <
typename Type>
36 setSampleRate (Type (1000));
44template <
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;
66template <
typename Type>
69 setSampleRate (Type (
spec.sampleRate));
70 setNumChannels (
spec.numChannels);
75template <
typename Type>
81 cutoffTransformSmoother.setCurrentAndTargetValue (cutoffTransformSmoother.getTargetValue());
82 scaledResonanceSmoother.setCurrentAndTargetValue (scaledResonanceSmoother.getTargetValue());
86template <
typename Type>
89 jassert (newValue > Type (0));
90 cutoffFreqHz = newValue;
95template <
typename Type>
98 jassert (newValue >= Type (0) && newValue <= Type (1));
104template <
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);
116template <
typename Type>
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];
144template <
typename Type>
145void LadderFilter<Type>::updateSmoothers()
noexcept
147 cutoffTransformValue = cutoffTransformSmoother.getNextValue();
148 scaledResonanceValue = scaledResonanceSmoother.getNextValue();
152template <
typename Type>
153void LadderFilter<Type>::setSampleRate (Type newValue)
noexcept
155 jassert (newValue > Type (0));
158 static constexpr Type smootherRampTimeSec = Type (0.05);
159 cutoffTransformSmoother.reset (newValue, smootherRampTimeSec);
160 scaledResonanceSmoother.reset (newValue, smootherRampTimeSec);
166template class LadderFilter<float>;
167template class LadderFilter<double>;
void fill(const ParameterType &newValue) noexcept
void setResonance(Type newValue) noexcept
void setMode(Mode newValue) noexcept
void setDrive(Type newValue) noexcept
void prepare(const juce::dsp::ProcessSpec &spec)
void setCutoffFrequencyHz(Type newValue) noexcept