procedure IirInitBQ(const sos: TVec; var IIRState: TIirState; ComplexData: Boolean);
Initialize an IIR filter with second order sections.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | sos | TVec | |
| 2 | IIRState | TIirState | |
| 3 | ComplexData | Boolean |
Result: stored in self (calling object)
Remarks:
Initialize an IIR filter by initializing the IirState variable. Set ComplexData to True, if the data stream to be filtered will be complex. The Sos (real) vector variable contains second order sections as produced by the ZeroPoleToSOS function:
(B00, B10, B20, A00, A10, A20), (B01, B11, B21, A01, A11, A21), (.... ),...
B - numerator sections array A - denumarator sections array
Using second order sections to compute an IIR filter results in higher numerical accuracy and greater filter stability at a slightly higher cost on performance.
Examples
uses MtxExpr, Math387, MtxVec, SignalUtils, MtxVecTee, MtxVecEdit, IIRFilters;
procedure TForm42.Button1Click(Sender: TObject);
var b,c,Response,Response1,sos: Vector;
State: TIirState;
n,i: integer;
begin
Tone(b,300,6/300,0,1);
// Alternative: try gaussian noise
// b := RandGauss(300);
c.Size(b);
ChebyshevIFilter(6,0.2,[0.6],ftLowpass,false,sos); //design filter
FillChar(State,SizeOf(State),0);
IirInitBQ(sos,State); //initialize filtering structure
try
c.Copy(b); //make backup of data
IirFilter(c,State); //apply filter to data
DrawIt([b,c],['Original signal','Filtered signal']);
FrequencyResponse(b,nil,Response,8,True,wtHanning);
FrequencyResponse(c,nil,Response1,8,True,wtHanning);
DrawIt([Response,Response1],['Orig. signal','Filtered']);
finally
IirFree(State);
end;
end;