biquada
A sweepable general purpose biquadratic digital filter with a-rate parameters.
Syntax
ares biquada asig, ab0, ab1, ab2, aa0, aa1, aa2 [, iskip]
 
Initialization
iskip (optional, default=0) -- if non-zero, intialization will be skipped. Default value 0. (New in Csound version 3.50)
asig -- input signal
biquada is a general purpose biquadratic digital filter of the form:
\[
a_0 y(n) + a_1 y(n-1) + a_2 y(n-2) = b_0 x(n) + b_1 x(n-1) + b_2 x(n-2)
\]
This filter has the following frequency response:
\[
H(z) = \frac{B(z)}{A(z)} = \frac{b_0 + b_1 z^{-1} + b_2 z^{-2}}{a_0 + a_1 z^{-1} + a_2 z^{-2}}
\]
This type of filter is often encountered in digital signal processing literature. It allows six user-defined a-rate coefficients.
Examples
Here is an example of the biquada opcode. It uses the file
biquada.csd.
| Example of the biquada 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 biquad.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>
; Initialize the global variables.
sr = 44100
kr = 4410
ksmps = 10
nchnls = 2
; Instrument #1.
instr 1
  ; Get the values from the score.
  idur = p3
  iamp = p4
  icps = cpspch(p5)
  afco   expon  100, p3, 2000
  arez   line  0.8, p3, 0.99
  ; Calculate the biquadratic filter's coefficients 
  afcon = 2*3.14159265*afco/sr
  aalpha = 1-2*arez*cos(afcon)*cos(afcon)+arez*arez*cos(2*afcon)
  abeta = arez*arez*sin(2*afcon)-2*arez*cos(afcon)*sin(afcon)
  agama = 1+cos(afcon)
  am1 = aalpha*agama+abeta*sin(afcon)
  am2 = aalpha*agama-abeta*sin(afcon)
  aden = sqrt(am1*am1+am2*am2)
  ab0 = 1.5*(aalpha*aalpha+abeta*abeta)/aden
  ab1 = ab0
  ab2 = 0
  aa0 = 1
  aa1 = -2*arez*cos(afcon)
  aa2 = arez*arez
  ; Generate an input signal.
  axn vco 1, icps, 1
  ; Filter the input signal.
  ayn biquada axn, ab0, ab1, ab2, aa0, aa1, aa2
  outs ayn*iamp/2, ayn*iamp/2
endin
</CsInstruments>
<CsScore>
; Table #1, a sine wave.
f 1 0 16384 10 1
;    Sta  Dur  Amp    Pitch
i 1  0.0  5.0  20000  6.00 
e
</CsScore>
</CsoundSynthesizer>
  | 
 
See also
Standard filters: Biquad filters
Credits
Author: John ffitch after Hans Mikelson
August 2001
New in Csound version 4.13