Debian Codegraph @

src/Examples/McCurdy Collection/RealtimeScoreGeneration/DrunkWalk.csd

raw
1 ;Written by Iain McCurdy, 2008
2
3 ;Modified for QuteCsound by René, March 2011
4 ;Tested on Ubuntu 10.04 with csound-float 5.13.0 and QuteCsound svn rev 817
5
6 ;Notes on modifications from original csd:
7
8
9 ;my flags on Ubuntu: -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=null -m0
10 <CsoundSynthesizer>
11 <CsOptions>
12
13 </CsOptions>
14 <CsInstruments>
15 sr = 44100 ;SAMPLE RATE
16 ksmps = 1 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
17 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
18 0dbfs = 1 ;MAXIMUM AMPLITUDE REGARDLESS OF BIT DEPTH
19
20
21 ;INITIAL INDEX VALUE (FROM WHERE IN THE giscale TABLE WE WILL BEGIN READING FROM)
22 giindex init 5
23
24 ;TABLE STORING PCH VALUES USED IN THE DRUNK WALK
25 ; 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
26 giscale ftgen 0,0,32,-2,6.00,6.03,6.05,6.07,6.10,7.00,7.03,7.05,7.07,7.10,8.00,8.03,8.05,8.07,8.10,9.00
27
28
29 instr 10 ;GUI
30 ktrig metro 10
31 if (ktrig == 1) then
32 gkBoundary invalue "Boundary"
33 gkTrigFreq invalue "SpeedWalk"
34 gkoutgain invalue "OutGain"
35 endif
36 endin
37
38 instr 1 ;NOTE TRIGGERING INSTRUMENT
39 ktrigger metro gkTrigFreq ;CREATE A METRONOME OF MOMENTARY '1's
40
41 ; TRIGGER | MINTIM | MAXNUM | INSNUM | WHEN | KDUR
42 schedkwhen ktrigger, 0, 0, p1+1, 0, 0.01 ;TRIGGER NEXT INSTRUMENT METRONOMICALLY
43 endin
44
45 instr 2 ;PROCESS DRUNK WALK
46 istep random 0, 2 ;STEP VALUE SET TO RANDOM FLOAT BETWEEN 0 AND 2
47 istep = (int(istep)*2)-1 ;istep WILL BE EITHER 1 OR -1
48 iindex = giindex + istep ;ADD RANDOM VALUE TO OLD INDEX VALUE
49
50 if gkBoundary!=1 goto SKIP1 ;IF BOUNDARY MODE IS SET TO 'BOUNCE'
51 if iindex==-1 then ;IF INDEX PUSHES BELOW BOUNDARY...
52 iindex=1 ;...SET TO ONE ABOVE MINIMUM
53 elseif iindex==16 then ;IF INDEX PUSHES BEYOND BOUNDARY...
54 iindex=14 ;...BOUNCE TO ONE BELOW BOUNDARY
55 endif ;END OF CONDITIONAL BRANCHING
56 goto SKIP2 ;GOTO LABEL
57 SKIP1:
58 iindex limit iindex, 0, 15 ;LIMIT INDEX VALUE WITHIN TABLE LIMITS
59 if iindex == giindex&&gkBoundary==2 goto SKIP3 ;NO REPEATS
60 SKIP2: ;LABEL
61 turnoff2 3, 1, 1 ;TURNOFF 'OLD' NOTE TO PREVENT POLYPHONY
62 ; i strt dur p4
63 event_i "i", p1+1, 0.01, 8, giindex ;PLAY A NOTE USING NEXT INSTRUMENT
64 SKIP3: ;LABEL
65 giindex = iindex ;GLOBAL INDEX (USED AS THE 'OLD' INDEX VALUE FOR COMPARISON IN NEXT PERFORMANCE PASS)
66 outvalue "Step", istep ;WRITE STEP VALUE TO FL TEXT BOX
67 outvalue "Index", giindex ;WRITE INDEX VALUE TO FL TEXT BOX
68 turnoff ;TURN THIS INSTRUMENT OFF
69 endin
70
71 instr 3
72 ipch table p4, giscale ;READ PCH VALUE FROM TABLE USING INDEX
73 aenv linsegr 0, 0.005, 1, p3-0.105, 1, 0.1, 0 ;AMPLITUDE ENVELOP WITH RELEASE STAGE
74 iplk random 0.1,0.3 ;SLIGHTLY RANDOMIZE PLUCK POSITION
75 asig wgpluck2 0.98, 1, cpspch(ipch), iplk, 0.6 ;PLUCKED STRING PHYSICAL MODEL
76 asig = asig * aenv * gkoutgain ;SCALE AUDIO SIGNAL USING AMPLITUDE ENVELOPE AND OUTPUT GAIN SLIDER
77 outs asig, asig ;SEND AUDIO TO OUTPUTS
78 endin
79 </CsInstruments>
80 <CsScore>
81 i 10 0 3600 ;GUI
82 </CsScore>
83 </CsoundSynthesizer>
84
85 <bsbPanel>
86 <label>Widgets</label>
87 <objectName/>
88 <x>1159</x>
89 <y>92</y>
90 <width>520</width>
91 <height>519</height>
92 <visible>true</visible>
93 <uuid/>
94 <bgcolor mode="background">
95 <r>241</r>
96 <g>226</g>
97 <b>185</b>
98 </bgcolor>
99 <bsbObject version="2" type="BSBLabel">
100 <objectName/>
101 <x>2</x>
102 <y>2</y>
103 <width>510</width>
104 <height>510</height>
105 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
106 <visible>true</visible>
107 <midichan>0</midichan>
108 <midicc>0</midicc>
109 <label>Drunk Walk</label>
110 <alignment>center</alignment>
111 <font>Liberation Sans</font>
112 <fontsize>18</fontsize>
113 <precision>3</precision>
114 <color>
115 <r>0</r>
116 <g>0</g>
117 <b>0</b>
118 </color>
119 <bgcolor mode="background">
120 <r>244</r>
121 <g>248</g>
122 <b>200</b>
123 </bgcolor>
124 <bordermode>border</bordermode>
125 <borderradius>5</borderradius>
126 <borderwidth>2</borderwidth>
127 </bsbObject>
128 <bsbObject version="2" type="BSBLabel">
129 <objectName/>
130 <x>8</x>
131 <y>112</y>
132 <width>220</width>
133 <height>30</height>
134 <uuid>{640b50b7-7200-4f81-8394-89d9843ae939}</uuid>
135 <visible>true</visible>
136 <midichan>0</midichan>
137 <midicc>0</midicc>
138 <label>Speed of Walk (Hz)</label>
139 <alignment>left</alignment>
140 <font>Liberation Sans</font>
141 <fontsize>10</fontsize>
142 <precision>3</precision>
143 <color>
144 <r>0</r>
145 <g>0</g>
146 <b>0</b>
147 </color>
148 <bgcolor mode="nobackground">
149 <r>255</r>
150 <g>255</g>
151 <b>255</b>
152 </bgcolor>
153 <bordermode>noborder</bordermode>
154 <borderradius>1</borderradius>
155 <borderwidth>1</borderwidth>
156 </bsbObject>
157 <bsbObject version="2" type="BSBHSlider">
158 <objectName>SpeedWalk</objectName>
159 <x>8</x>
160 <y>90</y>
161 <width>500</width>
162 <height>27</height>
163 <uuid>{5585fa6f-0f63-4ac3-bf1b-809c2b1d9134}</uuid>
164 <visible>true</visible>
165 <midichan>0</midichan>
166 <midicc>0</midicc>
167 <minimum>0.10000000</minimum>
168 <maximum>20.00000000</maximum>
169 <value>2.01040000</value>
170 <mode>lin</mode>
171 <mouseControl act="jump">continuous</mouseControl>
172 <resolution>-1.00000000</resolution>
173 <randomizable group="0">false</randomizable>
174 </bsbObject>
175 <bsbObject version="2" type="BSBDisplay">
176 <objectName>SpeedWalk</objectName>
177 <x>448</x>
178 <y>112</y>
179 <width>60</width>
180 <height>30</height>
181 <uuid>{b731b52e-e14a-476a-a583-f3b2bd885539}</uuid>
182 <visible>true</visible>
183 <midichan>0</midichan>
184 <midicc>0</midicc>
185 <label>2.010</label>
186 <alignment>right</alignment>
187 <font>Liberation Sans</font>
188 <fontsize>9</fontsize>
189 <precision>3</precision>
190 <color>
191 <r>0</r>
192 <g>0</g>
193 <b>0</b>
194 </color>
195 <bgcolor mode="nobackground">
196 <r>255</r>
197 <g>255</g>
198 <b>255</b>
199 </bgcolor>
200 <bordermode>noborder</bordermode>
201 <borderradius>1</borderradius>
202 <borderwidth>1</borderwidth>
203 </bsbObject>
204 <bsbObject version="2" type="BSBLabel">
205 <objectName/>
206 <x>8</x>
207 <y>173</y>
208 <width>500</width>
209 <height>335</height>
210 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
211 <visible>true</visible>
212 <midichan>0</midichan>
213 <midicc>0</midicc>
214 <label>--------------------------------------------------------------------------------------------------------------------------
215 The Drunk Walk is a common concept of data generation in algorithmic composition. The metaphor is of a drunk person walking home - the person does not walk forward in a straight line, instead randomly taking a step either to the left or to the right. In this example this concept is applied to the generation of note data. Data for two octaves of a pentatonic scale is stored in a GEN 2 function table. A metronome rhythmically triggers notes. Each time a new note is triggered a random choice is made to either take a step up or down this sequence.
216 Whenever the walk attempts to cross the upper or lower boundary one of three responses is taken depending on which 'Boundary Rule' has been chosen by the user:
217 If 'None' has been chosen the boundary limit value is repeated.
218 If 'Bounce' has been chosen the walker 'bounces' off the boundary and a step is taken in the opposite direction.
219 If 'No Repeats' has been chosen the walker holds the boundary limit location but does not play a note.
220 Valuator boxes indicate for the user whether the walker is taking a step up or down the scale and where the walker is within the scale (index). The index value will range from zero to 10.</label>
221 <alignment>left</alignment>
222 <font>Liberation Sans</font>
223 <fontsize>14</fontsize>
224 <precision>3</precision>
225 <color>
226 <r>0</r>
227 <g>0</g>
228 <b>0</b>
229 </color>
230 <bgcolor mode="nobackground">
231 <r>255</r>
232 <g>255</g>
233 <b>255</b>
234 </bgcolor>
235 <bordermode>noborder</bordermode>
236 <borderradius>1</borderradius>
237 <borderwidth>1</borderwidth>
238 </bsbObject>
239 <bsbObject version="2" type="BSBButton">
240 <objectName/>
241 <x>8</x>
242 <y>10</y>
243 <width>80</width>
244 <height>26</height>
245 <uuid>{04d44ebe-12eb-4bb0-a3f5-9e4fd3e7830e}</uuid>
246 <visible>true</visible>
247 <midichan>0</midichan>
248 <midicc>0</midicc>
249 <type>event</type>
250 <pressedValue>1.00000000</pressedValue>
251 <stringvalue/>
252 <text> On / Off</text>
253 <image>/</image>
254 <eventLine>i 1 0 -1</eventLine>
255 <latch>true</latch>
256 <latched>false</latched>
257 </bsbObject>
258 <bsbObject version="2" type="BSBLabel">
259 <objectName/>
260 <x>1</x>
261 <y>56</y>
262 <width>100</width>
263 <height>25</height>
264 <uuid>{7c945fd6-92be-427f-bceb-ab7630e97198}</uuid>
265 <visible>true</visible>
266 <midichan>0</midichan>
267 <midicc>0</midicc>
268 <label>Boundary Rule</label>
269 <alignment>right</alignment>
270 <font>Liberation Sans</font>
271 <fontsize>10</fontsize>
272 <precision>3</precision>
273 <color>
274 <r>0</r>
275 <g>0</g>
276 <b>0</b>
277 </color>
278 <bgcolor mode="nobackground">
279 <r>255</r>
280 <g>255</g>
281 <b>255</b>
282 </bgcolor>
283 <bordermode>noborder</bordermode>
284 <borderradius>1</borderradius>
285 <borderwidth>1</borderwidth>
286 </bsbObject>
287 <bsbObject version="2" type="BSBLabel">
288 <objectName/>
289 <x>217</x>
290 <y>52</y>
291 <width>60</width>
292 <height>26</height>
293 <uuid>{d604a2a6-123b-4883-9e29-bf844e323419}</uuid>
294 <visible>true</visible>
295 <midichan>0</midichan>
296 <midicc>0</midicc>
297 <label>Step</label>
298 <alignment>right</alignment>
299 <font>Liberation Sans</font>
300 <fontsize>10</fontsize>
301 <precision>3</precision>
302 <color>
303 <r>0</r>
304 <g>0</g>
305 <b>0</b>
306 </color>
307 <bgcolor mode="nobackground">
308 <r>255</r>
309 <g>255</g>
310 <b>255</b>
311 </bgcolor>
312 <bordermode>noborder</bordermode>
313 <borderradius>1</borderradius>
314 <borderwidth>1</borderwidth>
315 </bsbObject>
316 <bsbObject version="2" type="BSBLabel">
317 <objectName/>
318 <x>8</x>
319 <y>158</y>
320 <width>220</width>
321 <height>30</height>
322 <uuid>{a79e966a-f875-4240-9f22-44a0a2fde9ac}</uuid>
323 <visible>true</visible>
324 <midichan>0</midichan>
325 <midicc>0</midicc>
326 <label>Output Gain</label>
327 <alignment>left</alignment>
328 <font>Liberation Sans</font>
329 <fontsize>10</fontsize>
330 <precision>3</precision>
331 <color>
332 <r>0</r>
333 <g>0</g>
334 <b>0</b>
335 </color>
336 <bgcolor mode="nobackground">
337 <r>255</r>
338 <g>255</g>
339 <b>255</b>
340 </bgcolor>
341 <bordermode>noborder</bordermode>
342 <borderradius>1</borderradius>
343 <borderwidth>1</borderwidth>
344 </bsbObject>
345 <bsbObject version="2" type="BSBHSlider">
346 <objectName>OutGain</objectName>
347 <x>8</x>
348 <y>136</y>
349 <width>500</width>
350 <height>27</height>
351 <uuid>{774f68ec-19bc-4a55-9a46-523c4f691bc3}</uuid>
352 <visible>true</visible>
353 <midichan>0</midichan>
354 <midicc>0</midicc>
355 <minimum>0.00000000</minimum>
356 <maximum>1.00000000</maximum>
357 <value>0.50000000</value>
358 <mode>lin</mode>
359 <mouseControl act="jump">continuous</mouseControl>
360 <resolution>-1.00000000</resolution>
361 <randomizable group="0">false</randomizable>
362 </bsbObject>
363 <bsbObject version="2" type="BSBDisplay">
364 <objectName>OutGain</objectName>
365 <x>448</x>
366 <y>158</y>
367 <width>60</width>
368 <height>30</height>
369 <uuid>{374358b4-4923-4722-a810-00f8348a4757}</uuid>
370 <visible>true</visible>
371 <midichan>0</midichan>
372 <midicc>0</midicc>
373 <label>0.500</label>
374 <alignment>right</alignment>
375 <font>Liberation Sans</font>
376 <fontsize>9</fontsize>
377 <precision>3</precision>
378 <color>
379 <r>0</r>
380 <g>0</g>
381 <b>0</b>
382 </color>
383 <bgcolor mode="nobackground">
384 <r>255</r>
385 <g>255</g>
386 <b>255</b>
387 </bgcolor>
388 <bordermode>noborder</bordermode>
389 <borderradius>1</borderradius>
390 <borderwidth>1</borderwidth>
391 </bsbObject>
392 <bsbObject version="2" type="BSBDropdown">
393 <objectName>Boundary</objectName>
394 <x>105</x>
395 <y>52</y>
396 <width>116</width>
397 <height>30</height>
398 <uuid>{2940aaee-8fb3-46d5-bb2c-a70e3e47e5cd}</uuid>
399 <visible>true</visible>
400 <midichan>0</midichan>
401 <midicc>0</midicc>
402 <bsbDropdownItemList>
403 <bsbDropdownItem>
404 <name>None</name>
405 <value>0</value>
406 <stringvalue/>
407 </bsbDropdownItem>
408 <bsbDropdownItem>
409 <name>Bounce</name>
410 <value>1</value>
411 <stringvalue/>
412 </bsbDropdownItem>
413 <bsbDropdownItem>
414 <name>No Repeats</name>
415 <value>2</value>
416 <stringvalue/>
417 </bsbDropdownItem>
418 </bsbDropdownItemList>
419 <selectedIndex>0</selectedIndex>
420 <randomizable group="0">false</randomizable>
421 </bsbObject>
422 <bsbObject version="2" type="BSBLabel">
423 <objectName/>
424 <x>364</x>
425 <y>52</y>
426 <width>60</width>
427 <height>26</height>
428 <uuid>{7d62f3ed-2a79-4f34-90a9-81caedc2fcdb}</uuid>
429 <visible>true</visible>
430 <midichan>0</midichan>
431 <midicc>0</midicc>
432 <label>Index</label>
433 <alignment>right</alignment>
434 <font>Liberation Sans</font>
435 <fontsize>10</fontsize>
436 <precision>3</precision>
437 <color>
438 <r>0</r>
439 <g>0</g>
440 <b>0</b>
441 </color>
442 <bgcolor mode="nobackground">
443 <r>255</r>
444 <g>255</g>
445 <b>255</b>
446 </bgcolor>
447 <bordermode>noborder</bordermode>
448 <borderradius>1</borderradius>
449 <borderwidth>1</borderwidth>
450 </bsbObject>
451 <bsbObject version="2" type="BSBDisplay">
452 <objectName>Step</objectName>
453 <x>277</x>
454 <y>52</y>
455 <width>60</width>
456 <height>25</height>
457 <uuid>{45bbc5fc-efb7-4c01-aa9a-c2022e615b89}</uuid>
458 <visible>true</visible>
459 <midichan>0</midichan>
460 <midicc>0</midicc>
461 <label>1.000</label>
462 <alignment>left</alignment>
463 <font>Liberation Sans</font>
464 <fontsize>10</fontsize>
465 <precision>3</precision>
466 <color>
467 <r>0</r>
468 <g>0</g>
469 <b>0</b>
470 </color>
471 <bgcolor mode="nobackground">
472 <r>255</r>
473 <g>255</g>
474 <b>255</b>
475 </bgcolor>
476 <bordermode>border</bordermode>
477 <borderradius>6</borderradius>
478 <borderwidth>1</borderwidth>
479 </bsbObject>
480 <bsbObject version="2" type="BSBDisplay">
481 <objectName>Index</objectName>
482 <x>423</x>
483 <y>52</y>
484 <width>60</width>
485 <height>25</height>
486 <uuid>{0129cc6e-3de1-44fa-a5cf-26287a71e589}</uuid>
487 <visible>true</visible>
488 <midichan>0</midichan>
489 <midicc>0</midicc>
490 <label>11.000</label>
491 <alignment>left</alignment>
492 <font>Liberation Sans</font>
493 <fontsize>10</fontsize>
494 <precision>3</precision>
495 <color>
496 <r>0</r>
497 <g>0</g>
498 <b>0</b>
499 </color>
500 <bgcolor mode="nobackground">
501 <r>255</r>
502 <g>255</g>
503 <b>255</b>
504 </bgcolor>
505 <bordermode>border</bordermode>
506 <borderradius>6</borderradius>
507 <borderwidth>1</borderwidth>
508 </bsbObject>
509 </bsbPanel>
510 <bsbPresets>
511 </bsbPresets>
512 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="false" loopStart="0" loopEnd="0"> </EventPanel>