Nband LinkwitzRiley crossovers

 KVRian
 Topic Starter
 574 posts since 1 Jan, 2013 from Denmark
Nice, yeah that seems possible  but on the other hand then the bands will require extra processing when summing them back, and also the bands will be out of phase while processing them independently..
However, as you increase the # of bands, this optimization scales actually! So that may be an option if you want to scale back the CPU usage.
However, as you increase the # of bands, this optimization scales actually! So that may be an option if you want to scale back the CPU usage.

 KVRAF
 7420 posts since 17 Feb, 2005
For the serial case, it may be possible to cascade the lowpasses instead, which should offer "more precision".
The biquad filters in Reaktor have a resonance tuning from 0  1. I am trying to figure out how to translate that to Q/bandwidth.
The biquad filters in Reaktor have a resonance tuning from 0  1. I am trying to figure out how to translate that to Q/bandwidth.

 KVRist
 56 posts since 16 Mar, 2014
There is a tutorial on multiband splitters at http://flowstone.guru/downloads/multib ... tutorial/ where the use of allpasses is explained and demonstrated. You will need Flowstone to fully appreciate, though. FS tryout version will suffice.

 KVRian
 Topic Starter
 574 posts since 1 Jan, 2013 from Denmark
Thanks for sharing, I don't have flowstone so perhaps you could elaborate on the differences/similarities to the discussed method?martinvicanek wrote:There is a tutorial on multiband splitters at http://flowstone.guru/downloads/multib ... tutorial/ where the use of allpasses is explained and demonstrated. You will need Flowstone to fully appreciate, though. FS tryout version will suffice.

 KVRist
 56 posts since 16 Mar, 2014
I'll ty to summarize the main points:
1. You need allpasses for the bands to add.
2. For each bandsplitter you need an allpass at the opposite branch.
3. Doing it the naive way the number of components grows very fast for each additional band.
4. There is a smart way to do it. The trick is to place allpasses as close as possible to the root.
Here are two references with more details:
Complementary NBand IIR Filterbank Based on 2Band Complementary Filters,
Favrot, Alexis and Faller, Christof, IWAENC 2010 Proceedings.
http://www.iwaenc.org/proceedings/2010/ ... ds/975.pdf
The digital allpass filter: A versatile signal processing building block
P. A. Regalia, S. K. Mitra, and P. P. Vaidyanathan,
IEEE Proceedings Vol. 71 (1) 1988.
http://faculty.cua.edu/regalia/regalia ... jan88.pdf
1. You need allpasses for the bands to add.
2. For each bandsplitter you need an allpass at the opposite branch.
3. Doing it the naive way the number of components grows very fast for each additional band.
4. There is a smart way to do it. The trick is to place allpasses as close as possible to the root.
Here are two references with more details:
Complementary NBand IIR Filterbank Based on 2Band Complementary Filters,
Favrot, Alexis and Faller, Christof, IWAENC 2010 Proceedings.
http://www.iwaenc.org/proceedings/2010/ ... ds/975.pdf
The digital allpass filter: A versatile signal processing building block
P. A. Regalia, S. K. Mitra, and P. P. Vaidyanathan,
IEEE Proceedings Vol. 71 (1) 1988.
http://faculty.cua.edu/regalia/regalia ... jan88.pdf
 KVRAF
 7964 posts since 12 Feb, 2006 from Helsinki, Finland
