| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
-odac -d -m128 |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
;example by joachim heintz |
| 7 |
sr = 44100 |
| 8 |
ksmps = 32 |
| 9 |
nchnls = 2 |
| 10 |
0dbfs = 1 |
| 11 |
|
| 12 |
ires1 system_i 1,{{ atsa fox.wav fox.ats }} ; default settings |
| 13 |
|
| 14 |
giSine ftgen 0, 0, 1024, 10, 1 |
| 15 |
gSfile = "fox.ats" |
| 16 |
giNumParts ATSinfo gSfile, 3 ;overall number of partials |
| 17 |
giDur ATSinfo gSfile, 7 ;duration |
| 18 |
seed 0 |
| 19 |
|
| 20 |
|
| 21 |
instr ReadOnePartial |
| 22 |
iPartial = p4 |
| 23 |
p3 = giDur |
| 24 |
ktime line 0, giDur, giDur |
| 25 |
prints "Resynthesizing partial number %d.\n", iPartial |
| 26 |
kFq,kAmp ATSread ktime, gSfile, iPartial |
| 27 |
kAmp port kAmp, .1 ;smooth amplitudes - still not satisfactoring |
| 28 |
aOut poscil kAmp, kFq, giSine |
| 29 |
aOut linen aOut, 0, p3, .01 ;anti-click |
| 30 |
outs aOut*10, aOut*10 |
| 31 |
|
| 32 |
;start next instr: normal speed, three loops, pause between loops one second |
| 33 |
event_i "i", "MasterRand", giDur+3, 1, 1, 3, 2 |
| 34 |
endin |
| 35 |
|
| 36 |
instr MasterRand |
| 37 |
;random selections of 10 partials per second, overlapping |
| 38 |
iSpeed = p4 ;speed of reading / playing |
| 39 |
iNumLoops = p5 ;number of loops |
| 40 |
iPause = p6 ;length of pause between loops |
| 41 |
prints "Resynthesizing random partials.\n" |
| 42 |
p3 = (giDur/iSpeed+iPause) * iNumLoops |
| 43 |
;start next instr: half speed, three loops, three seonds pause between loops |
| 44 |
event_i "i", "MasterArp", p3+3, 1, .5, 3, 3 |
| 45 |
;loop over duration plus pause |
| 46 |
loop: |
| 47 |
timout 0, giDur/iSpeed+iPause, play |
| 48 |
reinit loop |
| 49 |
play: |
| 50 |
gkTime line 0, giDur/iSpeed, giDur ;start time from 0 in each loop |
| 51 |
kTrig metro 10 ;10 new partials per second |
| 52 |
;call subinstrument if trigger and no pause |
| 53 |
if kTrig == 1 && gkTime < giDur then |
| 54 |
kPart random 1, giNumParts+.999 |
| 55 |
event "i", "PlayRand", 0, 1, int(kPart) |
| 56 |
endif |
| 57 |
|
| 58 |
endin |
| 59 |
|
| 60 |
instr MasterArp |
| 61 |
;argeggio-like reading and playing of partials |
| 62 |
iSpeed = p4 ;speed of reading / playing |
| 63 |
iNumLoops = p5 ;number of loops |
| 64 |
iPause = p6 ;length of pause between loops |
| 65 |
prints "Arpeggiating partials.\n" |
| 66 |
p3 = (giDur/iSpeed+iPause) * iNumLoops |
| 67 |
loop: |
| 68 |
timout 0, giDur/iSpeed+iPause, play |
| 69 |
reinit loop |
| 70 |
play: |
| 71 |
gkTime line 0, giDur/iSpeed, giDur |
| 72 |
kArp linseg 1, (giDur/iSpeed)/2, giNumParts, (giDur/iSpeed)/2, 1 ;arp up and down |
| 73 |
kTrig metro 10 ;10 new partials per second |
| 74 |
if kTrig == 1 && gkTime < giDur then |
| 75 |
event "i", "PlayArp", 0, 5, int(kArp) |
| 76 |
endif |
| 77 |
|
| 78 |
;exit csound when finished |
| 79 |
event_i "i", "End", p3+5, 1 |
| 80 |
endin |
| 81 |
|
| 82 |
instr PlayRand |
| 83 |
iPartial = p4 |
| 84 |
kFq,kAmp ATSread gkTime, gSfile, iPartial |
| 85 |
kamp port kAmp, .15 ;smooth amplitudes |
| 86 |
aOut poscil kAmp, kFq, giSine |
| 87 |
aOut linen aOut, .01, p3, .01 |
| 88 |
outs aOut, aOut |
| 89 |
endin |
| 90 |
|
| 91 |
instr PlayArp |
| 92 |
kCount init 1 ;k-cycle |
| 93 |
iPartial = p4 |
| 94 |
kFq,kAmp ATSread gkTime, gSfile, iPartial |
| 95 |
if kCount == 1 then ;get freq from first k-cycle |
| 96 |
kModFq = kFq |
| 97 |
;avoid to go with 0 Hz as this blocks the mode filter |
| 98 |
if kModFq == 0 then |
| 99 |
turnoff |
| 100 |
endif |
| 101 |
endif |
| 102 |
iVol random -42, -12 ;db |
| 103 |
iOffset random .01, .1 ;no too regularily ... |
| 104 |
aImp mpulse ampdb(iVol), p3, iOffset |
| 105 |
iQ random 500, 5000 |
| 106 |
aOut mode aImp, kModFq, iQ |
| 107 |
aOut linen aOut, 0, p3, p3/3 |
| 108 |
outs aOut, aOut |
| 109 |
kCount = 2 |
| 110 |
endin |
| 111 |
|
| 112 |
instr End |
| 113 |
exitnow |
| 114 |
endin |
| 115 |
</CsInstruments> |
| 116 |
<CsScore> |
| 117 |
i "ReadOnePartial" 0 1 10 |
| 118 |
e 999 |
| 119 |
</CsScore> |
| 120 |
</CsoundSynthesizer> |