| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
-ndm0 |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
|
| 7 |
kr=100 |
| 8 |
|
| 9 |
;start the python interpreter |
| 10 |
pyinit |
| 11 |
;set variable a to zero at init-time |
| 12 |
pyruni "a = 0" |
| 13 |
|
| 14 |
instr 1 |
| 15 |
;increment variable a by one in each k-cycle |
| 16 |
pyrun "a = a + 1" |
| 17 |
endin |
| 18 |
|
| 19 |
instr 2 |
| 20 |
;print out the state of a at this instrument's initialization |
| 21 |
pyruni "print 'instr 2: a = %d' % a" |
| 22 |
endin |
| 23 |
|
| 24 |
instr 3 |
| 25 |
;perform two more increments and print out immediately |
| 26 |
kCount timeinstk |
| 27 |
pyrun "a += 1" |
| 28 |
pyrun "print 'instr 3: a = %d' % a" |
| 29 |
;;turnoff after k-cycle number two |
| 30 |
if kCount == 2 then |
| 31 |
turnoff |
| 32 |
endif |
| 33 |
endin |
| 34 |
</CsInstruments> |
| 35 |
<CsScore> |
| 36 |
i 1 0 1 ;Adds to a for 1 second |
| 37 |
i 2 1 0 ;Prints a |
| 38 |
i 1 2 2 ;Adds to a for another two seconds |
| 39 |
i 3 4 1 ;Prints a again |
| 40 |
</CsScore> |
| 41 |
</CsoundSynthesizer> |
| 42 |
;Example by Andrés Cabrera and Joachim Heintz |