| 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 readk4.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 |
giSine ftgen 0, 0, 2^10, 10, 1 |
| 17 |
|
| 18 |
instr 1 ;writes four control signals to a file |
| 19 |
kcf randh 950, 1, 2, 1, 1050 ;generates one random number between 100 and 2000 per second |
| 20 |
kq randh 10, 1, 2, 1, 11 ;generates another random number between 1 and 21 per second |
| 21 |
kdb randh 9, 1, 2, 1, -15 ;amplitudes in dB between -24 and -6 |
| 22 |
kpan randh .5, 1, 2, 1, .5 ;panning between 0 and 1 |
| 23 |
dumpk4 kcf, kq, kdb, kpan, "dumpk4.txt", 8, 1 ;writes the control signals |
| 24 |
prints "WRITING:\n" |
| 25 |
printks "kcf = %f, kq = %f, kdb = %f, kpan = %f\n", 1, kcf, kq, kdb, kpan ;prints them |
| 26 |
endin |
| 27 |
|
| 28 |
instr 2 ;reads the file written by instr 1 |
| 29 |
kcf,kq,kdb,kp readk4 "dumpk4.txt", 8, 1 |
| 30 |
prints "READING:\n" |
| 31 |
printks "kcf = %f, kq = %f, kdb = %f, kpan = %f\n", 1, kcf, kq, kdb, kp ;prints values |
| 32 |
kdb lineto kdb, .1 ;smoothing amp transition |
| 33 |
kp lineto kp, .1 ;smoothing pan transition |
| 34 |
anoise rand ampdb(kdb), 2, 1 |
| 35 |
kbw = kcf/kq ;bandwidth of resonant filter |
| 36 |
abp reson anoise, kcf, kbw |
| 37 |
aout balance abp, anoise |
| 38 |
aL, aR pan2 aout, kp |
| 39 |
outs aL, aR |
| 40 |
endin |
| 41 |
|
| 42 |
</CsInstruments> |
| 43 |
<CsScore> |
| 44 |
i 1 0 5 |
| 45 |
i 2 5 5 |
| 46 |
e |
| 47 |
</CsScore> |
| 48 |
</CsoundSynthesizer> |