| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
; Select audio/midi flags here according to platform |
| 4 |
-odac -d ;;;realtime audio out |
| 5 |
;-iadc ;;;uncomment -iadc if realtime audio input is needed too |
| 6 |
</CsOptions> |
| 7 |
<CsInstruments> |
| 8 |
|
| 9 |
; By Stefano Cucchi - 2020 |
| 10 |
|
| 11 |
; Initialize the global variables. |
| 12 |
sr = 44100 |
| 13 |
ksmps = 32 |
| 14 |
nchnls = 2 |
| 15 |
0dbfs = 1 |
| 16 |
|
| 17 |
|
| 18 |
instr 1 |
| 19 |
|
| 20 |
; Instr 1 trigger instr 2: every time you press any key, instr 2 produce a note. |
| 21 |
; The pitch of the tone produced by instr 2 is equal to the ASCII code of the key pressed. |
| 22 |
|
| 23 |
gkNumber, gkPress sensekey |
| 24 |
|
| 25 |
if changed(gkPress) == 1 then |
| 26 |
if (gkPress == 1) then |
| 27 |
event "i", 2, 0, 0.3 |
| 28 |
endif |
| 29 |
endif |
| 30 |
endin |
| 31 |
|
| 32 |
instr 2 |
| 33 |
|
| 34 |
iCps init i(gkNumber) |
| 35 |
print iCps |
| 36 |
asig oscili 0.2, iCps, 1 |
| 37 |
kenvelope linseg 0, 0.1, 1, 0.1, 1, 0.1, 0 |
| 38 |
outs asig*kenvelope, asig*kenvelope |
| 39 |
endin |
| 40 |
|
| 41 |
</CsInstruments> |
| 42 |
<CsScore> |
| 43 |
f 1 0 4096 10 1 1 0.3 0 0.2 0.3 0.5 |
| 44 |
|
| 45 |
i 1 0 2000 |
| 46 |
e |
| 47 |
</CsScore> |
| 48 |
</CsoundSynthesizer> |