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

Brickwall lookahead limiter with optional ISP (true-peak) detection and adaptive release for mastering. More...

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

Go to the source code of this file.

Classes

class  dspark::Limiter< T >
 High-performance brickwall lookahead limiter. More...
 

Namespaces

namespace  dspark
 Main namespace for the DSPark framework.
 

Detailed Description

Brickwall lookahead limiter with optional ISP (true-peak) detection and adaptive release for mastering.

A peak limiter that prevents audio from exceeding a configurable ceiling. It uses a lookahead delay line with a peak hold over the lookahead window and a smoothed attack envelope, so transients are turned down transparently instead of being clipped. Optional ISP (Inter-Sample Peak) detection feeds the sidechain with the ITU-R BS.1770 4x oversampled true-peak estimate, which greatly reduces inter-sample overs. The exact brickwall guarantee is in the sample domain (a final clamp at the ceiling); true-peak levels after that clamp are reduced but not mathematically bounded.

Note
This class is strictly real-time safe. It performs zero allocations in the audio thread. The maximum lookahead time dictates the memory allocated during prepare().

Features:

  • Brickwall limiting (sample peaks never exceed the ceiling)
  • ISP true-peak detection (4x oversampled FIR sidechain)
  • Lookahead peak hold + smoothed attack curve (artifact-free transients)
  • CPU-optimized adaptive release (avoids std::exp in hot paths)
  • Real-time safe parameter updates (lock-free atomics)

Threading: prepare() belongs to the setup thread (allocates; never call it concurrently with processing). processBlock(), processSample() and reset() belong to the audio thread. All setters are lock-free atomic publications, safe from any thread; changes are consumed at the next block (or the next channel-0 sample). Non-finite setter arguments are ignored. getLatency() derives from the published lookahead parameter, so a host reads the correct value immediately after setLookahead(). getGainReductionDb() is metering: an unsynchronized cross-thread read of the live envelope (approximate).

Dependencies: DspMath.h, AudioSpec.h, AudioBuffer.h, RingBuffer.h, SmoothedValue.h, DenormalGuard.h, TruePeakDetector.h, StateBlob.h.

Definition in file Limiter.h.