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

Real-time safe dry/wet mixer with parameter smoothing and mix laws. More...

#include "AudioBuffer.h"
#include "AudioSpec.h"
#include <algorithm>
#include <atomic>
#include <cmath>
Include dependency graph for DryWetMixer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  dspark::DryWetMixer< T, MaxChannels >
 Pre-allocated, SIMD-friendly dry/wet blender for real-time audio. More...
 

Namespaces

namespace  dspark
 Main namespace for the DSPark framework.
 

Detailed Description

Real-time safe dry/wet mixer with parameter smoothing and mix laws.

Captures a copy of the dry (unprocessed) signal before an effect runs, then blends it with the wet (processed) signal. Includes block-level parameter smoothing to prevent zipper noise during DAW automation, and supports both Linear and Equal Power mixing laws.

Note
If your effect introduces algorithmic latency (e.g., FIR filters), ensure the dry signal is delayed (Latency Compensation) before calling pushDry() to prevent phase cancellation (comb filtering).

Threading: pushDry() / mixWet() belong to the processing thread. setMixRule() is atomic and callable from any thread. prepare() and setLatencyCompensation() allocate and belong to the setup thread.

Dependencies: AudioBuffer.h, AudioSpec.h, C++20 standard library (<algorithm>, <atomic>, <cmath>).

void prepare(const dspark::AudioSpec& spec) {
mixer.prepare(spec);
}
void process(dspark::AudioBufferView<float> buffer) {
mixer.pushDry(buffer);
applyEffect(buffer); // Modifies buffer in-place (now wet)
mixer.mixWet(buffer, 0.5f); // Smoothly transitions to 50% wet
}
Non-owning view over audio channel data.
Definition AudioBuffer.h:50
Pre-allocated, SIMD-friendly dry/wet blender for real-time audio.
Definition DryWetMixer.h:72
void mixWet(AudioBufferView< T > wetBuffer, T targetMix) noexcept
Blends the stored dry signal with the current (wet) buffer in-place.
void pushDry(const AudioBufferView< const T > &input) noexcept
Captures a snapshot of the dry (unprocessed) signal.
void setMixRule(MixRule rule) noexcept
Sets the mathematical curve to use during the mix phase.
void prepare(const AudioSpec &spec)
Allocates the internal dry buffer for the given audio spec.
Describes the audio environment for a DSP processor.
Definition AudioSpec.h:35

Definition in file DryWetMixer.h.