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