| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
-odac |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
sr = 44100 |
| 7 |
ksmps = 32 |
| 8 |
nchnls = 2 |
| 9 |
0dbfs = 1 |
| 10 |
|
| 11 |
seed 0 |
| 12 |
|
| 13 |
instr 1; time loop with timout. events are triggered by event_i (i-rate) |
| 14 |
loop: |
| 15 |
idurloop random 1, 4; duration of each loop |
| 16 |
timout 0, idurloop, play |
| 17 |
reinit loop |
| 18 |
play: |
| 19 |
idurins random 1, 5; duration of the triggered instrument |
| 20 |
event_i "i", 10, 0, idurins; triggers instrument 10 |
| 21 |
endin |
| 22 |
|
| 23 |
instr 2; time loop with metro. events are triggered by event (k-rate) |
| 24 |
kfreq init 1; give a start value for the trigger frequency |
| 25 |
kTrig metro kfreq |
| 26 |
if kTrig == 1 then ;if trigger impulse: |
| 27 |
kdur random 1, 5; random duration for instr 10 |
| 28 |
event "i", 10, 0, kdur; call instr 10 |
| 29 |
kfreq random .25, 1; set new value for trigger frequency |
| 30 |
endif |
| 31 |
endin |
| 32 |
|
| 33 |
instr 10; triggers 8-13 partials |
| 34 |
inumparts random 8, 14 |
| 35 |
inumparts = int(inumparts); 8-13 as integer |
| 36 |
ibasoct random 5, 10; base pitch in octave values |
| 37 |
ibasfreq = cpsoct(ibasoct) |
| 38 |
ipan random .2, .8; random panning between left (0) and right (1) |
| 39 |
icnt = 0; counter |
| 40 |
loop: |
| 41 |
event_i "i", 100, 0, p3, ibasfreq, icnt+1, inumparts, ipan |
| 42 |
loop_lt icnt, 1, inumparts, loop |
| 43 |
endin |
| 44 |
|
| 45 |
instr 100; plays one partial |
| 46 |
ibasfreq = p4; base frequency of sound mixture |
| 47 |
ipartnum = p5; which partial is this (1 - N) |
| 48 |
inumparts = p6; total number of partials |
| 49 |
ipan = p7; panning |
| 50 |
ifreqgen = ibasfreq * ipartnum; general frequency of this partial |
| 51 |
ifreqdev random -10, 10; frequency deviation between -10% and +10% |
| 52 |
; -- real frequency regarding deviation |
| 53 |
ifreq = ifreqgen + (ifreqdev*ifreqgen)/100 |
| 54 |
ixtratim random 0, p3; calculate additional time for this partial |
| 55 |
p3 = p3 + ixtratim; new duration of this partial |
| 56 |
imaxamp = 1/inumparts; maximum amplitude |
| 57 |
idbdev random -6, 0; random deviation in dB for this partial |
| 58 |
iamp = imaxamp * ampdb(idbdev-ipartnum); higher partials are softer |
| 59 |
ipandev random -.1, .1; panning deviation |
| 60 |
ipan = ipan + ipandev |
| 61 |
aEnv transeg 0, .005, 0, iamp, p3-.005, -10, 0 |
| 62 |
aSine poscil aEnv, ifreq |
| 63 |
aL, aR pan2 aSine, ipan |
| 64 |
outs aL, aR |
| 65 |
prints "ibasfreq = %d, ipartial = %d, ifreq = %d%n",\ |
| 66 |
ibasfreq, ipartnum, ifreq |
| 67 |
endin |
| 68 |
|
| 69 |
</CsInstruments> |
| 70 |
<CsScore> |
| 71 |
i 1 0 300 ;try this, or the next line (or both) |
| 72 |
;i 2 0 300 |
| 73 |
</CsScore> |
| 74 |
</CsoundSynthesizer> |
| 75 |
;example by joachim heintz |