Debian Codegraph @

src/Examples/CsoundQt/Miscellaneous/Reinit_Example.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 </CsOptions>
4 <CsInstruments>
5
6 sr = 44100
7 ksmps = 128
8 nchnls = 2
9 0dbfs = 1
10
11 ; This table maps menu values to vco2 oscillator modes
12 giwavemodes ftgen 0, 0, 8, -2, 0, 10, 12
13
14 instr 1 ;read widgets
15 ; When values from sliders are to be used on the init pass,
16 ; they must be read outside the instrument, because
17 ; they are not read during the init pass
18 gkwave invalue "wave"
19 gkfreq invalue "freq"
20 gkfreq portk gkfreq, 0.05 ;smooth frequency values
21 endin
22
23 instr 10
24 ktrig changed gkwave
25 if ktrig = 1 then
26 ; forces a new init pass from label newwaveform
27 ; this makes waveform change even if a note is already on
28 reinit newwaveform
29 endif
30
31 ;The envelope is outside the reinit loop, otherwise it is reinitialized
32 kenv adsr p3/5, p3/5, 0.6, p3/2
33
34 newwaveform:
35 prints "instr 1-init"
36 imode tab_i i(gkwave), giwavemodes ;This line is only run every init pass
37 aout vco2 0.2, gkfreq, imode ;This line must be within the reinit section
38 rireturn ;End of reinit section
39
40 outs aout*kenv, aout*kenv
41 endin
42
43 </CsInstruments>
44 <CsScore>
45 i 1 0 3600
46 f 0 3600
47 </CsScore>
48 </CsoundSynthesizer>
49 <bsbPanel>
50 <label>Widgets</label>
51 <objectName/>
52 <x>375</x>
53 <y>213</y>
54 <width>361</width>
55 <height>291</height>
56 <visible>true</visible>
57 <uuid/>
58 <bgcolor mode="background">
59 <r>170</r>
60 <g>170</g>
61 <b>127</b>
62 </bgcolor>
63 <bsbObject version="2" type="BSBDropdown">
64 <objectName>wave</objectName>
65 <x>11</x>
66 <y>8</y>
67 <width>122</width>
68 <height>23</height>
69 <uuid>{a391e289-ce5a-454b-9817-083317d177d8}</uuid>
70 <visible>true</visible>
71 <midichan>0</midichan>
72 <midicc>-3</midicc>
73 <bsbDropdownItemList>
74 <bsbDropdownItem>
75 <name>saw</name>
76 <value>0</value>
77 <stringvalue/>
78 </bsbDropdownItem>
79 <bsbDropdownItem>
80 <name>square</name>
81 <value>1</value>
82 <stringvalue/>
83 </bsbDropdownItem>
84 <bsbDropdownItem>
85 <name>triangle</name>
86 <value>2</value>
87 <stringvalue/>
88 </bsbDropdownItem>
89 </bsbDropdownItemList>
90 <selectedIndex>1</selectedIndex>
91 <randomizable group="0">false</randomizable>
92 </bsbObject>
93 <bsbObject version="2" type="BSBLabel">
94 <objectName/>
95 <x>137</x>
96 <y>8</y>
97 <width>205</width>
98 <height>26</height>
99 <uuid>{ae683ee8-7638-47e1-8b00-bb719111dd7c}</uuid>
100 <visible>true</visible>
101 <midichan>0</midichan>
102 <midicc>-3</midicc>
103 <label>&lt;--Select waveform from this menu</label>
104 <alignment>center</alignment>
105 <font>Helvetica</font>
106 <fontsize>10</fontsize>
107 <precision>3</precision>
108 <color>
109 <r>255</r>
110 <g>255</g>
111 <b>255</b>
112 </color>
113 <bgcolor mode="nobackground">
114 <r>32</r>
115 <g>32</g>
116 <b>32</b>
117 </bgcolor>
118 <bordermode>noborder</bordermode>
119 <borderradius>1</borderradius>
120 <borderwidth>1</borderwidth>
121 </bsbObject>
122 <bsbObject version="2" type="BSBHSlider">
123 <objectName>freq</objectName>
124 <x>11</x>
125 <y>44</y>
126 <width>180</width>
127 <height>20</height>
128 <uuid>{0aada694-ff37-4a9b-a312-5e9fec7b6e6a}</uuid>
129 <visible>true</visible>
130 <midichan>0</midichan>
131 <midicc>-3</midicc>
132 <minimum>200.00000000</minimum>
133 <maximum>800.00000000</maximum>
134 <value>520.00000000</value>
135 <mode>lin</mode>
136 <mouseControl act="jump">continuous</mouseControl>
137 <resolution>-1.00000000</resolution>
138 <randomizable group="0">false</randomizable>
139 </bsbObject>
140 <bsbObject version="2" type="BSBLabel">
141 <objectName/>
142 <x>207</x>
143 <y>39</y>
144 <width>130</width>
145 <height>25</height>
146 <uuid>{f4ca4244-ba74-4152-940e-d6b763ed5666}</uuid>
147 <visible>true</visible>
148 <midichan>0</midichan>
149 <midicc>-3</midicc>
150 <label>Frequency</label>
151 <alignment>left</alignment>
152 <font>Bitstream Vera Sans</font>
153 <fontsize>10</fontsize>
154 <precision>3</precision>
155 <color>
156 <r>255</r>
157 <g>255</g>
158 <b>255</b>
159 </color>
160 <bgcolor mode="nobackground">
161 <r>255</r>
162 <g>255</g>
163 <b>255</b>
164 </bgcolor>
165 <bordermode>noborder</bordermode>
166 <borderradius>1</borderradius>
167 <borderwidth>1</borderwidth>
168 </bsbObject>
169 <bsbObject version="2" type="BSBButton">
170 <objectName>button1</objectName>
171 <x>11</x>
172 <y>71</y>
173 <width>180</width>
174 <height>40</height>
175 <uuid>{eb1f02f6-2cb9-419c-8ae6-ee9b3a8aa079}</uuid>
176 <visible>true</visible>
177 <midichan>0</midichan>
178 <midicc>-3</midicc>
179 <type>event</type>
180 <pressedValue>1.00000000</pressedValue>
181 <stringvalue/>
182 <text>Generate note</text>
183 <image>/</image>
184 <eventLine>i10 0 5</eventLine>
185 <latch>false</latch>
186 <latched>false</latched>
187 </bsbObject>
188 <bsbObject version="2" type="BSBLabel">
189 <objectName/>
190 <x>196</x>
191 <y>69</y>
192 <width>148</width>
193 <height>44</height>
194 <uuid>{72a619e9-5162-49f8-bc95-498c21af9846}</uuid>
195 <visible>true</visible>
196 <midichan>0</midichan>
197 <midicc>-3</midicc>
198 <label>Push this button to generate notes</label>
199 <alignment>center</alignment>
200 <font>Bitstream Vera Sans</font>
201 <fontsize>10</fontsize>
202 <precision>3</precision>
203 <color>
204 <r>255</r>
205 <g>255</g>
206 <b>255</b>
207 </color>
208 <bgcolor mode="nobackground">
209 <r>255</r>
210 <g>255</g>
211 <b>255</b>
212 </bgcolor>
213 <bordermode>noborder</bordermode>
214 <borderradius>1</borderradius>
215 <borderwidth>1</borderwidth>
216 </bsbObject>
217 <bsbObject version="2" type="BSBLabel">
218 <objectName/>
219 <x>10</x>
220 <y>117</y>
221 <width>332</width>
222 <height>131</height>
223 <uuid>{58f8a5b4-2172-4465-bd99-c96814d417d8}</uuid>
224 <visible>true</visible>
225 <midichan>0</midichan>
226 <midicc>-3</midicc>
227 <label/>
228 <alignment>left</alignment>
229 <font>DejaVu Sans</font>
230 <fontsize>10</fontsize>
231 <precision>3</precision>
232 <color>
233 <r>0</r>
234 <g>0</g>
235 <b>0</b>
236 </color>
237 <bgcolor mode="background">
238 <r>153</r>
239 <g>158</g>
240 <b>100</b>
241 </bgcolor>
242 <bordermode>noborder</bordermode>
243 <borderradius>1</borderradius>
244 <borderwidth>1</borderwidth>
245 </bsbObject>
246 <bsbObject version="2" type="BSBLabel">
247 <objectName/>
248 <x>121</x>
249 <y>130</y>
250 <width>91</width>
251 <height>26</height>
252 <uuid>{f2f1ffb7-e499-450f-ac22-a2d9d7c3cae7}</uuid>
253 <visible>true</visible>
254 <midichan>0</midichan>
255 <midicc>-3</midicc>
256 <label>Reinit</label>
257 <alignment>left</alignment>
258 <font>Bitstream Vera Sans</font>
259 <fontsize>16</fontsize>
260 <precision>3</precision>
261 <color>
262 <r>131</r>
263 <g>65</g>
264 <b>48</b>
265 </color>
266 <bgcolor mode="nobackground">
267 <r>255</r>
268 <g>255</g>
269 <b>255</b>
270 </bgcolor>
271 <bordermode>noborder</bordermode>
272 <borderradius>1</borderradius>
273 <borderwidth>1</borderwidth>
274 </bsbObject>
275 <bsbObject version="2" type="BSBLabel">
276 <objectName/>
277 <x>18</x>
278 <y>160</y>
279 <width>313</width>
280 <height>73</height>
281 <uuid>{94d46c4e-b4b7-4c46-85c5-cb2ac3d2d94b}</uuid>
282 <visible>true</visible>
283 <midichan>0</midichan>
284 <midicc>-3</midicc>
285 <label>Using a reinit pass values for vco2 waveform (which is i-rate) are changed. Values for frequency are no longer used with i() so they change whenever the slider changes</label>
286 <alignment>center</alignment>
287 <font>Bitstream Vera Sans</font>
288 <fontsize>10</fontsize>
289 <precision>3</precision>
290 <color>
291 <r>255</r>
292 <g>255</g>
293 <b>255</b>
294 </color>
295 <bgcolor mode="nobackground">
296 <r>255</r>
297 <g>255</g>
298 <b>255</b>
299 </bgcolor>
300 <bordermode>noborder</bordermode>
301 <borderradius>1</borderradius>
302 <borderwidth>1</borderwidth>
303 </bsbObject>
304 </bsbPanel>
305 <bsbPresets>
306 </bsbPresets>
307 <MacOptions>
308 Version: 3
309 Render: Real
310 Ask: Yes
311 Functions: ioObject
312 Listing: Window
313 WindowBounds: 375 213 361 291
314 CurrentView: io
315 IOViewEdit: On
316 Options: -b128 -A -s -m167 -R
317 </MacOptions>
318 <MacGUI>
319 ioView background {43690, 43690, 32639}
320 ioMenu {11, 8} {122, 23} 1 303 "saw,square,triangle" wave
321 ioText {137, 8} {205, 26} label 0.000000 0.00100 "" center "Helvetica" 10 {65280, 65280, 65280} {65280, 65280, 65280} nobackground noborder <--Select waveform from this menu
322 ioSlider {11, 44} {180, 20} 200.000000 800.000000 520.000000 freq
323 ioText {207, 39} {130, 25} label 0.000000 0.00100 "" left "Bitstream Vera Sans" 10 {65280, 65280, 65280} {65280, 65280, 65280} nobackground noborder Frequency
324 ioButton {11, 71} {180, 40} event 1.000000 "button1" "Generate note" "/" i10 0 5
325 ioText {196, 69} {148, 44} label 0.000000 0.00100 "" center "Bitstream Vera Sans" 10 {65280, 65280, 65280} {65280, 65280, 65280} nobackground noborder Push this button to generate notes
326 ioText {10, 117} {332, 131} label 0.000000 0.00100 "" left "DejaVu Sans" 10 {0, 0, 0} {39168, 40448, 25600} nobackground noborder
327 ioText {121, 130} {91, 26} label 0.000000 0.00100 "" left "Bitstream Vera Sans" 16 {33536, 16640, 12288} {65280, 65280, 65280} nobackground noborder Reinit
328 ioText {18, 160} {313, 73} label 0.000000 0.00100 "" center "Bitstream Vera Sans" 10 {65280, 65280, 65280} {65280, 65280, 65280} nobackground noborder Using a reinit pass values for vco2 waveform (which is i-rate) are changed. Values for frequency are no longer used with i() so they change whenever the slider changes
329 </MacGUI>