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

Convolution reverb with one-line IR loading and progressive API. More...

#include "../Core/Convolver.h"
#include "../Core/DryWetMixer.h"
#include "../Core/RingBuffer.h"
#include "../Core/AudioSpec.h"
#include "../Core/AudioBuffer.h"
#include "../Core/DspMath.h"
#include "../Core/Resampler.h"
#include "../Core/StateBlob.h"
#include "../IO/WavFile.h"
#include <algorithm>
#include <atomic>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <vector>
Include dependency graph for Reverb.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  dspark::Reverb< T >
 Convolution reverb with IR loading, dry/wet, and pre-delay. More...
 
struct  dspark::Reverb< T >::ConvolverBank
 

Namespaces

namespace  dspark
 Main namespace for the DSPark framework.
 

Detailed Description

Convolution reverb with one-line IR loading and progressive API.

Wraps the Convolver engine into a complete reverb effect with dry/wet mix, pre-delay, and automatic IR management. Supports loading impulse responses from WAV files or from raw sample data. The dry path is delay-compensated against the convolution engine's latency, so dry and wet stay sample-aligned at any mix setting (getLatency() reports the shared latency to the host).

IR shaping (setDecayScale / setStretch) reshapes the loaded impulse response without touching the stored original, so the controls are always relative to the file as loaded:

  • Decay scale multiplies the IR's own T60 (estimated from its Schroeder decay curve). Values below 1 also trim the now-silent tail, which directly reduces convolution CPU cost.
  • Stretch resamples the IR (tape-speed style): above 1 the space gets larger and darker, below 1 smaller and brighter.

Three levels of API complexity:

  • Level 1 (simple): reverb.loadIR("hall.wav"); reverb.setMix(0.3f);
  • Level 2 (intermediate): Pre-delay, IR decay scale / stretch.
  • Level 3 (expert): Direct access to Convolver and DryWetMixer internals.

Threading: prepare() belongs to the setup thread (allocates; never call it concurrently with processing). processBlock() and reset() belong to the audio thread. loadIR(), setDecayScale(), setStretch() and setState() rebuild the convolver bank (they allocate) on the calling GUI/setup thread and publish it atomically: safe while audio runs, one writer at a time. setMix()/setPreDelay() are lock-free atomic publications, safe from any thread. Non-finite setter arguments are ignored. Loading an IR changes getLatency(): hosts must be notified.

File loading (loadIR from a path) is excluded when DSPARK_NO_FILE_IO is defined; the raw-data overload keeps working on embedded targets.

Dependencies: Convolver.h, DryWetMixer.h, RingBuffer.h, AudioSpec.h, AudioBuffer.h, DspMath.h, Resampler.h, StateBlob.h, WavFile.h (only without DSPARK_NO_FILE_IO).

reverb.prepare(spec);
reverb.loadIR("hall.wav"); // One line, done
reverb.setMix(0.3f); // 30% wet
reverb.processBlock(buffer);
// With pre-delay:
reverb.setPreDelay(20.0f); // 20 ms
Convolution reverb with IR loading, dry/wet, and pre-delay.
Definition Reverb.h:93
void processBlock(AudioBufferView< T > buffer) noexcept
Processes audio through the reverb.
Definition Reverb.h:161
bool loadIR(const char *wavFilePath)
Loads an impulse response from a WAV file.
Definition Reverb.h:233
void prepare(const AudioSpec &spec)
Prepares the reverb for processing.
Definition Reverb.h:110
void setMix(T dryWet) noexcept
Sets the dry/wet mix.
Definition Reverb.h:279
void setPreDelay(T ms) noexcept
Sets the pre-delay time in milliseconds.
Definition Reverb.h:323

Definition in file Reverb.h.