Debian Codegraph @

src/Examples/FLOSS Manual Examples/04 Sound Synthesis/04B02_Subtractive_timbres.csd

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