1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
<CsoundSynthesizer>
<CsOptions>
-o dac
-M0
-d
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1
massign 0, 1
ga1 init 0
opcode cpsmid, k, k
kmid xin
#define MIDI2CPS(xmidi) # (440.0*exp(log(2.0)*(($xmidi)-69.0)/12.0)) #
kcps = $MIDI2CPS(kmid)
xout kcps
endop
instr 1
midinoteonkey p4, p5
kpch cpsmid p4
iattack chnget "attack"
idecay chnget "decay"
isustain chnget "sustain"
irelease chnget "release"
k2 linsegr 0, iattack, 1, idecay, isustain, irelease, 0
a1 vco2 k2 * .2, kpch
ga1 = ga1 + a1
endin
instr 2
kcutoff chnget "cutoff"
kresonance chnget "resonance"
a1 moogladder ga1, kcutoff, kresonance
aL, aR reverbsc a1, a1, .72, 5000
outs aL, aR
ga1 = 0
endin
instr allNotesOff
turnoff2 1, 0, 1
turnoff
endin
</CsInstruments>
<CsScore>
f1 0 16384 10 1
i2 0 360000
</CsScore>
</CsoundSynthesizer>
|