Skip to content

pareq

Implementation of Zoelzer's parametric equalizer filters, with some modifications by the author.

The formulas below use f for kc, V for kv, and Q for kq. The filter divides all coefficients by a0.

The formula for the low shelf filter is:

omega = 2*pi*f/sr
K     = tan(omega/2)

b0    = 1 + sqrt(2*V)*K + V*K^2
b1    = 2*(V*K^2 - 1)
b2    = 1 - sqrt(2*V)*K + V*K^2

a0    = 1 + K/Q + K^2
a1    = 2*(K^2 - 1)
a2    = 1 - K/Q + K^2

The formula for the high shelf filter is:

omega = 2*pi*f/sr
K     = tan((pi-omega)/2)

b0    = 1 + sqrt(2*V)*K + V*K^2
b1    = -2*(V*K^2 - 1)
b2    = 1 - sqrt(2*V)*K + V*K^2

a0    = 1 + K/Q + K^2
a1    = -2*(K^2 - 1)
a2    = 1 - K/Q + K^2

The formula for the peaking filter is:

omega = 2*pi*f/sr
K     = tan(omega/2)

b0 =  1 + V*K/Q + K^2
b1 =  2*(K^2 - 1)
b2 =  1 - V*K/Q + K^2

a0 =  1 + K/Q + K^2
a1 =  2*(K^2 - 1)
a2 =  1 - K/Q + K^2

Syntax

ares = pareq(asig, kc, kv, kq [, imode] [, iskip])
ares pareq asig, kc, kv, kq [, imode] [, iskip]

Initialization

imode (optional, default: 0) -- operating mode

  • 0 = Peaking
  • 1 = Low Shelving
  • 2 = High Shelving

iskip (optional, default=0) -- a nonzero value keeps the filter's mode and history on reinitialization. First use always initializes the filter. With zero, reinitialization clears the history and applies imode.

Performance

kc -- center frequency in peaking mode, corner frequency in shelving mode.

kv -- linear gain: a value below 1 is a cut, and a value above 1 is a boost. In peaking mode, 1 gives a flat response. In shelving modes, a flat response also requires kq = sqrt(.5); other Q values can shape the response near the corner frequency even when kv = 1.

kq -- Q of the filter (sqrt(.5) is no resonance)

asig -- the incoming signal

Examples

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

Example of the pareq 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 pareq.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

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

instr 15
  ifc     =       p4                       ; Center / Shelf
  kq      =       p5                       ; Quality factor sqrt(.5) is no resonance
  kv      =       ampdb(p6)                ; Volume Boost/Cut
  imode   =       p7                       ; Mode 0=Peaking EQ, 1=Low Shelf, 2=High Shelf
  kfc     linseg  ifc*2, p3, ifc/2
  asig    rand    0.15  ; Random number source for testing
  aout    pareq   asig, kfc, kv, kq, imode ; Parmetric equalization
          outs    aout, aout               ; Output the results
endin


</CsInstruments>
<CsScore>

; SCORE:
  ;   Sta  Dur  Fcenter  Q        Boost/Cut(dB)  Mode
  i15 0    1    10000   .2          12             1
  i15 +    .    5000    .2          12             1
  i15 .    .    1000    .707       -12             2
  i15 .    .    5000    .1         -12             0
  e


</CsScore>
</CsoundSynthesizer>

See also

Specialized Filters: Parametric EQ

Credits

Hans Mikelson
December 1998

New in Csound version 3.50