Debian Codegraph @

examples/ampmidicurve.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 ; Select audio/midi flags here according to platform
4 ;;;RT audio out, note=p4 and velocity=p5
5 -odac --midi-key=4 --midi-velocity-amp=5
6 ;-iadc ;;;uncomment -iadc if RT audio input is needed too
7 ; For Non-realtime ouput leave only the line below:
8 ; -o ampmidid.wav -W ;;; for file output any platform
9 </CsOptions>
10 <CsInstruments>
11
12 sr = 44100
13 ksmps = 32
14 nchnls = 2
15 0dbfs = 1
16
17 massign 0, 1 ;assign all midi to instr. 1
18
19 instr 1
20
21 isine ftgenonce 0, 0, 4096, 10, 1 ;sine wave
22
23 ihz = cpsmidinn(p4)
24 ivelocity = p5
25 ; MIDI velocity to signal amplitude.
26 iamplitude = ampdb(ivelocity)
27 ; Gain with compressed dynamic range, soft knee.
28 igain ampmidicurve ivelocity, .92, 3
29 print ivelocity, iamplitude, igain
30 a1 oscili 1, ihz, isine
31 aenv madsr 0.05, 0.1, 0.5, 0.2
32 asig = a1 * aenv * igain
33 outs asig, asig
34
35 endin
36
37 </CsInstruments>
38 <CsScore>
39 ; note velocity
40 i 1 0 2 61 100
41 i 1 + 2 65 10
42 e
43 </CsScore>
44 </CsoundSynthesizer>