Debian Codegraph @

src/Examples/FLOSS Manual Examples/03 Csound Language/03A09_k-inits_in_multiple_calls_2.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -nm0
4 </CsOptions>
5 <CsInstruments>
6 ksmps = 32
7
8 gkArray[] fillarray 1, 2, 3, 5, 8
9
10 instr Call
11 kNumCall init 1
12 kTrig metro 1
13 if kTrig == 1 then
14 event "i", "Called", 0, 1, kNumCall
15 kNumCall += 1
16 endif
17 endin
18
19 instr Called
20 ;get the number of the instrument instance
21 iNumCall = p4
22 ;set the start index for the while-loop
23 kIndex = 0
24 ;get the init value of kIndex
25 prints "Initialization value of kIndx in call %d = %d\n", iNumCall, i(kIndex)
26 ;perform the while-loop until kIndex equals five
27 while kIndex < lenarray(gkArray) do
28 printf "Index %d of gkArray has value %d\n",
29 kIndex+1, kIndex, gkArray[kIndex]
30 kIndex += 1
31 od
32 ;last value of kIndex is 5 because of increment
33 printks " Last value of kIndex in call %d = %d\n", 0, iNumCall, kIndex
34 ;turn this instance off after first k-cycle
35 turnoff
36 endin
37
38 </CsInstruments>
39 <CsScore>
40 i "Call" 0 1 ;change performance time to 2 to get an error!
41 </CsScore>
42 </CsoundSynthesizer>
43 ;example by joachim heintz