Csound Csound-dev Csound-tekno Search About

moog filters orc/sco

Date1998-02-18 11:41
Fromjames@maths.ex.ac.uk
Subjectmoog filters orc/sco
owner-csound-outgoing wrote
>From owner-csound-outgoing Sat Feb  7 16:59:22 1998
From: owner-csound-outgoing
Date: Sat, 7 Feb 98 16:59:22 GMT
To: owner-csound-outgoing
Subject: BOUNCE Csound: Non-member submission from [Josep M Comajuncosas ]

Received: from hermes.ex.ac.uk by maths.ex.ac.uk; Sat, 7 Feb 98 16:59:12 GMT
Received: from root@lix.intercom.es [194.179.21.2] by hermes via ESMTP (QAA10807); Sat, 7 Feb 1998 16:59:00 GMT
Received: from jcn100110011001 (iv1-192.intercom.es [195.76.154.192]) by lix.intercom.es (8.7.3/8.6.12) with ESMTP id SAA24524 for ; Sat, 7 Feb 1998 18:05:36 +0100
Message-Id: <34DC634E.49C5DF57@intercom.es>
Date: Sat, 07 Feb 1998 14:36:14 +0100
From: Josep M Comajuncosas 
X-Mailer: Mozilla 4.01 [en] (WinNT; I)
Mime-Version: 1.0
To: csound
Subject: Two resonant LPF designs
X-Priority: 3 (Normal)
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-Mime-Autoconverted: from 8bit to quoted-printable by exeter.ac.uk id QAA10807

Here you have two 24 dB Moog style resonant Lowpass filters. The first
is a direct translation of some papers about a digital implementation of
the classycal Moog filter, the second one is maybe more elegant but
works in a very similar way.
Hope you=B4ll like them.

Josep M Comajuncosas

sr =3D 44100
kr =3D 44100
ksmps =3D 1

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;=
;;;;;;;;;;;;;;;;;;;;;;

instr 1; Moog 24 dB (4 pole) LPF with resonance !!
; based on papers by Stilson & Smith
; coded in C by (?)
; ported to Csound by Josep M Comajuncosas
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;=
;;;;;;;;;;;;;;;;;;;;;;

kout0 init 0
kout4 init 0

kap1 init 0
kap2 init 0
kap3 init 0
kap4 init 0

kin1 init 0
kin2 init 0
kin3 init 0
kin4 init 0

;sound source: put here what you want
kinput rand 10000

; kfcon / kresin between 0 and 1
; works best between 0 ~ sr/4 Hz (or sr/6...)

ilimres =3D 10000; an empyrical value to play with
kfco linseg 100, p3/2, 5000, p3/2, 1000; filter cutoff frequency
(suggested 0 to sr/4)
kresin linseg .25, p3/2, .5, p3/2, .99; resonance amount (0 to 1
-oscillation)

kfcon =3D 2*kfco/sr; normalized freq. 0 to Nyquist

kreso =3D 1 - kfcon; empyrical tuning
kreso =3D 1 + 3.5 * kreso * kreso
kreso =3D kreso * kresin;

kfcon =3D kfcon * 2.0 - 1.0;

kreso =3D kreso * kout4;

; limit resonance (just simple clipping...)
kreso =3D ( kreso >  ilimres  ?  ilimres : kreso)
kreso =3D ( kreso < -ilimres ? -ilimres : kreso)

kout0 =3D kinput - kreso; feedback!

; lowpass 1
kap1  =3D (kout0 - kap1) * kfcon + kin1; allpass section
kin1  =3D  kout0;
kout1 =3D (kout0 + kap1) * 0.5; combine with kinput

; lowpass 2
kap2  =3D (kout1 - kap2) * kfcon + kin2;
kin2  =3D  kout1;
kout2 =3D (kout1 + kap2) * 0.5;

; lowpass 3
kap3  =3D (kout2 - kap3) * kfcon + kin3;
kin3  =3D  kout2;
kout3 =3D (kout2 + kap3) * 0.5;

; lowpass 4
kap4 =3D (kout3 - kap4) * kfcon + kin4;
kin4 =3D  kout3;
kout4 =3D (kout3 + kap4) * 0.5;

aout upsamp kout4;
out aout

endin

i1  0 10
e

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;=
;;;;;;;;;;;;;;;;;;;;;;;

instr 4; 24 dB LPF with resonance. Can self-oscillate !
; loosely based on some papers by Stilson & Smith (CCRMA)
; coded by Josep M Comajuncosas / jan=B498
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;=
;;;;;;;;;;;;;;;;;;;;;;;

aout init 0
iamp =3D 10000; intended maximum amplitude
kfreq =3D 100
ifco =3D p4; keep it well below sr/4 or less


kenv linen 1, .05, p3, p3-.25
kres =3D kenv*3.9; resonance (0,4)
;4 for self-oscillation, but be careful
kfco =3D kfreq + ifco*kenv; filter cutoff frequency

kfcn =3D kfco/sr; frequency normalized (0, 1/4)
kcorr =3D1-4*kfcn; some empyrical tuning...
kres =3D kres/kcorr; more feedback for higher frequencies
;this is to compensate for the worse efficiency of the filter at high
kfco
;(phase resp. at kfco goes from pi/4 at ~ 0 Hz to 0 at sr/4 for a 1st
order IIR LPF)
;this also makes impossible to use frequencies above sr/4

asig buzz 1,kfreq,sr/(2*kfreq),1; sound source, what you want

arez =3D asig - kres*aout; inverted feedback to the filter
; as ph. resp. of a 4 stage LPF at kfco is 180=BA but  at DC & sr/2 =3D 0=
=BA
; inverting it in the feedback loop causes the filter to emphasize
kfco("corner peaking")
alpf tone arez, kfco; 4 cascaded 1st order IIR LPF
alpf tone alpf, kfco
alpf tone alpf, kfco
aout tone alpf, kfco

out aout*iamp*kcorr*20; a minimum equalisation
; 20 is empyrical, you may have to remove it for other sound sources
; but even thus the amplitude obviously increases with kfco.
endin

f1 0  32769 10 1
i1 0 3 380
i1 3 . 570
i1 6 . 1067
i1 9 . 2473
i1 12 . 5062
i1 15 . 7041
e



-- 
James Andrews, maths CDO, ext.3977