I realise I'm a little late to this party, but I thought I'd still try to explain how this works, since it's actually much less complicated than it first appears.
They key is to think in terms of the underlying Butterworth filters, which (for any given cutoff frequency) all share the exact same pole configuration (and only differ in terms of zeroes). Then if we filter one signal with two lowpass filters (of order k each) and two highpass filters (of order k each) in parallel paths and add these together, then we have a total of 2*k poles, half of which cancel out with the resulting zeroes(!) and the remaining ones forming an allpass; one set of the duplicate poles cancel out with the minimumphase half of the zeros (which form a circle; recall that Butterworth filters have their poles in a halfcircle) and what remains is a Butterworth allpass (of order k). In digital domain BLT preserves this "magical" property.
In other words, for Butterworth filters we have: LP(w)*LP(w) + HP(w)*HP(w) = AP(w). This is the key to Nband crossovers.
Suppose we want to build a 3band crossover. We can split the highband from the main signal with one 2band crossover and insert another 2band crossover in the lowmid part to split it further into low and mid. When we add these two together, the result is a Butterworth allpass filter response (with cutoff at the lowmid cutoff). So all we have to do in order to match the phases for the highband is to pass the highband signal through an identical allpass filter!
So for the Nband case, if you splitoff one band at a time (and for audio purposes I would suggest you keep splitting off the highend of the unsplit signal, because this way the lowest band gets the highest order filtering, which plays well with our hearing*), then each time you split off another band, you pass all the previously split bands through an allpass that matches the crossover used at this point. This keeps all the phases perfectly "in sync" and will give you a flat sum for arbitrary number of bands.
There is another interesting optimisation possible: You can completely skip the highpass filters and instead just process the double lowpass in parallel with a (single) allpass for the band you are splitting further. The highpass part of the band is then simply the difference between the allpass and the (double) lowpass signals (which works for the same reason the flat summing works). This leads to one possible algorithm: split additional bands from the lowend by doublelowpass filtering (with Butterworth) the lowest current band to build a new lower band, then allpass filter all the previous bands (with a matching cutoff) and then subtracting the newly formed lower band from the second lowest band (ie. the previous lowest band).
While this seemingly requires a triangular (rather than linear) number of component filters (which you can't avoid if you actually need to output the separate bands), there is a final optimisation possible if (and only if) you also control the final summing (that is, you are doing multiband processing rather than just splitting for external use): since at any point you are applying an identical allpass filter to "all existing bands" you can actually process these bands as you split them off, then add them to a summed "processed" signal, which only needs further allpass filters applied once (ie. you only need to track two signals: one is the unprocessed one from which you split further bands, the other one is the processed band which gets allpass compensation filters applied). In this special case the number of filters required is linear with the number of bands (specifically 2xButterworth lowpass for the new band split, one Butterworth allpass for getting the highpass and one Butterworth allpass for compensating the sum of the previously processed bands).
*) one can argue about this and it's not the most important thing, but most people would intuitively think of splitting as a binary tree and I feel this just makes things more complicated in practice, in addition to placing the (slightly) steeper cutoffs at the midfrequencies; for parallel implementation purposes I would suggest software pipelining instead.
They key is to think in terms of the underlying Butterworth filters, which (for any given cutoff frequency) all share the exact same pole configuration (and only differ in terms of zeroes). Then if we filter one signal with two lowpass filters (of order k each) and two highpass filters (of order k each) in parallel paths and add these together, then we have a total of 2*k poles, half of which cancel out with the resulting zeroes(!) and the remaining ones forming an allpass; one set of the duplicate poles cancel out with the minimumphase half of the zeros (which form a circle; recall that Butterworth filters have their poles in a halfcircle) and what remains is a Butterworth allpass (of order k). In digital domain BLT preserves this "magical" property.
In other words, for Butterworth filters we have: LP(w)*LP(w) + HP(w)*HP(w) = AP(w). This is the key to Nband crossovers.
Suppose we want to build a 3band crossover. We can split the highband from the main signal with one 2band crossover and insert another 2band crossover in the lowmid part to split it further into low and mid. When we add these two together, the result is a Butterworth allpass filter response (with cutoff at the lowmid cutoff). So all we have to do in order to match the phases for the highband is to pass the highband signal through an identical allpass filter!
So for the Nband case, if you splitoff one band at a time (and for audio purposes I would suggest you keep splitting off the highend of the unsplit signal, because this way the lowest band gets the highest order filtering, which plays well with our hearing*), then each time you split off another band, you pass all the previously split bands through an allpass that matches the crossover used at this point. This keeps all the phases perfectly "in sync" and will give you a flat sum for arbitrary number of bands.
There is another interesting optimisation possible: You can completely skip the highpass filters and instead just process the double lowpass in parallel with a (single) allpass for the band you are splitting further. The highpass part of the band is then simply the difference between the allpass and the (double) lowpass signals (which works for the same reason the flat summing works). This leads to one possible algorithm: split additional bands from the lowend by doublelowpass filtering (with Butterworth) the lowest current band to build a new lower band, then allpass filter all the previous bands (with a matching cutoff) and then subtracting the newly formed lower band from the second lowest band (ie. the previous lowest band).
While this seemingly requires a triangular (rather than linear) number of component filters (which you can't avoid if you actually need to output the separate bands), there is a final optimisation possible if (and only if) you also control the final summing (that is, you are doing multiband processing rather than just splitting for external use): since at any point you are applying an identical allpass filter to "all existing bands" you can actually process these bands as you split them off, then add them to a summed "processed" signal, which only needs further allpass filters applied once (ie. you only need to track two signals: one is the unprocessed one from which you split further bands, the other one is the processed band which gets allpass compensation filters applied). In this special case the number of filters required is linear with the number of bands (specifically 2xButterworth lowpass for the new band split, one Butterworth allpass for getting the highpass and one Butterworth allpass for compensating the sum of the previously processed bands).
*) one can argue about this and it's not the most important thing, but most people would intuitively think of splitting as a binary tree and I feel this just makes things more complicated in practice, in addition to placing the (slightly) steeper cutoffs at the midfrequencies; for parallel implementation purposes I would suggest software pipelining instead.

 KVRian
 Topic Starter
 574 posts since 1 Jan, 2013 from Denmark
Hey mystran, and thanks for chiming in.
I really feel like a lot of this stuff comes much more naturally if have a fundamental understanding of the complex representations of the filters (and not just trying to reason about phase/resonance etc) so I appreciate you covering the theoretical approach.
As said, I happened to use svf filters so you get free lowpass and highpass simultaneously anyway  and I can definitely see there are possible tricks if you control the summing stage (I need the bands aligned separately unfortunately)! I guess this is also a luxury designers for speaker crossovers never had.
I really feel like a lot of this stuff comes much more naturally if have a fundamental understanding of the complex representations of the filters (and not just trying to reason about phase/resonance etc) so I appreciate you covering the theoretical approach.
As said, I happened to use svf filters so you get free lowpass and highpass simultaneously anyway  and I can definitely see there are possible tricks if you control the summing stage (I need the bands aligned separately unfortunately)! I guess this is also a luxury designers for speaker crossovers never had.
 KVRAF
 7964 posts since 12 Feb, 2006 from Helsinki, Finland
While this works well for 2nd order crossover, it's still kinda cheaper to just stack two onepoles (you can get the allpass as a "separate output" from the first one). For anything higher order (ie. most applications given that a twostack of onepoles are not a very good crossover filter) you typically decompose to 2nd order sections and it's an even bigger win.Mayae wrote: As said, I happened to use svf filters so you get free lowpass and highpass simultaneously anyway.

 KVRian
 Topic Starter
 574 posts since 1 Jan, 2013 from Denmark
Wait, this is interesting. Originally I wanted to compose the structure out of onepoles both for efficiency and flexibility (and of course the nice identity that two cascaded onepoles = 0.5 Q twopole). But I couldn't figure out how to design the complimentary highpass outputs  also why I asked that as the 'bonus question'.mystran wrote:While this works well for 2nd order crossover, it's still kinda cheaper to just stack two onepoles (you can get the allpass as a "separate output" from the first one). For anything higher order (ie. most applications given that a twostack of onepoles are not a very good crossover filter) you typically decompose to 2nd order sections and it's an even bigger win.Mayae wrote: As said, I happened to use svf filters so you get free lowpass and highpass simultaneously anyway.
If you can derive both the allpass and the highpass somehow that could be great:
Would you mind sketching a simple crossover using onepoles with ap, lp and hp outputs?(you can get the allpass as a "separate output" from the first one).

 KVRian
 1273 posts since 9 Jan, 2006
Hope this is useful for one pole filters:
That's a diagram of a multimode onepole  allpass is lowpass minus highpass (highpass minus lowpass inverts phase). In code:
That's a diagram of a multimode onepole  allpass is lowpass minus highpass (highpass minus lowpass inverts phase). In code:
Code: Select all
//init state
s = 0.0;
//calculate coefficients
g = tan(pi * centerFrequency / sampleRate);
g/=(1+g);
g2 = g*2;
//process loop
lp = input*g + s;
hp = inputlp;
ap = lphp;
s = (inputlp)*g2+s;

 KVRian
 Topic Starter
 574 posts since 1 Jan, 2013 from Denmark
Excellent, thanks a lot! I've made similar highpasses before, but I always thought it was 'cheating'.. Nice to know about the allpass. I guess you can generalize this structure for any cascaded order? Would the input forming the hp then be the original or the output from the first lowpass?matt42 wrote:Hope this is useful for one pole filters:
That's a diagram of a multimode onepole  allpass is lowpass minus highpass (highpass minus lowpass inverts phase). In code:Code: Select all
//init state s = 0.0; //calculate coefficients g = tan(pi * centerFrequency / sampleRate); g/=(1+g); g2 = g*2; //process loop lp = input*g + s; hp = inputlp; ap = lphp; s = (inputlp)*g2+s;

 KVRian
 1273 posts since 9 Jan, 2006
