Debian Codegraph @

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

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -odac -Ma
4 </CsOptions>
5 <CsInstruments>
6 sr = 44100
7 ksmps = 32
8 nchnls = 1
9 0dbfs = 1
10
11 giSine ftgen 0,0,2^10,10,1 ; a sine wave
12
13 instr 1
14 ; -- pitch bend --
15 kPchBnd pchbend 0,4 ;read in pitch bend (range -2 to 2)
16 kTrig1 changed kPchBnd ;if 'kPchBnd' changes generate a trigger
17 if kTrig1=1 then
18 printks "Pitch Bend:%f%n",0,kPchBnd ;print kPchBnd to console when it changes
19 endif
20
21 ; -- aftertouch --
22 kAfttch aftouch 0,0.9 ;read in aftertouch (range 0 to 0.9)
23 kTrig2 changed kAfttch ;if 'kAfttch' changes generate a trigger
24 if kTrig2=1 then
25 printks "Aftertouch:%d%n",0,kAfttch ;print kAfttch to console when it changes
26 endif
27
28 ; -- create a sound --
29 iNum notnum ;read in MIDI note number
30 ; MIDI note number + pitch bend are converted to cycles per seconds
31 aSig poscil 0.1,cpsmidinn(iNum+kPchBnd),giSine
32 out aSig ;audio to output
33 endin
34
35 </CsInstruments>
36 <CsScore>
37 </CsScore>
38 <CsoundSynthesizer>
39 ;example by Iain McCurdy