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

Automatic gain compensation for honest A/B comparison. More...

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

Go to the source code of this file.

Classes

class  dspark::AutoGain< T >
 Block-adaptive automatic gain compensation with SIMD-friendly linear interpolation. More...
 

Namespaces

namespace  dspark
 Main namespace for the DSPark framework.
 

Detailed Description

Automatic gain compensation for honest A/B comparison.

Measures the input level before processing and adjusts the output level after processing to match. This eliminates the loudness bias that makes louder signals sound "better", enabling honest A/B testing.

Usage pattern (sandwich):

autoGain.pushReference(buffer); // measure input level
myEffect.processBlock(buffer); // apply your processing
autoGain.compensate(buffer); // adjust output to match input level

Threading: prepare() belongs to the setup thread; pushReference(), compensate() and reset() belong to the audio thread. Setters are lock-free atomic publications, safe from any thread, consumed at the next compensate(). Non-finite setter arguments are ignored. getCompensationDb() may be read from any thread for metering (approximate: the value is written unsynchronised by the audio thread).

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

Definition in file AutoGain.h.