#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 */