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