## Multi-filter Parks McClellan algorithm

Started by 2 years ago13 replieslatest reply 2 years ago238 views

Hi everyone,

There are of course, many situations where the design of a single linear-phase FIR filter may be accomplished using the Parks McClellan algorithm. My question is how the same input parameters may be applied to design a system with two or more cascaded filters  -  either :

• a)  To enable passband ripple cancellation to give a more efficient implementation than with a single filter.   or:
• b)  Where the impulse and/or frequency response of one filter are known (and fixed), and the remaining filter(s) are required to create a defined system frequency response.

Initially, this would use float32 parameters, and the design process would probably take place in the frequency domain.

Any links or suggestions to relevant information (code, pseudo-code or even a block diagram) are most welcome.

[ - ]
Reply by December 16, 2020

If I'm using cascaded filters there is usually a change of sample rate involved.

But if not, maybe this may be of some help:

[ - ]
Reply by December 16, 2020

Hi Woodpecker,

Suppose you want overall magnitude response H(f), and you will realize this with cascaded responses H1(f) and H2(f), where H1(f) is given and H2(f) is not.  Since

H = H1 X H2, then H2 = H/H1, where all of these responses are magnitude responses.  You can then use the H2 response as your goal response for the Parks-McClellan algorithm.

regards,

Neil

[ - ]
Reply by December 16, 2020

Also,

If H1(f) has a region where it is very small (e.g. filter stopband), this region can be excluded.  For example, if H1 is a LP, you could just compute H2 over the passband, and use just the passband frequency range for the PM algorithm.

-- Neil

[ - ]
Reply by December 16, 2020

Hi Neil,

Thanks for your input on this. The problem here is that the PM algorithm may not be able to handle the H2 response parameters produced by H/H1.

For instance if H1 was an RRS or CIC filter, and I needed compensation for the droop in response.

I believe I may need incorporate both responses in the PM algorithm iterative process. Alternatively, I'm wondering if it may be possible to design the H2(f) filter with a different algorithm to Parks McClellan.

Food for thought anyway . . .

[ - ]
Reply by December 16, 2020

Hi Woodpecker,

It seems to me it could work well for a droop-compensation filter.  For example, I have used the Matlab firls [not PM] algorithm to design sinx/x correctors,see

--Neil

[ - ]
Reply by December 17, 2020

Aha !

Yes, this looks very promising Neil. Now if the h_goal parameter in the sinc_corr function could be modified to take on the inverse response of the second filter, then this could prove most useful.

I'll try some experiments and report back if successful. Thanks.

[ - ]
Reply by December 17, 2020

Woodpecker,

I just reviewed the post I referenced -- it turns out I actually used a least-squares approximation (Matlab firls), not PM.  I don't recall if it worked better than PM or not.

-- Neil

[ - ]
Reply by December 16, 2020

A single rate FIR (designed by any method) can be split up into cascaded filters . I prefer single design rather than multiple design tasks. In principle I can't explain if it is any better to break one single rate FIR to two or so. However the principle at coefficient level is simple, two filters(h1,h2) cascaded is same as one filter(h) if h = conv(h1,h2).

For multirate case it is useful to adapt cutoff demands to sampling rate.

[ - ]
Reply by December 16, 2020

Ok thanks kaz,

I agree wholeheartedly that a single design is preferable ;-) I'm wondering how, from your example, we calculate h2 given that we have h and h1 parameters.

Could this require some form of deconvolution...  I have read that deconvolution is not without it's pitfalls. In particular with regard to divide by zero (or very small values). Perhaps judicious use of window functions might also be required following the calculation ?

[ - ]
Reply by December 17, 2020

Hi Woodpecker,

I am a bit unclear about your task. How come you know h1 & h and want h2. Is this for some academic purpose...It will help if you give us more insight into your task. If my filter is having bad ripple I better sort out at source than fix it later by a second filter. In practice there might be cases where it is less costly to be economic at design and targeting a fix later.

[ - ]
Reply by December 17, 2020

Hi kaz,

I'm attempting to find a generic solution to the case where the second or subsequent filter(s) is not able to be changed, for some reason.

Perhaps it is better to consider this as a type of equalization problem, such as sometimes occurs when a number of audio systems are connected as a chain.

[ - ]
Reply by December 17, 2020

If you want a pre-equaliser for the second filter's passand ripple then you need to invert the ripple only as long as your second filter is ok for cutoff. If so you only need to invert passband and keep stopband as unity. This will lessen burden on your equaliser. If you are targetting equaliser for input signal then it is a different case.

[ - ]
Reply by December 21, 2020

Hi all,  I'm back again,

For anyone interested in designing phase/amplitude correction FIR filters, the free rePhase FIR tool on the minidsp.com website may be of interest.

Although, this seems to have been primarily designed for loudspeaker crossover units, I'm sure it could have other applications.

Here you can find details and application examples.

And download rePhase for Windows here. This URL also has some nice tutorial links.