1<CsoundSynthesizer>
2
3<CsOptions>
4--env:SSDIR+=../SourceMaterials -odac
5</CsOptions>
6
7<CsInstruments>
8;Example written by Iain McCurdy
9
10sr = 44100
11ksmps = 16
12nchnls = 2
130dbfs = 1
14
15  instr 1 ; triggers notes in instrument 2 with randomised p-fields
16krate  randomi 0.2,0.4,0.1   ;rate of note generation
17ktrig  metro  krate          ;triggers used by schedkwhen
18koct   random 5,12           ;fundemental pitch of synth note
19kdur   random 15,30          ;duration of note
20schedkwhen ktrig,0,0,2,0,kdur,cpsoct(koct) ;trigger a note in instrument 2
21  endin
22
23  instr 2 ; subtractive synthesis instrument
24aNoise  pinkish  1                  ;a noise source sound: pink noise
25kGap    rspline  0.3,0.05,0.2,2     ;time gap between impulses
26aPulse  mpulse   15, kGap           ;a train of impulses
27kCFade  rspline  0,1,0.1,1          ;crossfade point between noise and impulses
28aInput  ntrpol   aPulse,aNoise,kCFade;implement crossfade
29
30; cutoff frequencies for low and highpass filters
31kLPF_CF  rspline  13,8,0.1,0.4
32kHPF_CF  rspline  5,10,0.1,0.4
33; filter input sound with low and highpass filters in series -
34; - done twice per filter in order to sharpen cutoff slopes
35aInput    butlp    aInput, cpsoct(kLPF_CF)
36aInput    butlp    aInput, cpsoct(kLPF_CF)
37aInput    buthp    aInput, cpsoct(kHPF_CF)
38aInput    buthp    aInput, cpsoct(kHPF_CF)
39
40kcf     rspline  p4*1.05,p4*0.95,0.01,0.1 ; fundemental
41; bandwidth for each filter is created individually as a random spline function
42kbw1    rspline  0.00001,10,0.2,1
43kbw2    rspline  0.00001,10,0.2,1
44kbw3    rspline  0.00001,10,0.2,1
45kbw4    rspline  0.00001,10,0.2,1
46kbw5    rspline  0.00001,10,0.2,1
47kbw6    rspline  0.00001,10,0.2,1
48kbw7    rspline  0.00001,10,0.2,1
49kbw8    rspline  0.00001,10,0.2,1
50kbw9    rspline  0.00001,10,0.2,1
51kbw10   rspline  0.00001,10,0.2,1
52kbw11   rspline  0.00001,10,0.2,1
53kbw12   rspline  0.00001,10,0.2,1
54kbw13   rspline  0.00001,10,0.2,1
55kbw14   rspline  0.00001,10,0.2,1
56kbw15   rspline  0.00001,10,0.2,1
57kbw16   rspline  0.00001,10,0.2,1
58kbw17   rspline  0.00001,10,0.2,1
59kbw18   rspline  0.00001,10,0.2,1
60kbw19   rspline  0.00001,10,0.2,1
61kbw20   rspline  0.00001,10,0.2,1
62kbw21   rspline  0.00001,10,0.2,1
63kbw22   rspline  0.00001,10,0.2,1
64
65imode   =        0 ; amplitude balancing method used by the reson filters
66a1      reson    aInput, kcf*1,               kbw1, imode
67a2      reson    aInput, kcf*1.0019054878049, kbw2, imode
68a3      reson    aInput, kcf*1.7936737804878, kbw3, imode
69a4      reson    aInput, kcf*1.8009908536585, kbw4, imode
70a5      reson    aInput, kcf*2.5201981707317, kbw5, imode
71a6      reson    aInput, kcf*2.5224085365854, kbw6, imode
72a7      reson    aInput, kcf*2.9907012195122, kbw7, imode
73a8      reson    aInput, kcf*2.9940548780488, kbw8, imode
74a9      reson    aInput, kcf*3.7855182926829, kbw9, imode
75a10     reson    aInput, kcf*3.8061737804878, kbw10,imode
76a11     reson    aInput, kcf*4.5689024390244, kbw11,imode
77a12     reson    aInput, kcf*4.5754573170732, kbw12,imode
78a13     reson    aInput, kcf*5.0296493902439, kbw13,imode
79a14     reson    aInput, kcf*5.0455030487805, kbw14,imode
80a15     reson    aInput, kcf*6.0759908536585, kbw15,imode
81a16     reson    aInput, kcf*5.9094512195122, kbw16,imode
82a17     reson    aInput, kcf*6.4124237804878, kbw17,imode
83a18     reson    aInput, kcf*6.4430640243902, kbw18,imode
84a19     reson    aInput, kcf*7.0826219512195, kbw19,imode
85a20     reson    aInput, kcf*7.0923780487805, kbw20,imode
86a21     reson    aInput, kcf*7.3188262195122, kbw21,imode
87a22     reson    aInput, kcf*7.5551829268293, kbw22,imode
88
89; amplitude control for each filter output
90kAmp1    rspline  0, 1, 0.3, 1
91kAmp2    rspline  0, 1, 0.3, 1
92kAmp3    rspline  0, 1, 0.3, 1
93kAmp4    rspline  0, 1, 0.3, 1
94kAmp5    rspline  0, 1, 0.3, 1
95kAmp6    rspline  0, 1, 0.3, 1
96kAmp7    rspline  0, 1, 0.3, 1
97kAmp8    rspline  0, 1, 0.3, 1
98kAmp9    rspline  0, 1, 0.3, 1
99kAmp10   rspline  0, 1, 0.3, 1
100kAmp11   rspline  0, 1, 0.3, 1
101kAmp12   rspline  0, 1, 0.3, 1
102kAmp13   rspline  0, 1, 0.3, 1
103kAmp14   rspline  0, 1, 0.3, 1
104kAmp15   rspline  0, 1, 0.3, 1
105kAmp16   rspline  0, 1, 0.3, 1
106kAmp17   rspline  0, 1, 0.3, 1
107kAmp18   rspline  0, 1, 0.3, 1
108kAmp19   rspline  0, 1, 0.3, 1
109kAmp20   rspline  0, 1, 0.3, 1
110kAmp21   rspline  0, 1, 0.3, 1
111kAmp22   rspline  0, 1, 0.3, 1
112
113; left and right channel mixes are created using alternate filter outputs.
114; This shall create a stereo effect.
115aMixL    sum      a1*kAmp1,a3*kAmp3,a5*kAmp5,a7*kAmp7,a9*kAmp9,a11*kAmp11,\
116                        a13*kAmp13,a15*kAmp15,a17*kAmp17,a19*kAmp19,a21*kAmp21
117aMixR    sum      a2*kAmp2,a4*kAmp4,a6*kAmp6,a8*kAmp8,a10*kAmp10,a12*kAmp12,\
118                        a14*kAmp14,a16*kAmp16,a18*kAmp18,a20*kAmp20,a22*kAmp22
119
120kEnv     linseg   0, p3*0.5, 1,p3*0.5,0,1,0       ; global amplitude envelope
121outs   (aMixL*kEnv*0.00008), (aMixR*kEnv*0.00008) ; audio sent to outputs
122  endin
123
124</CsInstruments>
125
126<CsScore>
127i 1 0 3600  ; instrument 1 (note generator) plays for 1 hour
128e
129</CsScore>
130
131</CsoundSynthesizer>
132