|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
Linkwitz-Riley crossover with 2-12 bands, LR12/LR24/LR48. More...
#include <CrossoverFilter.h>
Public Types | |
| enum class | FilterMode { MinimumPhase , LinearPhase } |
| Filter processing mode. More... | |
Public Member Functions | |
| CrossoverFilter () | |
| void | prepare (const AudioSpec &spec) |
| Prepares the crossover for processing. | |
| int | processBlock (AudioBufferView< T > input, AudioBufferView< T > *bandOutputs, int numOutputBands) noexcept |
| Splits input into separate band outputs. | |
| void | setNumBands (int n) noexcept |
| Sets the number of output bands (2..MaxBands). | |
| void | setCrossoverFrequency (int index, T freqHz) noexcept |
| Sets a crossover frequency. Automatically maintains sorting. | |
| void | setOrder (int order) noexcept |
| Sets the crossover slope: 12, 24 or 48 (dB/oct). Other values are ignored. | |
| void | setFilterMode (FilterMode mode) noexcept |
| Sets the processing mode. A live switch resets filter state (transient). | |
| int | getNumBands () const noexcept |
| int | getOrder () const noexcept |
| FilterMode | getFilterMode () const noexcept |
| T | getCrossoverFrequency (int index) const noexcept |
Returns the target frequency of split point index. | |
| int | getLatency () const noexcept |
| Returns latency in samples (0 for IIR, FIR group delay for linear-phase). | |
| void | reset () noexcept |
| std::vector< uint8_t > | getState () const |
| Serializes the split topology (setup/UI threads; allocates). | |
| bool | setState (const uint8_t *data, size_t size) |
| Restores the split topology from a blob. | |
Linkwitz-Riley crossover with 2-12 bands, LR12/LR24/LR48.
| T | Sample type (float or double). |
| MaxBands | Maximum number of output bands (compile-time, default 12). |
Definition at line 76 of file CrossoverFilter.h.
|
strong |
Filter processing mode.
| Enumerator | |
|---|---|
| MinimumPhase | IIR biquads with allpass phase correction (zero latency). |
| LinearPhase | FFT-based FIR crossover (introduces latency, zero phase distortion, introduces pre-ringing). |
Definition at line 80 of file CrossoverFilter.h.
|
inline |
Definition at line 86 of file CrossoverFilter.h.
|
inlinenoexcept |
Returns the target frequency of split point index.
Definition at line 355 of file CrossoverFilter.h.
|
inlinenoexcept |
Definition at line 352 of file CrossoverFilter.h.
|
inlinenoexcept |
Returns latency in samples (0 for IIR, FIR group delay for linear-phase).
Reports the linear-phase latency only when the engine actually exists (see prepare()); if linear-phase mode fell back to IIR, this returns 0.
Definition at line 367 of file CrossoverFilter.h.
|
inlinenoexcept |
Definition at line 350 of file CrossoverFilter.h.
|
inlinenoexcept |
Definition at line 351 of file CrossoverFilter.h.
|
inline |
Serializes the split topology (setup/UI threads; allocates).
Definition at line 388 of file CrossoverFilter.h.
|
inline |
Prepares the crossover for processing.
Configured split frequencies, band count, order and mode are preserved across prepare() calls (configure-then-prepare is fully supported). The linear-phase engine is always allocated (so a later mode switch works) unless maxBlockSize exceeds 2^18, in which case linear-phase mode falls back to the IIR path and getLatency() reports 0.
| spec | Audio environment (sample rate, block size, channels). Invalid specs are ignored (previous state is kept). |
Definition at line 105 of file CrossoverFilter.h.
|
inlinenoexcept |
Splits input into separate band outputs.
The processed span is clamped to the prepared maxBlockSize and to the shortest output view. Input channels beyond the prepared/16-channel limit are passed through on band 0 (remaining bands silent) so the band sum still reconstructs the input.
| input | Input audio buffer. |
| bandOutputs | Array of AudioBufferView, one per band. |
| numOutputBands | Number of output bands (must match getNumBands(); fewer bands re-purpose the first splits only in IIR mode and is not a supported configuration). |
Definition at line 205 of file CrossoverFilter.h.
|
inlinenoexcept |
Definition at line 373 of file CrossoverFilter.h.
|
inlinenoexcept |
Sets a crossover frequency. Automatically maintains sorting.
Non-finite frequencies are ignored; values are floored to 1 Hz here and clamped to [20, 0.499 * sampleRate] at design time.
Definition at line 286 of file CrossoverFilter.h.
|
inlinenoexcept |
Sets the processing mode. A live switch resets filter state (transient).
Definition at line 340 of file CrossoverFilter.h.
|
inlinenoexcept |
Sets the number of output bands (2..MaxBands).
Definition at line 272 of file CrossoverFilter.h.
|
inlinenoexcept |
Sets the crossover slope: 12, 24 or 48 (dB/oct). Other values are ignored.
Definition at line 329 of file CrossoverFilter.h.
|
inline |
Restores the split topology from a blob.
Definition at line 405 of file CrossoverFilter.h.