-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTremoloStereoModule.binstr
412 lines (401 loc) · 15.1 KB
/
TremoloStereoModule.binstr
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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
<instrument type='blue.orchestra.BlueSynthBuilder' editEnabled='true'>
<name>Tremolo_adsr140_STEREO</name>
<comment>Tremolo Module for stereo use
needs the 3 UDOs: adsr140_calc_coef, adsr140 and k_Tremolo_adsr140_STEREO
---
version 1, October 2022
- initial version
</comment>
<globalOrc></globalOrc>
<globalSco/>
<instrumentText>;---------------------------------tremolo Module---------------------------------
asigL, asigR k_Tremolo_adsr140_STEREO <tremolo trigger>, asigL, asigR, <tremolo attack>, <tremolo decay>, <tremolo sustain>, <tremolo release>, <tremolo envelope speed>, <mix tremolo>
</instrumentText>
<alwaysOnInstrumentText></alwaysOnInstrumentText>
<graphicInterface editEnabled='false'>
<gridSettings>
<width>5</width>
<height>5</height>
<gridStyle>DOT</gridStyle>
<snapGridEnabled>true</snapGridEnabled>
</gridSettings>
<bsbObject type='blue.orchestra.blueSynthBuilder.BSBGroup'>
<objectName></objectName>
<x>0</x>
<y>0</y>
<groupName>Group</groupName>
<backgroundColor>0x00000033</backgroundColor>
<borderColor>0x000000ff</borderColor>
<labelTextColor>0xffffffff</labelTextColor>
<titleEnabled>true</titleEnabled>
<width>20</width>
<height>20</height>
<font>
<name>Roboto</name>
<size>12.0</size>
<style>0</style>
</font>
<bsbObject type='blue.orchestra.blueSynthBuilder.BSBGroup'>
<objectName></objectName>
<x>0</x>
<y>0</y>
<comment>trigger for tremolo envelope</comment>
<groupName>tremolo stereo</groupName>
<backgroundColor>0x59853eff</backgroundColor>
<borderColor>0x000000ff</borderColor>
<labelTextColor>0xffffffff</labelTextColor>
<titleEnabled>true</titleEnabled>
<width>20</width>
<height>20</height>
<font>
<name>Roboto</name>
<size>12.0</size>
<style>2</style>
</font>
<bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
<objectName></objectName>
<x>12</x>
<y>28</y>
<label>speed</label>
<font>
<name>Roboto</name>
<size>12.0</size>
<style>0</style>
</font>
</bsbObject>
<bsbObject type='blue.orchestra.blueSynthBuilder.BSBKnob' version='2'>
<objectName>mix tremolo</objectName>
<x>41</x>
<y>218</y>
<automationAllowed>true</automationAllowed>
<minimum>0.0</minimum>
<maximum>1.0</maximum>
<value>1.0</value>
<knobWidth>50</knobWidth>
<randomizable>true</randomizable>
<valueDisplayEnabled>false</valueDisplayEnabled>
<label>mix</label>
<labelEnabled>true</labelEnabled>
<font>
<name>Roboto</name>
<size>12.0</size>
<style>0</style>
</font>
</bsbObject>
<bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
<objectName></objectName>
<x>7</x>
<y>260</y>
<label>direct</label>
<font>
<name>Roboto</name>
<size>12.0</size>
<style>0</style>
</font>
</bsbObject>
<bsbObject type='blue.orchestra.blueSynthBuilder.BSBGroup'>
<objectName></objectName>
<x>77</x>
<y>23</y>
<comment>4 envelopes for amplitude</comment>
<groupName>Group</groupName>
<backgroundColor>0x00000033</backgroundColor>
<borderColor>0x000000ff</borderColor>
<labelTextColor>0xffffffff</labelTextColor>
<titleEnabled>false</titleEnabled>
<width>20</width>
<height>20</height>
<font>
<name>Roboto</name>
<size>12.0</size>
<style>0</style>
</font>
<bsbObject type='blue.orchestra.blueSynthBuilder.BSBKnob' version='2'>
<objectName>tremolo decay</objectName>
<x>10</x>
<y>45</y>
<automationAllowed>true</automationAllowed>
<minimum>0.0</minimum>
<maximum>1.0</maximum>
<value>0.6749303066059306</value>
<knobWidth>31</knobWidth>
<randomizable>true</randomizable>
<valueDisplayEnabled>false</valueDisplayEnabled>
<label>decay</label>
<labelEnabled>true</labelEnabled>
<font>
<name>Roboto</name>
<size>12.0</size>
<style>0</style>
</font>
</bsbObject>
<bsbObject type='blue.orchestra.blueSynthBuilder.BSBKnob' version='2'>
<objectName>tremolo attack</objectName>
<x>10</x>
<y>0</y>
<automationAllowed>true</automationAllowed>
<minimum>0.0</minimum>
<maximum>1.0</maximum>
<value>0.07121608179267352</value>
<knobWidth>31</knobWidth>
<randomizable>true</randomizable>
<valueDisplayEnabled>false</valueDisplayEnabled>
<label>attack</label>
<labelEnabled>true</labelEnabled>
<font>
<name>Roboto</name>
<size>12.0</size>
<style>0</style>
</font>
</bsbObject>
<bsbObject type='blue.orchestra.blueSynthBuilder.BSBKnob' version='2'>
<objectName>tremolo release</objectName>
<x>7</x>
<y>134</y>
<automationAllowed>true</automationAllowed>
<minimum>0.0</minimum>
<maximum>1.0</maximum>
<value>0.5754143184206626</value>
<knobWidth>31</knobWidth>
<randomizable>true</randomizable>
<valueDisplayEnabled>false</valueDisplayEnabled>
<label>release</label>
<labelEnabled>true</labelEnabled>
<font>
<name>Roboto</name>
<size>12.0</size>
<style>0</style>
</font>
</bsbObject>
<bsbObject type='blue.orchestra.blueSynthBuilder.BSBKnob' version='2'>
<objectName>tremolo sustain</objectName>
<x>7</x>
<y>90</y>
<automationAllowed>true</automationAllowed>
<minimum>0.0</minimum>
<maximum>1.0</maximum>
<value>0.0</value>
<knobWidth>31</knobWidth>
<randomizable>true</randomizable>
<valueDisplayEnabled>false</valueDisplayEnabled>
<label>sustain</label>
<labelEnabled>true</labelEnabled>
<font>
<name>Roboto</name>
<size>12.0</size>
<style>0</style>
</font>
</bsbObject>
</bsbObject>
<bsbObject type='blue.orchestra.blueSynthBuilder.BSBCheckBox'>
<objectName>tremolo trigger</objectName>
<x>0</x>
<y>0</y>
<comment>active retriggering of ADSR</comment>
<automationAllowed>true</automationAllowed>
<label>trigger</label>
<selected>false</selected>
<randomizable>true</randomizable>
</bsbObject>
<bsbObject type='blue.orchestra.blueSynthBuilder.BSBVSlider' version='2'>
<objectName>tremolo envelope speed</objectName>
<x>5</x>
<y>40</y>
<comment>speed of retriggering</comment>
<automationAllowed>true</automationAllowed>
<minimum>0.0</minimum>
<maximum>60.0</maximum>
<bdresolution>0.01</bdresolution>
<value>39.22</value>
<sliderHeight>145</sliderHeight>
<randomizable>true</randomizable>
<valueDisplayEnabled>true</valueDisplayEnabled>
</bsbObject>
<bsbObject type='blue.orchestra.blueSynthBuilder.BSBLabel' version='2'>
<objectName></objectName>
<x>89</x>
<y>260</y>
<label>ADSR</label>
<font>
<name>Roboto</name>
<size>12.0</size>
<style>0</style>
</font>
</bsbObject>
</bsbObject>
</bsbObject>
</graphicInterface>
<parameterList>
<parameter uniqueId='-1490019113' name='mix tremolo' label='' min='0.0' max='1.0' bdresolution='-1' automationEnabled='false' value='1.0'>
<line name='' version='2' max='1.0' min='0.0' bdresolution='-1' color='-8355712' rightBound='false' endPointsLinked='false'>
<linePoint x='0.0' y='1.0'/>
</line>
</parameter>
<parameter uniqueId='-1490019111' name='tremolo decay' label='' min='0.0' max='1.0' bdresolution='-1' automationEnabled='false' value='0.6749303066059306'>
<line name='' version='2' max='1.0' min='0.0' bdresolution='-1' color='-8355712' rightBound='false' endPointsLinked='false'>
<linePoint x='0.0' y='0.6749303066059306'/>
</line>
</parameter>
<parameter uniqueId='-1490019109' name='tremolo attack' label='' min='0.0' max='1.0' bdresolution='-1' automationEnabled='false' value='0.07121608179267352'>
<line name='' version='2' max='1.0' min='0.0' bdresolution='-1' color='-8355712' rightBound='false' endPointsLinked='false'>
<linePoint x='0.0' y='0.07121608179267352'/>
</line>
</parameter>
<parameter uniqueId='-1490019107' name='tremolo release' label='' min='0.0' max='1.0' bdresolution='-1' automationEnabled='false' value='0.5754143184206626'>
<line name='' version='2' max='1.0' min='0.0' bdresolution='-1' color='-8355712' rightBound='false' endPointsLinked='false'>
<linePoint x='0.0' y='0.5754143184206626'/>
</line>
</parameter>
<parameter uniqueId='-1490019105' name='tremolo sustain' label='' min='0.0' max='1.0' bdresolution='-1' automationEnabled='false' value='0.0'>
<line name='' version='2' max='1.0' min='0.0' bdresolution='-1' color='-8355712' rightBound='false' endPointsLinked='false'>
<linePoint x='0.0' y='0.0'/>
</line>
</parameter>
<parameter uniqueId='-1490019103' name='tremolo trigger' label='' min='0.0' max='1.0' bdresolution='1' automationEnabled='false' value='0.0'>
<line name='' version='2' max='1.0' min='0.0' bdresolution='1' color='-8355712' rightBound='false' endPointsLinked='false'>
<linePoint x='0.0' y='0.0'/>
</line>
</parameter>
<parameter uniqueId='-1490019101' name='tremolo envelope speed' label='' min='0.0' max='60.0' bdresolution='0.01' automationEnabled='false' value='39.22'>
<line name='' version='2' max='60.0' min='0.0' bdresolution='0.01' color='-8355712' rightBound='false' endPointsLinked='false'>
<linePoint x='0.0' y='39.22'/>
</line>
</parameter>
</parameterList>
<presetGroup name='Presets'/>
<opcodeList>
<udo>
<opcodeName>adsr140_calc_coef</opcodeName>
<outTypes>k</outTypes>
<inTypes>kk</inTypes>
<codeBody>
knum_samps, kratio xin
xout exp( -log((1.0 + kratio) / kratio) / knum_samps)
</codeBody>
<comments></comments>
</udo>
<udo>
<opcodeName>adsr140</opcodeName>
<outTypes>a</outTypes>
<inTypes>aakkkk</inTypes>
<codeBody>agate, aretrig, kattack, kdecay, ksustain, krelease xin
kstate init 0 ; 0 = attack, 1 = decay, 2 = sustain
klasttrig init -1
kval init 0.0
asig init 0
kindx = 0
kattack_base init 0
kdecay_base init 0
krelease_base init 0
kattack_samps init 0
kdecay_samps init 0
krelease_samps init 0
kattack_coef init 0
kdecay_coef init 0
ksustain_coef init 0
klast_attack init -1
klast_decay init -1
klast_release init -1
if (klast_attack != kattack) then
klast_attack = kattack
if(kattack > 0) then
kattack_samps = kattack * sr
kattack_coef = adsr140_calc_coef(kattack_samps, 0.3)
kattack_base = (1.0 + 0.3) * (1 - kattack_coef)
else
kattack_samps = 0
kattack_coef = 0
kattack_base = 0
endif
endif
if (klast_decay != kdecay) then
klast_decay = kdecay
kdecay_samps = kdecay * sr
kdecay_coef = adsr140_calc_coef(kdecay_samps, 0.0001)
kdecay_base = (ksustain - 0.0001) * (1.0 - kdecay_coef)
endif
if (klast_release != krelease) then
klast_release = krelease
krelease_samps = krelease * sr
krelease_coef = adsr140_calc_coef(krelease_samps, 0.0001)
krelease_base = -0.0001 * (1.0 - krelease_coef)
endif
while (kindx < ksmps) do
if (agate[kindx] > 0) then
kretrig = aretrig[kindx]
if (kretrig > 0 && klasttrig <= 0) then
kstate = 0
endif
klasttrig = kretrig
if (kstate == 0) then
if(kattack <= 0) then
kval = 1.0
kstate = 1
else
kval = kattack_base + (kval * kattack_coef)
if(kval >= 1.0) then
kval = 1.0
kstate = 1
endif
asig[kindx] = kval
endif
elseif (kstate == 1) then
kval = kdecay_base + (kval * kdecay_coef)
;kval *= 1.00005
if(kval <= ksustain) then
kval = ksustain
kstate = 2
endif
asig[kindx] = kval
else
asig[kindx] = ksustain
endif
else ; in a release state
kstate = 0
if (kval == 0.0) then
asig[kindx] = 0
else
; releasing
kval = krelease_base + (kval * krelease_coef)
if(kval <= 0.0) then
kval = 0.0
endif
asig[kindx] = kval
endif
endif
kindx += 1
od
xout asig
</codeBody>
<comments></comments>
</udo>
<udo>
<opcodeName>k_Tremolo_adsr140_STEREO</opcodeName>
<outTypes>aa</outTypes>
<inTypes>kaakkkkkk</inTypes>
<codeBody>kon, ain1, ain2, katt, kdec, ksus, krel, kspeed, kmix xin ; tremolo ON, in1, in2, attack, decay, sustain, release, speed, mix effect
if (kon == 1) then
if (kspeed > 0) then
agate = lfo(1, kspeed)
aretrig init 1
aadsr adsr140 agate, aretrig, katt, kdec, ksus, krel ; retriggering envelope 1
aadsr *= 1.2
else
aretrig init 1
agate = linseg:a(1, p3 - i(krel), 1, .001, 0, i(krel), 0)
aadsr adsr140 agate, aretrig, katt, kdec, ksus, krel ; envelope 2
endif
else ; no tremolo at all
aadsr = 1
endif
aresL = ain1 * aadsr ; impose tremolo on incoming audio
aresR = ain2 * aadsr
aoutL ntrpol ain1, aresL, kmix ; mix incoming audio with treated audio
aoutR ntrpol ain2, aresR, kmix
xout aoutL, aoutR</codeBody>
<comments>This Module takes in a stereo signal, outputs a stereo signal with tremolo and/or mixed with the original signal.
Needs other UDOs: adsr140_calc_coef and adsr140 (in that order)
</comments>
</udo>
</opcodeList>
</instrument>