|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
Pre-allocated, SIMD-friendly dry/wet blender for real-time audio. More...
#include <DryWetMixer.h>
Public Types | |
| enum class | MixRule { Linear , EqualPower } |
| Defines the mathematical curve used for mixing. More... | |
Public Member Functions | |
| DryWetMixer () noexcept=default | |
| DryWetMixer (DryWetMixer &&other) noexcept | |
| DryWetMixer & | operator= (DryWetMixer &&other) noexcept |
| DryWetMixer (const DryWetMixer &)=delete | |
| DryWetMixer & | operator= (const DryWetMixer &)=delete |
| void | prepare (const AudioSpec &spec) |
| Allocates the internal dry buffer for the given audio spec. | |
| void | reset () noexcept |
| Resets the internal buffer and smoothing states to zero. | |
| void | setMixRule (MixRule rule) noexcept |
| Sets the mathematical curve to use during the mix phase. | |
| void | setLatencyCompensation (int samples) |
| Delays the captured dry signal to compensate for an effect's internal latency (e.g. an oversampler's FIR group delay). | |
| int | getLatencyCompensation () const noexcept |
| Returns the configured dry-path latency compensation in samples. | |
| void | pushDry (const AudioBufferView< const T > &input) noexcept |
| Captures a snapshot of the dry (unprocessed) signal. | |
| void | mixWet (AudioBufferView< T > wetBuffer, T targetMix) noexcept |
| Blends the stored dry signal with the current (wet) buffer in-place. | |
| const T * | getDryChannel (int ch) const noexcept |
| Retrieves a read-only pointer to the captured dry channel data. | |
| int | getDryNumChannels () const noexcept |
| Returns the internal capacity of channels in the dry buffer. | |
| int | getDryCapturedSamples () const noexcept |
| Returns the number of samples valid from the last pushDry() call. | |
Pre-allocated, SIMD-friendly dry/wet blender for real-time audio.
| T | Sample type (float or double). |
| MaxChannels | Maximum number of channels (compile-time bound). |
Definition at line 71 of file DryWetMixer.h.
|
strong |
Defines the mathematical curve used for mixing.
| Enumerator | |
|---|---|
| Linear | Linear crossfade. Best for highly correlated signals (EQ, saturation). |
| EqualPower | Constant power crossfade. Best for uncorrelated signals (Reverb, Delay). |
Definition at line 75 of file DryWetMixer.h.
|
defaultnoexcept |
|
inlinenoexcept |
Definition at line 88 of file DryWetMixer.h.
|
delete |
|
inlinenoexcept |
Returns the number of samples valid from the last pushDry() call.
Definition at line 344 of file DryWetMixer.h.
|
inlinenoexcept |
Retrieves a read-only pointer to the captured dry channel data.
| ch | Channel index (0-based). |
Definition at line 334 of file DryWetMixer.h.
|
inlinenoexcept |
Returns the internal capacity of channels in the dry buffer.
Definition at line 341 of file DryWetMixer.h.
|
inlinenoexcept |
Returns the configured dry-path latency compensation in samples.
Definition at line 180 of file DryWetMixer.h.
|
inlinenoexcept |
Blends the stored dry signal with the current (wet) buffer in-place.
Automatically applies sample-accurate linear interpolation to the mix proportion to prevent zipper noise when the parameter changes.
Only the region covered by the last pushDry() snapshot is blended: without a captured snapshot (e.g. right after reset()) this is a no-op and the buffer stays fully wet. Channels beyond the prepared channel count also pass through untouched.
| wetBuffer | The processed buffer (modified in-place). |
| targetMix | Target mix amount: 0.0 = fully dry, 1.0 = fully wet. |
Definition at line 247 of file DryWetMixer.h.
|
delete |
|
inlinenoexcept |
Definition at line 98 of file DryWetMixer.h.
|
inline |
Allocates the internal dry buffer for the given audio spec.
| spec | Audio environment specification. |
Definition at line 119 of file DryWetMixer.h.
|
inlinenoexcept |
Captures a snapshot of the dry (unprocessed) signal.
Channels beyond the prepared channel count are ignored; a shorter input than the prepared block size shortens the valid snapshot (and therefore the region the next mixWet() call blends).
| input | The unprocessed audio buffer. Accepts const or mutable views implicitly (AudioBufferView converts T to const T). |
Definition at line 192 of file DryWetMixer.h.
|
inlinenoexcept |
Resets the internal buffer and smoothing states to zero.
Definition at line 136 of file DryWetMixer.h.
|
inline |
Delays the captured dry signal to compensate for an effect's internal latency (e.g. an oversampler's FIR group delay).
When the wet path introduces samples of delay, the dry copy must be delayed by the same amount; otherwise blending dry+wet (mix < 1, Delta or adaptive modes) produces comb filtering. Pass 0 to disable (default).
| samples | Latency in samples at this mixer's sample rate (>= 0). |
Definition at line 170 of file DryWetMixer.h.
|
inlinenoexcept |
Sets the mathematical curve to use during the mix phase.
Atomic: callable from any thread. mixWet() reads the rule once per block, so a change lands at the next block boundary.
| rule | The chosen MixRule (Linear or EqualPower). |
Definition at line 153 of file DryWetMixer.h.