| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
; Select audio/midi flags here according to platform |
| 4 |
-odac ;;;realtime audio out |
| 5 |
;-iadc ;;;uncomment -iadc if RT audio input is needed too |
| 6 |
; For Non-realtime ouput leave only the line below: |
| 7 |
; -o i_statement.wav -W ;;; for file output any platform |
| 8 |
</CsOptions> |
| 9 |
<CsInstruments> |
| 10 |
|
| 11 |
sr = 44100 |
| 12 |
ksmps = 32 |
| 13 |
nchnls = 2 |
| 14 |
0dbfs = 1 |
| 15 |
|
| 16 |
instr 10 |
| 17 |
|
| 18 |
icps init cpspch(p4) ; Get target pitch from score event |
| 19 |
iportime init abs(p3)/7 ; Portamento time dep on note length |
| 20 |
iamp0 init p5 ; Set default amps |
| 21 |
iamp1 init p5 |
| 22 |
iamp2 init p5 |
| 23 |
|
| 24 |
itie tival ; Check if this note is tied, |
| 25 |
if itie == 1 igoto nofadein ; if not fade in |
| 26 |
iamp0 init 0 |
| 27 |
|
| 28 |
nofadein: |
| 29 |
if p3 < 0 igoto nofadeout ; Check if this note is held, if not fade out |
| 30 |
iamp2 init 0 |
| 31 |
|
| 32 |
nofadeout: |
| 33 |
; Now do amp from the set values: |
| 34 |
kamp linseg iamp0, .03, iamp1, abs(p3)-.03, iamp2 |
| 35 |
|
| 36 |
; Skip rest of initialization on tied note: |
| 37 |
tigoto tieskip |
| 38 |
|
| 39 |
kcps init icps ; Init pitch for untied note |
| 40 |
kcps port icps, iportime, icps ; Drift towards target pitch |
| 41 |
|
| 42 |
kpw oscil .4, rnd(1), 1, rnd(.7) ; A simple triangle-saw oscil |
| 43 |
ar vco kamp, kcps, 3, kpw+.5, 1, 1/icps |
| 44 |
|
| 45 |
; (Used in testing - one may set ipch to cpspch(p4+2) |
| 46 |
; and view output spectrum) |
| 47 |
; ar oscil kamp, kcps, 1 |
| 48 |
|
| 49 |
outs ar, ar |
| 50 |
|
| 51 |
tieskip: ; Skip some initialization on tied note |
| 52 |
|
| 53 |
endin |
| 54 |
</CsInstruments> |
| 55 |
<CsScore> |
| 56 |
f1 0 8192 10 1 ; Sine |
| 57 |
|
| 58 |
i10.1 0 -1 7.00 .15 |
| 59 |
i10.2 0 -1 7.04 |
| 60 |
i10.3 0 -1 7.07 |
| 61 |
i10.1 1 -1 8.00 |
| 62 |
i10.2 1 -1 8.04 |
| 63 |
i10.3 1 -1 8.07 |
| 64 |
i10.1 2 1 7.11 |
| 65 |
i10.2 2 1 8.04 |
| 66 |
i10.3 2 1 8.07 |
| 67 |
e |
| 68 |
</CsScore> |
| 69 |
</CsoundSynthesizer> |
| 70 |
|