|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
Block-adaptive automatic gain compensation with SIMD-friendly linear interpolation. More...
#include <AutoGain.h>
Public Member Functions | |
| void | prepare (const AudioSpec &spec) noexcept |
| Prepares the auto-gain processor. | |
| void | pushReference (AudioBufferView< T > buffer) noexcept |
| Snapshots the input level. Must be called BEFORE processing. | |
| void | compensate (AudioBufferView< T > buffer) noexcept |
| Measures output level and applies smoothed gain compensation. Must be called AFTER processing. | |
| void | reset () noexcept |
| Hard resets the internal state to avoid feedback loops or stale measurements. | |
| T | getCompensationDb () const noexcept |
| Returns the current internal compensation in dB. Useful for UI metering. | |
| void | setMaxCompensation (T dB) noexcept |
| Thread-safe assignment of the maximum allowed compensation limit. | |
| void | setSmoothingTime (T ms) noexcept |
| Sets the smoothing time constant. | |
| T | getMaxCompensation () const noexcept |
| T | getSmoothingTime () const noexcept |
| std::vector< uint8_t > | getState () const |
| Serializes the parameter state (setup/UI threads; allocates). | |
| bool | setState (const uint8_t *data, size_t size) |
| Restores parameters from a blob (tolerant; rejects foreign ids). | |
Block-adaptive automatic gain compensation with SIMD-friendly linear interpolation.
Levels are measured across the channels passed to prepare(); channels beyond those are neither measured nor compensated (pass-through), and both calls are no-ops before prepare().
Note on silence: when BOTH the reference and the output are below -90 dB the compensation target is held at 0 dB (nothing meaningful to match). If only the reference is silent while the effect produces output (e.g. a reverb tail), the match pulls the output down, bounded by the max compensation clamp.
| T | Sample type (float or double). Must be lock-free atomic compatible if modified concurrently. |
Definition at line 63 of file AutoGain.h.
|
inlinenoexcept |
Measures output level and applies smoothed gain compensation. Must be called AFTER processing.
| buffer | Processed audio (modified in-place). |
Definition at line 108 of file AutoGain.h.
|
inlinenoexcept |
Returns the current internal compensation in dB. Useful for UI metering.
Definition at line 170 of file AutoGain.h.
|
inlinenoexcept |
Definition at line 197 of file AutoGain.h.
|
inlinenoexcept |
Definition at line 203 of file AutoGain.h.
|
inline |
Serializes the parameter state (setup/UI threads; allocates).
Definition at line 209 of file AutoGain.h.
|
inlinenoexcept |
Prepares the auto-gain processor.
An invalid spec (non-positive or non-finite fields) is a no-op that keeps the previous state.
| spec | Audio environment specification containing sample rate and channels. |
Definition at line 78 of file AutoGain.h.
|
inlinenoexcept |
Snapshots the input level. Must be called BEFORE processing.
An empty view (or one with no prepared channels) keeps the previous reference instead of degrading it.
| buffer | Input audio (read-only measurement). |
Definition at line 95 of file AutoGain.h.
|
inlinenoexcept |
Hard resets the internal state to avoid feedback loops or stale measurements.
Definition at line 160 of file AutoGain.h.
|
inlinenoexcept |
Thread-safe assignment of the maximum allowed compensation limit.
| dB | Max gain change in decibels (absolute value used symmetrically). Non-finite values are ignored (a NaN would silently disable the clamp). |
Definition at line 177 of file AutoGain.h.
|
inlinenoexcept |
Sets the smoothing time constant.
| ms | Smoothing time in milliseconds, floored at 1 ms. Non-finite values are ignored (a NaN would poison the compensation state permanently). |
Definition at line 189 of file AutoGain.h.
|
inline |
Restores parameters from a blob (tolerant; rejects foreign ids).
Definition at line 220 of file AutoGain.h.