Skip to content

phaser2

Second-order allpass filters arranged in a series.

Syntax

ares = phaser2(asig, kfreq, kq, kord, kmode, ksep, kfeedback [, iskip])
ares phaser2 asig, kfreq, kq, kord, kmode, ksep, kfeedback [, iskip]

Initialization

iskip (optional, default=0) -- zero clears the filter history and feedback. A nonzero value keeps them on reinitialization.

Performance

kfreq -- frequency in Hz of the first allpass stage. The other stage frequencies depend on kmode and ksep.

kq -- Q of each notch. Higher Q values result in narrow notches. A Q between 0.5 and 1 results in the strongest "phasing" effect, but higher Q values can be used for special effects.

kord -- number of second-order allpass stages in series. Use a positive integer. More stages require more computation.

kfeedback -- amount of the output which is fed back into the input of the allpass chain. With larger amounts of feedback, more prominent notches appear in the spectrum of the output. kfeedback must be between -1 and +1. for stability.

kmode -- used in calculation of notch frequencies.

📝 Note

Although kord and kmode are listed as k-rate, they are in fact accessed only at init-time. So if you are using k-rate arguments, they must be assigned with init.

ksep -- spacing factor used with kmode to set the frequencies of the later stages.

phaser2 connects kord second-order allpass stages in series. With fixed controls and zero feedback, the chain changes phase while keeping a flat magnitude response. Mix the output with the input to create notches in the spectrum, as shown below.

There are two modes for setting the stage frequencies. When kmode = 1, stage N (counting from 1) uses:

frequency of stage N = kfreq * (1 + ksep * (N - 1))

For example, with kmode = 1, ksep = 1, and kfreq = 100, the first four stages use 100, 200, 300, and 400 Hz. Vary ksep to change their spacing.

When kmode = 2, stage N uses kfreq * ksep^(N - 1). For example, the following lines space eight stages an octave apart and mix the result with the input:

aphs    phaser2    ain, kfreq, 0.5, 8, 2, 2, 0
aout    =          ain + aphs

Use a positive ksep in mode 2. Values above 1 raise the frequency of each later stage; values between 0 and 1 lower it.

Examples

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

Example of the phaser2 opcode.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out   Audio in    No messages
-odac           -iadc     -d     ;;;RT audio I/O
; For Non-realtime ouput leave only the line below:
; -o phaser2.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 10
nchnls = 1
0dbfs = 1

instr 2              ; demonstration of phase shifting abilities of phaser2. 
  ; Input mixed with output of phaser2 to generate notches. 
  ; Demonstrates the interaction of imode and ksep.
  idur   = p3 
  iamp   = p4 * .04
  iorder = p5        ; number of 2nd-order stages in phaser2 network
  ifreq  = p6        ; not used
  ifeed  = p7        ; amount of feedback for phaser2
  imode  = p8        ; mode for frequency scaling
  isep   = p9        ; used with imode to determine notch frequencies
  kamp   linseg 0, .2, iamp, idur - .2, iamp, .2, 0
  iharms = (sr*.4) / 100

  ; "Sawtooth" waveform exponentially decaying function, to control notch frequencies
  asig   gbuzz 1, 100, iharms, 1, .95, 2  
  kline  expseg 1, idur, .005
  aphs   phaser2 asig, kline * 2000, .5, iorder, imode, isep, ifeed

  out (asig + aphs) * iamp
endin


</CsInstruments>
<CsScore>

; cosine wave for gbuzz
f2 0  8192 9 1 1 .25     

; phaser2, imode=1
i2 00 10 0.21 8 .2 .9 1 .33
i2 11 10 0.21 8 .2 .9 1 2

; phaser2, imode=2
i2 22 10 0.21 8 .2 .9 2 .33
i2 33 10 0.21 8 .2 .9 2 2
e


</CsScore>
</CsoundSynthesizer>

Technical History

A general description of the differences between flanging and phasing can be found in Hartmann [1]. An early implementation of first-order allpass filters connected in series can be found in Beigel [2], where the bilinear z-transform is used for determining the phase shift frequency of each stage. Cronin [3] presents a similar implementation for a four-stage phase shifting network. Chamberlin [4] and Smith [5] both discuss using second-order allpass sections for greater control over notch depth, width, and frequency.

References

  1. Hartmann, W.M. "Flanging and Phasers." Journal of the Audio Engineering Society, Vol. 26, No. 6, pp. 439-443, June 1978.
  2. Beigel, Michael I. "A Digital 'Phase Shifter' for Musical Applications, Using the Bell Labs (Alles-Fischer) Digital Filter Module." Journal of the Audio Engineering Society, Vol. 27, No. 9, pp. 673-676,September 1979.
  3. Cronin, Dennis. "Examining Audio DSP Algorithms." Dr. Dobb's Journal, July 1994, p. 78-83.
  4. Chamberlin, Hal. Musical Applications of Microprocessors. Second edition. Indianapolis, Indiana: Hayden Books, 1985.
  5. Smith, Julius O. "An Allpass Approach to Digital Phasing and Flanging." Proceedings of the 1984 ICMC, p. 103-108.

See also

Special Effects

Credits

Author: Sean Costello
Seattle, Washington
1999

November 2002. Added a note about the kord and kmode parameters, thanks to Rasmus Ekman.

New in Csound version 4.0