| 1 |
<CsoundSynthesizer> |
| 2 |
|
| 3 |
<CsOptions> |
| 4 |
; Select audio/midi flags here according to platform |
| 5 |
; Audio out Audio in Silent MIDI in |
| 6 |
-odac -iadc -d -M0 ;;;realtime I/O |
| 7 |
</CsOptions> |
| 8 |
|
| 9 |
<CsInstruments> |
| 10 |
;Simple usage of the xtratim opcode |
| 11 |
sr = 44100 |
| 12 |
ksmps = 10 |
| 13 |
nchnls = 2 |
| 14 |
|
| 15 |
; sine wave for oscillators |
| 16 |
gisin ftgen 1, 0, 4096, 10, 1 |
| 17 |
|
| 18 |
instr 1 |
| 19 |
|
| 20 |
inum notnum |
| 21 |
icps cpsmidi |
| 22 |
iamp ampmidi 4000 |
| 23 |
; |
| 24 |
;------- complex envelope block ------ |
| 25 |
xtratim 1 ;extra-time, i.e. release dur |
| 26 |
krel init 0 |
| 27 |
krel release ;outputs release-stage flag (0 or 1 values) |
| 28 |
if (krel == 1) kgoto rel ;if in release-stage goto release section |
| 29 |
; |
| 30 |
;************ attack and sustain section *********** |
| 31 |
kmp1 linseg 0, .03, 1, .05, 1, .07, 0, .08, .5, 4, 1, 50, 1 |
| 32 |
kmp = kmp1*iamp |
| 33 |
kgoto done |
| 34 |
; |
| 35 |
;--------- release section -------- |
| 36 |
rel: |
| 37 |
kmp2 linseg 1, .3, .2, .7, 0 |
| 38 |
kmp = kmp1*kmp2*iamp |
| 39 |
done: |
| 40 |
;------ |
| 41 |
a1 oscili kmp, icps, gisin |
| 42 |
outs a1, a1 |
| 43 |
endin |
| 44 |
|
| 45 |
</CsInstruments> |
| 46 |
|
| 47 |
<CsScore> |
| 48 |
f 0 3600 ;dummy table to wait for realtime MIDI events |
| 49 |
e |
| 50 |
</CsScore> |
| 51 |
|
| 52 |
</CsoundSynthesizer> |