| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
; Select audio/midi flags here according to platform |
| 4 |
; Audio out |
| 5 |
-odac ;;;RT audio |
| 6 |
; For Non-realtime ouput leave only the line below: |
| 7 |
; -o partikkel_softsync.wav -W ;;; for file output any platform |
| 8 |
</CsOptions> |
| 9 |
|
| 10 |
<CsInstruments> |
| 11 |
|
| 12 |
sr = 44100 |
| 13 |
ksmps = 20 |
| 14 |
nchnls = 2 |
| 15 |
|
| 16 |
; Example by Oeyvind Brandtsegg 2007, revised 2008 |
| 17 |
|
| 18 |
giSine ftgen 0, 0, 65537, 10, 1 |
| 19 |
giCosine ftgen 0, 0, 8193, 9, 1, 1, 90 |
| 20 |
giSigmoRise ftgen 0, 0, 8193, 19, 0.5, 1, 270, 1 ; rising sigmoid |
| 21 |
giSigmoFall ftgen 0, 0, 8193, 19, 0.5, 1, 90, 1 ; falling sigmoid |
| 22 |
|
| 23 |
; ************************************************* |
| 24 |
; example of soft synchronization of two partikkel instances |
| 25 |
; ************************************************* |
| 26 |
instr 1 |
| 27 |
|
| 28 |
|
| 29 |
/*score parameters*/ |
| 30 |
igrainrate = p4 ; grain rate |
| 31 |
igrainsize = p5 ; grain size in ms |
| 32 |
igrainFreq = p6 ; fundamental frequency of source waveform |
| 33 |
iosc2Dev = p7 ; partikkel instance 2 grain rate deviation factor |
| 34 |
iMaxSync = p8 ; max soft sync amount (increasing to this value during length of note) |
| 35 |
|
| 36 |
/*overall envelope*/ |
| 37 |
iattack = 0.001 |
| 38 |
idecay = 0.2 |
| 39 |
isustain = 0.7 |
| 40 |
irelease = 0.2 |
| 41 |
amp linsegr 0, iattack, 1, idecay, isustain, 1, isustain, irelease, 0 |
| 42 |
|
| 43 |
kgrainfreq = igrainrate ; grains per second |
| 44 |
kdistribution = 0 ; periodic grain distribution |
| 45 |
idisttab = -1 ; (default) flat distribution used |
| 46 |
; for grain distribution |
| 47 |
async = 0 ; no sync input |
| 48 |
kenv2amt = 0 ; no secondary enveloping |
| 49 |
ienv2tab = -1 ; default secondary envelope (flat) |
| 50 |
ienv_attack = giSigmoRise ; default attack envelope (flat) |
| 51 |
ienv_decay = giSigmoFall ; default decay envelope (flat) |
| 52 |
ksustain_amount = 0.3 ; time (in fraction of grain dur) at |
| 53 |
; sustain level for each grain |
| 54 |
ka_d_ratio = 0.2 ; balance between attack and decay time |
| 55 |
kduration = igrainsize ; set grain duration in ms |
| 56 |
kamp = 0.2*0dbfs ; amp |
| 57 |
igainmasks = -1 ; (default) no gain masking |
| 58 |
kwavfreq = igrainFreq ; fundamental frequency of source waveform |
| 59 |
ksweepshape = 0 ; shape of frequency sweep (0=no sweep) |
| 60 |
iwavfreqstarttab = -1 ; default frequency sweep start |
| 61 |
; (value in table = 1, which give |
| 62 |
; no frequency modification) |
| 63 |
iwavfreqendtab = -1 ; default frequency sweep end |
| 64 |
; (value in table = 1, which give |
| 65 |
; no frequency modification) |
| 66 |
awavfm = 0 ; no FM input |
| 67 |
ifmamptab = -1 ; default FM scaling (=1) |
| 68 |
kfmenv = -1 ; default FM envelope (flat) |
| 69 |
icosine = giCosine ; cosine ftable |
| 70 |
kTrainCps = kgrainfreq ; set trainlet cps equal to grain |
| 71 |
; rate for single-cycle trainlet in |
| 72 |
; each grain |
| 73 |
knumpartials = 3 ; number of partials in trainlet |
| 74 |
kchroma = 1 ; balance of partials in trainlet |
| 75 |
ichannelmasks = -1 ; (default) no channel masking, |
| 76 |
; all grains to output 1 |
| 77 |
krandommask = 0 ; no random grain masking |
| 78 |
kwaveform1 = giSine ; source waveforms |
| 79 |
kwaveform2 = giSine ; |
| 80 |
kwaveform3 = giSine ; |
| 81 |
kwaveform4 = giSine ; |
| 82 |
iwaveamptab = -1 ; mix of 4 source waveforms and |
| 83 |
; trainlets (set to default) |
| 84 |
asamplepos1 = 0 ; phase offset for reading source waveform |
| 85 |
asamplepos2 = 0 ; |
| 86 |
asamplepos3 = 0 ; |
| 87 |
asamplepos4 = 0 ; |
| 88 |
kwavekey1 = 1 ; original key for source waveform |
| 89 |
kwavekey2 = 1 ; |
| 90 |
kwavekey3 = 1 ; |
| 91 |
kwavekey4 = 1 ; |
| 92 |
imax_grains = 100 ; max grains per k period |
| 93 |
iopcode_id = 1 ; id of opcode, linking partikkel |
| 94 |
; to partikkelsync |
| 95 |
|
| 96 |
a1 partikkel kgrainfreq, kdistribution, idisttab, async, kenv2amt, \ |
| 97 |
ienv2tab,ienv_attack, ienv_decay, ksustain_amount, ka_d_ratio, \ |
| 98 |
kduration, kamp, igainmasks, kwavfreq, ksweepshape, \ |
| 99 |
iwavfreqstarttab, iwavfreqendtab, awavfm, ifmamptab, kfmenv, \ |
| 100 |
icosine, kTrainCps, knumpartials, kchroma, ichannelmasks, \ |
| 101 |
krandommask, kwaveform1, kwaveform2, kwaveform3, kwaveform4, \ |
| 102 |
iwaveamptab, asamplepos1, asamplepos2, asamplepos3, asamplepos4, \ |
| 103 |
kwavekey1, kwavekey2, kwavekey3, kwavekey4, imax_grains, iopcode_id |
| 104 |
|
| 105 |
async1 partikkelsync iopcode_id ; clock pulse output of the |
| 106 |
; partikkel instance above |
| 107 |
ksyncGravity line 0, p3, iMaxSync ; strength of synchronization |
| 108 |
aphase2 init 0 |
| 109 |
asyncPolarity limit (int(aphase2*2)*2)-1, -1, 1 |
| 110 |
; use the phase of partikkelsync instance 2 to find sync |
| 111 |
; polarity for partikkel instance 2. |
| 112 |
; If the phase of instance 2 is less than 0.5, we want to |
| 113 |
; nudge it down when synchronizing, |
| 114 |
; and if the phase is > 0.5 we want to nudge it upwards. |
| 115 |
async1 = async1*ksyncGravity*asyncPolarity ; prepare sync signal |
| 116 |
; with polarity and strength |
| 117 |
|
| 118 |
kgrainfreq2 = igrainrate * iosc2Dev ; grains per second for second partikkel instance |
| 119 |
iopcode_id2 = 2 |
| 120 |
a2 partikkel kgrainfreq2, kdistribution, idisttab, async1, kenv2amt, \ |
| 121 |
ienv2tab, ienv_attack, ienv_decay, ksustain_amount, ka_d_ratio, \ |
| 122 |
kduration, kamp, igainmasks, kwavfreq, ksweepshape, \ |
| 123 |
iwavfreqstarttab, iwavfreqendtab, awavfm, ifmamptab, kfmenv, \ |
| 124 |
icosine, kTrainCps, knumpartials, kchroma, ichannelmasks, \ |
| 125 |
krandommask, kwaveform1, kwaveform2, kwaveform3, kwaveform4, \ |
| 126 |
iwaveamptab, asamplepos1, asamplepos2, asamplepos3, \ |
| 127 |
asamplepos4, kwavekey1, kwavekey2, kwavekey3, kwavekey4, \ |
| 128 |
imax_grains, iopcode_id2 |
| 129 |
|
| 130 |
async2, aphase2 partikkelsync iopcode_id2 |
| 131 |
; clock pulse and phase |
| 132 |
; output of the partikkel instance above, |
| 133 |
; we will only use the phase |
| 134 |
|
| 135 |
outs a1*amp, a2*amp |
| 136 |
|
| 137 |
endin |
| 138 |
|
| 139 |
</CsInstruments> |
| 140 |
<CsScore> |
| 141 |
|
| 142 |
/*score parameters |
| 143 |
igrainrate = p4 ; grain rate |
| 144 |
igrainsize = p5 ; grain size in ms |
| 145 |
igrainFreq = p6 ; frequency of source wave within grain |
| 146 |
iosc2Dev = p7 ; partikkel instance 2 grain rate deviation factor |
| 147 |
iMaxSync = p8 ; max soft sync amount (increasing to this value during length of note) |
| 148 |
*/ |
| 149 |
; GrRate GrSize GrFund Osc2Dev MaxSync |
| 150 |
|
| 151 |
i1 0 10 2 20 880 1.3 0.3 |
| 152 |
s |
| 153 |
i1 0 10 5 20 440 0.8 0.3 |
| 154 |
s |
| 155 |
i1 0 6 55 15 660 1.8 0.45 |
| 156 |
s |
| 157 |
i1 0 6 110 10 440 0.6 0.6 |
| 158 |
s |
| 159 |
i1 0 6 220 3 660 2.6 0.45 |
| 160 |
s |
| 161 |
i1 0 6 220 3 660 2.1 0.45 |
| 162 |
s |
| 163 |
i1 0 6 440 3 660 0.8 0.22 |
| 164 |
s |
| 165 |
|
| 166 |
e |
| 167 |
|
| 168 |
e |
| 169 |
</CsScore> |
| 170 |
</CsoundSynthesizer> |