Skip to content

hilbert2

A DFT-based implementation of a Hilbert transformer.

Syntax

c:a, s:a = hilbert2(sig:a, dftsize:i, hopsize:i)
csig:Complex[] = hilbert2(sig:a, dftsize:i, hopsize:i)
ac, as hilbert2 asig, idftsize, ihopsize
csig:Complex[] hilbert2 asig, idftsize, ihopsize

Initialization

idftsize -- DFT size in samples, at least 2. Csound rounds this down to a power of two. Below, N means the rounded DFT size.

ihopsize -- number of samples between analysis frames, at least 1. Csound rounds this down to a power of two, then limits it to N. A smaller hop gives more overlap and uses more processing time.

For example, a DFT size of 150 and a hop size of 35 become 128 and 32.

Performance

sig -- input signal

c -- cosine output of sig

s -- sine output of sig

csig -- Complex array containing the analytic signal.

hilbert2 is a DFT-based implementation of the Hilbert Transform producing two outputs in quadrature (90 degree phase difference across the spectrum). Unlike the IIR-based hilbert opcode, hilbert2 has a linear frequency response. Its streaming algorithm adds a delay equal to the DFT size in samples.

Examples

Here is an example of the hilbert2 opcode. It uses the file hilbert2.csd.

Example of the hilbert2 opcode.
<CsoundSynthesizer>
<CsOptions>
 -odac
</CsOptions>
<CsInstruments>

nchnls = 2
0dbfs = 1

instr 1

asig  oscili   0dbfs*p4, p5
a1,a2 hilbert2 asig, 1024, 256
      outs     a1, a2

endin

</CsInstruments>
<CsScore>
i1 0 10 0.5 440
</CsScore>
</CsoundSynthesizer>

See also

hilbert, Specialized Filters: Other filters

Credits

Author: Victor Lazzarini
2017