Search guides and the APICtrl K
  1. API reference
  2. DSP

crossover.h

A crossover into any number of bands that still sums flat.

#include <sonore/crossover.h>
On this page

Design notes

effects.h's LinkwitzRiley splits two ways and its two halves sum to an allpass, which is the whole reason to use it. Stack two of them to get three bands and the property is GONE: the low band went through one crossover's phase shift, the top band through two, and where they meet they no longer add up -- a multiband compressor built that way has a dip at every crossover with the compression turned off.

The fix is the standard one: every band that was split off EARLY passes through the allpass equivalent of every crossover that came AFTER it, so all the bands arrive with the same phase. An LR4's low plus high is exactly a second-order allpass at Q = 1/sqrt(2) -- (s^2 - sqrt2 s + 1) over (s^2 + sqrt2 s + 1), and the bilinear transform keeps the identity because every section shares one prewarp -- so each compensation is ONE biquad, where it used to be the crossover run again (four) and summed: (Bands-1)(Bands-2)/2 of them, three for four bands. The unit test sums the bands and asks for +/-0.15 dB from 20 Hz to 20 kHz, and checks the allpass against the crossover-and-sum it replaced, sample for sample.

Included by dsp.h.

Types 1

template <int Bands = 3> class MultibandSplitter

A Linkwitz-Riley crossover into Bands bands (2 to 8) that sum flat: every band split off early passes through an allpass for each later crossover, so all of them arrive in phase (see the file comment).

One channel, per sample: two of these for stereo. Call setSampleRate() in prepare(). The crossovers start log-spaced between 100 Hz and 8 kHz; setCrossover(k, hz) takes index 0 as the lowest split and clamps to 20 Hz up to 0.45 of the rate, but does not sort, so keep the frequencies ascending. Setters and process() run on the audio thread, and a crossover may move while audio runs: the sections are state-variable, as LinkwitzRiley's are.

↑↓ to move↵ to openEvery public name in the headers, and every guide