Debian Codegraph @

src/Examples/FLOSS Manual Examples/03 Csound Language/03F10_Events_collected.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -odac
4 </CsOptions>
5 <CsInstruments>
6 sr = 44100
7 ksmps = 32
8 nchnls = 2
9 0dbfs = 1
10
11 giPch ftgen 0, 0, 4, -2, 7.09, 8.04, 8.03, 8.04
12 seed 0; random seed different each time
13
14 instr 1; master instrument with event_i
15 itimes = 7; number of events to produce
16 icnt = 0; counter
17 istart = 0
18 loop: ;start of the i-time loop
19 idur random 1, 2.9999; duration of each note:
20 idur = int(idur); either 1 or 2
21 itabndx random 0, 3.9999; index for the giPch table:
22 itabndx = int(itabndx); 0-3
23 ipch table itabndx, giPch; random pitch value from the table
24 event_i "i", 3, istart, idur, ipch; new instrument event
25 istart = istart + idur; recalculate start for next scoreline
26 loop_lt icnt, 1, itimes, loop; end of the i-time loop
27 iend = istart + idur; calculate the total duration
28 p3 = iend; set p3 to the sum of all durations
29 print p3; print it
30 endin
31
32 instr 2; master instrument with scoreline_i
33 itimes = 7; number of events to produce
34 icnt = 0; counter
35 istart = 0
36 loop: ;start of the i-time loop
37 idur random 1, 2.9999; duration of each note:
38 idur = int(idur); either 1 or 2
39 itabndx random 0, 3.9999; index for the giPch table:
40 itabndx = int(itabndx); 0-3
41 ipch table itabndx, giPch; random pitch value from the table
42 Sline sprintf "i 3 %d %d %.2f", istart, idur, ipch; new scoreline
43 scoreline_i Sline; execute it
44 puts Sline, 1; print it
45 istart = istart + idur; recalculate start for next scoreline
46 loop_lt icnt, 1, itimes, loop; end of the i-time loop
47 iend = istart + idur; calculate the total duration
48 p3 = iend; set p3 to the sum of all durations
49 print p3; print it
50 endin
51
52 instr 3; plays the notes
53 asig pluck .2, cpspch(p4), cpspch(p4), 0, 1
54 aenv transeg 1, p3, 0, 0
55 outs asig*aenv, asig*aenv
56 endin
57
58 </CsInstruments>
59 <CsScore>
60 i 1 0 1
61 i 2 14 1
62 e
63 </CsScore>
64 </CsoundSynthesizer>
65 ;example by joachim heintz