Debian Codegraph @

src/Examples/FLOSS Manual Examples/03 Csound Language/03G14_UDO_zdf_svf.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 </CsOptions>
4 <CsInstruments>
5
6 sr = 44100
7 ksmps = 32
8 nchnls = 2
9 0dbfs = 1
10
11 opcode zdf_svf,aaa,aKK
12
13 ain, kcf, kR xin
14
15 ; pre-warp the cutoff- these are bilinear-transform filters
16 kwd = 2 * $M_PI * kcf
17 iT = 1/sr
18 kwa = (2/iT) * tan(kwd * iT/2)
19 kG = kwa * iT/2
20
21 ;; output signals
22 alp init 0
23 ahp init 0
24 abp init 0
25
26 ;; state for integrators
27 kz1 init 0
28 kz2 init 0
29
30 ;;
31 kindx = 0
32 while kindx < ksmps do
33 khp = (ain[kindx] - (2*kR+kG) * kz1 - kz2) / (1 + (2*kR*kG) + (kG*kG))
34 kbp = kG * khp + kz1
35 klp = kG * kbp + kz2
36
37 ; z1 register update
38 kz1 = kG * khp + kbp
39 kz2 = kG * kbp + klp
40
41 alp[kindx] = klp
42 ahp[kindx] = khp
43 abp[kindx] = kbp
44 kindx += 1
45 od
46
47 xout alp, abp, ahp
48
49
50 endop
51
52 opcode zdf_svf,aaa,aaa
53
54 ain, acf, aR xin
55
56 iT = 1/sr
57
58 ;; output signals
59 alp init 0
60 ahp init 0
61 abp init 0
62
63 ;; state for integrators
64 kz1 init 0
65 kz2 init 0
66
67 ;;
68 kindx = 0
69 while kindx < ksmps do
70
71 ; pre-warp the cutoff- these are bilinear-transform filters
72 kwd = 2 * $M_PI * acf[kindx]
73 kwa = (2/iT) * tan(kwd * iT/2)
74 kG = kwa * iT/2
75
76 kR = aR[kindx]
77
78 khp = (ain[kindx] - (2*kR+kG) * kz1 - kz2) / (1 + (2*kR*kG) + (kG*kG))
79 kbp = kG * khp + kz1
80 klp = kG * kbp + kz2
81
82 ; z1 register update
83 kz1 = kG * khp + kbp
84 kz2 = kG * kbp + klp
85
86 alp[kindx] = klp
87 ahp[kindx] = khp
88 abp[kindx] = kbp
89 kindx += 1
90 od
91
92 xout alp, abp, ahp
93
94
95 endop
96
97 giSine ftgen 0, 0, 2^14, 10, 1
98
99 instr 1
100
101 aBuzz buzz 1, 100, 50, giSine
102 aLp, aBp, aHp zdf_svf aBuzz, 1000, 1
103
104 out aHp, aHp
105
106 endin
107
108
109 </CsInstruments>
110 <CsScore>
111 i 1 0 10
112 </CsScore>
113 </CsoundSynthesizer>
114 ;example by steven yi