Debian Codegraph @

src/Examples/FLOSS Manual Examples/04 Sound Synthesis/04A05_Flexible_number_of_partials.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -o dac
4 </CsOptions>
5 <CsInstruments>
6 sr = 44100
7 ksmps = 32
8 nchnls = 2
9 0dbfs = 1
10
11 instr 1 ;master instrument
12 inumparts = p4 ;number of partials
13 ibasfreq = 200 ;base frequency
14 ipart = 1 ;count variable for loop
15 ;loop for inumparts over the ipart variable
16 ;and trigger inumpartss instanes of the subinstrument
17 loop:
18 ifreq = ibasfreq * ipart
19 iamp = 1/ipart/inumparts
20 event_i "i", 10, 0, p3, ifreq, iamp
21 loop_le ipart, 1, inumparts, loop
22 endin
23
24 instr 10 ;subinstrument for playing one partial
25 ifreq = p4 ;frequency of this partial
26 iamp = p5 ;amplitude of this partial
27 aenv transeg 0, .01, 0, iamp, p3-0.1, -10, 0
28 apart poscil aenv, ifreq
29 outs apart, apart
30 endin
31
32 </CsInstruments>
33 <CsScore>
34 ; number of partials
35 i 1 0 3 10
36 i 1 3 3 20
37 i 1 6 3 2
38 </CsScore>
39 </CsoundSynthesizer>
40 ;Example by joachim heintz