| 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 |
|
| 16 |
massign 0, 1 ;assign all midi to instr. 1 |
| 17 |
|
| 18 |
instr 1 |
| 19 |
|
| 20 |
isine ftgenonce 0, 0, 4096, 10, 1 ;sine wave |
| 21 |
|
| 22 |
ihz = cpsmidinn(p4) |
| 23 |
ivelocity = p5 |
| 24 |
idb ampmidid ivelocity, 20 ;map to dynamic range of 20 dB. |
| 25 |
idb = idb + 60 ;limit range to 60 to 80 decibels |
| 26 |
iamplitude = ampdb(idb) ;loudness in dB to signal amplitude |
| 27 |
|
| 28 |
a1 oscili iamplitude, ihz, isine |
| 29 |
aenv madsr 0.05, 0.1, 0.5, 0.2 |
| 30 |
asig = a1 * aenv |
| 31 |
outs asig, asig |
| 32 |
|
| 33 |
endin |
| 34 |
|
| 35 |
</CsInstruments> |
| 36 |
<CsScore> |
| 37 |
; note velocity |
| 38 |
i 1 0 2 61 100 |
| 39 |
i 1 + 2 65 10 |
| 40 |
e |
| 41 |
</CsScore> |
| 42 |
</CsoundSynthesizer> |