Csound Csound-dev Csound-tekno Search About

EQ Filters Orc/Sco

Date1998-11-19 03:41
FromHans Mikelson
SubjectEQ Filters Orc/Sco
Hi,

Here are a low shelf and a peaking EQ filter posted by Chris Townsend to the
music-dsp list and a high shelf filter by me derived from the low shelf
filter.  The Q looks like it behaves very nicely above sqrt(.5) making a
nice resonant peak.  Below sqrt(.5) it gives a much shallower roll-off which
may also be useful.

Good Luck,
Hans Mikelson

; ORCHESTRA
;----------------------------------------------------------------
; Biquadratic Equalizer Filters
; Coded by Hans Mikelson November 1998
;----------------------------------------------------------------
sr=44100
kr=4410
ksmps=10
nchnls=2

;----------------------------------------------------------------
; Low Shelf by Chris Townsend converted to Csound by Hans Mikelson
;----------------------------------------------------------------
        instr 11

ifc     =     p4      ; Center / Shelf
iq      =     p5      ; Quality factor sqrt(.5) is no resonance
igain   =     p6      ; Gain/Cut in dB
i2pi    =     2*3.14159265

iomega0 =     i2pi*ifc/sr
ik      =     tan(iomega0/2)
iv      =     ampdb(igain)              ; Convert dB to Amplitude

kb0     =     1+sqrt(2*iv)*ik+iv*ik*ik  ; Compute the coefficients
kb1     =     2*(iv*ik*ik-1)
kb2     =     1-sqrt(2*iv)*ik+iv*ik*ik
ka0     =     1+ik/iq+ik*ik
ka1     =     2*(ik*ik-1)
ka2     =     1-ik/iq+ik*ik

asig    rand  5000                     ; Random number source for testing

aout    biquad asig, kb0, kb1, kb2, ka0, ka1, ka2  ; Biquad filter

        outs   aout, aout              ; Output the results

endin

;----------------------------------------------------------------
; High Shelf by Hans Mikelson derived from low shelf by Chris Townsend
;----------------------------------------------------------------
        instr 12

ifc     =     p4      ; Center / Shelf
iq      =     p5      ; Quality factor sqrt(.5) is no resonance
igain   =     p6      ; Gain/Cut in dB
ipi     =     3.14159265
i2pi    =     2*ipi

iomega0 =     i2pi*ifc/sr
ik      =     tan((ipi-iomega0)/2)
iv      =     ampdb(igain)              ; Convert dB to Amplitude

kb0     =     1+sqrt(2*iv)*ik+iv*ik*ik  ; Compute the coefficients
kb1     =    -2*(iv*ik*ik-1)
kb2     =     1-sqrt(2*iv)*ik+iv*ik*ik
ka0     =     1+ik/iq+ik*ik
ka1     =    -2*(ik*ik-1)
ka2     =     1-ik/iq+ik*ik

asig    rand  5000                    ; Random number source for testing

aout    biquad asig, kb0, kb1, kb2, ka0, ka1, ka2  ; Biquad filter

        outs   aout, aout              ; Output the results

endin

;----------------------------------------------------------------
; Peaking EQ by Chris Townsend converted to Csound by Hans Mikelson
;----------------------------------------------------------------
        instr 13

ifc     =     p4      ; Center / Shelf
iq      =     p5      ; Quality factor
igain   =     p6      ; Gain/Cut in dB
ipi     =     3.14159265
i2pi    =     2*ipi

iomega0 =     i2pi*ifc/sr
ik      =     tan(iomega0/2)
iv      =     ampdb(igain)              ; Convert dB to Amplitude

kb0     =     1+iv*ik/iq+ik*ik  ; Compute the coefficients
kb1     =     2*(ik*ik-1)
kb2     =     1-iv*ik/iq+ik*ik
ka0     =     1+ik/iq+ik*ik
ka1     =     2*(ik*ik-1)
ka2     =     1-ik/iq+ik*ik

asig    rand  5000                    ; Random number source for testing

aout    biquad asig, kb0, kb1, kb2, ka0, ka1, ka2  ; Biquad filter

        outs   aout, aout              ; Output the results

endin

; SCORE
; Low shelf
;   Sta  Dur  Fcenter  BandWidth(Octaves)  Boost/Cut(dB)
i11 0    1    1000     .707                 12
i11 +    .    5000     .707                 12
i11 .    .    1000     .707                -12
i11 .    .    5000     .707                -12
; High Shelf
i12 4    1    1000     .707                 12
i12 +    .    5000     .707                 12
i12 .    .    1000     .707                -12
i12 .    .    5000     .707                -12
; EQ
i13 8    1    1000     .707                 12
i13 +    .    5000     .707                 12
i13 .    .    1000     .707                -12
i13 .    .    5000     .707                -12