DSPark 1.8.0
Header-only C++20 DSP for real-time and offline audio
Loading...
Searching...
No Matches
dspark::HilbertIIR< T > Class Template Reference

Zero-latency analytic pair from two allpass chains (a 90-degree phase-difference network). More...

#include <Hilbert.h>

Classes

struct  Result
 

Public Member Functions

void reset () noexcept
 Clears the allpass states. RT-safe.
 
Result process (T input) noexcept
 Processes one sample into the analytic pair. RT-safe.
 
T magnitude (T input) noexcept
 Processes one sample and returns the analytic magnitude sqrt(real^2 + imag^2): a ripple-free envelope for tones. RT-safe.
 
void magnitudeBlock (const T *in, T *out, int numSamples) noexcept
 Analytic magnitude of a block: out[i] = |analytic(in[i])|.
 

Detailed Description

template<FloatType T>
class dspark::HilbertIIR< T >

Zero-latency analytic pair from two allpass chains (a 90-degree phase-difference network).

Two cascades of seven allpass sections in z^-2, H(z) = (c - z^-2) / (1 - c z^-2), one of them followed by a one-sample delay: the classic polyphase-allpass Hilbert network (cf. O. Niemitalo's 90-degree phase difference IIR). The coefficients were designed for this header by minimax optimisation of the phase difference over 20 Hz at 192 kHz up to 20 kHz at 44.1 kHz (normalised 1.04e-4 .. 0.4535): the outputs stay within 0.065 degrees of quadrature over that whole band, so at any rate from 44.1 to 192 kHz the analytic magnitude of a tone ripples by +-0.06% (measured 0.11% peak to peak).

Unlike the FIR Hilbert above the pair has no latency and keeps its accuracy down to 20 Hz, but neither output is the undelayed input: both carry the same frequency-dependent allpass phase. Use it for envelopes (magnitude) and quadrature pairs, not for sample-aligned processing against a dry path. The recursion runs in double regardless of T (poles up to |z| = 0.9998).

Template Parameters
TSample type of the interface (float or double).

Definition at line 234 of file Hilbert.h.

Member Function Documentation

◆ magnitude()

template<FloatType T>
T dspark::HilbertIIR< T >::magnitude ( T  input)
inlinenoexcept

Processes one sample and returns the analytic magnitude sqrt(real^2 + imag^2): a ripple-free envelope for tones. RT-safe.

Definition at line 260 of file Hilbert.h.

◆ magnitudeBlock()

template<FloatType T>
void dspark::HilbertIIR< T >::magnitudeBlock ( const T *  in,
T *  out,
int  numSamples 
)
inlinenoexcept

Analytic magnitude of a block: out[i] = |analytic(in[i])|.

Same result as calling magnitude() per sample, computed section by section over short chunks so each allpass recursion keeps its state in registers (the cascade is latency bound when run sample by sample). in and out may alias. RT-safe.

Definition at line 275 of file Hilbert.h.

◆ process()

template<FloatType T>
Result dspark::HilbertIIR< T >::process ( T  input)
inlinenoexcept

Processes one sample into the analytic pair. RT-safe.

Definition at line 251 of file Hilbert.h.

◆ reset()

template<FloatType T>
void dspark::HilbertIIR< T >::reset ( )
inlinenoexcept

Clears the allpass states. RT-safe.

Definition at line 244 of file Hilbert.h.


The documentation for this class was generated from the following file: