| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
-o dac -Ma |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
sr = 44100 |
| 7 |
ksmps = 32 |
| 8 |
nchnls = 2 |
| 9 |
0dbfs = 1 |
| 10 |
|
| 11 |
massign 0, 1 ;all midi channels to instr 1 |
| 12 |
|
| 13 |
instr 1 ;master instrument |
| 14 |
ibasfreq cpsmidi ;base frequency |
| 15 |
iampmid ampmidi 20 ;receive midi-velocity and scale 0-20 |
| 16 |
inparts = int(iampmid)+1 ;exclude zero |
| 17 |
ipart = 1 ;count variable for loop |
| 18 |
;loop for inparts over the ipart variable |
| 19 |
;and trigger inparts instances of the sub-instrument |
| 20 |
loop: |
| 21 |
ifreq = ibasfreq * ipart |
| 22 |
iamp = 1/ipart/inparts |
| 23 |
event_i "i", 10, 0, 1, ifreq, iamp |
| 24 |
loop_le ipart, 1, inparts, loop |
| 25 |
endin |
| 26 |
|
| 27 |
instr 10 ;subinstrument for playing one partial |
| 28 |
ifreq = p4 ;frequency of this partial |
| 29 |
iamp = p5 ;amplitude of this partial |
| 30 |
aenv transeg 0, .01, 0, iamp, p3-.01, -3, 0 |
| 31 |
apart poscil aenv, ifreq |
| 32 |
outs apart/3, apart/3 |
| 33 |
endin |
| 34 |
|
| 35 |
</CsInstruments> |
| 36 |
<CsScore> |
| 37 |
|
| 38 |
</CsScore> |
| 39 |
</CsoundSynthesizer> |
| 40 |
;Example by Joachim Heintz |