<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
ginFile ftgen 0, 0 ,0 ,1, "guitar.wav", 0, 0, 0; sound source file
giSine ftgen 0,0,65536,10,1
giCosine ftgen 0,0,8193,9,1,1,90
giSigmoRise ftgen 0,0,8193,19,0.5,1,270,1
giSigmoFall ftgen 0,0,8193,19,0.5,1,90,1
giPan ftgen 0, 0, 32768, -21, 1 ; for panning (random values between 0 and 1)
instr 1; Granulator
/*csound instrument parameters*/
giamp = 0.1
gkspeed = 20.0
gkgrainrate = 25.0
gkgrainsize = 110.0;p6;
gkcent = 0.0; p7 transpositionin cent
gkposrand = 0.0 ;p8 ; time position randomness (offset) of the pointer in ms
gkcentrand = 0.0; p9 transposition randomness in cents
ipan = 0.0;p10; panning narrow(0) to wide(1)
idist = 0.5;p11 ; grain distribution (0=periodic, 1=scattered)
/* get lentgh of audio file for transposition and time pointer*/
ifilen tableng ginFile
ifildur = ifilen / sr
/*sync input*/
async = 0.0; disable external sync
/*grain envelope*/
kenv2amt = 0;no secondary enveloping
ienv2tab = -1; default secondary envelope
ienv_attack = giSigmoRise; attack envelope
ienv_decay = giSigmoFall; decay envelope
ksustain_amount = 0; time(infraction of grain duration) as sustain level for each grain.
ka2dratio = 0.5; balance between attack and decay
/*amplitude*/
igainmask = -1; no gain masking
/*transposition*/
gkcentrand rand gkcentrand; random transposition
iorig = 1/ ifildur; original pitch
kwavfreq = iorig * cent(gkcent + gkcentrand)
/*other pitch related params(disabled)*/
ksweepshape =0 ; no frequency sweep
iwavfreqstarttab = -1; default frequency sweep start
iwavfreqendtab = -1; default frequency sweep
awavfm = 0; no FM input
ifmamptab = -1; default FM scaling (=-1)
kfmenv = -1 ; default FM envelope(flat)
/*trainlet related params(disabled)*/
icosine = giCosine; cosine ftable
kTrainCps = gkgrainrate; set trainlet cps equal to grain rate for single-cycle trainlet in each grain
knumpartials = 1; number of partials in trainlet
kchroma = 1;
/*pannings, using channel mask*/
imid = .5; center
ileftmost = imid - ipan/2
irightmost = imid + ipan/2
giPanthis ftgen 0, 0, 32768, -24, giPan, ileftmost, irightmost; reScales gipan according to ipan
tableiw 0, 0, giPanthis; change index 0
tableiw 32766, 1, giPanthis; and 1 for ichannelmasks
ichannelmasks = giPanthis; ftable for panning
/*random gain masking (disabled)*/
krandommask = 0;
/*source waveforms*/
kwaveform1 = ginFile ; source waveform
kwaveform2 = ginFile ; all 4 sources are the same
kwaveform3 = ginFile
kwaveform4 = ginFile
iwaveamptab = -1 ; (default) equal mix of source waveforms and no amplitude for trainlets
/*timepointers*/
afilposphas phasor gkspeed / ifildur
/*generate random deviaton of the time pointer*/
gkposrandsec = gkposrand / 1000 ; ms -> sec
gkposrand = gkposrandsec / ifildur ; phase value (0-1)
gkrndpos linrand gkposrand; ranodm offset in phase values
/*add random deviation to the time pointer*/
asamplepos1 = afilposphas + gkrndpos; resulting phase values (0-1)
asamplepos2 = asamplepos1
asamplepos3 = asamplepos1
asamplepos4 = asamplepos1
/*original key for each source waveform*/
kwavekey1 = 1
kwavekey2 = kwavekey1
kwavekey3 = kwavekey1
kwavekey4 = kwavekey1
/* maximum number of grains per k-period*/
imax_grains = 100
aL, aR partikkel gkgrainrate, idist, -1, async, kenv2amt, ienv2tab, ienv_attack, ienv_decay,
ksustain_amount, ka2dratio, gkgrainsize, giamp, igainmask, kwavfreq,ksweepshape,
iwavfreqstarttab, iwavfreqendtab, awavfm, ifmamptab,kfmenv,icosine, kTrainCps,
knumpartials, kchroma, ichannelmasks, krandommask, kwaveform1, kwaveform2,
kwaveform3, kwaveform4,iwaveamptab, asamplepos1, asamplepos2, asamplepos3,
asamplepos4,kwavekey1, kwavekey2, kwavekey3, kwavekey4, imax_grains
outs aL, aR
endin
</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
i1 0 z
</CsScore>
</CsoundSynthesizer>