hilbert
A Hilbert transformer.
Syntax
Performance
asig -- input signal
ar1 -- sine output of asig
ar2 -- cosine output of asig
hilbert is an IIR filter based implementation of a broad-band 90 degree phase difference network. The input to hilbert is an audio signal, with a frequency range from 15 Hz to 15 kHz. The outputs of hilbert have an identical frequency response to the input (i.e. they sound the same), but the two outputs have a constant phase difference of 90 degrees, plus or minus some small amount of error, throughout the entire frequency range. The outputs are in quadrature.
hilbert is useful in the implementation of many digital signal processing techniques that require a signal in phase quadrature. ar1 corresponds to the cosine output of hilbert, while ar2 corresponds to the sine output. The two outputs have a constant phase difference throughout the audio range that corresponds to the phase relationship between cosine and sine waves.
Internally, hilbert is based on two parallel 6th-order allpass filters. Each allpass filter implements a phase lag that increases with frequency; the difference between the phase lags of the parallel allpass filters at any given point is approximately 90 degrees.
Unlike an FIR-based Hilbert transformer, the output of hilbert does not have a linear phase response. However, the IIR structure used in hilbert is far more efficient to compute, and the nonlinear phase response can be used in the creation of interesting audio effects, as in the second example below.
Examples
The first example implements frequency shifting, or single sideband amplitude modulation. Frequency shifting is similar to ring modulation, except the upper and lower sidebands are separated into individual outputs. By using only one of the outputs, the input signal can be "detuned," where the harmonic components of the signal are shifted out of harmonic alignment with each other, e.g. a signal with harmonics at 100, 200, 300, 400 and 500 Hz, shifted up by 50 Hz, will have harmonics at 150, 250, 350, 450, and 550 Hz.
Here is the first example of the hilbert opcode. It uses the file hilbert.csd, and drumsMlp.wav.
The second example is a variation of the first, but with the output being fed back into the input. With very small shift amounts (i.e. between 0 and +-6 Hz), the result is a sound that has been described as a “barberpole phaser” or “Shepard tone phase shifter.” Several notches appear in the spectrum, and are constantly swept in the direction opposite that of the shift, producing a filtering effect that is reminiscent of Risset's “endless glissando”.
Here is the second example of the hilbert opcode. It uses the file hilbert_barberpole.csd.
See also
Specialized Filters: Other filters
Technical History
The use of phase-difference networks in frequency shifters was pioneered by Harald Bode1. Bode and Bob Moog provide an excellent description of the implementation and use of a frequency shifter in the analog realm in 2; this would be an excellent first source for those that wish to explore the possibilities of single sideband modulation. Bernie Hutchins provides more applications of the frequency shifter, as well as a detailed technical analysis3. A recent paper by Scott Wardle4 describes a digital implementation of a frequency shifter, as well as some unique applications.
References
- H. Bode, "Solid State Audio Frequency Spectrum Shifter." AES Preprint No. 395 (1965).
- H. Bode and R.A. Moog, "A High-Accuracy Frequency Shfiter for Professional Audio Applications." Journal of the Audio Engineering Society, July/August 1972, vol. 20, no. 6, p. 453.
- B. Hutchins. Musical Engineer's Handbook (Ithaca, NY: Electronotes, 1975), ch. 6a.
- S. Wardle, "A Hilbert-Transformer Frequency Shifter for Audio." Available online at http://www.iua.upf.es/dafx98/papers/.
Credits
Author: Sean Costello
Seattle, Washington
1999
New in Csound version 3.55
The examples were updated April 2002. Thanks go to Sean Costello for fixing the barberpole example.