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-&gt;tick(highHPF-&gt;tick(sample));
midSample =   lowHPF-&gt;tick(highLPF-&gt;tick(sample));
lowSample =   lowLPF-&gt;tick(highLPF-&gt;tick(sample));


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

Thanks in advance!
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)}$$