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

Table-based waveshaping with Hermite interpolation for high-end audio. More...

#include "DspMath.h"
#include "AudioSpec.h"
#include "AudioBuffer.h"
#include "Oversampling.h"
#include "Interpolation.h"
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <memory>
#include <vector>
Include dependency graph for WaveshapeTable.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  dspark::WaveshapeTable< T >
 Zero-latency lookup-table waveshaper with RT-safe gain modulation. More...
 

Namespaces

namespace  dspark
 Main namespace for the DSPark framework.
 

Detailed Description

Table-based waveshaping with Hermite interpolation for high-end audio.

Stores a non-linear transfer function as a lookup table and applies it to audio signals using 3rd-order Hermite interpolation. This minimizes table-induced distortion and quantization noise compared to standard linear interpolation.

Note
Aliasing (honest scope). This is a MEMORYLESS nonlinearity: the curve creates harmonics above Nyquist that fold back as aliasing exactly like any waveshaper. The Hermite interpolation only reduces the error of reading BETWEEN table entries (table-interpolation/quantization noise) - it does NOT and cannot reduce harmonic aliasing, and this class carries no ADAA (antiderivative anti-aliasing) term. To suppress aliasing, enable the built in oversampling (setOversampling, RF-009/ADR-011: factor 1 = off, 2/4/8/16; getLatency() reports the group delay it adds, 0 when off) or oversample the surrounding chain. A finer table lowers interpolation noise but leaves the alias floor unchanged.
Thread Safety & Real-Time Constraints: The build...() and setOversampling() methods allocate memory. They MUST ONLY be called from the main thread (UI) or during the prepare() phase, and never while the audio thread is inside a process call (rebuilding the table concurrently with processing is a data race). For real-time automation of distortion amount, use the preGain parameter in the process() functions instead of rebuilding the table.

Dependencies: DspMath.h, AudioSpec.h, AudioBuffer.h, Oversampling.h, Interpolation.h.

Definition in file WaveshapeTable.h.