Debian Codegraph @

examples/OSCmidircv.csd

raw
1 <CsoundSynthesizer>
2 ; network_recv.csd
3 <CsOptions>
4 ; Select audio/midi flags here according to platform
5 ; Audio out Audio in
6 -odac -iadc ;;;RT audio I/O
7 </CsOptions>
8 <CsInstruments>
9
10 sr = 44100
11 ksmps = 128
12 nchnls = 1
13
14 ; Example by Jonathan Murphy and Andres Cabrera 2007
15 ; Use file OSCmidisend.csd to generate OSC events for this file
16
17 0dbfs = 1
18
19 gilisten OSCinit 47120
20
21 gisin ftgen 1, 0, 16384, 10, 1
22 givel ftgen 2, 0, 128, -2, 0
23 gicc ftgen 3, 0, 128, -7, 100, 128, 100 ;Default all controllers to 100
24
25 ;Define scale tuning
26 giji_12 ftgen 202, 0, 32, -2, 12, 2, 256, 60, 1, 16/15, 9/8, 6/5, 5/4, 4/3, 7/5, \
27 3/2, 8/5, 5/3, 9/5, 15/8, 2
28
29 #define DEST #"/midi"#
30 ; Use controller number 7 for volume
31 #define VOL #7#
32
33 turnon 1000
34
35
36 instr 1000
37
38 kst init 0
39 kch init 0
40 kd1 init 0
41 kd2 init 0
42
43 next:
44
45 kk OSClisten gilisten, $DEST, "iiii", kst, kch, kd1, kd2
46
47 if (kk == 0) goto done
48
49 printks "kst = %i, kch = %i, kd1 = %i, kd2 = %i\\n", \
50 0, kst, kch, kd1, kd2
51
52 if (kst == 176) then
53 ;Store controller information in a table
54 tablew kd2, kd1, gicc
55 endif
56
57 if (kst == 144) then
58 ;Process noteon and noteoff messages.
59 kkey = kd1
60 kvel = kd2
61 kcps cpstun kvel, kkey, giji_12
62 kamp = kvel/127
63
64 if (kvel == 0) then
65 turnoff2 1001, 4, 1
66 elseif (kvel > 0) then
67 event "i", 1001, 0, -1, kcps, kamp
68 endif
69 endif
70
71 kgoto next ;Process all events in queue
72
73 done:
74 endin
75
76
77
78 instr 1001 ;Simple instrument
79
80 icps init p4
81 kvol table $VOL, gicc ;Read MIDI volume from controller table
82 kvol = kvol/127
83
84 aenv linsegr 0, .003, p5, 0.03, p5 * 0.5, 0.3, 0
85 aosc oscil aenv, icps, gisin
86
87 out aosc * kvol
88 endin
89
90
91 </CsInstruments>
92 <CsScore>
93 f 0 3600 ;Dummy f-table
94 e
95 </CsScore>
96 </CsoundSynthesizer>