|
| void | prepare (double sampleRate) noexcept |
| | Prepares the transformer. The FIR kernel is sample-rate independent; sampleRate is accepted for API symmetry.
|
| |
| Result | process (T input) noexcept |
| | Processes one sample, returning the analytic signal {real, imag}.
|
| |
| void | processBlock (std::span< const T > input, std::span< T > outReal, std::span< T > outImag) noexcept |
| | Processes a block of samples. Optimized for CPU cache.
|
| |
| void | reset () noexcept |
| | Resets the delay line. Mandatory when seeking or starting playback.
|
| |
template<FloatType T>
class dspark::Hilbert< T >
90-degree phase-differencing network (analytic-signal generator).
Implemented as a windowed-sinc FIR Hilbert transformer: the quadrature (imaginary) output is the input convolved with the ideal Hilbert kernel, windowed with a Blackman window; the in-phase (real) output is the input delayed by the FIR group delay (kCenter samples) so the two outputs stay sample-aligned and form a true analytic pair.
This FIR design is correct by construction. With the default 191-tap kernel at 48 kHz the measured analytic-signal magnitude ripple is < 0.1% above ~1 kHz and < 2.5% down to ~500 Hz (the kernel is rate-independent, so these corner frequencies scale with the sample rate). Like every Hilbert transformer it cannot produce exact quadrature at DC, and the odd-length antisymmetric (Type III) design also rolls off approaching Nyquist - both inherent, not defects (lengthen the kernel for more sub-500 Hz accuracy).
- Note
- Introduces a latency of getLatencySamples() = kCenter samples on BOTH outputs. The real branch is the delayed input, so callers that mix the "dry" path from
real stay phase-aligned with the shifted/wet path.
- Template Parameters
-
| T | Sample type (float or double). |
Definition at line 73 of file Hilbert.h.
Processes one sample, returning the analytic signal {real, imag}.
Half of the 191 kernel taps are exact zeros (the ideal Hilbert impulse vanishes at even offsets from the centre), so only the samples of the newest one's parity meet a non-zero tap. Each parity has its own mirrored (double-write) delay line, the same even/odd split the framework's half-band filters use: the 96 non-zero taps are one contiguous SIMD dot product. Measured per sample, SSE2: float 10.3 -> 6.6 ns, double 27.2 -> 10.2 ns; AVX2: double 15.6 -> 7.2 ns, float about the same (7.9 -> 8.2 ns). The result equals the full convolution up to the order of the floating-point sum (within 1e-7); the real branch is exactly x[n - 95].
- Parameters
-
| input | Real-valued input sample. |
Definition at line 114 of file Hilbert.h.