Well, so long as the design method is equivalent to the BLT (this filter is designed with trapezoidal integration, so is equivalent) then the resulting high pass will have the phase and frequency response of a BLT high pass, so it's correct in that sense.Mayae wrote:I've made similar highpasses before, but I always thought it was 'cheating'
I didn't see mentioned that LinkwitzRiley is Butterworth squared (edit: I see it's in Mystran's post). In other words for the correct response we need two Butterworth filters in series. So if we use one pole sections the we need run though two lowpass, for lowband and two for highband. To retain the correct response. For second order sections we need butterworth 2nd order, q of 0.707, and as above we need run though two lowpass, for lowband and two for highband. The summed high/lowpass is an allpass filter. This means if we further split the high band to high and mid then the summed high and mid is phase shifted and will no longer sum to allpass when summed with the low band. In that example we can add a single butterworth allpass (set to the same frequency as the high/mid band) and apply this to the low band. This phase shifts the low band in the same manner as the summed high/mid band and we can now sum all bands to allpass.
So a one pole (actually there is no one pole LR filter. This is second order with q of 0.5) two band splitter would look like this:
and three band with one pole sections:
Added the block diagram as that might help with that question? Wasnt exactly sure what you meant.Mayae wrote:Would the input forming the hp then be the original or the output from the first lowpass?
Maybe check these:
https://en.wikipedia.org/wiki/Linkwitz% ... ley_filter
and maybe this old thread:
viewtopic.php?t=278736
Edit: Thanks, Mystran. Just read through your optimization tips with a clear mind. That would be handy if I ever need to use this.
Last edited by matt42 on Wed Mar 01, 2017 5:54 pm, edited 1 time in total.

 KVRian
 Topic Starter
 574 posts since 1 Jan, 2013 from Denmark
Great to know, thanks.matt42 wrote:Well, so long as the design method is equivalent to the BLT (this filter is designed with trapezoidal integration, so is equivalent) then the resulting high pass will have the phase and frequency response of a BLT high pass, so it's correct in that sense.Mayae wrote:I've made similar highpasses before, but I always thought it was 'cheating'
Ah, was talking about the equations  so to generalize for any (BLT) filter, this holds?Added the block diagram as that might help with that question? Wasnt exactly sure what you meant.Mayae wrote:Would the input forming the hp then be the original or the output from the first lowpass?
Code: Select all
lp = filter(input);
hp = inputlp;
ap = lphp;

 KVRian
 1273 posts since 9 Jan, 2006
Well, in the case of one pole, yes.Mayae wrote:]Ah, was talking about the equations  so to generalize for any (BLT) filter, this holds?Code: Select all
lp = filter(input); hp = inputlp; ap = lphp;
Code: Select all
//one pole transfer functions:
//lowpass transfer function
1/(1+s);
//highpass transfer function
s/(1+s);
//inputlowpass transfer function
11/(1+s);
//simplifies to
s/(1+s)//high pass

 KVRAF
 3080 posts since 17 Apr, 2005 from S.E. TN
