# 3 Band Crossover with Linkwitz Riley Filter

I would like to write a 3 Band "EQ" with BiQuad Filters but for some reason, I get some phase distortion.

The problem already got discussed here.

I found out that I need to work with Allpass filters in order to compensate the phase response of my filters. Btw, the filters are Linkwitz-Riley 2nd order filters.

But when I try to copy the idea to my project, I still have some distortion.

// low pass calcuation for linkwitz riley filters

float lowCutoff; // the lower cutoff frequency
float highCutoff; // the higher cutoff frequency

double omega = M_PI * cutoffFrequency;
double theta = omega / sampleRate;
double kappa = omega / tan(theta);
double delta = kappa * kappa + omega * omega + 2.0 * kappa * omega;

double a0 = (omega * omega) / delta;
double a1 = 2.0 * a0;
double a2 = a0;

double b1 = (-2.0 * kappa * kappa + 2.0 * omega * omega) / delta;
double b2 = (-2.0 * kappa * omega + kappa * kappa + omega * omega) / delta;

// high pass, only the calculation of a0 to b2 changes
// the intermediate values stay the same

double a0 = (kappa * kappa) / delta;
double a1 = -2.0 * a0;
double a2 = a0;

double b1 = (-2.0 * kappa * kappa + 2.0 * omega * omega) / delta;
double b2 = (-2.0 * kappa * omega + kappa * kappa + omega * omega) / delta;

// allpass filter to compensate phase response:

double q = 0.5;
double alpha = (tan(M_PI*q/sampleRate) - 1) / (tan(M_PI*0.5/sampleRate) + 1);
double beta =   -cos(lowCutoff  * M_PI / sampleRate);

double a0 = -alpha;
double a1 = beta*(1.0 - alpha);
double a2 = 1.0;
double b1 = beta*(1.0 - alpha);;
double b2 = -alpha;;


Since I use 2nd order filters, I also have to use a 2nd order all pass filter, right? I've read that for those filters and with this calculation, I hav to use q. So q should be the same as the q in the Linkwitz-Riley filter, which should be 0.5 right? (I've read this somewhere, not sure about it.)

Then, my actual processing looks something like this:

// filter names:
// loAPF, lowHPF, ... low: lower cutoffhigh: higher cutoff
// APF: allpass, HPF: highpass, LPF: lowpass

highSample =  lowAPF->tick(highHPF->tick(sample));
midSample =   lowHPF->tick(highLPF->tick(sample));
lowSample =   lowLPF->tick(highLPF->tick(sample));


Does somebody have any idea, why I might have problems with the phase response?

• I've just noticed that I used the high lowpass filtertwice, which isn't realy how you use dgital filters. :/ So this could be a problem but looking over, I also think that the phases are still off or not 360° shifted to each other. Nov 6 '14 at 20:48
• a LRF shouldnt have a Q value at all...
– bubu
Aug 16 '19 at 6:08
• That doesn't answer any of the points made in the question. Besides that, LRFs are put together usually with 2nd order IIR filters (cascaded) and thus have internal Q coefficients. They're however fixed by the design assumption that the sum of two filters (LP, HP) should have a flat cross over. So, A LRF doesn't have a parametric Q like a generic 2nd order lowpass. But it still has a Q parameter that is defined by the design assumption. Aug 16 '19 at 14:05

There is a reference at the Linkwitz website regarding the "The Duelund 3-way crossover filter function D3" that appears to be the 3-band that is not derived from splitting one band of a 2-band L-R crossover. I may have seen this before, but I am not familiar. I'll look at it now and see if I can grok it.

Here's another reference to the Duelund thingie.

Okay, it appears that this is the essential Duelund 3-way crossover:

$$H_\text{LP}(s) = \frac{1}{s^4 + 2as^3 + (a^2+2)s^2 + 2as + 1}$$

$$H_\text{BP}(s) = \frac{-(a^2+2)s^2}{s^4 + 2as^3 + (a^2+2)s^2 + 2as + 1}$$

$$H_\text{HP}(s) = \frac{s^4}{s^4 + 2as^3 + (a^2+2)s^2 + 2as + 1}$$

and this all adds up to an All-pass filter. Looks like $a=2\sqrt2$ is recommended.

A 2nd-order Linkwitz-Riley crossover needs 1st-order allpass phase compensation.

The Lowpass half of the LR crossover is:

$$\dfrac{1}{s^2+2s+1}$$

The Highpass half of the LR crossover is:

$$\dfrac{s^2}{s^2+2s+1}$$

With even-order LR crossovers, in order to sum-to-allpass one of the two sections has to have inverted polarity. Thus:

$$\dfrac{s^2}{s^2 + 2s +1} - \dfrac{1}{s^2 + 2s +1}= \dfrac{(s-1)(s+1)}{(s+1)(s+1)} = \dfrac{(s-1)}{(s+1)}$$

• Could you do me the favor and add some link which explaines what what 1/ (s²...) stands for? I sadly have no clue was s is and what the term means. ;D I've used 4th order and a 2nd order APF, which worked. But knowing how to solve this for 2nd order LR filters would be nice! :) Nov 12 '14 at 17:01
• en.wikipedia.org/wiki/Laplace_transform Dec 12 '14 at 16:45