# Linqwitz-Riley crossover doesn't have a flat gain response

EDIT: Problem was in a piece of code unrelated to this question, concerning the Bode diagram plot.

Hello!
I wanted to build a Linqwitz-Riley crossover by creating cascaded butterworth filters using the `dsp::FilterDesign` class.
I found out that this class is returning a `ReferencedArray` of `IIRCoefficient`. There are only 6 coefficients in the `IIRCoefficient` class, so I assume it can design filters up to 2nd order, and it is returning cascaded Butterworths in the array.

Hence, the following code should give me the coefficients for a Linqwitz-Riley crossover (2 cascaded 2nd order butterworth) at f=1000Hz:

``````auto hp_coefs = dsp::FilterDesign<float>::designIIRHighpassHighOrderButterworthMethod(1000, 44100, 2);
auto lp_coefs = dsp::FilterDesign<float>::designIIRLowpassHighOrderButterworthMethod(1000, 44100, 2);
``````

However, this is what I get when I plot the Bode diagram of the filters:

The pink curve which is the sum of the magnitude of recombined signals which went through both the LP and HP filters, should be completly flat because it represents the Linqwitz-Riley crossover.

Concerning the phase, I don’t know what to expect but asymptotically it looks okay: a 2nd order shift to +/-180 degrees.

But why isn’t my gain completly flat? How are the Butterworth filters designed internally?

A 4th order Butterworth is not the same as two cascaded 2nd order Butterworths, you need to chain two filters together.

`dsp::FilterDesign<float>::designIIRXXXHighOrderButterworthMethod` methods for an order `2*n` are returning `n` cascaded 2nd order Butterworths and not a single `2*n` order Butterworth, so that was not the reason. I simply did a small mistake while calculating the gain of the recomposed signals.