\doxysubsection{Cascade.\+h}
\hypertarget{Cascade_8h_source}{}\label{Cascade_8h_source}\index{iir/Cascade.h@{iir/Cascade.h}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ }
\DoxyCodeLine{00036\ \textcolor{preprocessor}{\#ifndef\ IIR1\_CASCADE\_H}}
\DoxyCodeLine{00037\ \textcolor{preprocessor}{\#define\ IIR1\_CASCADE\_H}}
\DoxyCodeLine{00038\ }
\DoxyCodeLine{00039\ \textcolor{preprocessor}{\#include\ "{}Common.h"{}}}
\DoxyCodeLine{00040\ \textcolor{preprocessor}{\#include\ "{}Biquad.h"{}}}
\DoxyCodeLine{00041\ \textcolor{preprocessor}{\#include\ "{}Layout.h"{}}}
\DoxyCodeLine{00042\ \textcolor{preprocessor}{\#include\ "{}MathSupplement.h"{}}}
\DoxyCodeLine{00043\ }
\DoxyCodeLine{00044\ \textcolor{keyword}{namespace\ }\mbox{\hyperlink{namespaceIir}{Iir}}\ \{}
\DoxyCodeLine{00045\ }
\DoxyCodeLine{00049\ \ \ \ \ \ \ \ \ \textcolor{keyword}{class\ }IIR\_EXPORT\ \mbox{\hyperlink{classIir_1_1Cascade}{Cascade}}}
\DoxyCodeLine{00050\ \ \ \ \ \ \ \ \ \{}
\DoxyCodeLine{00051\ \ \ \ \ \ \ \ \ \textcolor{keyword}{public}:}
\DoxyCodeLine{00052\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00053\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{classIir_1_1Cascade}{Cascade}}\ ()\ =\ \textcolor{keywordflow}{default};}
\DoxyCodeLine{00054\ }
\DoxyCodeLine{00059\ \ \ \ \ \ \ \ \ \textcolor{keyword}{struct\ }IIR\_EXPORT\ \mbox{\hyperlink{structIir_1_1Cascade_1_1Storage}{Storage}}}
\DoxyCodeLine{00060\ \ \ \ \ \ \ \ \ \{}
\DoxyCodeLine{00061\ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{structIir_1_1Cascade_1_1Storage}{Storage}}()\ =\ \textcolor{keyword}{delete};}
\DoxyCodeLine{00062\ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{structIir_1_1Cascade_1_1Storage}{Storage}}(\textcolor{keyword}{const}\ \textcolor{keywordtype}{int}\ maxNumBiquads,\ \mbox{\hyperlink{classIir_1_1Biquad}{Biquad}}*\ \textcolor{keyword}{const}\ biquadArray)\ :\ maxStages(maxNumBiquads),\ stageArray(biquadArray)\ \{\}}
\DoxyCodeLine{00063\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{int}\ maxStages\ =\ 0;}
\DoxyCodeLine{00064\ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{classIir_1_1Biquad}{Biquad}}*\ \textcolor{keyword}{const}\ stageArray\ =\ \textcolor{keyword}{nullptr};}
\DoxyCodeLine{00065\ \ \ \ \ \ \ \ \ \};}
\DoxyCodeLine{00066\ }
\DoxyCodeLine{00070\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ \mbox{\hyperlink{classIir_1_1Cascade_a9694b85c160e3689a4d71fd51ca6175d}{getNumStages}}\ ()\textcolor{keyword}{\ const}}
\DoxyCodeLine{00071\ \textcolor{keyword}{\ \ \ \ \ \ \ \ }\{}
\DoxyCodeLine{00072\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ m\_numStages;}
\DoxyCodeLine{00073\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00074\ }
\DoxyCodeLine{00078\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \mbox{\hyperlink{classIir_1_1Biquad}{Biquad}}\&\ operator[]\ (\textcolor{keywordtype}{int}\ index)}
\DoxyCodeLine{00079\ \ \ \ \ \ \ \ \ \{}
\DoxyCodeLine{00080\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((index\ <\ 0)\ ||\ (index\ >=\ m\_numStages))}
\DoxyCodeLine{00081\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ throw\_invalid\_argument(\textcolor{stringliteral}{"{}Index\ out\ of\ bounds."{}});}
\DoxyCodeLine{00082\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ m\_stageArray[index];}
\DoxyCodeLine{00083\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00084\ }
\DoxyCodeLine{00089\ \ \ \ \ \ \ \ \ complex\_t\ response\ (\textcolor{keywordtype}{double}\ normalizedFrequency)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00090\ }
\DoxyCodeLine{00094\ \ \ \ \ \ \ \ \ std::vector<PoleZeroPair>\ getPoleZeros\ ()\ \textcolor{keyword}{const};}
\DoxyCodeLine{00095\ }
\DoxyCodeLine{00096\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ setCascadeStorage\ (\textcolor{keyword}{const}\ Storage\&\ storage);}
\DoxyCodeLine{00097\ }
\DoxyCodeLine{00098\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ applyScale\ (\textcolor{keywordtype}{double}\ scale);}
\DoxyCodeLine{00099\ }
\DoxyCodeLine{00100\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ setLayout\ (\textcolor{keyword}{const}\ \mbox{\hyperlink{classIir_1_1LayoutBase}{LayoutBase}}\&\ proto);}
\DoxyCodeLine{00101\ }
\DoxyCodeLine{00102\ \ \ \ \ \ \ \ \ \textcolor{keyword}{private}:}
\DoxyCodeLine{00103\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ m\_numStages\ =\ 0;}
\DoxyCodeLine{00104\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ m\_maxStages\ =\ 0;}
\DoxyCodeLine{00105\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{classIir_1_1Biquad}{Biquad}}*\ m\_stageArray\ =\ \textcolor{keyword}{nullptr};}
\DoxyCodeLine{00106\ \ \ \ \ \ \ \ \ \};}
\DoxyCodeLine{00107\ }
\DoxyCodeLine{00108\ }
\DoxyCodeLine{00109\ \textcolor{comment}{//-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}}
\DoxyCodeLine{00110\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00115\ \ \ \ \ \ \ \ \ \textcolor{keyword}{template}\ <\textcolor{keywordtype}{int}\ MaxStages,\textcolor{keyword}{class}\ StateType>}
\DoxyCodeLine{00116\ \ \ \ \ \ \ \ \ \textcolor{keyword}{class\ }\mbox{\hyperlink{classIir_1_1CascadeStages}{CascadeStages}}\ \{}
\DoxyCodeLine{00117\ }
\DoxyCodeLine{00118\ \ \ \ \ \ \ \ \ \textcolor{keyword}{public}:}
\DoxyCodeLine{00119\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{classIir_1_1CascadeStages}{CascadeStages}}()\ =\ \textcolor{keywordflow}{default};}
\DoxyCodeLine{00120\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00121\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00122\ \ \ \ \ \ \ \ \ \textcolor{keyword}{public}:}
\DoxyCodeLine{00126\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{classIir_1_1CascadeStages_ae5253fde0be7ccfa459a3f70fe8e3e31}{reset}}\ ()}
\DoxyCodeLine{00127\ \ \ \ \ \ \ \ \ \{}
\DoxyCodeLine{00128\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keyword}{auto}\ \&state:\ m\_states)}
\DoxyCodeLine{00129\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ state.reset();}
\DoxyCodeLine{00130\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00131\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00132\ \ \ \ \ \ \ \ \ \textcolor{keyword}{public}:}
\DoxyCodeLine{00138\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{classIir_1_1CascadeStages_a56d24da4cf09f898b534b1b05578244d}{setup}}\ (\textcolor{keyword}{const}\ \textcolor{keywordtype}{double}\ (\&sosCoefficients)[MaxStages][6])\ \{}
\DoxyCodeLine{00139\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ MaxStages;\ i++)\ \{}
\DoxyCodeLine{00140\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ m\_stages[i].\mbox{\hyperlink{classIir_1_1Biquad_a7f005089c194c68aeecdc66a3e6c6a78}{setCoefficients}}(}
\DoxyCodeLine{00141\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sosCoefficients[i][3],}
\DoxyCodeLine{00142\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sosCoefficients[i][4],}
\DoxyCodeLine{00143\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sosCoefficients[i][5],}
\DoxyCodeLine{00144\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sosCoefficients[i][0],}
\DoxyCodeLine{00145\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sosCoefficients[i][1],}
\DoxyCodeLine{00146\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sosCoefficients[i][2]);}
\DoxyCodeLine{00147\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00148\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00149\ }
\DoxyCodeLine{00150\ \ \ \ \ \ \ \ \ \textcolor{keyword}{public}:}
\DoxyCodeLine{00156\ \ \ \ \ \ \ \ \ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ Sample>}
\DoxyCodeLine{00157\ \ \ \ \ \ \ \ \ \textcolor{keyword}{inline}\ Sample\ \mbox{\hyperlink{classIir_1_1CascadeStages_aa18e9abcaac65fd21be31ee859add3bb}{filter}}(\textcolor{keyword}{const}\ Sample\ in)}
\DoxyCodeLine{00158\ \ \ \ \ \ \ \ \ \{}
\DoxyCodeLine{00159\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{double}\ out\ =\ in;}
\DoxyCodeLine{00160\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ StateType*\ state\ =\ m\_states;}
\DoxyCodeLine{00161\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ \&stage:\ m\_stages)}
\DoxyCodeLine{00162\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ out\ =\ (state++)-\/>filter(out,\ stage);}
\DoxyCodeLine{00163\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{static\_cast<}Sample\textcolor{keyword}{>}\ (out);}
\DoxyCodeLine{00164\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00165\ }
\DoxyCodeLine{00169\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \mbox{\hyperlink{structIir_1_1Cascade_1_1Storage}{Cascade::Storage}}\ \mbox{\hyperlink{classIir_1_1CascadeStages_a034a9be8ae590b814c8499898a93987a}{getCascadeStorage}}()}
\DoxyCodeLine{00170\ \ \ \ \ \ \ \ \ \{}
\DoxyCodeLine{00171\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \mbox{\hyperlink{structIir_1_1Cascade_1_1Storage}{Cascade::Storage}}\ s(MaxStages,\ m\_stages);}
\DoxyCodeLine{00172\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ s;}
\DoxyCodeLine{00173\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00174\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00175\ \ \ \ \ \ \ \ \ \textcolor{keyword}{private}:}
\DoxyCodeLine{00176\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{classIir_1_1Biquad}{Biquad}}\ m\_stages[MaxStages]\ =\ \{\};}
\DoxyCodeLine{00177\ \ \ \ \ \ \ \ \ StateType\ m\_states[MaxStages]\ =\ \{\};}
\DoxyCodeLine{00178\ \ \ \ \ \ \ \ \ \};}
\DoxyCodeLine{00179\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00180\ \}}
\DoxyCodeLine{00181\ }
\DoxyCodeLine{00182\ \textcolor{preprocessor}{\#endif}}

\end{DoxyCode}
