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
void setCutoffFrequencyHz(Type newValue) noexcept
FloatType getTargetValue() const noexcept
void prepare(const juce::dsp::ProcessSpec &spec)
void reset(double sampleRate, double rampLengthInSeconds) noexcept
void setDrive(Type newValue) noexcept
void setMode(Mode newValue) noexcept
void setCurrentAndTargetValue(FloatType newValue)
void setResonance(Type newValue) noexcept