Debian Codegraph @

examples/alwayson.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 ; Select audio/midi flags here according to platform
4 -odac ;;;RT audio out
5 ;-iadc ;;;uncomment -iadc if RT audio input is needed too
6 ; For Non-realtime ouput leave only the line below:
7 ;-Wfo alwayson.wav
8 </CsOptions>
9 <CsInstruments>
10
11 ; Initialize the global variables.
12
13 sr = 44100
14 ksmps = 32
15 nchnls = 2
16
17 ; Connect up instruments and effects to create the signal flow graph.
18
19 connect "SimpleSine", "leftout", "Reverberator", "leftin"
20 connect "SimpleSine", "rightout", "Reverberator", "rightin"
21
22 connect "Moogy", "leftout", "Reverberator", "leftin"
23 connect "Moogy", "rightout", "Reverberator", "rightin"
24
25 connect "Reverberator", "leftout", "Compressor", "leftin"
26 connect "Reverberator", "rightout", "Compressor", "rightin"
27
28 connect "Compressor", "leftout", "Soundfile", "leftin"
29 connect "Compressor", "rightout", "Soundfile", "rightin"
30
31 ; Turn on the "effect" units in the signal flow graph.
32
33 alwayson "Reverberator", 0.91, 12000
34 alwayson "Compressor"
35 alwayson "Soundfile"
36
37 ; Define instruments and effects in order of signal flow.
38
39 instr SimpleSine
40 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
41 ; Default values: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10
42 pset 0, 0, 10, 0, 0, 0, 0.5
43 iattack = 0.015
44 idecay = 0.07
45 isustain = p3
46 irelease = 0.3
47 p3 = iattack + idecay + isustain + irelease
48 adamping linsegr 0.0, iattack, 1.0, idecay + isustain, 1.0, irelease, 0.0
49 iHz = cpsmidinn(p4)
50 ; Rescale MIDI velocity range to a musically usable range of dB.
51 iamplitude = ampdb(p5 / 127 * 15.0 + 60.0)
52 ; Use ftgenonce instead of ftgen, ftgentmp, or f statement.
53 icosine ftgenonce 0, 0, 65537, 11, 1
54 aoscili oscili iamplitude, iHz, icosine
55 aadsr madsr iattack, idecay, 0.6, irelease
56 asignal = aoscili * aadsr
57 aleft, aright pan2 asignal, p7
58 ; Stereo audio output to be routed in the orchestra header.
59 outleta "leftout", aleft
60 outleta "rightout", aright
61 endin
62
63 instr Moogy
64 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
65 ; Default values: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10
66 pset 0, 0, 10, 0, 0, 0, 0.5
67 iattack = 0.003
68 isustain = p3
69 irelease = 0.05
70 p3 = iattack + isustain + irelease
71 adamping linsegr 0.0, iattack, 1.0, isustain, 1.0, irelease, 0.0
72 iHz = cpsmidinn(p4)
73 ; Rescale MIDI velocity range to a musically usable range of dB.
74 iamplitude = ampdb(p5 / 127 * 20.0 + 60.0)
75 print iHz, iamplitude
76 ; Use ftgenonce instead of ftgen, ftgentmp, or f statement.
77 isine ftgenonce 0, 0, 65537, 10, 1
78 asignal vco iamplitude, iHz, 1, 0.5, isine
79 kfco line 2000, p3, 200
80 krez = 0.8
81 asignal moogvcf asignal, kfco, krez, 100000
82 asignal = asignal * adamping
83 aleft, aright pan2 asignal, p7
84 ; Stereo audio output to be routed in the orchestra header.
85 outleta "leftout", aleft
86 outleta "rightout", aright
87 endin
88 instr Reverberator
89 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
90 ; Stereo input.
91 aleftin inleta "leftin"
92 arightin inleta "rightin"
93 idelay = p4
94 icutoff = p5
95 aleft, aright reverbsc aleftin, arightin, idelay, icutoff
96 ; Stereo output.
97 outleta "leftout", aleft
98 outleta "rightout", aright
99 endin
100
101 instr Compressor
102 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
103 ; Stereo input.
104 aleftin inleta "leftin"
105 arightin inleta "rightin"
106 kthreshold = 25000
107 icomp1 = 0.5
108 icomp2 = 0.763
109 irtime = 0.1
110 iftime = 0.1
111 aleftout dam aleftin, kthreshold, icomp1, icomp2, irtime, iftime
112 arightout dam arightin, kthreshold, icomp1, icomp2, irtime, iftime
113 ; Stereo output.
114 outleta "leftout", aleftout
115 outleta "rightout", arightout
116 endin
117
118 instr Soundfile
119 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
120 ; Stereo input.
121 aleftin inleta "leftin"
122 arightin inleta "rightin"
123 outs aleftin, arightin
124 endin
125
126 </CsInstruments>
127 <CsScore>
128
129 ; It is not necessary to activate "effects" or create f-tables in the score!
130 ; Overlapping notes create new instances of instruments with proper connections.
131
132 i "SimpleSine" 1 5 60 85
133 i "SimpleSine" 2 5 64 80
134 i "Moogy" 3 5 67 75
135 i "Moogy" 4 5 71 70
136 ; 1 extra second after the performance
137 e 1
138
139 </CsScore>
140 </CsoundSynthesizer>