Yep, IIRC 2nd order or higher, [Input  LP] tends to result in a highpass about 6 dB per octave. The highpass is degraded because of the higherorder phase shift, resulting in "not very good" subtraction of lows from the broadband signal.
In some cases perhaps the assymetrical cutoff slopes could be desirable, dunno.
I like MyStran's idea about higher order filters "Apply lowpass to the Input; Apply allpass to the Input; Derive hipass by subtracting lowpass output from allpass output."
Have not tested, but that "seems like" it ought to work nicely. Captain Obvious says that for a secondorder lowpass, use a firstorder allpass, and for a fourthorder lowpass, use a secondorder allpass.
Been busy with some woodworking and carpentry, but began wondering whether a "flatsumming" multiband crossover (containing phase shifts which "line up with each other" such as LinkwitzRiley) would be really much of a benefit for instance multiband dynamics processing. Would like to test more closely sometime.
It ought to be fine for speaker crossover or other applications where the mix level of the different bands stays fixed during the processing run. But applications which "quickly" change the mix levels of the bands during playback
For instance a simple 2 band crossover which mixes flat Firstorder crossover or higherorder LinkwitzRiley For a firstorder crossover, if at some moment the highoutput gets heavily compressed then the mixed output phase at the crossover frequency would approach 45 degrees. But at some other moment if the lowoutput gets heavily compressed then the mixed output phase would approach +45 degrees.
With a secondorder LR, it would be the same except phase could be dynamically modulated up to +/ 90 degrees. With fourthorder LR, the mixed output could be dynamically modulated up to +/ 180 degrees.
This dynamic phase shifting ought to be most obvious in the vicinity of the crossover frequencies. I did some research on old tubetech vibrato units from the 1950s/60s, and such as the tube vibrato unit in wurlitzer electrostatic reed organs Those devices could make "fairly strong" true pitch vibrato by allpassmodulating the phase a mere +/ 45 degrees.
So a LinkwitzRiley based multiband dynamics processor at least in theory ought to be capable of rather extreme transient pitch shifts if the processor is pumping heavily. The transient pitch shifts ought to be "most obvious" in maybe an octave or two in vicinity of the crossover frequency for a firstorder crossover.
Higherorder crossover transient pitch shifts might be be "most obvious" over narrower frequency ranges. OTOH higherorder crossovers would have moreextreme phase modulation over this narrower frequency range, so perhaps transient pitch shifts could sound "worse" if the processor is pumping hard, even if a smaller frequency range is strongly pitch shifted? Or maybe steeper slopes would help hide transient pitch shifts?
Dunno how audible such pitch artifacts might be. Perhaps lessaudible with modest fairly slow gain changes and moreaudible with heavy or faster gain changes? Perhaps less audible on nonpitched drums or mono instruments, bass, vocal, sax? Perhaps more audible on stronglypitched poly instruments such as acoustic piano?
In some cases perhaps the assymetrical cutoff slopes could be desirable, dunno.
I like MyStran's idea about higher order filters "Apply lowpass to the Input; Apply allpass to the Input; Derive hipass by subtracting lowpass output from allpass output."
Have not tested, but that "seems like" it ought to work nicely. Captain Obvious says that for a secondorder lowpass, use a firstorder allpass, and for a fourthorder lowpass, use a secondorder allpass.
Been busy with some woodworking and carpentry, but began wondering whether a "flatsumming" multiband crossover (containing phase shifts which "line up with each other" such as LinkwitzRiley) would be really much of a benefit for instance multiband dynamics processing. Would like to test more closely sometime.
It ought to be fine for speaker crossover or other applications where the mix level of the different bands stays fixed during the processing run. But applications which "quickly" change the mix levels of the bands during playback
For instance a simple 2 band crossover which mixes flat Firstorder crossover or higherorder LinkwitzRiley For a firstorder crossover, if at some moment the highoutput gets heavily compressed then the mixed output phase at the crossover frequency would approach 45 degrees. But at some other moment if the lowoutput gets heavily compressed then the mixed output phase would approach +45 degrees.
With a secondorder LR, it would be the same except phase could be dynamically modulated up to +/ 90 degrees. With fourthorder LR, the mixed output could be dynamically modulated up to +/ 180 degrees.
This dynamic phase shifting ought to be most obvious in the vicinity of the crossover frequencies. I did some research on old tubetech vibrato units from the 1950s/60s, and such as the tube vibrato unit in wurlitzer electrostatic reed organs Those devices could make "fairly strong" true pitch vibrato by allpassmodulating the phase a mere +/ 45 degrees.
So a LinkwitzRiley based multiband dynamics processor at least in theory ought to be capable of rather extreme transient pitch shifts if the processor is pumping heavily. The transient pitch shifts ought to be "most obvious" in maybe an octave or two in vicinity of the crossover frequency for a firstorder crossover.
Higherorder crossover transient pitch shifts might be be "most obvious" over narrower frequency ranges. OTOH higherorder crossovers would have moreextreme phase modulation over this narrower frequency range, so perhaps transient pitch shifts could sound "worse" if the processor is pumping hard, even if a smaller frequency range is strongly pitch shifted? Or maybe steeper slopes would help hide transient pitch shifts?
Dunno how audible such pitch artifacts might be. Perhaps lessaudible with modest fairly slow gain changes and moreaudible with heavy or faster gain changes? Perhaps less audible on nonpitched drums or mono instruments, bass, vocal, sax? Perhaps more audible on stronglypitched poly instruments such as acoustic piano?