MUC4441/6445
Electroacoustic Music Composition/Digital I
Granular Synthesis
basic granular orchestra
;basicgrain.orc
; 70_01_1.orc ; synthesis: granular ; basic granular synthesis ; uniform pseudorandom selection of ; grain frequency, inter-grain time, ; and grain length ; coded: 6/95 RKP sr=48000 kr=480 ksmps=100 nchnls=1 instr 1 iamp = p4 ;amplitude of overall event ibpch = p5 ;basepch (center frequency) ibw = p6 ;bandwidth of random frequency variation of grains, ;1 = one semitone variation above and below the base frequency imiigt = p7 ;minimum inter-grain time imxigt = p8 ;maximum inter-grain time imigl = p9 ;minimum grain length imxgl = p10 ;maximum grain length iseed = p11 ;seed value for randh igefn = p12 ;grain envelope function number ;inter-grain time: uniform pseudorandom selection between imiigt and imxgt kr1 randh (imxigt-imiigt)/2,1/imiigt,iseed kigt = imiigt+ (kr1+((imxigt-imiigt)/2)) ;grain length: uniform pseudorandom selection between imigl and imxgl kr2 randh (imxgl-imigl)/2,1/imiigt,iseed kgl = imigl+(kr2+((imxgl-imigl)/2)) ;grain cps random variation: uniform pseudorandom selection. ;mean = ibpch, range = (ibpch) + - ibw kvar randh ibw/12,1/imiigt,iseed ;envelope for overall event kenv linen iamp,p3*.1,p3,p3*.3 reset: timout 0,i(kgl)+i(kigt),contin reinit reset contin: andx line 0,i(kgl),4096 agenv tablei andx,igefn ioct = octpch(ibpch) icps = cpsoct(ioct+i(kvar)) a1 oscili agenv,icps,1 out a1*i(kenv) endin
basic granular score
;basicgrain.sco ;70_01_1.sco ;coded: RKP 6/95 ;iamp amplitude of overall event ;ibpch base pch (center frequency) ;ibw bandwidth of random frequency variation of grains, ;1 = one semitone variation above and below the base frequency ;imiigt minimum inter-grain time ;imxigt maximum inter-grain time ;imigl minimum grain length ;imxgl maximum grain length ;iseed seed value for randh ;igefn grain envelope function number ; GEN functions ; waveform f1 0 4096 10 1 ;sine function for grain production ;grain envelope f31 0 4096 7 0 1024 1 2048 1 1024 0 ;score ;ins strt dur iamp ibpch ibw imiigt imxigt imigl imxgl iseed igefn i1 0 1 10000 9.09 1 .02 .1 .02 .05 .001 31 s ;ins strt dur iamp ibpch ibw imiigt imxigt imigl imxgl iseed igefn i1 0 1 10000 9.09 2 .02 .1 .02 .05 .001 31 s ;ins strt dur iamp ibpch ibw imiigt imxigt imigl imxgl iseed igefn i1 0 1 10000 9.09 3 .02 .1 .02 .05 .001 31 s ;ins strt dur iamp ibpch ibw imiigt imxigt imigl imxgl iseed igefn i1 0 1 10000 9.09 6 .02 .1 .02 .05 .001 31 s ;ins strt dur iamp ibpch ibw imiigt imxigt imigl imxgl iseed igefn i1 0 1 10000 9.09 12 .02 .1 .02 .05 .001 31 e
sample granular orchestra
;*********************************************************** ;* * ;* samplegrain.orc * ;* w/melodic contour added * ;* * ;*********************************************************** ; synthesis: granular ; basic granular sampling engine ; uniform pseudorandom selection of ; grain start point, inter-grain time, ; and grain length ; w/ intergrain time change over event ; w/ grain length change over event ; w/ center freq change over event ; coded: 7/95 JPS ; based: granular design by RK Parks sr=48000 kr=480 ksmps=100 nchnls=2 instr 1 itrnss = p4 ;event pitch (start: 1000=@ orig pitch) itrnsf = p5 ;event pitch (finish: 1000=@ orig pitch) iamp = p6 ;amplitude of overall event imiigts = p7 ;minimum inter-grain time (start) imiigtf = p8 ;minimum inter-grain time (finish) imxigts = p9 ;maximum inter-grain time (start) imxigtf = p10 ;maximum inter-grain time (finish) imigls = p11 ;minimum grain length (start) imiglf = p12 ;minimum grain length (finish) imxgls = p13 ;maximum grain length (start) imxglf = p14 ;maximum grain length (finish) iseed = p15 ;seed value for randh units irvars = p16 ;random var around read pointer (start) irvarf = p17 ;random var around read pointer (finish) ifns = p18 ;sound file source table ismpsz = p19 ;actual sample size ifnrp = p20 ;line function for read pointer ifnm = p21 ;function for melodic contour ifnmt = p22 ;number of repeats of melodic function/p3 ;inter-grain time kmiigt expseg imiigts,p3*.66,imiigtf,p3*.34,imiigts kmxigt expseg imxigts,p3*.66,imxigtf,p3*.34,imxigts kr1 randh (kmxigt-kmiigt)/2,1/kmiigt,iseed kigt = kmiigt+(kr1+((kmxigt-kmiigt)/2)) ;grain length kmxgl expseg imxgls,p3*.66,imxglf,p3*.34,imxgls kmigl expseg imigls,p3*.66,imiglf,p3*.34,imigls kr2 randh (kmxgl-kmigl)/2,1/kmiigt,iseed kgl = kmigl+(kr2+((kmxgl-kmigl)/2)) ;envelope for random stereo placement over event duration: ;uniform pseudorandom selection kstr randh .5,1/kmiigt,iseed ;read pointer newvar: krvar expseg irvars,p3*.34,irvarf,p3*.66,irvars ktrns expseg itrnss,p3*.34,itrnsf,p3*.66,itrnss kr4 oscil ktrns,ifnmt/p3,ifnm kr3 randh krvar*1000,1/kmiigt,iseed krpt oscil1 0,1,p3*2.5,ifnrp kbegg = (krpt*1000)*48+(kr3*48) kendg = kbegg+((kgl*kr4)*48) ;amplitude of overall event kenv linenr iamp,p3*.25,0,0.001 reset: timout 0,i(kigt)+i(kgl),contin reinit reset contin: if i(kendg)>ismpsz goto null if i(kbegg)<0 goto null andx line 0,i(kgl),4096 agenv tablei andx,81 adyn line i(kbegg),i(kgl),i(kendg) a1 tablei adyn,ifns,0,0,0 outs1 (a1*agenv*kenv)*(i(kstr)+.5) outs2 (a1*agenv*kenv)*(1-(i(kstr)+.5)) null: a2 = 0 outs a2,a2 endin
sample granular score
;*********************************************************** ;* * ;* samplegrain.sco * ;* run with samplegrain.orc * ;* * ;*********************************************************** ; coded: jps 7/95 ;itrnss = p4 event pitch (start: 1000=@ orig pitch) ;itrnsf = p5 event pitch (finish: 1000=@ orig pitch) ;iamp = p6 amplitude of overall event ;imiigt = p7 minimum inter-grain time (start) ;imiigt = p8 minimum inter-grain time (finish) ;imxigt = p9 maximum inter-grain time (start) ;imxigt = p10 maximum inter-grain time (finish) ;imigl = p11 minimum grain length (start) ;imigl = p12 minimum grain length (finish) ;imxgl = p13 maximum grain length (start) ;imxgl = p14 maximum grain length (finish) ;iseed = p15 seed value for randh units ;irvar = p16 random var around read pointer (start) ;irvar = p17 random var around read pointer (finish) ;ismpsz = p18 actual sample size ;ifns = p19 sound file source table ;ifnrp = p20 line function for read pointer ;GEN functions ;grain envelope f81 0 4096 8 0 1024 1 2048 1 1024 0 ;input source (substitute a sample of your here; check with the Csound manual for GEN1 options for various file formants) f71 0 32769 1 "CLAR48A.aiff" 0 4 1 ;sample file ;line generators for read pointer f31 0 4096 7 0 4096 1 ;melody function (substitute your melodic sequence function here) f32 0 4096 5 1.000 600 1.000 1 1.189 52 1.189 31 1.237 340 1.237 1 0.944 340 0.944 1 1.782 2730 1.782 ;score ;************************************************* ; single line melodic fragment with clarinet sample ;************************************************* ;ins strt dur itrnss itrnsf iamp imiigts imiigtf imxigts imxigtf imigls imiglf imxgls imxglf iseed irvars irvarf ifns ismpsz ifnrp ifnm i1 0 6 1000 1000 2000 .005 .01 .01 .1 .02 .04 .05 .1 .001 .001 .1 71 30948 31 32 e
- last update 16 September 2019 -