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

Downward expander with configurable ratio, hysteresis, and sidechain. More...

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

Go to the source code of this file.

Classes

class  dspark::Expander< T >
 Downward expander with ratio control, hysteresis, and sidechain. More...
 

Namespaces

namespace  dspark
 Main namespace for the DSPark framework.
 

Detailed Description

Downward expander with configurable ratio, hysteresis, and sidechain.

A generalization of the noise gate: instead of fully closing (infinite ratio), the expander applies a configurable ratio below the threshold. Includes an integrated envelope detector to prevent low-frequency intermodulation distortion, a true-stereo sidechain high-pass filter, and an external sidechain input (processBlock(audio, sidechain) keys the detector from the sidechain signal; a sidechain shorter than the audio block falls back to the internal key so the caller's buffer is never over-read).

Threading model:

  • prepare() / reset() / getState() / setState(): setup or UI threads only, never concurrently with processBlock().
  • All parameter setters are RT-safe atomic publications from any thread; the audio thread picks them up at the next block.
  • getGateState() / getCurrentGainDb() are approximate cross-thread metering reads (unsynchronized).
  • processBlock() before prepare() is a pass-through (it used to hard-mute: the smoothing coefficients were still zero, freezing the gain at 0).

Channels beyond the 16-channel detector cap still receive the (scalar) expander gain; only the per-channel sidechain HPF state is capped.

Dependencies: DspMath.h, AudioSpec.h, AudioBuffer.h, DenormalGuard.h, StateBlob.h.

Definition in file Expander.h.