|
| 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 62 of file Hilbert.h.
Processes one sample, returning the analytic signal {real, imag}.
Uses a mirrored (double-write) delay line so the convolution window is one contiguous span, dispatched to the SIMD dot product - an order of magnitude faster than a wrapped per-tap loop for 191 taps. (Half of the kernel taps are exact zeros - the ideal Hilbert kernel vanishes on even indices - but a contiguous dot product still beats a strided read that would skip them; same trade-off as the framework's half-band FIRs.)
- Parameters
-
| input | Real-valued input sample. |
Definition at line 99 of file Hilbert.h.