- #1
- 970
- 670
I am experimenting with GNU Radio (using the Companion graphical editor) to do some simple audio processing.
As my first experiment, I am trying to set up a very simple 2nd order IIR filter at 170 Hz with a sample rate of 16000 samples/sec. I used this Mathematica code to find the taps:
Here's how I verify within Mathematica that the filter should work OK:
And this gives this plot, where I can verify that the resonant frequency is around 170 Hz as intended.
Now when I enter the feedforward taps into the GNU Radio IIR as [1] and the feedback taps as [1.97559, -0.9801] --- which I got from the first code block above and which works in the test filter above --- I get nothing resembling the above.
The impulse response in GNU Radio looks like this:
Now, the IIR block has a dropdown that selects the so-called "old" or "new" convention for the polarities of the tap values. If I change that option, I get the following, where the filter seems to have become unstable and is "hunting" at the sample rate.
So if anyone knows about the quirks of the IIR block in GNU Radio, please help me understand this. Thanks.
As my first experiment, I am trying to set up a very simple 2nd order IIR filter at 170 Hz with a sample rate of 16000 samples/sec. I used this Mathematica code to find the taps:
Code:
fs=16000;
fr=170 (* Center Frequency *)
\[CapitalTheta]=N[2 Pi fr / fs ]
r=0.99; (* this controls the Q *)
t1=2 r Cos[\[CapitalTheta]]
t2= -r*r
{t1,t2} (* these are the tap values that I want to use in GNU Radio's IIR block *)
Here's how I verify within Mathematica that the filter should work OK:
Code:
y1=0;
y2=0;
yyy=Reap[For[i=0,i<400,i++,
x=If[i<4,10,0]; (* inputs a short pulse to the system *)
y=x + t1* y1 + t2*y2;
Sow[y];
y2=y1;
y1=y;
]
][[2,1]];
ListPlot[yyy,PlotRange->All]
And this gives this plot, where I can verify that the resonant frequency is around 170 Hz as intended.
Now when I enter the feedforward taps into the GNU Radio IIR as [1] and the feedback taps as [1.97559, -0.9801] --- which I got from the first code block above and which works in the test filter above --- I get nothing resembling the above.
The impulse response in GNU Radio looks like this:
Now, the IIR block has a dropdown that selects the so-called "old" or "new" convention for the polarities of the tap values. If I change that option, I get the following, where the filter seems to have become unstable and is "hunting" at the sample rate.
So if anyone knows about the quirks of the IIR block in GNU Radio, please help me understand this. Thanks.