Issues with Linkwitz Riley filters

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

I want to use a pair of Linkwitz Riley filters for a crossover, but I'm not getting the results I anticipated.

I got the coefficients from the "Designing Audio Effect Plugins in C++" book (section 6.6.6) and plugged them into JUCE's IIRC filter, making both a low pass and a high pass set.

Alone, they seem to look ok (feeding them pink noise):
Screen Shot 2016-05-05 at 5.10.31 PM.png
Screen Shot 2016-05-05 at 5.11.19 PM.png
But when I run them in parallel, they don't add up flat.
Screen Shot 2016-05-05 at 5.09.28 PM.png
Here's the code:

Code: Select all

    IIRFilter myLRLow, myLRHigh;

    const double cutoffFreq = 800.0;

    const double theta = M_PI * cutoffFreq / sampleRate;
    const double omega = M_PI * cutoffFreq;
    const double kappa = omega / std::tan(theta);
    const double delta = (kappa * kappa) + (omega * omega) + 2.0 * kappa * omega;
    
    const double lp_a0 = (omega * omega / delta);
    const double lp_a1 = 2.0 * lp_a0;
    const double lp_a2 = lp_a0;
    
    const double b1 = ((-2.0 * kappa * kappa) + (2.0 * omega * omega)) / delta;
    const double b2 = ((-2.0 * kappa * omega) + (kappa * kappa) + (omega * omega)) / delta;

    const double hp_a0 = (kappa * kappa) / delta;
    const double hp_a1 = -2.0 * hp_a0;
    const double hp_a2 = hp_a0;

    myLRLow.setCoefficients(IIRCoefficients(lp_a0, lp_a1, lp_a2, 1.0, b1, b2));
    myLRHigh.setCoefficients(IIRCoefficients(hp_a0, hp_a1, hp_a2, 1.0, b1, b2));

Code: Select all

for(int i = 0; i < numSamples; i++)
{
    float n = noise.clock();
    float high = myLRHigh.processSingleSampleRaw(n);
    float low = myLRLow.processSingleSampleRaw(n);
    channelData[i] =  low + high;
}
I thought this would be pretty straight forward, but obviously I've missed something.
You do not have the required permissions to view the files attached to this post.

Post


Post

With -12dB/oct filters in a crossover, one of the bands must be phase inverted.
channelData = low + (high * -1.f);

Post

Bam.

Thank you.

Post Reply

Return to “DSP and Plugin Development”