36 #ifndef IIR1_CASCADE_H
37 #define IIR1_CASCADE_H
42 #include "MathSupplement.h"
65 : maxStages (maxStages_)
66 , stageArray (stageArray_)
87 if ((index < 0) || (index >= m_numStages))
88 throw std::invalid_argument(
"Index out of bounds.");
89 return m_stageArray[index];
96 complex_t response (
double normalizedFrequency)
const;
101 std::vector<PoleZeroPair> getPoleZeros ()
const;
106 void setCascadeStorage (
const Storage& storage);
108 void applyScale (
double scale);
126 template <
int MaxStages,
class StateType>
134 for (
auto &state: m_states)
144 void setup (
const double (&sosCoefficients)[MaxStages][6]) {
145 for (
int i = 0; i < MaxStages; i++) {
146 m_stages[i].setCoefficients(
147 sosCoefficients[i][3],
148 sosCoefficients[i][4],
149 sosCoefficients[i][5],
150 sosCoefficients[i][0],
151 sosCoefficients[i][1],
152 sosCoefficients[i][2]);
162 template <
typename Sample>
166 StateType* state = m_states;
167 for (
const auto &stage: m_stages)
168 out = (state++)->filter(out, stage);
169 return static_cast<Sample
> (out);
181 Biquad m_stages[MaxStages];
182 StateType m_states[MaxStages];