#include "/twist/transform_api.udo" #include "/fx_autoglitch.udo" #include "/sample_level.udo" instr twst_tfi_rearrange $TWST_TRANSFORM ileft, iright, istartsamp, iendsamp, idocut, ilength twst_tf_getstate istereounique = twst_parami("stereounique") ichops = twst_parami("chopnumber") ichopmin = twst_parami("chopmin") ichopmax = twst_parami("chopmax") ifnL, ifnR twst_tfi_getfn if (ileft == 1 && iright == 1) then if (istereounique == 1) then aL smp_rearrange ichops, ichopmin, ichopmax, ifnL aR smp_rearrange ichops, ichopmin, ichopmax, ifnR else aL, aR smp_rearrange ichops, ichopmin, ichopmax, ifnL, ifnR endif elseif (ileft == 1) then aL smp_rearrange ichops, ichopmin, ichopmax, ifnL elseif (iright == 1) then aR smp_rearrange ichops, ichopmin, ichopmax, ifnR endif outs aL, aR endin instr twst_tfi_grain $TWST_TRANSFORM ileft, iright, istartsamp, iendsamp, idocut, ilength twst_tf_getstate kamp = twst_param:k("amp") kpitch = twst_tf_pitchscale() kdensity = twst_param:k("density") kgrainsize = twst_param:k("grainsize") kampvar = twst_param:k("ampvar") kpitchvar = twst_param:k("pitchvar") irandom = twst_parami("randomread") ifnWindow = twst_tf_getwintype() ifnL, ifnR twst_tfi_getfn kpitch *= (sr / ftlen(ifnL)) if (ileft == 1) then aL grain kamp, kpitch, kdensity, kampvar, kpitchvar, kgrainsize, ifnL, ifnWindow, 0.5, irandom endif if (iright == 1) then aR grain kamp, kpitch, kdensity, kampvar, kpitchvar, kgrainsize, ifnR, ifnWindow, 0.5, irandom endif outs aL, aR endin instr twst_tfi_syncgrain $TWST_TRANSFORM ileft, iright, istartsamp, iendsamp, idocut, ilength twst_tf_getstate kamp = twst_param:k("amp") kfreq = twst_param:k("frequency") kpitch = twst_tf_pitchscale() kgrsize = twst_param:k("grainsize") ioverlaps = twst_parami("overlaps") itimescale = twst_parami("timescale") ifnWindow = twst_tf_getwintype() iprate = (1 / ioverlaps) * itimescale p3 = ilength * itimescale ifnL, ifnR twst_tfi_getfn if (ileft == 1) then aL syncgrain kamp, kfreq, kpitch, kgrsize, iprate, ifnL, ifnWindow, ioverlaps endif if (iright == 1) then aR syncgrain kamp, kfreq, kpitch, kgrsize, iprate, ifnR, ifnWindow, ioverlaps endif outs aL, aR endin instr twst_tf_autoglitch $TWST_TRANSFORM aL, aR, ileft, iright twst_getinput kminratio = twst_param:k("minratio") kchangerate = twst_param:k("changerate") kchangechance = twst_param:k("changechance") kporttime = twst_param:k("porttime") kdo_distortion = twst_param:k("distortion") kdo_ampchange = twst_param:k("ampchange") ibuflens = twst_parami("buflens") kreadmode = twst_param:k("readmode") istereounique = twst_parami("stereounique") twst_setlatencyseconds ibuflens if (ileft == 1 && iright == 1) then aL, aR fx_autoglitch aL, aR, kminratio, kchangerate, kchangechance, kporttime, kdo_distortion, kdo_ampchange, ibuflens, istereounique, kreadmode elseif (ileft == 1) then aL fx_autoglitch aL, kminratio, kchangerate, kchangechance, kporttime, kdo_distortion, kdo_ampchange, ibuflens, kreadmode elseif (iright == 1) then aR fx_autoglitch aR, kminratio, kchangerate, kchangechance, kporttime, kdo_distortion, kdo_ampchange, ibuflens, kreadmode endif outs aL, aR endin instr twst_tfi_retriglitch $TWST_TRANSFORM ileft, iright, istartsamp, iendsamp, idocut, ilength twst_tf_getstate ktriglen = twst_param:k("triglen") kpitchscale = twst_tf_pitchscale() kapplywindowing = twst_param:k("applywindowing") ireadmode = twst_parami("readmode") kwintype twst_tf_getwintypek p3 = ilength if (ireadmode == 0) then atime linseg 0, p3, ilength elseif (ireadmode == 1) then ktime = twst_param:k("readtime") twst_tf_setplayposition ktime atime = a(ktime * ilength) elseif (ireadmode == 2) then itimescale = twst_parami("timescale") p3 = ilength * itimescale atime linseg 0, p3, ilength elseif (ireadmode == 3) then atime linseg ilength, p3, 0 elseif (ireadmode == 4) then atime init -1 endif ifnL, ifnR twst_tfi_getfn if (ileft == 1) then aL fx_retrigglitch ifnL, ktriglen, atime, kpitchscale, kapplywindowing, kwintype endif if (iright == 1) then aR fx_retrigglitch ifnR, ktriglen, atime, kpitchscale, kapplywindowing, kwintype endif outs aL, aR endin