IIR filters

 IIR – Feedback is infinity

Fir Filter are always stable, So we don’t have any poles & zeros

Biquad Filter is second order recursive filter with infinity feedback which has two poles & two zeros.

 


When Coefficients are normalized then a0 = 1

 



Why we use cascading in Biquad filters ?

Basically High-order infinite impulse response filters are highly sensitive to quantization of their coefficients and easily become unstable. But with first & second filters it is very less. So to make it stable, implement high order filters as serially cascaded Biquad sections which will make it stable by keeping all the poles inside the unit circle.

Direct Form 1:

From fig : 

𝑧1Means delay by 1 sample

𝑧2 Means delay by 2 samples

Y[n] = 1/a0 (b0x[n] + b1x[n-1] + b2x[n-2] – a1y[n-1] -a2y[n-2])

Y[n] = b0x[n] + b1x[n-1]+b2x[n-2]-a1y[n-1]-a2y[n-2]

Where b0, b1, b2 are current sample coefficients determine zeros

a1, a2 are previous output samples determines the poles

 

 

 



                              






Here path b0, b1, b2 is feed forward & a1, a2 is feed backward path

Direct Form II



 

W(n) = x(n) – a1 w(n-1) – a2 w(n-2)

Y(n) = b0w(n) + b1w(n-1) + b2(w-2)

 

 





                                








Transposition theorem rules

  1. Reverse all signal paths: Change the direction of all arrows in the signal flow graph.
  2. Interchange the input and output: The original input, 𝑥(𝑛), becomes the output, and the original output, 𝑦(𝑛), becomes the input.
  3. Swap all summing and branching points.

                               













 

Direct Form 1

Transposed Direct Form1

1) In above picture . represents branch nodes which must replace with Summation

 

2) Swapped b2 & a2, a1 & b1, b0 & a0 (where a0=1)

 

3) Reverse arrows feedforward -> feed backward vice versa

 

 





                    

Direct Form II

Transposed Direct FormII

 

Y[n] = b0 x[n] + w1[n-1]

W1[n] = b1 x[n] – a1 Y[n] + w2[n-1]

W2[n] = b2 x[n] – a2 Y[n]

Direct Form I

Direct Form II

Requires 4 delay elements

Require 2 Delay elements

Requires more memory

Requires less memory

Direct form1 & transpose DF2 we are evaluating Numerator first & then denominator

Direct form2 & transpose DF1 we are evaluating denominator first & then Numerator

 

 

 

In Fixed point processor we prefer Direct Form1 over Direct Form2

If we except small values at numerator then we need to perform Numerator first. So, we will choose DF1 or TDF2

If we except small values at denominator then we need to perform denominator first. So, we will choose DF2 or TDF1

But choosing topology will depend on architecture and processor and filter coefficients

For SIMD processors TDF2 will be beneficial because of parallelism and easier to optimize

Cascade Form

In GTT we don’t have even number of biquads

 

For Magnitude & phase response: https://www.earlevel.com/main/2021/09/02/biquad-calculator-v3/

 

Parameter

Description

Tunable or Controllable

Range

Frequency

Filtering frequency to be applied

Control/Tunable

20Hz-20kHz

Gain

Filter gain

Control/Tunable

-18 to 18dB

Quality

Quality of the filtering coefficients

Control/Tunable

0.1-10

Type

Filter type

Tunable

Highpass,Lowpass,etc...

RampTime

Ramp time for filter coefficient to adapt to new coefficient

Tunable

0 to 500msec

 

As we have different biquads based on how you compute cofficients & how we are going to tune

1)       Parameter biquad

2)       Crossover biquad

3)       Tonecontrolled biquad

4)       Coefficient biquad

Parameter

Tone Control

Crossover

Coefficient

Used in equalizers where you want to boost or cut a narrow frequency band

 

Used in simpler EQ for treble/bass control

Low-shelf - Boost or cuts bass region

High shelf – Boosts or cuts treble region

Used in Multi audio systems (Subwoofers, mid, tweeters)

It is just representing or configuring the coefficients

 

What is sections in biquads

Basically sections is nothing but no of biquads using in a filter

Ex: 3 sections means using 3 biquads

1Biquad -> 2nd Order

2Biquads -> 4th Order

3Biquads -> 6th Order

So 3 sections = three cascaded 2nd order filters per channel

 

Example — 2 Channels × 3 Sections

Coefficients array (coeff)

Each section’s coefficients are stored contiguously, section by section:

Section

Coeff Index Range

Coefficients

0

0 – 4

b0, b1, b2, a1, a2

1

5 – 9

b0, b1, b2, a1, a2

2

10 – 14

b0, b1, b2, a1, a2

 

So :

float coeff[15] = {

   b00, b01, b02, a01, a02,   // section 0

   b10, b11, b12, a11, a12,   // section 1

   b20, b21, b22, a21, a22    // section 2

};

State array (state)

For 2 channels × 3 sections, we need:

2×3×2=12 state variables

Each section per channel keeps its own s1, s2. Where s1,s2 are state variables

Layout:

Channel

Section

State Indices

Contents

0 (Left)

0

0,1

s1L0, s2L0

0 (Left)

1

2,3

s1L1, s2L1

0 (Left)

2

4,5

s1L2, s2L2

1 (Right)

0

6,7

s1R0, s2R0

1 (Right)

1

8,9

s1R1, s2R1

1 (Right)

2

10,11

s1R2, s2R2

 

 

Ramping: Updating the biquad coefficients over time instead of changing them suddenly

In tuning perspective, When filter parameters like gain,cutoff changes we need to smoothly transition from old coefficients to new coefficients.

Why Ramping is needed ?

1.       In real time when coefficients jump suddenly cause audio pops or distortions

2.       It will cause sometimes move poles & zeros outside the unit circle which will cause filter un-stable

 

Comments

Popular posts from this blog

Q format representation

Binary representation of numbers

DSP Basics