|
|
@@ -0,0 +1,309 @@ |
|
|
nebconfigbegin |
|
|
sr,48000 |
|
|
ksmps,64 |
|
|
-B,2048 |
|
|
-b,512 |
|
|
nebconfigend |
|
|
|
|
|
giBufSize = 3; buffer length in seconds at time 1 |
|
|
giftl ftgen 0, 0, -(giBufSize * sr), 7, 0 |
|
|
giftr ftgen 0, 0, -(giBufSize * sr), 7, 0 |
|
|
giCosine ftgen 0, 0, 8193, 9, 1, 1, 90 |
|
|
|
|
|
; windows, tables, and other misc globals |
|
|
giwindowtablesize = 512 |
|
|
giHamming ftgen 0, 0, giwindowtablesize, 20, 9, 1 |
|
|
giBartlett ftgen 0, 0, giwindowtablesize, 20, 3 |
|
|
giBlkHarris ftgen 0, 0, giwindowtablesize, 20, 5 |
|
|
giGaussian ftgen 0, 0, giwindowtablesize, 20, 6 |
|
|
giRectangle ftgen 0, 0, giwindowtablesize, 20, 8, 1 |
|
|
giRampUp ftgen 0, 0, giwindowtablesize, 7, 0, 15.0 * (giwindowtablesize / 16.0), 1, (giwindowtablesize / 16.0), 0 |
|
|
giRampDown ftgen 0, 0, giwindowtablesize, 7, 0,(giwindowtablesize / 16.0),1 , 15.0 * (giwindowtablesize / 16.0), 0 |
|
|
giWinMix ftgen 0, 0, giwindowtablesize, 20, 9, 1 |
|
|
giWin ftgen 0, 0, giwindowtablesize, 20, 9, 1 |
|
|
giWinB ftgen 0, 0, giwindowtablesize, 20, 9, 1 |
|
|
|
|
|
; please ignore this one. |
|
|
gigrainsizes ftgen 0, 0, 256, 2, \ |
|
|
0.032000, 0.032344, 0.032688, 0.033031, 0.033406, 0.033750, 0.034125, 0.034500, \ |
|
|
0.034875, 0.035250, 0.035656, 0.036031, 0.036437, 0.036812, 0.037219, 0.037625, \ |
|
|
0.038031, 0.038469, 0.038875, 0.039281, 0.039719, 0.040156, 0.040594, 0.041031, \ |
|
|
0.041469, 0.041938, 0.042406, 0.042844, 0.043312, 0.043781, 0.044281, 0.044750, \ |
|
|
0.045250, 0.045719, 0.046219, 0.046719, 0.047250, 0.047750, 0.048281, 0.048813, \ |
|
|
0.049344, 0.049875, 0.050406, 0.050969, 0.051531, 0.052094, 0.052656, 0.053219, \ |
|
|
0.053812, 0.054375, 0.054969, 0.055594, 0.056188, 0.056781, 0.057406, 0.058031, \ |
|
|
0.058687, 0.059312, 0.059969, 0.060625, 0.061281, 0.061937, 0.062625, 0.063281, \ |
|
|
0.064000, 0.064687, 0.065375, 0.066094, 0.066812, 0.067531, 0.068281, 0.069031, \ |
|
|
0.069781, 0.070531, 0.071313, 0.072094, 0.072875, 0.073656, 0.074469, 0.075281, \ |
|
|
0.076094, 0.076938, 0.077750, 0.078594, 0.079469, 0.080344, 0.081219, 0.082094, \ |
|
|
0.082969, 0.083875, 0.084812, 0.085719, 0.086656, 0.087594, 0.088563, 0.089531, \ |
|
|
0.090500, 0.091469, 0.092469, 0.093469, 0.094500, 0.095531, 0.096562, 0.097625, \ |
|
|
0.098687, 0.099750, 0.100844, 0.101938, 0.103063, 0.104188, 0.105313, 0.106469, \ |
|
|
0.107625, 0.108781, 0.109969, 0.111187, 0.112375, 0.113594, 0.114844, 0.116094, \ |
|
|
0.117375, 0.118625, 0.119938, 0.121250, 0.122563, 0.123906, 0.125250, 0.126594, \ |
|
|
0.128000, 0.129375, 0.130781, 0.132219, 0.133656, 0.135094, 0.136594, 0.138063, \ |
|
|
0.139563, 0.141094, 0.142625, 0.144187, 0.145750, 0.147344, 0.148938, 0.150562, \ |
|
|
0.152188, 0.153875, 0.155531, 0.157219, 0.158938, 0.160688, 0.162438, 0.164187, \ |
|
|
0.165969, 0.167781, 0.169625, 0.171469, 0.173344, 0.175219, 0.177125, 0.179063, \ |
|
|
0.181000, 0.182969, 0.184969, 0.186969, 0.189031, 0.191062, 0.193156, 0.195250, \ |
|
|
0.197375, 0.199531, 0.201719, 0.203906, 0.206125, 0.208375, 0.210656, 0.212938, \ |
|
|
0.215250, 0.217594, 0.219969, 0.222375, 0.224781, 0.227219, 0.229719, 0.232219, \ |
|
|
0.234750, 0.237281, 0.239875, 0.242500, 0.245125, 0.247812, 0.250500, 0.253219, \ |
|
|
0.256000, 0.258781, 0.261594, 0.264437, 0.267313, 0.270219, 0.273188, 0.276156, \ |
|
|
0.279156, 0.282187, 0.285281, 0.288375, 0.291500, 0.294687, 0.297906, 0.301156, \ |
|
|
0.304406, 0.307750, 0.311094, 0.314469, 0.317906, 0.321375, 0.324875, 0.328406, \ |
|
|
0.331969, 0.335594, 0.339250, 0.342938, 0.346687, 0.350438, 0.354250, 0.358125, \ |
|
|
0.362031, 0.365969, 0.369937, 0.373969, 0.378063, 0.382156, 0.386344, 0.390531, \ |
|
|
0.394781, 0.399094, 0.403438, 0.407844, 0.412281, 0.416750, 0.421312, 0.425875, \ |
|
|
0.430531, 0.435219, 0.439937, 0.444750, 0.449594, 0.454469, 0.459437, 0.464438, \ |
|
|
0.469500, 0.474594, 0.479781, 0.485000, 0.490281, 0.495625, 0.501000, 0.506469, \ |
|
|
0.512000 |
|
|
|
|
|
instr 1 |
|
|
|
|
|
ainl, ainr inch 1, 2 |
|
|
|
|
|
; inits |
|
|
ilen tableng giftl ; tables BETTER be the same size |
|
|
aphasor init 0 |
|
|
awriteindex init 0 |
|
|
areadphasor init 0 |
|
|
areadtime init 0 |
|
|
asyncin init 0 |
|
|
kloopstart init 0 |
|
|
kdensity init 0 |
|
|
kpitch init 0 |
|
|
aspeed init 0 |
|
|
asigl init 0 |
|
|
asigr init 0 |
|
|
amixl init 0 |
|
|
amixr init 0 |
|
|
kfirsttime init 1 |
|
|
|
|
|
seed 0 |
|
|
|
|
|
; cleanup inputs/setup parameters ============================================================== |
|
|
if gkloopstart < 0.0015 then |
|
|
gkloopstart = 0; we can't do any processing in zero time, we will skip later |
|
|
endif |
|
|
if gkloopstart > 0.995 then |
|
|
gkloopstart = 0.999; if we set 1, it's the same as 0 |
|
|
endif |
|
|
|
|
|
; there are issues when the read and write heads are too close |
|
|
kloopstart = 0.97 * gkloopstart + 0.03 |
|
|
|
|
|
; this pitch stuff from the nebulae source. |
|
|
kpitch = 0.125 * exp(gkpitch * log(32)) |
|
|
kpitch = (kpitch <= 1.005 && kpitch >= 0.995 ? 1.0 : kpitch) |
|
|
|
|
|
; create a positive semi-definite density |
|
|
kdensity = abs(0.93 - 1.86 * gkdensity) + 0.07 |
|
|
kdensity = (kdensity < 0 ? 0 : kdensity) |
|
|
|
|
|
kfeedback = gkoverlap_alt ^ 3 |
|
|
|
|
|
kspeed = gkspeed |
|
|
aspeed = 8 * a(kspeed) - 4 |
|
|
;=============================================================================================== |
|
|
|
|
|
; general phasor and also write head. |
|
|
; don't advance it when we are frozen: both heads do not move. |
|
|
if gkfreeze == 0 then |
|
|
aphasor, asyncphasor syncphasor 1/(ilen/sr), asyncin |
|
|
endif |
|
|
|
|
|
|
|
|
; it seems counter-intuitive that increasing the value of |
|
|
; start should decrease where the play head is, but intuitively |
|
|
; we are increasing the amount of time between recording and |
|
|
; playing. at start=0, playing occurs zero time after recording. |
|
|
; perhaps visualize a stationary circular tape with moving heads. |
|
|
; start=0 start small start large |
|
|
; r | r | r | >>>>heads move this way >>>> |
|
|
; w | w | w | >>>>heads move this way >>>> |
|
|
; ================================================ = = tape is circular = = = = |
|
|
|
|
|
awriteindex = aphasor * ilen |
|
|
areadphasor = ((aphasor - kloopstart) - floor(aphasor - kloopstart)) |
|
|
areadindex = areadphasor * ilen |
|
|
areadtime = areadphasor * giBufSize |
|
|
|
|
|
if gkrecord == 1 && gkfreeze == 0 then |
|
|
tabw ainl + (amixl * kfeedback), aphasor, giftl, 1 |
|
|
tabw ainr + (amixr * kfeedback), aphasor, giftr, 1 |
|
|
endif |
|
|
|
|
|
; size and density, clouds style, adapted from clouds code |
|
|
if gkdensity <= 0.5 then |
|
|
ktargetgrains = kdensity * kdensity * kdensity * 80 |
|
|
kgrainfreq = ktargetgrains / giBufSize |
|
|
else |
|
|
kgrainfreq = 80 / giBufSize |
|
|
endif |
|
|
kgrainsize table (256 * gkloopsize), gigrainsizes; in seconds |
|
|
kgrainsize = kgrainsize * 1000; in ms |
|
|
|
|
|
; this bit on windows taken from nebulae code |
|
|
kwindow portk gkwindow, 0.1 |
|
|
kwindowsel = int(kwindow * 6) |
|
|
kwindowblend = kwindow * 6 |
|
|
kwindowchanged changed kwindowsel |
|
|
if kwindowchanged == 1 || kfirsttime == 1 then |
|
|
if kwindowsel < 1 then |
|
|
tablecopy giWin, giGaussian |
|
|
tablecopy giWinB, giBlkHarris |
|
|
elseif kwindowsel < 2 then |
|
|
tablecopy giWin, giBlkHarris |
|
|
tablecopy giWinB, giRampDown |
|
|
elseif kwindowsel < 3 then |
|
|
tablecopy giWin, giRampDown |
|
|
tablecopy giWinB, giBartlett |
|
|
elseif kwindowsel < 4 then |
|
|
tablecopy giWin, giBartlett |
|
|
tablecopy giWinB, giRampUp |
|
|
elseif kwindowsel < 5 then |
|
|
tablecopy giWin, giRampUp |
|
|
tablecopy giWinB, giHamming |
|
|
elseif kwindowsel < 6 then |
|
|
tablecopy giWin, giHamming |
|
|
tablecopy giWinB, giRectangle |
|
|
elseif kwindowsel < 7 then |
|
|
tablecopy giWin, giRectangle |
|
|
endif |
|
|
kfirsttime = 0 |
|
|
endif |
|
|
kwblend = kwindowblend - kwindowsel |
|
|
tablemix giWinMix, 0, giwindowtablesize, giWin, 0, 1.0-kwblend, giWinB, 0, kwblend |
|
|
|
|
|
|
|
|
; more params |
|
|
kdistribution = 0 |
|
|
idisttab = -1 |
|
|
async = 0 |
|
|
kenv2amt = 1 |
|
|
ienv2tab = giWinMix |
|
|
ienv_attack = -1 |
|
|
ienv_decay = -1 |
|
|
ksustain_amount = 0 |
|
|
ka_d_ratio = 0.5 |
|
|
kduration = kgrainsize |
|
|
kamp = 0.45 |
|
|
igainmasks = -1 |
|
|
kwavfreq = (1/giBufSize) * kpitch |
|
|
ksweepshape = 0 |
|
|
iwavfreqstarttab = -1 |
|
|
iwavfreqendtab = -1 |
|
|
awavfm = 0 |
|
|
ifmamptab = -1 |
|
|
ifmenv = -1 |
|
|
icosine = giCosine |
|
|
ktraincps = 1 |
|
|
knumpartials = 1 |
|
|
kchroma = 1 |
|
|
ichannelmasks = -1 |
|
|
if gkdensity > 0.5 then |
|
|
krandommask = 1 - kdensity |
|
|
else |
|
|
krandommask = 0 |
|
|
endif |
|
|
kwaveform1l = giftl |
|
|
kwaveform2l = giftl |
|
|
kwaveform3l = giftl |
|
|
kwaveform4l = giftl |
|
|
kwaveform1r = giftr |
|
|
kwaveform2r = giftr |
|
|
kwaveform3r = giftr |
|
|
kwaveform4r = giftr |
|
|
iwaveamptab = -1 |
|
|
asamplepos1 = areadphasor |
|
|
asamplepos2 = areadphasor |
|
|
asamplepos3 = areadphasor |
|
|
asamplepos4 = areadphasor |
|
|
kwavekey1 = 1 |
|
|
kwavekey2 = 1 |
|
|
kwavekey3 = 1 |
|
|
kwavekey4 = 1 |
|
|
imax_grains = 10 |
|
|
|
|
|
asigl mincer areadtime, 1, kpitch, giftl, 1, 2048, 4 |
|
|
asigr mincer areadtime, 1, kpitch, giftr, 1, 2048, 4 |
|
|
|
|
|
agrainl partikkel kgrainfreq, kdistribution, idisttab, async, \ |
|
|
kenv2amt, ienv2tab, ienv_attack, ienv_decay, ksustain_amount, \ |
|
|
ka_d_ratio, kduration, kamp, igainmasks, kwavfreq, ksweepshape, \ |
|
|
iwavfreqstarttab, iwavfreqendtab, awavfm, ifmamptab, ifmenv, icosine, \ |
|
|
ktraincps, knumpartials, kchroma, ichannelmasks, krandommask, \ |
|
|
kwaveform1l, kwaveform2l, kwaveform3l, kwaveform4l, iwaveamptab, \ |
|
|
asamplepos1, asamplepos2, asamplepos3, asamplepos4, \ |
|
|
kwavekey1, kwavekey2, kwavekey3, kwavekey4, imax_grains |
|
|
|
|
|
agrainr partikkel kgrainfreq, kdistribution, idisttab, async, \ |
|
|
kenv2amt, ienv2tab, ienv_attack, ienv_decay, ksustain_amount, \ |
|
|
ka_d_ratio, kduration, kamp, igainmasks, kwavfreq, ksweepshape, \ |
|
|
iwavfreqstarttab, iwavfreqendtab, awavfm, ifmamptab, ifmenv, icosine, \ |
|
|
ktraincps, knumpartials, kchroma, ichannelmasks, krandommask, \ |
|
|
kwaveform1r, kwaveform2r, kwaveform3r, kwaveform4r, iwaveamptab, \ |
|
|
asamplepos1, asamplepos2, asamplepos3, asamplepos4, \ |
|
|
kwavekey1, kwavekey2, kwavekey3, kwavekey4, imax_grains |
|
|
|
|
|
; verb: TODO make a nicer one, tutorials online. |
|
|
kroomsize = log(20 * gkoverlap + 1) / log(21) |
|
|
kdamp = 1 - gkoverlap * gkoverlap * gkoverlap |
|
|
averbl, averbr freeverb agrainl, agrainr, kroomsize, kdamp |
|
|
if gkoverlap < 0.005 then |
|
|
averbl = 0 |
|
|
averbr = 0 |
|
|
endif |
|
|
agrainl = agrainl + averbl |
|
|
agrainr = agrainr + averbr |
|
|
|
|
|
; mixer, constant power functions |
|
|
kblend = gkblend |
|
|
kblend_alt = gkblend_alt |
|
|
if kblend > 1.0 then |
|
|
kblend = 1.0 |
|
|
endif |
|
|
if kblend < 0.0 then |
|
|
kblend = 0.0 |
|
|
endif |
|
|
if kblend_alt > 1.0 then |
|
|
kblend_alt = 1.0 |
|
|
endif |
|
|
if kblend_alt < 0.0 then |
|
|
kblend_alt = 0.0 |
|
|
endif |
|
|
ablend interp kblend |
|
|
ablend_alt interp kblend_alt |
|
|
|
|
|
ablend *= 2.0 |
|
|
ablend -= 1.0 |
|
|
ablend_alt *= 2.0 |
|
|
ablend_alt -= 1.0 |
|
|
ablend max ablend, a(-1.0) |
|
|
ablend min ablend, a(1.0) |
|
|
ablend_alt max ablend_alt, a(-1.0) |
|
|
ablend_alt min ablend_alt, a(1.0) |
|
|
|
|
|
ablendvocoder = sqrt(0.5 * (1 - ablend_alt)) |
|
|
ablendgranular = sqrt(0.5 * (1 + ablend_alt)) |
|
|
ablenddry = sqrt(0.5 * (1 - ablend)) |
|
|
ablendwet = sqrt(0.5 * (1 + ablend)) |
|
|
|
|
|
ablendvocoder min ablendvocoder, a(1.0) |
|
|
ablendgranular min ablendgranular, a(1.0) |
|
|
ablenddry min ablenddry, a(1.0) |
|
|
ablendwet min ablendwet, a(1.0) |
|
|
ablendvocoder max ablendvocoder, a(0.0) |
|
|
ablendgranular max ablendgranular, a(0.0) |
|
|
ablenddry max ablenddry, a(0.0) |
|
|
ablendwet max ablendwet, a(0.0) |
|
|
|
|
|
amixl = (asigl * ablendvocoder) + (agrainl * ablendgranular) |
|
|
amixr = (asigr * ablendvocoder) + (agrainr * ablendgranular) |
|
|
aoutl = (ablendwet * amixl) + (ablenddry * ainl) |
|
|
aoutr = (ablendwet * amixr) + (ablenddry * ainr) |
|
|
|
|
|
outs aoutl, aoutr |
|
|
|
|
|
endin |