Debian Codegraph @

examples/midipitchbend.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 ; Select audio/midi flags here according to platform
4 -odac -M1 ;;;realtime audio out and midi in
5 ;-iadc ;;;uncomment -iadc if realtime audio input is needed too
6 ; For Non-realtime ouput leave only the line below:
7 ; -o midipitchbend.wav -W ;;; for file output any platform
8 </CsOptions>
9 <CsInstruments>
10
11 sr = 44100
12 ksmps = 32
13 nchnls = 2
14 0dbfs = 1
15
16 instr 1
17
18 midinoteonoct p4, p5 ;gets a MIDI note number value as octave-point-decimal value into p4, and MIDI velocity into p5
19
20 kvel = p5/127 ;scale midi velocity to 0-1
21 kpb init 0
22 midipitchbend kpb
23 printk2 kpb ;display the pitch-bend value when it changes
24 koct = p4+kpb ;add pitchbend values to octave-point-decimal value
25 kcps = cpsoct(koct) ;convert octave-point-decimal value into Hz
26 kenv madsr 0.5, 0.8, 0.8, 0.5 ;amplitude envelope multiplied by
27 asig vco2 kenv*kvel, kcps ;velocity value
28 outs asig, asig
29
30 endin
31 </CsInstruments>
32 <CsScore>
33 f 0 30 ;runs for 30 seconds
34 f 2 0 4096 10 1
35
36 i 1 0 2 8.000 100 ; play these notes from score as well
37 i 1 + 2 8.917 100
38 e
39
40 </CsScore>
41 </CsoundSynthesizer>
42