|
| | WaveshapeTable () |
| | Constructor. Initializes a safe passthrough table to prevent RT crashes.
|
| |
| void | buildFromFunction (std::function< T(T)> func, int tableSize=4096, T xMax=T(8)) |
| | Builds the lookup table from an arbitrary transfer function.
|
| |
| void | buildTanh (int tableSize=4096) |
| | Builds a normalized tanh (soft clip) table.
|
| |
| void | buildHardClip (T threshold=T(0.8), int tableSize=4096) |
| | Builds a hard-clip table.
|
| |
| void | buildSoftClip (int tableSize=4096) |
| | Builds a cubic soft-clip table.
|
| |
| void | buildAsymmetric (int tableSize=4096) |
| | Builds an asymmetric clipping table for even-harmonic generation.
|
| |
| T | process (T input, T preGain=T(1), T postGain=T(1)) const noexcept |
| | Processes a single sample through the waveshaper with Hermite interpolation.
|
| |
| void | process (T *__restrict data, int numSamples, T preGain=T(1), T postGain=T(1)) const noexcept |
| | Processes a buffer in-place.
|
| |
| void | prepare (const AudioSpec &spec) |
| | Prepares the waveshaper for oversampled block processing.
|
| |
| void | setOversampling (int factor) |
| | Enables oversampling.
|
| |
| int | getOversamplingFactor () const noexcept |
| |
| void | processBlock (AudioBufferView< T > buffer, T preGain=T(1), T postGain=T(1)) noexcept |
| | Processes a buffer view with optional oversampling.
|
| |
| void | setAntialiasing (bool enabled) noexcept |
| | Enables first-order antiderivative anti-aliasing (ADAA) in processBlock().
|
| |
| bool | isAntialiasingEnabled () const noexcept |
| | True when processBlock() applies ADAA.
|
| |
| void | reset () noexcept |
| |
| int | getTableSize () const noexcept |
| |
| bool | isReady () const noexcept |
| |
| T | getInputRange () const noexcept |
| | Returns the half-range of the table's input domain.
|
| |
| int | getLatency () const noexcept |
| | Reports the processing latency in samples.
|
| |
template<FloatType T>
class dspark::WaveshapeTable< T >
Zero-latency lookup-table waveshaper with RT-safe gain modulation.
- Template Parameters
-
| T | Sample type (float or double). |
Definition at line 64 of file WaveshapeTable.h.
template<FloatType T>
| void dspark::WaveshapeTable< T >::buildFromFunction |
( |
std::function< T(T)> |
func, |
|
|
int |
tableSize = 4096, |
|
|
T |
xMax = T(8) |
|
) |
| |
|
inline |
Builds the lookup table from an arbitrary transfer function.
- Warning
- Allocates memory. Do not call from the audio thread.
The table spans the input range [-xMax, +xMax]. A range wider than the nominal [-1, 1] is what makes preGain work as a true drive control: driven samples keep following the curve instead of slamming into a hard plateau at the table edge.
- Parameters
-
| func | Transfer function mapping [-xMax, xMax] to output. |
| tableSize | Number of active table entries (default: 4096). |
| xMax | Half-range of the table input domain (default: 8). |
Definition at line 89 of file WaveshapeTable.h.
Enables first-order antiderivative anti-aliasing (ADAA) in processBlock().
Each output is the mean of the curve over the segment between two consecutive (driven) inputs, (F(x[n]) - F(x[n-1])) / (x[n] - x[n-1]), which suppresses the harmonics that would fold back. It shifts the signal by half a sample at the processing rate (not reported by getLatency()) and, like any first-order ADAA, averages adjacent samples: at 1x that rolls off the top octave (-11.7 dB at 20 kHz @ 48 kHz), so combine it with setOversampling(2) or more (-2.0 dB at 2x, -0.5 dB at 4x). The first 16 channels are anti-aliased; further channels run the plain memoryless curve. The per-sample process() overloads stay memoryless. Owner-managed like the other setters: call it from the processing thread or while no process call is running. Enabling starts each channel from its next input (no stale history, no click).
Definition at line 313 of file WaveshapeTable.h.