| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
-Ma -odac -m128 |
| 4 |
; activate all midi devices, real time sound output, suppress note printing |
| 5 |
</CsOptions> |
| 6 |
<CsInstruments> |
| 7 |
sr = 44100 |
| 8 |
ksmps = 32 |
| 9 |
nchnls = 1 |
| 10 |
0dbfs = 1 |
| 11 |
|
| 12 |
gisine ftgen 0,0,2^12,10,1 |
| 13 |
|
| 14 |
massign 1,3 ; channel 1 notes directed to instr 3 |
| 15 |
massign 2,1 ; channel 2 notes directed to instr 1 |
| 16 |
massign 3,2 ; channel 3 notes directed to instr 2 |
| 17 |
|
| 18 |
instr 1 ; 1 impulse (midi channel 1) |
| 19 |
iChn midichn ; discern what midi channel |
| 20 |
prints "channel:%d%tinstrument: %d%n",iChn,p1 ; print instr and midi channel |
| 21 |
reset: ; label 'reset' |
| 22 |
timout 0, 1, impulse ; jump to 'impulse' for 1 second |
| 23 |
reinit reset ; reinitialize pass from 'reset' |
| 24 |
impulse: ; label 'impulse' |
| 25 |
aenv expon 1, 0.3, 0.0001 ; a short percussive envelope |
| 26 |
aSig poscil aenv, 500, gisine ; audio oscillator |
| 27 |
out aSig ; send audio to output |
| 28 |
endin |
| 29 |
|
| 30 |
instr 2 ; 2 impulses (midi channel 2) |
| 31 |
iChn midichn |
| 32 |
prints "channel:%d%tinstrument: %d%n",iChn,p1 |
| 33 |
reset: |
| 34 |
timout 0, 1, impulse |
| 35 |
reinit reset |
| 36 |
impulse: |
| 37 |
aenv expon 1, 0.3, 0.0001 |
| 38 |
aSig poscil aenv, 500, gisine |
| 39 |
a2 delay aSig, 0.15 ; delay generates a 2nd impulse |
| 40 |
out aSig+a2 ; mix two impulses at the output |
| 41 |
endin |
| 42 |
|
| 43 |
instr 3 ; 3 impulses (midi channel 3) |
| 44 |
iChn midichn |
| 45 |
prints "channel:%d%tinstrument: %d%n",iChn,p1 |
| 46 |
reset: |
| 47 |
timout 0, 1, impulse |
| 48 |
reinit reset |
| 49 |
impulse: |
| 50 |
aenv expon 1, 0.3, 0.0001 |
| 51 |
aSig poscil aenv, 500, gisine |
| 52 |
a2 delay aSig, 0.15 ; delay generates a 2nd impulse |
| 53 |
a3 delay a2, 0.15 ; delay generates a 3rd impulse |
| 54 |
out aSig+a2+a3 ; mix three impulses at output |
| 55 |
endin |
| 56 |
|
| 57 |
</CsInstruments> |
| 58 |
|
| 59 |
<CsScore> |
| 60 |
f 0 300 |
| 61 |
</CsScore> |
| 62 |
<CsoundSynthesizer> |
| 63 |
;example by Iain McCurdy |