Debian Codegraph @

examples/sumarray.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 ; Select audio/midi flags here according to platform
4 -n
5 </CsOptions>
6 <CsInstruments>
7 ;example by joachim heintz
8
9 seed 0
10
11 instr 1
12 ;create an array with 10 elements
13 kArr[] init 10
14 ;fill in random numbers and print them out
15 kIndx = 0
16 until kIndx == 10 do
17 kNum random 0, 10
18 kArr[kIndx] = kNum
19 printf "kArr[%d] = %10f\n", kIndx+1, kIndx, kNum
20 kIndx += 1
21 od
22 ;calculate sum of all values and print it out
23 kSum sumarray kArr
24 printf "Sum of all values in kArr = %f\n", kIndx+1, kSum
25 turnoff
26 endin
27 </CsInstruments>
28 <CsScore>
29 i1 0 0.1
30 e
31 </CsScore>
32 </CsoundSynthesizer>