Debian Codegraph @

examples/mididefault.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 mididefault.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 mididefault 60, p3 ;ensures that a MIDI-activated instrument will have a positive p3 field
19 midinoteoncps p4, p5 ;puts MIDI key translated to cycles per second into p4, and MIDI velocity into p5
20
21 kvel = p5/127 ;scale midi velocity to 0-1
22 kenv madsr 0.5, 0.8, 0.8, 0.5 ;amplitude envelope multiplied by
23 asig pluck kenv*kvel, p4, p4, 2, 1 ;velocity
24 outs asig, asig
25
26 endin
27 </CsInstruments>
28 <CsScore>
29 f 0 30 ;runs for 30 seconds
30 f 2 0 4096 10 1
31
32 i 1 0 2 440 100 ; play these notes from score as well
33 i 1 + 2 1440 100
34 e
35
36 </CsScore>
37 </CsoundSynthesizer>