| @@ -148,6 +148,7 @@ namespace StateVariableFilter | |||||
| void processBlock (const SampleType* input, SampleType* output, size_t n) noexcept | void processBlock (const SampleType* input, SampleType* output, size_t n) noexcept | ||||
| { | { | ||||
| auto state = *parameters; | auto state = *parameters; | ||||
| for (size_t i = 0 ; i < n; ++i) | for (size_t i = 0 ; i < n; ++i) | ||||
| output[i] = processLoop<type> (input[i], state); | output[i] = processLoop<type> (input[i], state); | ||||
| @@ -187,6 +188,10 @@ namespace StateVariableFilter | |||||
| void setCutOffFrequency (double sampleRate, NumericType frequency, | void setCutOffFrequency (double sampleRate, NumericType frequency, | ||||
| NumericType resonance = static_cast<NumericType> (1.0 / std::sqrt (2.0))) noexcept | NumericType resonance = static_cast<NumericType> (1.0 / std::sqrt (2.0))) 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)); | g = static_cast<NumericType> (std::tan (MathConstants<double>::pi * frequency / sampleRate)); | ||||
| R2 = static_cast<NumericType> (1.0 / resonance); | R2 = static_cast<NumericType> (1.0 / resonance); | ||||
| h = static_cast<NumericType> (1.0 / (1.0 + R2 * g + g * g)); | h = static_cast<NumericType> (1.0 / (1.0 + R2 * g + g * g)); | ||||