DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
Filters.h File Reference

Multi-mode cascaded biquad filter engine with real-time parameter smoothing. More...

#include "../Core/AudioBuffer.h"
#include "../Core/AudioSpec.h"
#include "../Core/Biquad.h"
#include "../Core/DspMath.h"
#include "../Core/Smoothers.h"
#include "../Core/AnalogRandom.h"
#include "../Core/DenormalGuard.h"
#include "../Core/StateBlob.h"
#include <algorithm>
#include <array>
#include <atomic>
#include <cmath>
#include <cstdint>
#include <vector>
Include dependency graph for Filters.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  dspark::FilterEngine< T, MaxChannels >
 Professional multi-mode filter with cascaded biquad stages. More...
 
struct  dspark::FilterEngine< T, MaxChannels >::CascadeInfo
 Per-stage Butterworth cascade layout for an LP/HP slope (for analysis). More...
 
struct  dspark::FilterEngine< T, MaxChannels >::ButterworthCascade
 

Namespaces

namespace  dspark
 Main namespace for the DSPark framework.
 

Detailed Description

Multi-mode cascaded biquad filter engine with real-time parameter smoothing.

Supports all standard filter shapes (LP, HP, BP, Peak, Shelves, Notch, Tilt, AllPass) with configurable slopes from 6 to 48 dB/oct via cascaded biquad stages. Parameters are smoothed per-sample to prevent zipper noise.

Warning
Biquad filters are not suited for audio-rate cutoff modulation. Nonlinearity and analog drift update the coefficients at chunk rate (every 16 samples) to maintain CPU stability and prevent severe phase distortion.

Dependencies: Core/AudioBuffer.h, Core/AudioSpec.h, Core/Biquad.h, Core/DspMath.h, Core/Smoothers.h, Core/AnalogRandom.h, Core/DenormalGuard.h, Core/StateBlob.h.

Threading: prepare(), enableAnalogDrift() and setState() belong to the setup thread; processBlock()/processSample()/reset() to the audio thread. The remaining parameter setters are safe from any thread (relaxed atomics read once per block); non-finite setter values are ignored. The shape helpers (setLowPass()/setShape()/...) write several atomics non-atomically as a group: the audio thread may see the new topology with the previous targets for one block (smoothed, click-free).

filter.prepare(spec);
filter.setLowPass(2000.0f, 0.707f, 24); // 2kHz, Butterworth Q, 24dB/oct
filter.processBlock(buffer);
// Real-time parameter changes from UI thread (thread-safe):
filter.setFrequency(4000.0f);
Professional multi-mode filter with cascaded biquad stages.
Definition Filters.h:72
void setLowPass(float freq, float Q=0.707f, int slopeDb=12)
Configures a low-pass filter.
Definition Filters.h:130
void processBlock(AudioBufferView< T > buffer) noexcept
Processes an entire block of audio data. Internally branches into static, smoothed,...
Definition Filters.h:424
void setFrequency(float freq) noexcept
Sets the target cutoff/center frequency. Thread-safe.
Definition Filters.h:347
void prepare(const AudioSpec &spec)
Initializes the filter engine with the current audio specification.
Definition Filters.h:93

Definition in file Filters.h.