aboutsummaryrefslogtreecommitdiff
path: root/site/udo/twist/transforms
diff options
context:
space:
mode:
authorRichard <q@1bpm.net>2025-04-13 18:48:02 +0100
committerRichard <q@1bpm.net>2025-04-13 18:48:02 +0100
commit9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22 (patch)
tree291bd79ce340e67affa755a8a6b4f6a83cce93ea /site/udo/twist/transforms
downloadapps.csound.1bpm.net-9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22.tar.gz
apps.csound.1bpm.net-9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22.tar.bz2
apps.csound.1bpm.net-9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22.zip
initial
Diffstat (limited to 'site/udo/twist/transforms')
-rwxr-xr-xsite/udo/twist/transforms/amplitude.udo179
-rwxr-xr-xsite/udo/twist/transforms/cross_processing.udo176
-rwxr-xr-xsite/udo/twist/transforms/delay.udo72
-rwxr-xr-xsite/udo/twist/transforms/filter.udo172
-rwxr-xr-xsite/udo/twist/transforms/frequency.udo65
-rwxr-xr-xsite/udo/twist/transforms/general.udo28
-rwxr-xr-xsite/udo/twist/transforms/generate.udo363
-rwxr-xr-xsite/udo/twist/transforms/granular.udo138
-rwxr-xr-xsite/udo/twist/transforms/harmonic.udo142
-rwxr-xr-xsite/udo/twist/transforms/reverb.udo80
-rwxr-xr-xsite/udo/twist/transforms/spectral.udo642
-rwxr-xr-xsite/udo/twist/transforms/warping.udo210
12 files changed, 2267 insertions, 0 deletions
diff --git a/site/udo/twist/transforms/amplitude.udo b/site/udo/twist/transforms/amplitude.udo
new file mode 100755
index 0000000..d477b4f
--- /dev/null
+++ b/site/udo/twist/transforms/amplitude.udo
@@ -0,0 +1,179 @@
+#include "/twist/transform_api.udo"
+#include "/frequency_tools.udo"
+
+opcode _twst_tf_normalise_analyse, i, iii
+ ifn, istartsamp, iendsamp xin
+ iscale = 0
+ imaxpos = 0
+ imaxneg = 0
+ while (istartsamp < iendsamp) do
+ ival table istartsamp, ifn
+ if (ival > 0 && ival > imaxpos) then
+ imaxpos = ival
+ elseif (ival < 0 && ival < imaxneg) then
+ imaxneg = ival
+ endif
+ istartsamp += 1
+ od
+ iscale = ((1 / max(abs(imaxneg), abs(imaxpos))))
+ xout iscale
+endop
+
+instr twst_tf_normalise
+ $TWST_TRANSFORM
+ i_, i_, istartsamp, iendsamp, idocut, ilength twst_tf_getstate
+ aL, aR, ileft, iright twst_getinput
+ istereoequal = twst_parami("equal")
+ kuserscale = twst_param:k("scale")
+
+ if (ileft == 1) then
+ iscalingL _twst_tf_normalise_analyse gitwst_bufferL[gitwst_instanceindex], istartsamp, iendsamp
+ endif
+ if (iright == 1) then
+ iscalingR _twst_tf_normalise_analyse gitwst_bufferR[gitwst_instanceindex], istartsamp, iendsamp
+ endif
+
+ if (istereoequal == 1 && ileft == 1 && iright == 1) then
+ iscaling = min(iscalingL, iscalingR)
+ aL *= iscaling * kuserscale
+ aR *= iscaling * kuserscale
+ elseif (ileft == 1) then
+ aL *= iscalingL * kuserscale
+ elseif (iright == 1) then
+ aR *= iscalingR * kuserscale
+ endif
+
+ outs aL, aR
+endin
+
+instr twst_tf_amplitude
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kgain = twst_param:k("gain")
+ kbalance = twst_param:k("balance")
+ if (ileft == 1) then
+ kb = max:k(1, (1 - kbalance) * 2)
+ aL *= kgain * kb
+ endif
+ if (iright == 1) then
+ kb = max:k(1, kbalance * 2)
+ aR *= kgain * kb
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_strobe
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ krate = twst_param:k("rate")
+ kholdtime = twst_param:k("holdtime")
+ kwindowed = twst_param:k("windowed")
+
+ ktrig metro krate
+ ktrig trighold ktrig, kholdtime
+ kamp = 1 - ktrig
+
+ if (kwindowed == 1) then
+ kenv portk kamp, kholdtime * 0.5
+ else
+ kenv = kamp
+ endif
+
+ if (ileft == 1) then
+ aL *= kenv
+ endif
+ if (iright == 1) then
+ aR *= kenv
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_bitcrush
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kcrush = twst_param:k("crush")
+ if (ileft == 1) then
+ aL bitcrush aL, kcrush
+ elseif (iright == 1) then
+ aR bitcrush aR, kcrush
+ endif
+ outs aL, aR
+endin
+
+
+instr twst_tf_suppress
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kmode = twst_param:k("mode")
+ kthreshold = twst_param:k("threshold")
+
+ if (ileft == 1) then
+ if (kmode == 0) then
+ aL limit aL, -kthreshold, kthreshold
+ elseif (kmode == 1) then
+ aL wrap aL, -kthreshold, kthreshold
+ elseif (kmode == 2) then
+ aL mirror aL, -kthreshold, kthreshold
+ endif
+ endif
+ if (iright == 1) then
+ if (kmode == 0) then
+ aR limit aR, -kthreshold, kthreshold
+ elseif (kmode == 1) then
+ aR wrap aR, -kthreshold, kthreshold
+ elseif (kmode == 2) then
+ aR mirror aR, -kthreshold, kthreshold
+ endif
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_pdclip
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kwidth = twst_param:k("width")
+ kcentre = twst_param:k("centre")
+ ibipolar = twst_parami("bipolar")
+ ifullscale = twst_parami("fullscale")
+
+ if (ileft == 1) then
+ aL pdclip aL, kwidth, kcentre, ibipolar, ifullscale
+ endif
+ if (iright == 1) then
+ aR pdclip aR, kwidth, kcentre, ibipolar, ifullscale
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_distort
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kamount = twst_param:k("amount")
+ ihp = twst_parami("halfpower")
+ ifn twst_tf_getwaveform
+
+ if (ileft == 1) then
+ aL distort aL, kamount, ifn, ihp
+ endif
+ if (iright == 1) then
+ aL distort aR, kamount, ifn, ihp
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_distort1
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kpregain = twst_param:k("pregain")
+ kpostgain = twst_param:k("postgain")
+ kshape1 = twst_param:k("shape1")
+ kshape2 = twst_param:k("shape2")
+
+ if (ileft == 1) then
+ aL distort1 aL, kpregain, kpostgain, kshape1, kshape2, 1
+ endif
+ if (iright == 1) then
+ aL distort1 aR, kpregain, kpostgain, kshape1, kshape2, 1
+ endif
+ outs aL, aR
+endin
diff --git a/site/udo/twist/transforms/cross_processing.udo b/site/udo/twist/transforms/cross_processing.udo
new file mode 100755
index 0000000..203c393
--- /dev/null
+++ b/site/udo/twist/transforms/cross_processing.udo
@@ -0,0 +1,176 @@
+#include "/twist/transform_api.udo"
+#include "/mfcc_match.udo"
+#include "/fftconvolve.udo"
+#include "/chop.udo"
+
+
+instr twst_tf_crossrearrange
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kminsamples = twst_param:k("minsamples")
+ kmaxsamples = twst_param:k("maxsamples")
+ kstereounique = twst_param:k("stereounique")
+ krate = twst_param:k("rate")
+
+ ktrig metro krate
+ async init 0
+
+ if (ktrig == 1) then
+ kfnLo, kfnRo twst_getrandombuffers kstereounique
+ ktablen = tableng:k(kfnLo)
+ klen = min:k(random:k(kminsamples, kmaxsamples), ktablen)
+ kstart = random:k(0, ktablen - klen)
+ async = 1
+ else
+ async = 0
+ endif
+
+ apos, a_ syncphasor 1 / (klen / sr), async
+ areadpos = (apos * klen) + kstart
+
+ if (ileft == 1) then
+ aL tablekt areadpos, kfnLo
+ endif
+ if (iright == 1) then
+ aR tablekt areadpos, kfnRo
+ endif
+
+ outs aL, aR
+endin
+
+instr twst_tf_directconvolve
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ ifnLo, ifnRo twst_tfi_getcrossfn
+ kamp = twst_parami("amp")
+ isizeratio = twst_parami("sizeratio")
+ if (ileft == 1) then
+ aL dconv aL * kamp, isizeratio * ftlen(ifnLo), ifnLo
+ endif
+ if (iright == 1) then
+ aR dconv aR * kamp, isizeratio * ftlen(ifnRo), ifnRo
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_blockconvolve
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ aLo, aRo, ilefto, irighto twst_getcrossinput
+ ifftsize = twst_parami("fftsize")
+ ioverlap = twst_parami("overlap")
+ ihopsize = ifftsize / ioverlap
+
+ if (ileft == 1 && ilefto == 1) then
+ aL blockconvolve aL, aLo, ifftsize, ihopsize
+ endif
+ if (iright == 1 && irighto == 1) then
+ aR blockconvolve aR, aRo, ifftsize, ihopsize
+ endif
+ outs aL, aR
+endin
+
+/* not in WASM at current
+instr twst_tf_tvconv
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ aLo, aRo, ilefto, irighto twst_getcrossinput
+ kapply1 = twst_param:k("apply1")
+ kapply2 = twst_param:k("apply2")
+ imode = twst_parami("mode")
+ iparts = twst_parami("parts")
+ idftfiltersize = twst_parami("dftfiltersize")
+ ifirfiltersize = twst_parami("firfiltersize")
+
+ if (imode == 1) then
+ iparts = 1
+ ifiltersize = ifirfiltersize
+ else
+ ifiltersize = idftfiltersize
+ endif
+
+ if (ileft == 1 && ilefto == 1) then
+ aL tvconv aL, aLo, kapply1, kapply2, iparts, ifiltersize
+ endif
+
+ if (iright == 1 && irighto == 1) then
+ aR tvconv aR, aRo, kapply1, kapply2, iparts, ifiltersize
+ endif
+ outs aL, aR
+endin
+*/
+
+instr twst_tf_crosssynth
+ $TWST_TRANSFORM
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ fLo, fRo, ilefto, irighto twst_getfcrossinput
+ kamp1 = twst_param:k("amp1")
+ kamp2 = twst_param:k("amp2")
+
+ if (ileft == 1 && ilefto == 1) then
+ foutL pvscross fL, fLo, kamp1, kamp2
+ aL twst_tf_fresynth foutL
+ endif
+
+ if (iright == 1 && irighto == 1) then
+ foutR pvscross fR, fRo, kamp1, kamp2
+ aR twst_tf_fresynth foutR
+ endif
+ outs aL, aR
+endin
+
+
+instr twst_tf_morph
+ $TWST_TRANSFORM
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ fLo, fRo, ilefto, irighto twst_getfcrossinput
+ kamp = twst_param:k("amp")
+ kfreq = twst_param:k("freq")
+
+ if (ileft == 1 && ilefto == 1) then
+ foutL pvsmorph fL, fLo, kamp, kfreq
+ aL twst_tf_fresynth foutL
+ endif
+
+ if (iright == 1 && irighto == 1) then
+ foutR pvsmorph fR, fRo, kamp, kfreq
+ aR twst_tf_fresynth foutR
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_mfccmatch
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ ifnoL, ifnoR twst_tfi_getcrossfn
+ ifftsize = twst_parami("fftsize")
+ ifreqmin = twst_parami("freqmin")
+ ifreqmax = twst_parami("freqmax")
+ ibands = twst_parami("bands")
+ kstretch = twst_param:k("stretch")
+ kauditionreadyL init 0
+ kauditionreadyR init 0
+ ktimek timeinstk
+
+ if (ileft == 1) then
+ kdone, ifnAnalysisL mfm_analysecorpus ktimek, ifnoL, ifreqmin, ifreqmax, ifftsize, ibands, -1, 1
+ if (kdone == 1) then
+ kauditionreadyL = 1
+ aoutL mfm_matchplay aL, ifnoL, ifnAnalysisL, kstretch, ifreqmin, ifreqmax, ifftsize, ibands
+ endif
+ else
+ kauditionreadyL = 1
+ endif
+ if (iright == 1) then
+ kdone, ifnAnalysisR mfm_analysecorpus ktimek, ifnoR, ifreqmin, ifreqmax, ifftsize, ibands, -1, 1
+ if (kdone == 1) then
+ kauditionreadyR = 1
+ aoutR mfm_matchplay aR, ifnoR, ifnAnalysisR, kstretch, ifreqmin, ifreqmax, ifftsize, ibands
+ endif
+ else
+ kauditionreadyR = 1
+ endif
+
+ chnset (kauditionreadyL & kauditionreadyR), "auditionready"
+ outs aoutL, aoutR
+endin
diff --git a/site/udo/twist/transforms/delay.udo b/site/udo/twist/transforms/delay.udo
new file mode 100755
index 0000000..5d59612
--- /dev/null
+++ b/site/udo/twist/transforms/delay.udo
@@ -0,0 +1,72 @@
+#include "/twist/transform_api.udo"
+
+instr twst_tf_vdelay
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kdelay = twst_param:k("delay") * 1000
+ kfeedback = twst_param:k("feedback")
+ adelay = a(kdelay)
+
+ if (ileft == 1) then
+ afbkL init 0
+ aLd vdelay3 aL + afbkL, adelay, 1000
+ afbkL = aLd * kfeedback
+ aL = aLd
+ endif
+ if (iright == 1) then
+ afbkR init 0
+ aRd vdelay3 aR + afbkR, adelay, 1000
+ afbkR = aRd * kfeedback
+ aR = aRd
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_flanger
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kdelay = twst_param:k("delay")
+ kfeedback = twst_param:k("feedback")
+
+ adelay = a(kdelay)
+ if (ileft == 1) then
+ aL flanger aL, adelay, kfeedback
+ endif
+ if (iright == 1) then
+ aR flanger aR, adelay, kfeedback
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_phaser1
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kfreq = twst_param:k("freq")
+ iord = twst_parami("order")
+ kfeedback = twst_param:k("feedback")
+ if (ileft == 1) then
+ aL phaser1 aL, kfreq, iord, kfeedback
+ endif
+ if (iright == 1) then
+ aR phaser1 aR, kfreq, iord, kfeedback
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_phaser2
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kfreq = twst_param:k("freq")
+ kq = twst_param:k("q")
+ iord = twst_parami("order")
+ imode = twst_parami("mode")
+ ksep = twst_param:k("sep")
+ kfeedback = twst_param:k("feedback")
+ if (ileft == 1) then
+ aL phaser2 aL, kfreq, kq, iord, imode, ksep, kfeedback
+ endif
+ if (iright == 1) then
+ aR phaser2 aR, kfreq, kq, iord, imode, ksep, kfeedback
+ endif
+ outs aL, aR
+endin
diff --git a/site/udo/twist/transforms/filter.udo b/site/udo/twist/transforms/filter.udo
new file mode 100755
index 0000000..38fad69
--- /dev/null
+++ b/site/udo/twist/transforms/filter.udo
@@ -0,0 +1,172 @@
+#include "/twist/transform_api.udo"
+
+instr twst_tf_lpf
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kfreq = twst_param:k("frequency")
+ if (ileft == 1) then
+ aL butterlp aL, kfreq
+ endif
+ if (iright == 1) then
+ aR butterlp aR, kfreq
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_hpf
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kfreq = twst_param:k("frequency")
+ if (ileft == 1) then
+ aL butterhp aL, kfreq
+ endif
+ if (iright == 1) then
+ aR butterhp aR, kfreq
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_bpf
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kfreq = twst_param:k("frequency")
+ kbw = twst_param:k("bandwidth")
+ if (ileft == 1) then
+ aL butterbp aL, kfreq, kbw
+ endif
+ if (iright == 1) then
+ aR butterbp aR, kfreq, kbw
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_pareq
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kfreq = twst_param:k("frequency")
+ kgain = twst_param:k("gain")
+ kq = twst_param:k("q")
+ if (ileft == 1) then
+ aL pareq aL, kfreq, kgain, kq
+ endif
+ if (iright == 1) then
+ aR pareq aR, kfreq, kgain, kq
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_dcblock
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ if (ileft == 1) then
+ aL dcblock2 aL
+ endif
+ if (iright = 1) then
+ aR dcblock2 aR
+ endif
+ outs aL, aR
+endin
+
+/* not in WASM
+{
+ name: "Non-linear filter",
+ instr: "twst_tf_nlfilter",
+ parameters: [
+ {name: "Parameter a", channel: "pa", min: 0, max: 1, dfault: 0.3},
+ {name: "Parameter b", channel: "pb", min: -1, max: 1, dfault: 0.1},
+ {name: "Parameter d", channel: "pd", min: 0, max: 1, dfault: 0.7},
+ {name: "Parameter C", channel: "pC", min: 0, max: 1, dfault: 0.12},
+ {name: "Parameter L", channel: "pL", min: 1, max: 220, dfault: 20},
+ {preset: "applymode"}
+ ]
+},
+
+instr twst_tf_nlfilter
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kpa = twst_param:k("pa")
+ kpb = twst_param:k("pb")
+ kpd = twst_param:k("pd")
+ kpC = twst_param:k("pC")
+ kpL = twst_param:k("pL")
+ nfilt
+ if (ileft == 1) then
+ aL nfilt2 aL, kpa, kpb, kpd, kpC, kpL
+ endif
+ if (iright == 1) then
+ aR nfilt2 aR, kpa, kpb, kpd, kpC, kpL
+ endif
+ outs aL, aR
+endin
+*/
+
+instr twst_tf_mooghpf
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kfreq = twst_param:k("freq")
+ if (ileft == 1) then
+ aL mvchpf aL, kfreq
+ endif
+ if (iright == 1) then
+ aR mvchpf aR, kfreq
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_mooglpf
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kfreq = twst_param:k("freq")
+ kres = twst_param:k("resonance")
+ kmode = twst_param:k("mode")
+ if (ileft == 1) then
+ if (kmode == 0) then
+ aL mvclpf1 aL, kfreq, kres
+ elseif (kmode == 1) then
+ aL mvclpf2 aL, kfreq, kres
+ elseif (kmode == 2) then
+ aL mvclpf3 aL, kfreq, kres
+ endif
+ endif
+ if (iright == 1) then
+ if (kmode == 0) then
+ aR mvclpf1 aR, kfreq, kres
+ elseif (kmode == 1) then
+ aR mvclpf2 aR, kfreq, kres
+ elseif (kmode == 2) then
+ aR mvclpf3 aR, kfreq, kres
+ endif
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_waveguide1
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kfreq = twst_param:k("freq")
+ kcutoff = twst_param:k("cutoff")
+ kfeedback = twst_param:k("feedback")
+ if (ileft == 1) then
+ aL wguide1 aL, kfreq, kcutoff, kfeedback
+ endif
+ if (iright == 1) then
+ aR wguide1 aR, kfreq, kcutoff, kfeedback
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_tbvcf
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kfreq = twst_param:k("freq")
+ kres = twst_param:k("resonance")
+ kdist = twst_param:k("dist")
+ kasym = twst_param:k("asym")
+ if (ileft == 1) then
+ aL tbvcf aL, kfreq, kres, kdist, kasym
+ endif
+ if (iright == 1) then
+ aR tbvcf aR, kfreq, kres, kdist, kasym
+ endif
+ outs aL, aR
+endin
diff --git a/site/udo/twist/transforms/frequency.udo b/site/udo/twist/transforms/frequency.udo
new file mode 100755
index 0000000..a56b808
--- /dev/null
+++ b/site/udo/twist/transforms/frequency.udo
@@ -0,0 +1,65 @@
+#include "/twist/transform_api.udo"
+#include "/frequency_tools.udo"
+
+instr twst_tf_freqshift1
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kshift = twst_param:k("shift")
+ if (ileft == 1 && iright == 1) then
+ aL, aR freqshift1 aL, aR, kshift
+ elseif (ileft == 1) then
+ aL freqshift1 aL, kshift
+ elseif (iright == 1) then
+ aR freqshift1 aR, kshift
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_freqshift2
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kshift = twst_param:k("shift")
+ if (ileft == 1 && iright == 1) then
+ aL, aR freqshift2 aL, aR, kshift
+ elseif (ileft == 1) then
+ aL freqshift2 aL, kshift
+ elseif (iright == 1) then
+ aR freqshift2 aR, kshift
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_ringmod
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kfreq = twst_param:k("frequency")
+ if (ileft == 1 && iright == 1) then
+ aL, aR ringmod1 aL, aR, kfreq
+ elseif (ileft == 1) then
+ aL ringmod1 aL, kfreq
+ elseif (iright == 1) then
+ aR ringmod1 aR, kfreq
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_exciter
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kfreqlow = twst_tf_freq_custom("low")
+ kfreqhigh = twst_tf_freq_custom("high")
+ kharmonics = twst_param:k("harmonics")
+ kblend = twst_param:k("blend")
+
+ if (kfreqhigh < kfreqlow) then
+ kfreqhigh = kfreqlow
+ endif
+
+ if (ileft == 1) then
+ aL exciter aL, kfreqlow, kfreqhigh, kharmonics, kblend
+ endif
+ if (iright == 1) then
+ aR exciter aR, kfreqlow, kfreqhigh, kharmonics, kblend
+ endif
+ outs aL, aR
+endin
diff --git a/site/udo/twist/transforms/general.udo b/site/udo/twist/transforms/general.udo
new file mode 100755
index 0000000..b46f570
--- /dev/null
+++ b/site/udo/twist/transforms/general.udo
@@ -0,0 +1,28 @@
+#include "/twist/transform_api.udo"
+
+instr twst_tfi_reverse
+ $TWST_TRANSFORM
+ ileft, iright, istartsamp, iendsamp, idocut, ilength twst_tf_getstate
+ ifnL, ifnR twst_tfi_getfn
+ ioffline twst_tf_isoffline
+ apos linseg (iendsamp - istartsamp) - 1, ilength, 0
+ if (ileft == 1) then
+ if (ioffline == 1) then
+ ifntempL ftgentmp 0, 0, -ftlen(ifnL), -2, 0
+ tableicopy ifntempL, ifnL
+ aL table3 apos, ifntempL
+ else
+ aL table3 apos, ifnL
+ endif
+ endif
+ if (iright == 1) then
+ if (ioffline == 1) then
+ ifntempR ftgentmp 0, 0, -ftlen(ifnR), -2, 0
+ tableicopy ifntempR, ifnR
+ aR table3 apos, ifntempR
+ else
+ aR table3 apos, ifnR
+ endif
+ endif
+ outs aL, aR
+endin
diff --git a/site/udo/twist/transforms/generate.udo b/site/udo/twist/transforms/generate.udo
new file mode 100755
index 0000000..e7355a8
--- /dev/null
+++ b/site/udo/twist/transforms/generate.udo
@@ -0,0 +1,363 @@
+#include "/addsub.udo"
+
+instr twst_tf_gensilence
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ a0 init 0
+ if (ileft == 1) then
+ aL = a0
+ endif
+ if (iright == 1) then
+ aR = a0
+ endif
+ outs aL, aR
+endin
+
+
+instr twst_tf_genadditive
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ ifreq = twst_parami("minfreq")
+ ifreqmax = twst_parami("maxfreq")
+ ifreqstepmult = twst_parami("step")
+ ifreqstepmultrand = twst_parami("steprand")
+ iamp = twst_parami("amp")
+ iampmult = twst_parami("ampmult")
+
+ if (ileft == 1) then
+ aL as_additive ifreq, ifreqmax, ifreqstepmult, ifreqstepmultrand, iamp, iampmult
+ endif
+ if (iright == 1) then
+ aR as_additive ifreq, ifreqmax, ifreqstepmult, ifreqstepmultrand, iamp, iampmult
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_gentone
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kamp = twst_param:k("amp")
+ kfreq twst_tf_freq
+ kfn twst_tf_getwaveformk
+
+ aosc oscilikt kamp, kfreq, kfn
+ if (ileft == 1) then
+ aL = aosc
+ endif
+ if (iright == 1) then
+ aR = aosc
+ endif
+ outs aL, aR
+endin
+
+
+opcode twst_tf_gensimpleadditive, a, kkkkkio
+ kamp, kmultiplier, kfreq, kstepmult, kampprofile, iharmonics, index xin
+ if (kampprofile == 0) then
+ kgain = 1
+ else
+ kgain = (1 - (index / iharmonics))
+ endif
+ aosc oscili (1 / iharmonics) * kgain, (kfreq * kmultiplier)
+ if (index < iharmonics) then
+ arec twst_tf_gensimpleadditive, min:k(kfreq * kstepmult, sr / 2), kstepmult, kampprofile, iharmonics, index + 1
+ aosc += arec
+ endif
+ xout aosc * kamp
+endop
+
+instr twst_tf_gensimpleadditive
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kamp = twst_param:k("amp")
+ kfreq twst_tf_freq
+ kmultiplier = twst_param:k("multiplier")
+ kstepmult = twst_param:k("stepmultiplier")
+ kampprofile = twst_param:k("ampprofile")
+ iharmonics = twst_parami("harmonics")
+
+ if (ileft == 1) then
+ aL twst_tf_gensimpleadditive kamp, kmultiplier, kfreq, kstepmult, kampprofile, iharmonics
+ endif
+ if (iright == 1) then
+ aR twst_tf_gensimpleadditive kamp, kmultiplier, kfreq, kstepmult, kampprofile, iharmonics
+ endif
+ outs aL, aR
+endin
+
+opcode twst_tf_genfeedback, a, kkkk
+ kfeedback, kfreq, kpostgain, kbw xin
+ asig init 0
+ asig += noise(0.00001, 0)
+ adel delay asig, 0.0001
+ asig += (adel * kfeedback)
+ asig butterbp asig, kfreq, kbw
+ asig butterbp asig, kfreq, kbw
+ asig tanh ain
+ asig *= kpostgain
+ xout asig
+endop
+
+instr twst_tf_genfeedback
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kamp = twst_param:k("amp")
+ kfeedback = twst_param:k("feedback")
+ kfreq twst_tf_freq
+ kpostgain = twst_param:k("postgain")
+ kbw = twst_param:k("bandwidth")
+ if (ileft == 1) then
+ aL twst_tf_genfeedback kfeedback, kfreq, kpostgain
+ aL *= kamp
+ endif
+ if (iright == 1) then
+ aR twst_tf_genfeedback kfeedback, kfreq, kpostgain
+ aR *= kamp
+ endif
+ outs aL, aR
+endin
+
+
+instr twst_tf_genfm
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kfreq twst_tf_freq
+ kamp = twst_param:k("amp")
+ kcarrier = twst_param:k("carrier")
+ kmod = twst_param:k("modulator")
+ kindex = twst_param:k("index")
+ kstereo = twst_param:k("stereovar")
+ ifn twst_tf_getwaveform
+
+ if (ileft == 0 || iright == 0) then
+ kstereo = 1
+ endif
+
+ if (ileft == 1) then
+ aL foscili kamp, kfreq, kcarrier * kstereo, kmod * kstereo, kindex * kstereo, ifn
+ endif
+ if (iright == 1) then
+ kstereo = 1 - (kstereo - 1)
+ aR foscili kamp, kfreq, kcarrier * kstereo, kmod * kstereo, kindex * kstereo, ifn
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_genfmmodel
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kfreq twst_tf_freq
+ ifmtype = twst_parami("fmtype")
+ kamp = twst_param:k("amp")
+ kc1 = twst_param:k("control1")
+ kc2 = twst_param:k("control2")
+ kvibdepth = twst_param:k("vibdepth")
+ kvibrate = twst_param:k("vibrate")
+ ifn1 twst_tf_getwaveform twst_parami("wave1")
+ ifn2 twst_tf_getwaveform twst_parami("wave2")
+ ifn3 twst_tf_getwaveform twst_parami("wave3")
+ ifn4 twst_tf_getwaveform twst_parami("wave4")
+ ifnv twst_tf_getwaveform twst_parami("vibwave")
+ kstereo = twst_param:k("stereovar")
+
+ if (ileft == 0 || iright == 0) then
+ kstereo = 1
+ endif
+
+ if (ileft == 1) then
+ ifmtypei = (ifmtype == 5) ? round(random(0, 4)) : ifmtype
+ if (ifmtypei == 0) then
+ aL fmb3 kamp, kfreq, kc1 * kstereo, kc2 * kstereo, kvibdepth * kstereo, kvibrate * kstereo, ifn1, ifn2, ifn3, ifn4, ifnv
+ elseif (ifmtypei == 1) then
+ aL fmbell kamp, kfreq, kc1 * kstereo, kc2 * kstereo, kvibdepth * kstereo, kvibrate * kstereo, ifn1, ifn2, ifn3, ifn4, ifnv
+ elseif (ifmtypei == 2) then
+ aL fmpercfl kamp, kfreq, kc1 * kstereo, kc2 * kstereo, kvibdepth * kstereo, kvibrate * kstereo, ifn1, ifn2, ifn3, ifn4, ifnv
+ elseif (ifmtypei == 3) then
+ aL fmrhode kamp, kfreq, kc1 * kstereo, kc2 * kstereo, kvibdepth * kstereo, kvibrate * kstereo, ifn1, ifn2, ifn3, ifn4, ifnv
+ elseif (ifmtypei == 4) then
+ aL fmwurlie kamp, kfreq, kc1 * kstereo, kc2 * kstereo, kvibdepth * kstereo, kvibrate * kstereo, ifn1, ifn2, ifn3, ifn4, ifnv
+ endif
+ endif
+ if (iright == 1) then
+ kstereo = 1 - (kstereo - 1)
+ ifmtypei = (ifmtype == 5) ? round(random(0, 4)) : ifmtype
+
+ if (ifmtypei == 0) then
+ aR fmb3 kamp, kfreq, kc1 * kstereo, kc2 * kstereo, kvibdepth * kstereo, kvibrate * kstereo, ifn1, ifn2, ifn3, ifn4, ifnv
+ elseif (ifmtypei == 1) then
+ aR fmbell kamp, kfreq, kc1 * kstereo, kc2 * kstereo, kvibdepth * kstereo, kvibrate * kstereo, ifn1, ifn2, ifn3, ifn4, ifnv
+ elseif (ifmtypei == 2) then
+ aR fmpercfl kamp, kfreq, kc1 * kstereo, kc2 * kstereo, kvibdepth * kstereo, kvibrate * kstereo, ifn1, ifn2, ifn3, ifn4, ifnv
+ elseif (ifmtypei == 3) then
+ aR fmrhode kamp, kfreq, kc1 * kstereo, kc2 * kstereo, kvibdepth * kstereo, kvibrate * kstereo, ifn1, ifn2, ifn3, ifn4, ifnv
+ elseif (ifmtypei == 4) then
+ aR fmwurlie kamp, kfreq, kc1 * kstereo, kc2 * kstereo, kvibdepth * kstereo, kvibrate * kstereo, ifn1, ifn2, ifn3, ifn4, ifnv
+ endif
+ endif
+ outs aL, aR
+endin
+
+
+opcode _twst_tf_genrepluck, a, kkiiikkkkk
+ kamp, kfn, ipluckpoint, ifreq, ipickuppoint, krefl, kexcitemode, kexcitefn, kexcitefreq, kexciteamp xin
+
+ if (kexcitemode == 0) then
+ aexcite noise kexciteamp, 0.5
+ else
+ aexcite oscilikt kexciteamp, kexcitefreq, kexcitefn
+ endif
+ aout repluck ipluckpoint, kamp, ifreq, ipickuppoint, krefl, aexcite
+ aout dcblock2 aout
+ xout aout
+endop
+
+instr twst_tf_genrepluck
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kamp = twst_param:k("amp")
+ kfn twst_tf_getwaveformk
+ ipluckpoint = twst_parami("pluckpoint")
+ ifreq twst_tf_freqi
+ ipickuppoint = twst_parami("pickpoint")
+ krefl = twst_param:k("reflection")
+ kexciteamp = twst_param:k("exciteamp")
+ kexcitemode = twst_param:k("excitemode")
+ kexcitefn twst_tf_getwaveformk twst_param:k("excitewave")
+ kexcitefreq = twst_tf_freq_custom("excite")
+
+ if (ileft == 1) then
+ aL _twst_tf_genrepluck kamp, kfn, ipluckpoint, ifreq, ipickuppoint, krefl, kexcitemode, kexcitefn, kexcitefreq, kexciteamp
+ endif
+ if (iright == 1) then
+ aR _twst_tf_genrepluck kamp, kfn, ipluckpoint, ifreq, ipickuppoint, krefl, kexcitemode, kexcitefn, kexcitefreq, kexciteamp
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_genwgbow
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kamp = twst_param:k("amp")
+ kfreq twst_tf_freq
+ kpres = twst_param:k("pressure")
+ kpos = twst_param:k("position")
+ kvibf = twst_param:k("vibfreq")
+ kvamp = twst_param:k("vibamp")
+ ifn twst_tf_getwaveform
+
+ if (ileft == 1) then
+ aL wgbow kamp, kfreq, kpres, kpos, kvibf, kvamp, ifn, 20
+ endif
+ if (iright == 1) then
+ aR wgbow kamp, kfreq, kpres, kpos, kvibf, kvamp, ifn, 20
+ endif
+ outs aL, aR
+endin
+
+/* not quite right, doesn't create sound as expected
+instr twst_tf_genwgbowedbar
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kamp = twst_param:k("amp")
+ kfreq twst_tf_freq
+ kpres = twst_param:k("pressure")
+ kpos = twst_param:k("position")
+ kgain = twst_param:k("filtergain")
+
+ if (ileft == 1) then
+ aL wgbowedbar kamp, kfreq, kpos, kpres, kgain
+ endif
+ if (iright == 1) then
+ aR wgbowedbar kamp, kfreq, kpos, kpres, kgain
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_genwgbrass
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kamp = twst_param:k("amp")
+ kfreq twst_tf_freq
+ ktension = twst_param:k("tension")
+ iattack = twst_parami("attack")
+ kvibf = twst_param:k("vibfreq")
+ kvamp = twst_param:k("vibamp")
+ ifn twst_tf_getwaveform
+
+ if (ileft == 1) then
+ aL wgbrass kamp, kfreq, ktension, iattack, kvibf, kvamp, ifn, 100
+ endif
+ if (iright == 1) then
+ aR wgbrass kamp, kfreq, ktension, iattack, kvibf, kvamp, ifn, 100
+ endif
+ outs aL, aR
+endin
+*/
+
+instr twst_tf_gennoise
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ ktype = twst_param:k("type")
+ kamp = twst_param:k("amp")
+ kbeta = twst_param:k("beta")
+
+ if (ileft == 1) then
+ if (ktype == 0) then
+ aL unirand 2
+ aL = aL - 1
+ elseif (ktype == 1) then
+ aL pinker
+ endif
+ aL *= kamp
+ endif
+ if (iright == 1) then
+ if (ktype == 0) then
+ aR unirand 2
+ aR = aR - 1
+ elseif (ktype == 1) then
+ aR pinker
+ endif
+ aR *= kamp
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_genbamboo
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kamp = twst_param:k("amp")
+ inum = twst_parami("number")
+ ifreq1 = twst_parami("r1freq")
+ ifreq2 = twst_parami("r2freq")
+ ifreq3 = twst_parami("r3freq")
+
+ if (ileft == 1) then
+ aL bamboo kamp, 0, inum, 0, 0, ifreq1, ifreq2, ifreq3
+ endif
+ if (iright == 1) then
+ aR bamboo kamp, 0, inum, 0, 0, ifreq1, ifreq2, ifreq3
+ endif
+ outs aL, aR
+endin
+
+/* opcode unavailable in WASM
+{name: "Fractal noise", instr: "twst_tf_genfractalnoise", parameters: [
+ {name: "Type", options: ["White", "Pink", "Brown"], automatable: true, description: "Type of noise"},
+ {preset: "amp"},
+ {preset: "applymode"}
+]}
+
+instr twst_tf_genfractalnoise
+ aL, aR, ileft, iright twst_getinput
+ ktype = twst_param:k("type")
+ kamp = twst_param:k("amp")
+
+ if (ileft == 1) then
+ aL fractalnoise kamp, ktype
+ endif
+ if (iright == 1) then
+ aR fractalnoise kamp, ktype
+ endif
+ outs aL, aR
+endin
+*/
diff --git a/site/udo/twist/transforms/granular.udo b/site/udo/twist/transforms/granular.udo
new file mode 100755
index 0000000..c25a517
--- /dev/null
+++ b/site/udo/twist/transforms/granular.udo
@@ -0,0 +1,138 @@
+#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
diff --git a/site/udo/twist/transforms/harmonic.udo b/site/udo/twist/transforms/harmonic.udo
new file mode 100755
index 0000000..717de44
--- /dev/null
+++ b/site/udo/twist/transforms/harmonic.udo
@@ -0,0 +1,142 @@
+#include "/twist/transform_api.udo"
+
+instr twst_tf_resony
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kfreq twst_tf_freq
+ kbw = twst_param:k("bandwidth")
+ inum = twst_parami("num")
+ ksep = twst_param:k("separation")
+ isepmode = twst_parami("sepmode")
+ ibalance = twst_parami("balance")
+
+ if (ileft == 1) then
+ aLr resony aL, kfreq, kbw, inum, ksep, isepmode
+ if (ibalance == 1) then
+ aL balance aLr, aL
+ else
+ aL = aLr
+ endif
+ endif
+ if (iright == 1) then
+ aRr resony aR, kfreq, kbw, inum, ksep, isepmode
+ if (ibalance == 1) then
+ aR balance aRr, aR
+ else
+ aR = aRr
+ endif
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_resonx
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kfreq twst_tf_freq
+ kbw = twst_param:k("bandwidth")
+ inum = twst_parami("num")
+ ibalance = twst_parami("balance")
+
+ if (ileft == 1) then
+ aLr resonx aL, kfreq, kbw, inum
+ if (ibalance == 1) then
+ aL balance aLr, aL
+ else
+ aL = aLr
+ endif
+ endif
+ if (iright == 1) then
+ aRr resonx aR, kfreq, kbw, inum
+ if (ibalance == 1) then
+ aR balance aRr, aR
+ else
+ aR = aRr
+ endif
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_streson
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kfreq twst_tf_freq
+ kfeedback = twst_param:k("feedback")
+ if (ileft == 1) then
+ aL streson aL, kfreq, kfeedback
+ endif
+ if (iright == 1) then
+ aR streson aR, kfreq, kfeedback
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_mvmfilter
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kfreq = twst_param:k("freq")
+ kdecay = twst_param:k("decay")
+ kbalance = twst_param:k("balance")
+ if (ileft == 1) then
+ aLf mvmfilter aL, kfreq, kdecay
+ if (kbalance == 1) then
+ aL balance aLf, aL
+ else
+ aL = aLf
+ endif
+ endif
+ if (iright == 1) then
+ aRf mvmfilter aR, kfreq, kdecay
+ if (kbalance == 1) then
+ aL balance aRf, aR
+ else
+ aR = aRf
+ endif
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_harmon
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kestfreq = twst_param:k("estfreq")
+ kmaxvar = twst_param:k("maxvar")
+ kgenfreq1 = twst_param:k("genfreq1")
+ kgenfreq2 = twst_param:k("genfreq2")
+ iminfreq = twst_parami("minfreq")
+ ianalysistime = twst_parami("analysistime")
+ if (ileft == 1) then
+ aL harmon aL, kestfreq, kmaxvar, kgenfreq1, kgenfreq2, 0, iminfreq, ianalysistime
+ endif
+ if (iright == 1) then
+ aR harmon aR, kestfreq, kmaxvar, kgenfreq1, kgenfreq2, 0, iminfreq, ianalysistime
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_formantharmon
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kgenfreq1 = twst_param:k("genfreq1")
+ kgenfreq2 = twst_param:k("genfreq2")
+ kgenfreq3 = twst_param:k("genfreq3")
+ kgenfreq4 = twst_param:k("genfreq4")
+ iminfreq = octcps:i(twst_parami("minfreq"))
+ ipolarity = twst_parami("polarity")
+
+ ipupdate = twst_parami("pupdate")
+ iplow = octcps:i(twst_parami("plowfreq"))
+ iphigh = octcps:i(twst_parami("phighfreq"))
+ ipthresh = dbamp:i(twst_parami("pthresh"))
+ ipfrqs = twst_parami("pfrqs")
+ ipconfirm = twst_parami("pconfirms")
+
+ if (ileft == 1) then
+ koct, kamp pitch aL, ipupdate, iplow, iphigh, ipthresh, ipfrqs, ipconfirm
+ aL harmon4 aL, koct, kgenfreq1, kgenfreq2, kgenfreq3, kgenfreq4, 0, iminfreq, ipolarity
+ endif
+ if (iright == 1) then
+ koct, kamp pitch aR, ipupdate, iplow, iphigh, ipthresh, ipfrqs, ipconfirm
+ aR harmon4 aR, koct, kgenfreq1, kgenfreq2, kgenfreq3, kgenfreq4, 0, iminfreq, ipolarity
+ endif
+ outs aL, aR
+endin
diff --git a/site/udo/twist/transforms/reverb.udo b/site/udo/twist/transforms/reverb.udo
new file mode 100755
index 0000000..e6f66ec
--- /dev/null
+++ b/site/udo/twist/transforms/reverb.udo
@@ -0,0 +1,80 @@
+#include "/twist/transform_api.udo"
+
+instr twst_tf_reverb1
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ ktime = twst_param:k("time")
+ if (ileft == 1) then
+ aL reverb aL, ktime
+ endif
+ if (iright == 1) then
+ aR reverb aR, ktime
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_reverb2
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ ktime = twst_param:k("time")
+ khfdamp = twst_param:k("hfdamp")
+ if (ileft == 1) then
+ aL nreverb aL, ktime, khfdamp
+ endif
+ if (iright == 1) then
+ aR nreverb aR, ktime, khfdamp
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_reverb3
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kroomsize = twst_param:k("roomsize")
+ khfdamp = twst_param:k("hfdamp")
+ if (ileft != 1) then
+ aL noise 0.001, 0.5
+ endif
+ if (iright != 1) then
+ aR noise 0.001, 0.5
+ endif
+ aL, aR freeverb aL, aR, kroomsize, khfdamp
+ outs aL, aR
+endin
+
+instr twst_tf_reverb4
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kfeedback = twst_param:k("feedback")
+ khfdamp = twst_param:k("hfdamp") * (sr / 2)
+ ipitchmod = twst_parami("pitchmod")
+ if (ileft != 1) then
+ aL noise 0.001, 0.5
+ endif
+ if (iright != 1) then
+ aR noise 0.001, 0.5
+ endif
+ aL, aR reverbsc aL, aR, kfeedback, khfdamp, sr, ipitchmod
+ outs aL, aR
+endin
+
+
+instr twst_tf_reverb5
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ iwidth = twst_parami("width")
+ idepth = twst_parami("depth")
+ iheight = twst_parami("height")
+ kposx = twst_param:k("posx") * iwidth
+ kposy = twst_param:k("posy") * idepth
+ kposz = twst_param:k("posz") * iheight
+ if (ileft == 1 && iright == 1) then
+ ainput = (aL + aR) * 0.5
+ elseif (ileft != 1) then
+ ainput = aR
+ else
+ ainput = aL
+ endif
+ aL, aR babo ainput, kposx, kposy, kposz, iwidth, idepth, iheight
+ outs aL, aR
+endin
diff --git a/site/udo/twist/transforms/spectral.udo b/site/udo/twist/transforms/spectral.udo
new file mode 100755
index 0000000..b5f2fab
--- /dev/null
+++ b/site/udo/twist/transforms/spectral.udo
@@ -0,0 +1,642 @@
+#include "/twist/transform_api.udo"
+#include "/pvs_tabproc.udo"
+#include "/spectral_transforms.udo"
+#include "/fx_autoglitch.udo"
+#include "/host_platform.udo"
+#include "/addsub.udo"
+
+instr twst_tf_tpvinvert
+ $TWST_TRANSFORM
+ setksmps(64)
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ kinvertamp = twst_param:k("invertamp")
+ kinvertfreq = twst_param:k("invertfreq")
+
+ if (ileft == 1) then
+ kreadyL, itpvdataL tpv_anal fL
+ tpv_invert kreadyL, itpvdataL, kinvertamp, kinvertfreq
+ fL tpv_resynth itpvdataL, fL
+ aL twst_tf_fresynth fL
+ endif
+ if (iright == 1) then
+ kreadyR, itpvdataR tpv_anal fR
+ tpv_invert kreadyR, itpvdataR, kinvertamp, kinvertfreq
+ fR tpv_resynth itpvdataR, fR
+ aR twst_tf_fresynth fR
+ endif
+ outs aL, aR
+endin
+
+
+instr twst_tf_tpvbubble
+ $TWST_TRANSFORM
+ setksmps(64)
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ kchance = twst_param:k("chance")
+ kstereounique = twst_param:k("stereounique")
+
+ if (ileft == 1) then
+ kreadyL, itpvdataL tpv_anal fL
+ tpv_bubble kreadyL, itpvdataL, kchance, kstereounique
+ fL tpv_resynth itpvdataL, fL
+ aL twst_tf_fresynth fL
+ endif
+ if (iright == 1) then
+ kreadyR, itpvdataR tpv_anal fR
+ tpv_bubble kreadyR, itpvdataR, kchance, kstereounique
+ fR tpv_resynth itpvdataR, fR
+ aR twst_tf_fresynth fR
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_tpvsmear
+ $TWST_TRANSFORM
+ setksmps(64)
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ imaxframes = twst_parami("maxframes")
+ kframes = twst_param:k("frames")
+ kavgfreqs = twst_param:k("avgfreqs")
+ kincludeoriginal = twst_param:k("includeoriginal")
+
+ if (ileft == 1) then
+ kreadyL, itpvdataL tpv_anal fL
+ tpv_smear kreadyL, itpvdataL, imaxframes, kframes, kavgfreqs, kincludeoriginal
+ fL tpv_resynth itpvdataL, fL
+ aL twst_tf_fresynth fL
+ endif
+ if (iright == 1) then
+ kreadyR, itpvdataR tpv_anal fR
+ tpv_smear kreadyR, itpvdataR, imaxframes, kframes, kavgfreqs, kincludeoriginal
+ fR tpv_resynth itpvdataR, fR
+ aR twst_tf_fresynth fR
+ endif
+ outs aL, aR
+endin
+
+
+instr twst_tf_tpvscramble
+ $TWST_TRANSFORM
+ setksmps(64)
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ kstep = twst_param:k("step")
+ kdoamp = twst_param:k("scrambleamp")
+ kdofreq = twst_param:k("scramblefreq")
+
+ if (ileft == 1) then
+ kreadyL, itpvdataL tpv_anal fL
+ tpv_scramble kreadyL, itpvdataL, kstep, kdoamp, kdofreq
+ fL tpv_resynth itpvdataL, fL
+ aL twst_tf_fresynth fL
+ endif
+ if (iright == 1) then
+ kreadyR, itpvdataR tpv_anal fR
+ tpv_scramble kreadyR, itpvdataR, kstep, kdoamp, kdofreq
+ fR tpv_resynth itpvdataR, fR
+ aR twst_tf_fresynth fR
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_tpvthreshold
+ $TWST_TRANSFORM
+ setksmps(64)
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ kthreshold = twst_param:k("threshold")
+ kdirection = twst_param:k("direction")
+
+ if (ileft == 1) then
+ kreadyL, itpvdataL tpv_anal fL
+ tpv_threshold kreadyL, itpvdataL, kthreshold, kdirection
+ fL tpv_resynth itpvdataL, fL
+ aL twst_tf_fresynth fL
+ endif
+ if (iright == 1) then
+ kreadyR, itpvdataR tpv_anal fR
+ tpv_threshold kreadyR, itpvdataR, kthreshold, kdirection
+ fR tpv_resynth itpvdataR, fR
+ aR twst_tf_fresynth fR
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_tpvfreeze
+ $TWST_TRANSFORM
+ setksmps(64)
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ kfreeze = twst_param:k("freeze")
+ kfreezeamp = twst_param:k("freezeamp")
+ kfreezefreq = twst_param:k("freezefreq")
+ kcrossfade = twst_param:k("crossfade")
+
+ if (ileft == 1) then
+ kreadyL, itpvdataL tpv_anal fL
+ tpv_freeze1 kreadyL, itpvdataL, kfreeze, kfreezeamp, kfreezefreq, kcrossfade
+ fL tpv_resynth itpvdataL, fL
+ aL twst_tf_fresynth fL
+ endif
+ if (iright == 1) then
+ kreadyR, itpvdataR tpv_anal fR
+ tpv_freeze1 kreadyR, itpvdataR, kfreeze, kfreezeamp, kfreezefreq, kcrossfade
+ fR tpv_resynth itpvdataR, fR
+ aR twst_tf_fresynth fR
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_tpvwrap
+ $TWST_TRANSFORM
+ setksmps(64)
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ kwrapampbin = twst_param:k("wrapampbin")
+ kwrapfreqbin = twst_param:k("wrapfreqbin")
+
+ if (ileft == 1) then
+ i_, inumbins, i_, i_ pvsinfo fL
+ kreadyL, itpvdataL tpv_anal fL
+ tpv_wrap kreadyL, itpvdataL, kwrapampbin * inumbins, kwrapfreqbin * inumbins
+ fL tpv_resynth itpvdataL, fL
+ aL twst_tf_fresynth fL
+ endif
+ if (iright == 1) then
+ i_, inumbins, i_, i_ pvsinfo fR
+ kreadyR, itpvdataR tpv_anal fR
+ tpv_wrap kreadyR, itpvdataR, kwrapampbin * inumbins, kwrapfreqbin * inumbins
+ fR tpv_resynth itpvdataR, fR
+ aR twst_tf_fresynth fR
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_tpvswap
+ $TWST_TRANSFORM
+ setksmps(64)
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ kampStart = twst_param:k("ampstart")
+ kampLength = twst_param:k("amplength")
+ kampTarget = twst_param:k("amptarget")
+ kfreqStart = twst_param:k("freqstart")
+ kfreqLength = twst_param:k("freqlength")
+ kfreqTarget = twst_param:k("freqtarget")
+ kwrapmode = twst_param:k("wrapmode")
+
+ if (ileft == 1) then
+ i_, inumbins, i_, i_ pvsinfo fL
+ kreadyL, itpvdataL tpv_anal fL
+ tpv_swap kreadyL, itpvdataL, kampStart * inumbins, kampLength * inumbins, kampTarget * inumbins, kfreqStart * inumbins, kfreqLength * inumbins, kfreqTarget * inumbins, kwrapmode
+ fL tpv_resynth itpvdataL, fL
+ aL twst_tf_fresynth fL
+ endif
+ if (iright == 1) then
+ i_, inumbins, i_, i_ pvsinfo fR
+ kreadyR, itpvdataR tpv_anal fR
+ tpv_swap kreadyR, itpvdataR, kampStart * inumbins, kampLength * inumbins, kampTarget * inumbins, kfreqStart * inumbins, kfreqLength * inumbins, kfreqTarget * inumbins, kwrapmode
+ fR tpv_resynth itpvdataR, fR
+ aR twst_tf_fresynth fR
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_tpvaverage
+ $TWST_TRANSFORM
+ setksmps(64)
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ kmax = twst_param:k("maxframes")
+ kavgamp = twst_param:k("avgamp")
+ kavgfreq = twst_param:k("avgfreq")
+ krate = twst_param:k("rate")
+
+ ktrig metro krate
+
+ if (ileft == 1) then
+ kreadyL, itpvdataL tpv_anal fL
+ tpv_average kreadyL, itpvdataL, kmax, kavgamp, kavgfreq, ktrig
+ fL tpv_resynth itpvdataL, fL
+ aL twst_tf_fresynth fL
+ endif
+ if (iright == 1) then
+ kreadyR, itpvdataR tpv_anal fR
+ tpv_average kreadyR, itpvdataR, kmax, kavgamp, kavgfreq, ktrig
+ fR tpv_resynth itpvdataR, fR
+ aR twst_tf_fresynth fR
+ endif
+ outs aL, aR
+endin
+
+
+/*
+instr twst_tf_stencil
+ $TWST_TRANSFORM
+ Spvx = strcat(host_tempdir(), "twist_stencil.pvx")
+ ifftsize = twst_parami("fftsize")
+ kran init 0
+ ktimek timeinstk
+ if (ktimek == 1) then
+ ifnL, ifnR, istart, ilen, ileft, iright twst_getcrossdata
+ ikcycles = round(ilen / kr)
+ kcount = 1
+ while (kcount < ikcycles) do
+ aLo, aRo, ileft, iright twst_getcrossinput
+ if (ileft == 1 && iright == 1) then
+ ain = (aLo + aRo) * 0.5
+ elseif (ileft == 1) then
+ ain = aLo
+ elseif (iright == 1) then
+ ain = aRo
+ endif
+ f1 pvsanal ain, ifftsize, ifftsize/4, ifftsize, 1
+ pvsfwrite f1, Spvx
+ kcount += 1
+ od
+
+ elseif (ktimek == 1) then
+ schedulek("_twst_tf_stencilplayback", 0, p3, p4, Spvx) ; TODO : won't work offline
+ endif
+
+ aL, aR bus_read "stencilplayback"
+ kreleasing init 0
+ if (kreleasing == 0 && release:k() == 1) then
+ turnoff2 "_twst_tf_stencilplayback", 0, 1
+ kreleasing = 1
+ endif
+
+ outs aL, aR
+endin
+
+instr _twst_tf_stencilplayback
+ $TWST_TRANSFORM
+ Spvx = strget(p5)
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ ifftsize = twst_parami("fftsize")
+ kgain = twst_param:k("gain")
+ klevel = twst_param:k("level")
+
+ ifn ftgentmp 0, 0, (ifftsize * 2) + 1, 43, Spvx, 1
+
+ if (ileft == 1) then
+ fpsL pvstencil fL, kgain, klevel, ifn
+ aL twst_tf_fresynth fpsL
+ endif
+ if (iright == 1) then
+ fpsR pvstencil fR, kgain, klevel, ifn
+ aR twst_tf_fresynth fpsR
+ endif
+ bus_mix("stencilplayback", aL, aR)
+endin
+*/
+
+instr twst_tf_spectralshift
+ $TWST_TRANSFORM
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ kfreqincr = twst_param:k("freqincr")
+ kporttime = twst_param:k("porttime")
+ kfreqscale = twst_tf_pitchscale()
+ istart = twst_parami("start")
+ iend = twst_parami("end")
+ ifn = twst_tf_getwaveform()
+
+ if (ileft == 1) then
+ aL spc_shift fL, kfreqincr, istart, iend, kfreqscale, kporttime, ifn
+ endif
+ if (iright == 1) then
+ aR spc_shift fR, kfreqincr, istart, iend, kfreqscale, kporttime, ifn
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_spectraldelay
+ $TWST_TRANSFORM
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ kdeltime = twst_param:k("time")
+ kdeladd = twst_param:k("add")
+ kporttime = twst_param:k("porttime")
+ kfreqscale = twst_tf_pitchscale()
+ istart = twst_parami("start")
+ iend = twst_parami("end")
+ ifn = twst_tf_getwaveform()
+
+ if (ileft == 1) then
+ aL spc_delay fL, kdeltime, kdeladd, istart, iend, kfreqscale, kporttime, ifn
+ endif
+ if (iright == 1) then
+ aR spc_delay fR, kdeltime, kdeladd, istart, iend, kfreqscale, kporttime, ifn
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_spectralgate
+ $TWST_TRANSFORM
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ kthresh = twst_param:k("threshold")
+ khold = twst_param:k("hold")
+ kporttime = twst_param:k("porttime")
+ kfreqscale = twst_tf_pitchscale()
+ istart = twst_parami("start")
+ iend = twst_parami("end")
+ ifn = twst_tf_getwaveform()
+
+ if (ileft == 1) then
+ aL spc_gate fL, kthresh, khold, istart, iend, kfreqscale, kporttime, ifn
+ endif
+ if (iright == 1) then
+ aR spc_gate fR, kthresh, khold, istart, iend, kfreqscale, kporttime, ifn
+ endif
+ outs aL, aR
+endin
+
+instr twst_tfi_spectralgrain1
+ $TWST_TRANSFORM
+ ileft, iright, istartsamp, iendsamp, idocut, ilength twst_tf_getstate
+ ifnL, ifnR twst_tfi_getfn
+
+ ireadmode = twst_parami("readmode")
+ if (ireadmode == 0) then
+ ktime linseg 0, p3, ilength
+ elseif (ireadmode == 1) then
+ ktime = twst_param:k("readtime")
+ twst_tf_setplayposition ktime
+ ktime *= ilength
+ elseif (ireadmode == 2) then
+ itimescale = twst_parami("timescale")
+ p3 = ilength * itimescale
+ ktime linseg 0, p3, ilength
+ elseif (ireadmode == 3) then
+ ktime linseg ilength, p3, 0
+ endif
+
+ kgraindur = twst_param:k("graindur")
+ ifftsize = twst_parami("fftsize")
+ ilayers = twst_parami("layers")
+ kporttime = twst_param:k("porttime")
+ kfreqscale = twst_tf_pitchscale()
+ kfreqrand = twst_param:k("freqrand")
+ kdurrand = twst_param:k("durrand")
+ kpitchrand = twst_param:k("pitchrand")
+ istart = twst_parami("start")
+ iend = twst_parami("end")
+ ifn = twst_tf_getwaveform()
+ twst_setlatencysamples(ifftsize)
+
+ if (ileft == 1) then
+ aL spc_grain1 ifnL, ktime, kgraindur, ifftsize, ilayers, istart, iend, kfreqscale, kfreqrand, kdurrand, kpitchrand, kporttime, ifn
+ endif
+ if (iright == 1) then
+ aR spc_grain1 ifnR, ktime, kgraindur, ifftsize, ilayers, istart, iend, kfreqscale, kfreqrand, kdurrand, kpitchrand, kporttime, ifn
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_spectralread
+ $TWST_TRANSFORM
+ ileft, iright, istartsamp, iendsamp, idocut, ilength twst_tf_getstate
+ ifftsize = twst_parami("fftsize")
+ ktime = twst_param:k("readtime") * ilength
+ twst_tf_setplayposition ktime
+ twst_setlatencysamples(ifftsize)
+
+ ktimek timeinstk
+ ilensamps = iendsamp - istartsamp
+ ikcycles = ilength * kr
+ kcount init 0
+ if (ktimek == 1) then
+ while (kcount < ikcycles) do
+ apos linseg 0, ilength, iendsamp
+ if (ileft == 1 && iright == 1) then
+ aL table3 apos, gitwst_bufferL[gitwst_instanceindex]
+ aR table3 apos, gitwst_bufferR[gitwst_instanceindex]
+ asig = (aL + aR) * 0.5
+ elseif (ileft == 1) then
+ asig table3 apos, gitwst_bufferL[gitwst_instanceindex]
+ elseif (iright == 1) then
+ asig table3 apos, gitwst_bufferR[gitwst_instanceindex]
+ endif
+ fsig pvsanal asig, ifftsize, ifftsize/4, ifftsize, 1
+ ipbuf, k_ pvsbuffer fsig, ilength
+ kcount += 1
+ od
+ else
+ if (ileft == 1) then
+ fL pvsbufread ktime, ipbuf
+ aL twst_tf_fresynth fL
+ endif
+ if (iright == 1) then
+ fR pvsbufread ktime, ipbuf
+ aR twst_tf_fresynth fR
+ endif
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_centroidoscillator
+ $TWST_TRANSFORM
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ kporttime = twst_param:k("porttime")
+ kfreqscale = twst_tf_pitchscale()
+ kfn twst_tf_getwaveformk
+
+ if (ileft == 1) then
+ kcent pvscent fL
+ kfreq portk kcent * kfreqscale, kporttime
+ aL oscilikt 1, kfreq, kfn
+ endif
+ if (iright == 1) then
+ kcent pvscent fR
+ kfreq portk kcent * kfreqscale, kporttime
+ aR oscilikt 1, kfreq, kfn
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_binoscillator
+ $TWST_TRANSFORM
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ kporttime = twst_param:k("porttime")
+ kbin = twst_param:k("bin")
+ kfreqscale = twst_tf_pitchscale()
+ kfn twst_tf_getwaveformk
+
+ if (ileft == 1) then
+ i_, inumbins, i_, i_ pvsinfo fL
+ kamp, kfreqbase pvsbin fL, round:k(kbin * inumbins)
+ kfreq portk kfreqbase * kfreqscale, kporttime
+ aL oscilikt 1, kfreq, kfn
+ endif
+ if (iright == 1) then
+ i_, inumbins, i_, i_ pvsinfo fR
+ kamp, kfreqbase pvsbin fL, round:k(kbin * inumbins)
+ kfreq portk kfreqbase * kfreqscale, kporttime
+ aR oscilikt 1, kfreq, kfn
+ endif
+ outs aL, aR
+endin
+
+opcode _twst_tf_partialreconstruction, a, aikkkikkki
+ ain, ifftsize, kthresh, kminpoints, kmaxgap, imaxtracks, kampscale, kfreqscale, kmaxtracks, ifn xin
+ ffreq, fphase pvsifd ain, ifftsize, ifftsize/4, 1
+ ftrks partials ffreq, fphase, kthresh, kminpoints, kmaxgap, imaxtracks
+ aout resyn ftrks, kampscale, kfreqscale, kmaxtracks, ifn
+ aout dcblock aout
+ xout aout
+endop
+
+instr twst_tf_partialreconstruction
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ ifftsize = twst_parami("fftsize")
+ kthresh = twst_param:k("threshold")
+ kminpoints = twst_param:k("minpoints")
+ kmaxgap = twst_param:k("maxgap")
+ imaxtracks = round(twst_parami("anlmaxtracks") * ifftsize * 0.5)
+ kampscale = twst_param:k("ampscale")
+ kfreqscale = twst_tf_pitchscale()
+ kmaxtracks = round:k(twst_param:k("resmaxtracks") * ifftsize * 0.5)
+ ifn = twst_tf_getwaveform()
+ twst_setlatencysamples(ifftsize)
+
+ if (ileft == 1) then
+ aL _twst_tf_partialreconstruction aL, ifftsize, kthresh, kminpoints, kmaxgap, imaxtracks, kampscale, kfreqscale, kmaxtracks, ifn
+ endif
+ if (iright == 1) then
+ aR _twst_tf_partialreconstruction aR, ifftsize, kthresh, kminpoints, kmaxgap, imaxtracks, kampscale, kfreqscale, kmaxtracks, ifn
+ endif
+ outs aL, aR
+endin
+
+opcode _twst_tf_residual, a, aii
+ ain, ifftsize, ihsize xin
+ ffr, fphs pvsifd ain, ifftsize, ihsize, 1
+ ftrk partials ffr, fphs, 0, 1, 3, 500
+ aout sinsyn ftrk, 2, 500, gifnSine
+ asd delayr ifftsize / sr
+ asig deltapn ifftsize - ihsize
+ delayw ain
+ xout asig - aout
+endop
+
+instr twst_tf_residual
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ ifftsize = twst_parami("fftsize")
+ twst_setlatencysamples(ifftsize)
+ ihsize = ifftsize / 4
+ if (ileft == 1) then
+ aL _twst_tf_residual aL, ifftsize, ihsize
+ endif
+ if (iright == 1) then
+ aR _twst_tf_residual aR, ifftsize, ihsize
+ endif
+ outs aL, aR
+endin
+
+/* not in WASM
+instr twst_tf_trace
+ $TWST_TRANSFORM
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ inumbins = twst_parami("fftsize") / 2
+ kbins = twst_param("bins") * inumbins
+
+ if (ileft == 1) then
+ foutL pvstrace fL, kbins
+ aL twst_tf_fresynth foutL
+ endif
+ if (iright == 1) then
+ foutR pvstrace fR, kbins
+ aR twst_tf_fresynth foutR
+ endif
+ outs aL, aR
+endin
+*/
+
+instr twst_tf_isolator
+ $TWST_TRANSFORM
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ kbin = twst_param("bin")
+ kattenuation = twst_param("attenuation")
+ kgain = twst_param("accentuation")
+
+ if (ileft == 1) then
+ foutL pvsarp fL, kbin, kattenuation, kgain
+ aL twst_tf_fresynth foutL
+ endif
+ if (iright == 1) then
+ foutR pvsarp fR, kbin, kattenuation, kgain
+ aR twst_tf_fresynth foutR
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_blur
+ $TWST_TRANSFORM
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ ktime = twst_param:k("time")
+ if (ileft == 1) then
+ fL1 pvsblur fL, ktime, 3
+ aL twst_tf_fresynth fL1
+ endif
+ if (iright == 1) then
+ fR1 pvsblur fR, ktime, 3
+ aR twst_tf_fresynth fR1
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_spectralautoglitch
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kchangerate = twst_param:k("changerate")
+ kchangechance = twst_param:k("changechance")
+ kporttime = twst_param:k("porttime")
+ kdo_pitchalter = twst_param:k("pitchalter")
+ ifftsize = twst_parami("fftsize")
+
+ twst_setlatencysamples ifftsize
+
+ if (ileft == 1) then
+ aL fx_spectralautoglitch aL, kchangerate, kchangechance, kdo_pitchalter, kporttime, ifftsize
+ endif
+ if (iright == 1) then
+ aR fx_spectralautoglitch aR, kchangerate, kchangechance, kdo_pitchalter, kporttime, ifftsize
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_subtractive
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ ifreq = twst_parami("minfreq")
+ ifreqmax = twst_parami("maxfreq")
+ ifreqstepmult = twst_parami("step")
+ ifreqstepmultrand = twst_parami("steprand")
+ iamp = twst_parami("amp")
+ iampmult = twst_parami("ampmult")
+
+ if (ileft == 1) then
+ aL as_subtractive aL, ifreq, ifreqmax, ifreqstepmult, ifreqstepmultrand, iamp, iampmult
+ endif
+ if (iright == 1) then
+ aR as_subtractive aR, ifreq, ifreqmax, ifreqstepmult, ifreqstepmultrand, iamp, iampmult
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_phasemash
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ ifftsize = twst_parami("fftsize")
+ kphasemode = twst_param:k("phasereplace")
+ kphasevalue = twst_param:k("phasevalue")
+
+ if (kphasemode == 0) then
+ kphasevalue *= 7
+ else
+ kphasevalue = ((kphasevalue * 2) - 1) * 3.141
+ endif
+
+ if (ileft == 1) then
+ aL spc_phasemash aL, kphasemode, kphasevalue, ifftsize
+ endif
+ if (iright == 1) then
+ aR spc_phasemash aR, kphasemode, kphasevalue, ifftsize
+ endif
+ outs aL, aR
+endin
diff --git a/site/udo/twist/transforms/warping.udo b/site/udo/twist/transforms/warping.udo
new file mode 100755
index 0000000..3eb4e6e
--- /dev/null
+++ b/site/udo/twist/transforms/warping.udo
@@ -0,0 +1,210 @@
+#include "/twist/transform_api.udo"
+#include "/sample_level.udo"
+
+instr twst_tf_smphold
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kratio = twst_param:k("ratio")
+ if (ileft == 1) then
+ aL smp_hold aL, kratio
+ endif
+ if (iright == 1) then
+ aR smp_hold aR, kratio
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_fftpitchscale
+ $TWST_TRANSFORM
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ kscale = twst_tf_pitchscale()
+ kformant = twst_param:k("formants")
+ kcoefs = twst_param:k("formantcoefs")
+
+ if (ileft == 1) then
+ fL1 pvscale fL, kscale, kformant, 1, kcoefs
+ aL twst_tf_fresynth fL1
+ endif
+ if (iright == 1) then
+ fR1 pvscale fR, kscale, kformant, 1, kcoefs
+ aR twst_tf_fresynth fR1
+ endif
+ outs aL, aR
+endin
+
+opcode _twst_tf_autotune, f, fkkk
+ fsig, kthreshold, kformant, kcoefs xin
+ kfreq, kamp pvspitch fsig, kthreshold
+ if (kfreq > 20) then
+ knote ftom kfreq
+ kscale = cpsmidinn:k(int:k(knote)) / kfreq
+ fsigo pvscale fsig, kscale, kformant, 1, kcoefs
+ else
+ fsigo = fsig
+ endif
+ xout fsigo
+endop
+
+
+instr twst_tf_autotune
+ $TWST_TRANSFORM
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ kthreshold = twst_param:k("threshold")
+ kformant = twst_param:k("formants")
+ kcoefs = twst_param:k("formantcoefs")
+
+ if (ileft == 1) then
+ fL1 _twst_tf_autotune fL, kthreshold, kformant, kcoefs
+ aL twst_tf_fresynth fL1
+ endif
+ if (iright == 1) then
+ fR1 _twst_tf_autotune fR, kthreshold, kformant, kcoefs
+ aR twst_tf_fresynth fR1
+ endif
+ outs aL, aR
+endin
+
+
+instr twst_tf_hilbertpitchscale
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ ifftsize = twst_parami("fftsize")
+ kscale = twst_tf_pitchscale()
+ twst_setlatencysamples(ifftsize)
+
+ if (ileft == 1) then
+ ahL1, ahL2 hilbert2 aL, ifftsize, ifftsize / 4
+ amL, afmL fmanal ahL1, ahL2
+ aL oscil amL, afmL * kscale
+ endif
+ if (iright == 1) then
+ ahR1, ahR2 hilbert2 aR, ifftsize, ifftsize / 4
+ amR, afmR fmanal ahR1, ahR2
+ aR oscil amR, afmR * kscale
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_waveset
+ $TWST_TRANSFORM
+ aL, aR, ileft, iright twst_getinput
+ kreps = twst_param:k("reps")
+ if (ileft == 1) then
+ aL waveset aL, kreps
+ endif
+ if (iright == 1) then
+ aR waveset aR, kreps
+ endif
+ outs aL, aR
+endin
+
+instr twst_tf_freeze
+ $TWST_TRANSFORM
+ fL, fR, aL, aR, ileft, iright twst_getfinput
+ kfreezeamp = twst_param:k("freezeamp")
+ kfreezefreq = twst_param:k("freezefreq")
+ if (ileft == 1) then
+ fL1 pvsfreeze fL, kfreezeamp, kfreezefreq
+ aL twst_tf_fresynth fL1
+ endif
+ if (iright == 1) then
+ fR1 pvsfreeze fR, kfreezeamp, kfreezefreq
+ aR twst_tf_fresynth fR1
+ endif
+ outs aL, aR
+endin
+
+instr twst_tfi_sndwarp
+ $TWST_TRANSFORM
+ ileft, iright, istartsamp, iendsamp, idocut, ilength twst_tf_getstate
+ ireadmode = twst_parami("readmode")
+ kpitchscale = twst_tf_pitchscale()
+ iwinsize = twst_parami("winsize")
+ irandwin = twst_parami("randwin")
+ ioverlap = twst_parami("overlap")
+ ifnWindow = twst_tf_getwintype()
+
+ 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
+ endif
+
+ ifnL, ifnR twst_tfi_getfn
+
+ kpitchscale *= ftsr(ifnL) / sr
+ apitchscale = a(kpitchscale)
+ if (ileft == 1) then
+ aL sndwarp 1, atime, apitchscale, ifnL, 0, iwinsize, irandwin, ioverlap, ifnWindow, 1
+ endif
+ if (iright == 1) then
+ aR sndwarp 1, atime, apitchscale, ifnR, 0, iwinsize, irandwin, ioverlap, ifnWindow, 1
+ endif
+ outs aL, aR
+endin
+
+instr twst_tfi_mincer
+ $TWST_TRANSFORM
+ ileft, iright, istartsamp, iendsamp, idocut, ilength twst_tf_getstate
+ ifftsize = twst_parami("fftsize")
+ kpitchscale = twst_tf_pitchscale()
+ klock = twst_param:k("phaselock")
+ ireadmode = twst_parami("readmode")
+ idecimation = twst_parami("decimation")
+
+ 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
+ endif
+
+ twst_setlatencysamples(ifftsize)
+ ifnL, ifnR twst_tfi_getfn
+ if (ileft == 1) then
+ aL mincer atime, 1, kpitchscale, ifnL, klock, ifftsize, idecimation
+ endif
+ if (iright == 1) then
+ aR mincer atime, 1, kpitchscale, ifnR, klock, ifftsize, idecimation
+ endif
+ outs aL, aR
+endin
+
+instr twst_tfi_paulstretch
+ $TWST_TRANSFORM
+ ileft, iright, istartsamp, iendsamp, idocut, ilength twst_tf_getstate
+
+ istretch = twst_parami("stretch")
+ iwinsize = twst_parami("winsize")
+ iduration = ilength * istretch
+ p3 = iduration
+
+ twst_setlatencyseconds iwinsize
+
+ ifnL, ifnR twst_tfi_getfn
+
+ if (ileft == 1) then
+ aL paulstretch istretch, iwinsize, ifnL
+ endif
+ if (iright == 1) then
+ aR paulstretch istretch, iwinsize, ifnR
+ endif
+ outs aL, aR
+endin