|
| | Dither (int targetBits=16, bool noiseShaping=false) noexcept |
| | Constructs a dithering processor.
|
| |
| void | setTargetBitDepth (int bits) noexcept |
| | Sets the target bit depth and recalculates scaling factors.
|
| |
| void | setNoiseShaping (bool enabled) noexcept |
| | Enables or disables 1st-order noise shaping.
|
| |
| void | reset () noexcept |
| | Resets the noise shaping state. Call this when playback stops or flushes.
|
| |
| T | processSample (T input, int channel=0) noexcept |
| | Applies TPDF dither and quantises a single sample.
|
| |
| void | processBlock (T *data, int numSamples, int channel=0) noexcept |
| | Applies dithering to an entire audio buffer in-place.
|
| |
| int | getTargetBitDepth () const noexcept |
| |
| T | getQuantisationStep () const noexcept |
| |
template<typename T>
class dspark::Dither< T >
TPDF dithering processor with optional 1st-order noise shaping.
Adds Triangular Probability Density Function (TPDF) noise of 2 LSB peak-to-peak before quantisation. This replaces correlated quantisation distortion (truncation harmonics, noise modulation) with a constant, signal-independent noise floor.
The optional noise shaper feeds back the total requantisation error (dither + quantiser) through a one-sample delay, first-order highpass shaping the entire noise floor: about 15 dB less noise at 1 kHz (44.1 kHz rate) in exchange for a gentle rise towards Nyquist where hearing is least sensitive.
Quantised output lies exactly on the integer level grid of the target depth: levels in [-2^(bits-1), 2^(bits-1) - 1], so positive full scale is one step below 1.0, exactly like the int16/int24 file writers. Feeding the output to WavFile round-trips bit-exactly.
Threading is owner-managed: call setters and processing from the thread that owns the stream (the PRNG and error state are plain members by design). Use one instance per processing thread.
- Template Parameters
-
| T | Sample type (float or double). |
Definition at line 55 of file Dither.h.