; Random-cycle "resonant sync" with windowing ; The effect is a kind of synchronous (?) granular ; synthesis with random frequency sine wave sources ; February 2, 2008 ; by Anthony Kozar ; http://www.anthonykozar.net/ ksmps = 1 instr 3 ifreq = cpspch(p4) iloReson = p5 ; scalar for lowest amount of resonance ihiReson = p6 ; scalar for highest amount of resonance itable = p7 ismoothtbl = p8 imaxamp = 10000 anosync init 0.0 ; calculate the range of random "resonance" frequencies ilow = ifreq * iloReson ihigh = ifreq * ihiReson irange = ihigh - ilow ; generate a new random freq between ilow and ihigh arnd linrand irange arndfreq = arnd + ilow ; pair of synced phasors aslavecps init ifreq amaster, async syncphasor ifreq, anosync ; master aslave, async2 syncphasor aslavecps, async ; slave ; check if at beginning of master cycle ; and if so, assign a new random freq to slave phasor ksync init 0 ksync vaget 0, async if (ksync == 1.0) then aslavecps = arndfreq endif ; generate sound aosc tablei aslave, itable, 1 ; use slave phasor to read a (co)sine table asmooth tablei amaster, ismoothtbl, 1 ; use master phasor to read smoothing table aout = aosc * asmooth adeclick linseg 0.0, 0.05, 1.0, p3 - 0.1, 1.0, 0.05, 0.0 out aout * adeclick * imaxamp endin ; adds low and high "resonance" values for the end of the note ; with a lines from start to the end values instr 4 idur = p3 ifreq = cpspch(p4) iloResSt = p5 ; start value for lowest amount of resonance ihiResSt = p6 ; start value for highest amount of resonance iloResEnd = p7 ; end value for lowest amount of resonance ihiResEnd = p8 ; end value for highest amount of resonance itable = p9 ismoothtbl = p10 imaxamp = 10000 anosync init 0.0 ; calculate the range of random "resonance" frequencies ilostart = ifreq * iloResSt ihistart = ifreq * ihiResSt iloend = ifreq * iloResEnd ihiend = ifreq * ihiResEnd ; generate a new random freq between klow and khigh klow line ilostart, idur, iloend khigh line ihistart, idur, ihiend krange = khigh - klow arnd linrand krange arndfreq = arnd + klow ; pair of synced phasors aslavecps init ifreq amaster, async syncphasor ifreq, anosync ; master aslave, async2 syncphasor aslavecps, async ; slave ; check if at beginning of master cycle ; and if so, assign a new random freq to slave phasor ksync init 0 ksync vaget 0, async if (ksync == 1.0) then aslavecps = arndfreq endif ; generate sound aosc tablei aslave, itable, 1 ; use slave phasor to read a (co)sine table asmooth tablei amaster, ismoothtbl, 1 ; use master phasor to read smoothing table aout = aosc * asmooth adeclick linseg 0.0, 0.05, 1.0, p3 - 0.1, 1.0, 0.05, 0.0 out aout * adeclick * imaxamp endin f1 0 16385 10 1 f2 0 16385 -19 1 0.5 270 0.5 ; unipolar inverted cosine f3 0 16385 9 1 1.0 270 ; bipolar inverted cosine f5 0 4097 7 0.0 2048 1.0 2049 0.0 ; unipolar triangle f6 0 4097 7 1.0 2048 1.0 2049 0.0 ; "trapezoid" ; Cosine resonance with a sine table i3 0 5 7.00 0.5 16.0 1 2 i. + . 8.00 1.0 4.0 i. + . 9.00 2.0 10.0 i4 15 5 8.07 0.2 10.0 1.0 1.0 1 2 e