Debian Codegraph @

src/Examples/McCurdy Haikus/2.csd

raw
1 ; Csound Haiku II
2 ; Iain McCurdy 2011
3 ; small code modifcations by joachim heintz 2024
4
5 <CsoundSynthesizer>
6 <CsOptions>
7 -odac -m128
8 </CsOptions>
9 <CsInstruments>
10 sr = 44100
11 ksmps = 32
12 nchnls = 2
13 0dbfs = 1
14 seed 0
15
16 giampscl = ftgen(0,0,20000,-16,1,20,0,1,19980,-5,1)
17 giwave1 = ftgen(0,0,131073,9, 6,1,0, 9,1/10,0, 13,1/14,0, 17,1/18,0, 21,1/22,0, 25,1/26,0, 29,1/30,0, 33,1/34,0)
18 giwave2 = ftgen(0,0,131073,9, 7,1,0, 10,1/10,0, 14,1/14,0, 18,1/18,0, 22,1/22,0, 26,1/26,0, 30,1/30,0, 34,1/34,0)
19 giwave3 = ftgen(0,0,131073,9, 8,1,0, 11,1/10,0, 15,1/14,0, 19,1/18,0, 23,1/22,0, 27,1/26,0, 31,1/30,0, 35,1/34,0)
20 giwave4 = ftgen(0,0,131073,9, 9,1,0, 12,1/10,0, 16,1/14,0, 20,1/18,0, 24,1/22,0, 28,1/26,0, 32,1/30,0, 36,1/34,0)
21 giwave5 = ftgen(0,0,131073,9, 10,1,0, 13,1/10,0, 17,1/14,0, 21,1/18,0, 25,1/22,0, 29,1/26,0, 33,1/30,0, 37,1/34,0)
22 giwave6 = ftgen(0,0,131073,9, 11,1,0, 19,1/10,0, 28,1/14,0, 37,1/18,0, 46,1/22,0, 55,1/26,0, 64,1/30,0, 73,1/34,0)
23 giwave7 = ftgen(0,0,131073,9, 12,1/4,0, 25,1,0, 39,1/14,0, 63,1/18,0, 87,1/22,0, 111,1/26,0, 135,1/30,0, 159,1/34,0)
24 giseq = ftgen(0,0,12,-2, 1, 1/3,1/3,1/3, 1, 1/3,1/3,1/3, 1/2,1/2, 1/2,1/2)
25 gidurs = ftgen(0,0,100,-17, 0,0.4,50,0.8,90,1.5)
26 girescales = ftgen(0,0,-7,-2, 6,7,8,9,10,11,12)
27
28 gasendL,gasendR,gamixL,gamixR init 0
29
30 opcode tonea,a,aii
31 setksmps(1)
32 ain,icps,iDecay xin
33 kcfenv = transeg:k(icps*4,iDecay,-8,1,1,0,1)
34 aout = tone:a(ain,kcfenv)
35 xout(aout)
36 endop
37
38 instr start_sequences
39 schedkwhennamed(metro(1/4),0,0,"play_sequence",0,48)
40 endin
41 schedule("start_sequences",0,-1)
42
43 instr play_sequence
44 itime_unit = random:i(2,5)
45 istart = random:i(0,6)
46 iloop = random:i(6,13)
47 ktrig = seqtime(int(itime_unit)/3,int(istart),int(iloop),0,giseq)
48 inote = random:i(48,100)
49 ienvscl = ((1-(inote-48)/(100-48))*0.8)+0.2
50 ienvscl = limit:i(ienvscl,0.3,1)
51 icps = mtof:i(int(inote))
52 ipan = random:i(0,1)
53 isend = random:i(0.3,0.5)
54 kamp = rspline:k(0.007,0.6,0.05,0.2)
55 kflam = random:k(0,0.02)
56 ifn = random:i(0,7)
57 schedkwhennamed(ktrig,0,0,"play_note",kflam,0.01,icps,ipan,isend,kamp,int(ifn),ienvscl)
58 endin
59
60 instr play_note
61 idurndx = random:i(0,100)
62 p3 = table:i(idurndx,gidurs)
63 ijit = random:i(0.1,1)
64 acps = expseg:a(8000,0.003,p4,1,p4)
65 aenv = expsega(0.001,0.003,ijit^2,(p3-0.2-0.002)*p9,0.002,0.2,0.001,1,0.001)
66 adip = transeg:a(1,p3,4,0.99)
67 iampscl = table:i(p4,giampscl)
68 irescale = table:i(p8, girescales)
69 idtn = random:i(0.995,1.005)
70 a1 = oscili:a(p7*aenv*iampscl,(acps*adip*idtn)/(6+irescale),giwave1+p8)
71 adlt = rspline:a(1,10,0.1,0.2)
72 aramp = linseg:a(0,0.02,1)
73 acho = vdelay(a1*aramp,adlt,40)
74 icf = random:i(0,2)
75 kcfenv = transeg:k(p4+(p4*icf^3),p9,-8,1,1,0,1)
76 a1 = tonex(a1,kcfenv)
77 a1,a2 pan2 a1,p5
78 out(a1,a2)
79 gamixL += a1
80 gamixR += a2
81 gasendL += a1*(p6^2)
82 gasendR += a2*(p6^2)
83 endin
84
85 instr sound_output
86 a1,a2 reverbsc gamixL,gamixR,0.01,500
87 a1 *= 100
88 a2 *= 100
89 a1 = atone:a(a1,250)
90 a2 = atone:a(a2,250)
91 out(a1,a2)
92 clear(gamixL,gamixR)
93 endin
94 schedule("sound_output",0,-1)
95
96 instr reverb
97 aL,aR reverbsc gasendL,gasendR,0.75,4000
98 out(aL,aR)
99 clear(gasendL,gasendR)
100 endin
101 schedule("reverb",0,-1)
102
103 </CsInstruments>
104 <CsScore>
105 </CsScore>
106 </CsoundSynthesizer>
107 <bsbPanel>
108 <label>Widgets</label>
109 <objectName/>
110 <x>100</x>
111 <y>100</y>
112 <width>320</width>
113 <height>240</height>
114 <visible>true</visible>
115 <uuid/>
116 <bgcolor mode="background">
117 <r>240</r>
118 <g>240</g>
119 <b>240</b>
120 </bgcolor>
121 </bsbPanel>
122 <bsbPresets>
123 </bsbPresets>