#include <cmath>#include <cstddef>#include <cstdint>Go to the source code of this file.
Classes | |
| struct | pulp::signal::SnapChunk |
| One chunk of a block: samples [begin, end). More... | |
| class | pulp::signal::SnapChunks |
| The chunks of [0, num_samples), consecutive and at most kSnapChunkSamples long, as a range. More... | |
| class | pulp::signal::SnapChunks::iterator |
Namespaces | |
| namespace | pulp |
| namespace | pulp::signal |
Macros | |
| #define | PULP_DSP_ENABLE_SNAP_TO_ZERO 1 |
| Denormal-flushing utility. | |
Functions | |
| template<typename T> | |
| constexpr T | pulp::signal::snap_threshold () |
| Threshold in absolute value below which a sample is treated as zero. | |
| template<typename T> | |
| T | pulp::signal::snap_to_zero (T x) |
| Returns 0 if |x| < snap_threshold, else x. | |
| template<typename T> | |
| T | pulp::signal::snap_recursion_state (T x) |
| Snap a per-sample recursion's state: snap_to_zero() where subnormals are slow, the identity where kSubnormalsAreFree. | |
| template<typename T> | |
| void | pulp::signal::snap_to_zero (T *samples, int n) |
| Snap an entire buffer in place. | |
| constexpr SnapChunks | pulp::signal::snap_chunks (std::size_t num_samples) noexcept |
| template<typename T> | |
| bool | pulp::signal::is_denormal (T x) |
Return true if x is a denormal (subnormal) float. | |
Variables | |
| constexpr bool | pulp::signal::kSubnormalsAreFree |
| Whether subnormal arithmetic runs at full speed on this target. | |
| constexpr std::size_t | pulp::signal::kSnapChunkSamples = 64 |
| Samples a block path runs between denormal snaps of its recursive state. | |
| #define PULP_DSP_ENABLE_SNAP_TO_ZERO 1 |
Denormal-flushing utility.
Denormal floating-point values cause severe CPU stalls on x86 when they enter recursive paths like IIR filter state or reverb feedback. snap_to_zero returns 0 when the input is below a threshold whose magnitude is large enough to catch denormals (and very-quiet tails) but small enough not to be audible. The threshold is 1e-15 (~-300 dB FS for float; see snap_threshold() below) — the single source of truth for the magnitude quoted here.
Use at the end of each recursive state update in IIR / SVF / TPT / Ladder / Ballistics / Reverb feedback paths.
Build-time toggle: define PULP_DSP_ENABLE_SNAP_TO_ZERO=0 to compile out the check (the function becomes the identity). Default: ON.