1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
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 kamp, kmultiplier, 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 asig
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, kbw
aL *= kamp
endif
if (iright == 1) then
aR twst_tf_genfeedback kfeedback, kfreq, kpostgain, kbw
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
*/
|