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

Crossfade between two audio signals with selectable curve and artifact-free parameter smoothing. More...

#include "../Core/DspMath.h"
#include <algorithm>
#include <atomic>
#include <cassert>
#include <cmath>
Include dependency graph for Crossfade.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  dspark::Crossfade< T >
 Artifact-free, SIMD-friendly crossfader for two audio signals. More...
 

Namespaces

namespace  dspark
 Main namespace for the DSPark framework.
 

Detailed Description

Crossfade between two audio signals with selectable curve and artifact-free parameter smoothing.

Provides highly optimized crossfade curves for audio transitions. Designed for zero-allocation real-time contexts, featuring automatic block-level parameter smoothing to prevent zipper noise.

Curves:

  • Linear: Constant sum (A * (1-t) + B * t). Fast, but exhibits a -3 dB power dip at the centre for uncorrelated signals.
  • EqualPower: Constant energy (A^2 + B^2 = 1) via the hardware sqrt instruction. Perfect for uncorrelated audio.
  • SCurve: Smoothstep S-curve. Provides a perceptually smoother transition speed, though it shares the -3 dB centre power dip of the Linear curve.

Dependencies: Core/DspMath.h.

Threading: setCurve()/setPosition() are safe from any thread (atomics, consumed by the processing calls on the audio thread); non-finite positions are ignored. The processing calls and the gain getters belong to the audio thread (getters read unsynchronized audio-thread state: metering only).

Definition in file Crossfade.h.