/** The type of the IIR filter */
Type type = Type::lowPass;
/** Sets the cutoff frequency and resonance of the IIR filter.
Note: The bandwidth of the resonance increases with the value of the
parameter. To have a standard 12 dB/octave filter, the value must be set
at 1 / sqrt(2).
*/
void setCutOffFrequency (double sampleRate, NumericType frequency,
NumericType resonance = static_cast<NumericType> (1.0 / MathConstants<double>::sqrt2)) noexcept
{
jassert (sampleRate > 0);
jassert (resonance > NumericType (0));
jassert (frequency > NumericType (0) && frequency <= NumericType (sampleRate * 0.5));
g = static_cast<NumericType> (std::tan (MathConstants<double>::pi * frequency / sampleRate));
R2 = static_cast<NumericType> (1.0 / resonance);
h = static_cast<NumericType> (1.0 / (1.0 + R2 * g + g * g));
}
//==============================================================================
/** The Coefficients structure is ref-counted, so this is a handy type that can be used
as a pointer to one.
*/
using Ptr = ReferenceCountedObjectPtr<Parameters>;
//==============================================================================
Parameters() = default;
Parameters (const Parameters& o) : g (o.g), R2 (o.R2), h (o.h) {}
Parameters& operator= (const Parameters& o) noexcept { g = o.g; R2 = o.R2; h = o.h; return *this; }
//==============================================================================
NumericType g = static_cast<NumericType> (std::tan (MathConstants<double>::pi * 200.0 / 44100.0));
NumericType R2 = static_cast<NumericType> (MathConstants<double>::sqrt2);
NumericType h = static_cast<NumericType> (1.0 / (1.0 + R2 * g + g * g));
};
}
} // namespace dsp
} // namespace juce
Can anyone please explain this logic used for StateVariable Filter?
Thanks in advance.