| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
-o dac |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
sr = 44100 |
| 7 |
ksmps = 32 |
| 8 |
nchnls = 2 |
| 9 |
0dbfs = 1 |
| 10 |
|
| 11 |
;initialize the global audio variables |
| 12 |
gaBusL init 0 |
| 13 |
gaBusR init 0 |
| 14 |
;make the seed for random values each time different |
| 15 |
seed 0 |
| 16 |
|
| 17 |
instr 1; produces short signals |
| 18 |
loop: |
| 19 |
iDur random .3, 1.5 |
| 20 |
timout 0, iDur, makenote |
| 21 |
reinit loop |
| 22 |
makenote: |
| 23 |
iFreq random 300, 1000 |
| 24 |
iVol random -12, -3; dB |
| 25 |
iPan random 0, 1; random panning for each signal |
| 26 |
aSin oscil3 ampdb(iVol), iFreq, 1 |
| 27 |
aEnv transeg 1, iDur, -10, 0; env in a-rate is cleaner |
| 28 |
aAdd = aSin * aEnv |
| 29 |
aL, aR pan2 aAdd, iPan |
| 30 |
gaBusL = gaBusL + aL; add to the global audio signals |
| 31 |
gaBusR = gaBusR + aR |
| 32 |
endin |
| 33 |
|
| 34 |
instr 2; produces short filtered noise signals (4 partials) |
| 35 |
loop: |
| 36 |
iDur random .1, .7 |
| 37 |
timout 0, iDur, makenote |
| 38 |
reinit loop |
| 39 |
makenote: |
| 40 |
iFreq random 100, 500 |
| 41 |
iVol random -24, -12; dB |
| 42 |
iPan random 0, 1 |
| 43 |
aNois rand ampdb(iVol) |
| 44 |
aFilt reson aNois, iFreq, iFreq/10 |
| 45 |
aRes balance aFilt, aNois |
| 46 |
aEnv transeg 1, iDur, -10, 0 |
| 47 |
aAdd = aRes * aEnv |
| 48 |
aL, aR pan2 aAdd, iPan |
| 49 |
gaBusL = gaBusL + aL; add to the global audio signals |
| 50 |
gaBusR = gaBusR + aR |
| 51 |
endin |
| 52 |
|
| 53 |
instr 3; reverb of gaBus and output |
| 54 |
aL, aR freeverb gaBusL, gaBusR, .8, .5 |
| 55 |
outs aL, aR |
| 56 |
endin |
| 57 |
|
| 58 |
instr 100; clear global audios at the end |
| 59 |
clear gaBusL, gaBusR |
| 60 |
endin |
| 61 |
|
| 62 |
</CsInstruments> |
| 63 |
<CsScore> |
| 64 |
f 1 0 1024 10 1 .5 .3 .1 |
| 65 |
i 1 0 20 |
| 66 |
i 2 0 20 |
| 67 |
i 3 0 20 |
| 68 |
i 100 0 20 |
| 69 |
</CsScore> |
| 70 |
</CsoundSynthesizer> |
| 71 |
;example by joachim heintz |