Debian Codegraph @

examples/midichn_advanced.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 ; Select audio/midi flags here according to platform
4 -odac -F midichn_advanced.mid ;;;realtime audio out with MIDI file input
5 ; For Non-realtime ouput leave only the line below:
6 ; -o midichn_advanced.wav -W ;;; for file output any platform
7 </CsOptions>
8 <CsInstruments>
9
10 sr = 44100
11 ksmps = 32
12 nchnls = 2
13 0dbfs = 1
14
15 massign 1, 1 ; all channels use instr 1
16 massign 2, 1
17 massign 3, 1
18 massign 4, 1
19 massign 5, 1
20 massign 6, 1
21 massign 7, 1
22 massign 8, 1
23 massign 9, 1
24 massign 10, 1
25 massign 11, 1
26 massign 12, 1
27 massign 13, 1
28 massign 14, 1
29 massign 15, 1
30 massign 16, 1
31
32 gicnt = 0 ; note counter
33
34 instr 1
35
36 gicnt = gicnt + 1 ; update note counter
37 kcnt init gicnt ; copy to local variable
38 ichn midichn ; get channel number
39 istime times ; note-on time
40
41 if (ichn > 0.5) goto l2 ; MIDI note
42 printks "note %.0f (time = %.2f) was activated from the score\\n", \
43 3600, kcnt, istime
44 goto l1
45 l2:
46 printks "note %.0f (time = %.2f) was activated from channel %.0f\\n", \
47 3600, kcnt, istime, ichn
48 l1:
49
50 icps cpsmidi ; convert midi note to pitch
51 kenv madsr 0.1, 0, 0.8, 0.9
52 asig pluck kenv, icps, icps, 1, 1
53 outs asig, asig
54
55 endin
56 </CsInstruments>
57 <CsScore>
58 t 0 60 ;beats per minute
59
60 f 0 8 ;stay active for 8 seconds
61 f 1 0 4096 10 1 ;sine
62
63 e
64 </CsScore>
65 </CsoundSynthesizer>