| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
; Select audio/midi flags here according to platform |
| 4 |
-odac ;;;realtime audio out |
| 5 |
;-iadc ;;;uncomment -iadc if realtime audio input is needed too |
| 6 |
; For Non-realtime ouput leave only the line below: |
| 7 |
; -o turnoff2.wav -W ;;; for file output any platform |
| 8 |
</CsOptions> |
| 9 |
<CsInstruments> |
| 10 |
|
| 11 |
sr = 44100 ;samples per second for sound |
| 12 |
ksmps = 32 |
| 13 |
nchnls = 2 |
| 14 |
0dbfs = 1 |
| 15 |
|
| 16 |
; example by Lou Cohen |
| 17 |
|
| 18 |
gisine ftgen 1, 0, 131073, 9, 1, 1, 0 ;single sine tone |
| 19 |
|
| 20 |
;----------------------------------------- |
| 21 |
instr 2 ;start |
| 22 |
ktrigger init 0 |
| 23 |
if (ktrigger = 0) then |
| 24 |
kMultiple = 1.1 |
| 25 |
kHz = 440 |
| 26 |
kAmp = (0dbfs/10) |
| 27 |
;startup four instances of instrument 200 |
| 28 |
event "i", 200, 0, 3000, kAmp, kHz |
| 29 |
kAmp = kAmp * 0.75 |
| 30 |
kHz = kHz * kMultiple |
| 31 |
event "i", 200, 0, 3000, kAmp, kHz |
| 32 |
kAmp = kAmp * 0.75 |
| 33 |
kHz = kHz * kMultiple |
| 34 |
event "i", 200, 0, 3000, kAmp, kHz |
| 35 |
kAmp = kAmp * 0.75 |
| 36 |
kHz = kHz * kMultiple |
| 37 |
event "i", 200, 0, 3000, kAmp, kHz |
| 38 |
kAmp = kAmp * 0.75 |
| 39 |
kHz = kHz * kMultiple |
| 40 |
ktrigger = 1 |
| 41 |
endif |
| 42 |
endin |
| 43 |
;--------------------------------------------- |
| 44 |
instr 3 ;after 10 seconds, turn off the instruments |
| 45 |
ktrigger init 1 |
| 46 |
if (ktrigger==1) then |
| 47 |
turnoff2 200, 1, 1 ;turn off must recently started instrument instance |
| 48 |
kactive active 200 ;find out how many are still active |
| 49 |
printk2 kactive ;print mainly to show progress |
| 50 |
turnoff2 200, 0, 1 ;turn off all the rest of the instruments |
| 51 |
kactive active 200 ;find out how many are still active |
| 52 |
printk2 kactive, 10 ;print to show progress |
| 53 |
endif |
| 54 |
endin |
| 55 |
;---------------------------------------------------- |
| 56 |
instr 200 ;play the tone |
| 57 |
kEnv linen 1, 0.1, p3, 0.1 |
| 58 |
ar oscil kEnv*p4, p5, 1 |
| 59 |
outs ar, ar |
| 60 |
print p4, p5 |
| 61 |
endin |
| 62 |
</CsInstruments> |
| 63 |
<CsScore> |
| 64 |
i2 0 0.1 |
| 65 |
i3 10 0.1 |
| 66 |
</CsScore> |
| 67 |
</CsoundSynthesizer> |