Debian Codegraph @

src/Examples/FLOSS Manual Examples/07 MIDI/07E03_midiout_cc.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 ; amend device number accordingly
4 -Q999
5 </CsOptions>
6 <CsInstruments>
7 ksmps = 32 ; no audio so sr and nchnls irrelevant
8
9 instr 1
10 ; play a midi note
11 ; read in values from p-fields
12 ichan init p4
13 inote init p5
14 iveloc init p6
15 kskip init 0 ; 'skip' flag ensures that note-on is executed just once
16 if kskip=0 then
17 midiout 144, ichan, inote, iveloc; send raw midi data (note on)
18 kskip = 1 ; flip flag to prevent repeating the above line
19 endif
20 krelease release ; normally zero, on final k pass this will output 1
21 if krelease=1 then ; if we are on the final k pass...
22 midiout 144, ichan, inote, 0 ; send a note off
23 endif
24
25 ; send continuous controller data
26 iCCnum = p7
27 kCCval line 0, p3, 127.1 ; continuous controller data function
28 kCCval = int(kCCval) ; convert data function to integers
29 ktrig changed kCCval ; generate a trigger each time kCCval changes
30 if ktrig=1 then ; if kCCval has changed...
31 midiout 176, ichan, iCCnum, kCCval ; ...send a controller message
32 endif
33 endin
34
35 </CsInstruments>
36 <CsScore>
37 ;p1 p2 p3 p4 p5 p6 p7
38 i 1 0 5 1 60 100 1
39 f 0 7 ; extending performance time prevents note-offs from being lost
40 </CsScore>
41 </CsoundSynthesizer>
42 ;example by Iain McCurdy