| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
-Ma |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
sr = 44100 |
| 7 |
ksmps = 32 |
| 8 |
nchnls = 1 |
| 9 |
0dbfs = 1 |
| 10 |
|
| 11 |
massign 0, 1 ;assign all incoming midi to instr 1 |
| 12 |
instr 1 ;global midi instrument, calling instr 2.cc.nnn |
| 13 |
;(c=channel, n=note number) |
| 14 |
inote notnum ;get midi note number |
| 15 |
ichn midichn ;get midi channel |
| 16 |
instrnum = 2 + ichn/100 + inote/100000 ;make fractional instr number |
| 17 |
; -- call with indefinite duration |
| 18 |
event_i "i", instrnum, 0, -1, ichn, inote |
| 19 |
kend release ;get a "1" if instrument is turned off |
| 20 |
if kend == 1 then |
| 21 |
event "i", -instrnum, 0, 1 ;then turn this instance off |
| 22 |
endif |
| 23 |
endin |
| 24 |
|
| 25 |
instr 2 |
| 26 |
ichn = int(frac(p1)*100) |
| 27 |
inote = round(frac(frac(p1)*100)*1000) |
| 28 |
prints "instr %f: ichn = %f, inote = %f%n", p1, ichn, inote |
| 29 |
printks "instr %f playing!%n", 1, p1 |
| 30 |
endin |
| 31 |
|
| 32 |
</CsInstruments> |
| 33 |
<CsScore> |
| 34 |
</CsScore> |
| 35 |
</CsoundSynthesizer> |
| 36 |
;Example by Joachim Heintz, using code of Victor Lazzarini |