-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsynthesizer.txt
413 lines (382 loc) · 8.39 KB
/
synthesizer.txt
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
413
//----- Variables -----------------------------------------------------------------------------------------------------
arm7.pc = 0
arm7.read_return = 0
arm9.pc = 0
arm9.read_return = 0
bg_mode = 0
c8.Load/Save_Quirk = 0
c8.Shift_quirk = 0
c8.Wrap_mode = 0
c8scrnsize = 0
calc.char = 0
calc.return = 0
calc.temp = 0
calc.temp2 = 0
chip8.audio toggle = 0
chip8.audio_buffer = 0
chip8.blendmode = 0
chip8.delay_timer = 0
chip8.drawflag = 0
chip8.drawmode = 0
chip8.drawplane = 0
chip8.drawvariety = 0
chip8.dummy = 0
chip8.dummy2 = 0
chip8.dummy3 = 0
chip8.dummy4 = 0
chip8.dummy5 = 0
chip8.fx0aflag = 0
chip8.HPSFlag = 0
chip8.I = 0
chip8.pc = 0
chip8.pitch = 0
chip8.rand = 0
chip8.return = 0
chip8.screenheight = 0
chip8.screenwidth = 0
chip8.sound_timer = 0
chip8.spritewidth = 0
chip8m.collisioncolor = 0
core.byte_return = 0
core.condition_test = 0
core.dummy = 0
core.dummy2 = 0
core.dummy_op = 0
core.instruction_format = 0
core.little_endian = 0
core.op.dummy = 0
core.op.dummy2 = 0
core.read_return = 0
core.rotate_return = 0
core.shift_return = 0
CPF = 0
flags.met = 0
op.opcode = 0
op.pos = 0
op.temp = 0
program.done = 0
read.return = 0
read.single.return = 0
scanX = 0
scanY = 0
SF2091! fix = 0
storage.byte = 0
tile_mode = 0
VIP jumps = 0
_id = 1
_pitch = -260.06665369993
//----- Lists ---------------------------------------------------------------------------------------------------------
arm7.registers = { }
arm9.flags = { }
arm9.registers = { }
Boot-128 = { }
chip8.keyboard = { }
chip8.memory = { }
chip8.registers = { }
chip8.screen = { }
chip8.screen2 = { }
chip8.screen3 = { }
chip8.screen4 = { }
chip8.stack = { }
schip8.font = { }
schip8.RPL = { }
//----- Broadcast received events -------------------------------------------------------------------------------------
WhenBroadcastReceived(exit emulator)
{
Stop(other scripts in sprite);
Event.Broadcast("prune");
Sound.StopAllSounds();
}
WhenBroadcastReceived(prune)
{
List.DeleteAll(wave);
List.DeleteAll(FT.re);
List.DeleteAll(FT.im);
List.DeleteAll(vol);
List.DeleteAll(temp.0);
List.DeleteAll(temp.1);
Control.DeleteThisClone();
}
WhenBroadcastReceived(sound.updatech8buffer)
{
Call convert buffer to bits;
Call put Input;
Call FFT;
Call apply to vol;
}
WhenBroadcastReceived(wave)
{
Forever
{
If (pitch == -400)
{
If (Not ((Sound.Volume() == 0)))
{
Sound.SetVolumeTo(0);
Sound.StopAllSounds();
}
Wait Until (pitch > -400);
}
If (_id > q)
{
If (Sound.Volume() > 0)
{
Sound.SetVolumeTo(0);
}
}
Else
{
If (Not ((Sound.Volume() == vol[_id])))
{
Sound.SetVolumeTo(vol[_id]);
}
}
}
}
WhenBroadcastReceived(wave)
{
Sound.SetVolumeTo(0);
Forever
{
If (Sound.Volume() == 0)
{
Wait Until (Sound.Volume() > 0);
}
Sound.PlayUntilDone(_id);
}
}
WhenBroadcastReceived(wave)
{
Forever
{
If ((Not ((pitch == -400))) And (Not ((_pitch == pitch))))
{
_pitch = pitch;
Sound.SetEffectTo(PITCH, pitch);
}
}
}
WhenBroadcastReceived(wave create)
{
Stop(other scripts in sprite);
Call instant;
Event.Broadcast("wave");
}
//----- Custom blocks -------------------------------------------------------------------------------------------------
Define apply to vol (warp=true)
{
r.0 = 1;
List.DeleteAll(vol);
Repeat (List.Length(FT.im))
{
r.0 += 1;
r.1 = FT.re[r.0];
r.2 = FT.im[r.0];
List.Add(vol, (3 * sqrt(((r.1 * r.1) + (r.2 * r.2)))));
}
}
Define convert buffer to bits (warp=true)
{
List.DeleteAll(wave);
control_clear_counter ?? - probably legacy function from Scratch 2.0;
Repeat (16)
{
r.1 = 256;
control_incr_counter ?? - probably legacy function from Scratch 2.0;
Repeat (8)
{
r.1 = (r.1 / 2);
List.Add(wave, (12 * (floor((chip8.audiobuffer[control_get_counter ?? - probably legacy function from Scratch 2.0] / r.1)) % 2)));
}
}
}
Define FFT (warp=true)
{
List.DeleteAll(temp.0);
List.DeleteAll(temp.1);
If (List.Length(FT.re) < List.Length(FT.im))
{
r.0 = List.Length(FT.im);
}
Else
{
r.0 = List.Length(FT.re);
}
r.0 += -1;
r.2 = 1;
r.3 = 0;
Repeat Until (r.2 > r.0)
{
r.2 += r.2;
r.3 += 1;
}
Repeat (r.2)
{
r.0 = List.Length(temp.0);
r.1 = 0;
Repeat (r.3)
{
r.1 = (r.1 * 2);
r.1 += (r.0 % 2);
r.0 = floor((r.0 / 2));
}
r.1 += 1;
List.Add(temp.0, (FT.re[r.1] + 0));
List.Add(temp.1, (FT.im[r.1] + 0));
}
r.1 = 1;
Repeat (r.3)
{
r.0 = 1;
r.2 = (r.2 / 2);
Repeat (r.2)
{
r.8 = 0;
r.9 = (-180 / r.1);
Repeat (r.1)
{
r.0 += r.1;
r.4 = cos(r.8);
r.5 = sin(r.8);
r.3 = temp.0[r.0];
r.7 = temp.1[r.0];
r.6 = ((r.3 * r.4) - (r.7 * r.5));
r.7 = ((r.3 * r.5) + (r.7 * r.4));
r.0 += (0 - r.1);
r.4 = temp.0[r.0];
r.5 = temp.1[r.0];
List.ReplaceItem(temp.0, r.0, (r.4 + r.6));
List.ReplaceItem(temp.1, r.0, (r.5 + r.7));
r.0 += r.1;
List.ReplaceItem(temp.0, r.0, (r.4 - r.6));
List.ReplaceItem(temp.1, r.0, (r.5 - r.7));
r.0 += (1 - r.1);
r.8 += r.9;
}
r.0 += r.1;
}
r.1 += r.1;
}
List.DeleteAll(FT.re);
List.DeleteAll(FT.im);
r.1 = sqrt(List.Length(temp.0));
control_clear_counter ?? - probably legacy function from Scratch 2.0;
Repeat (List.Length(temp.0))
{
control_incr_counter ?? - probably legacy function from Scratch 2.0;
List.Add(FT.re, (temp.0[control_get_counter ?? - probably legacy function from Scratch 2.0] / r.1));
List.Add(FT.im, (temp.1[control_get_counter ?? - probably legacy function from Scratch 2.0] / r.1));
}
}
Define instant (warp=true)
{
_pitch = 0;
q = 64;
_id = 64;
Repeat (63)
{
Control.CreateCloneOf(_myself_);
_id += -1;
}
}
Define put Input (warp=true)
{
List.DeleteAll(FT.re);
List.DeleteAll(FT.im);
control_clear_counter ?? - probably legacy function from Scratch 2.0;
Repeat (128)
{
control_incr_counter ?? - probably legacy function from Scratch 2.0;
List.Add(FT.re, (wave[control_get_counter ?? - probably legacy function from Scratch 2.0] / 15));
List.Add(FT.re, (wave[control_get_counter ?? - probably legacy function from Scratch 2.0] / 15));
}
}
Define tick(string sample) (warp=true)
{
List.DeleteAll(chip8.audiobuffer);
r.0 = 1;
Repeat (64)
{
List.Add(chip8.audiobuffer, chip8m.PCM[(sample + r.0)]);
r.0 += 1;
}
Call convert buffer to bits;
Call put Input;
Call FFT;
}
//----- Orphaned blocks -----------------------------------------------------------------------------------------------
If
{
r.9 = (180 / r.1);
}
Else
{
}
Event.BroadcastAndWait("prune")
//----- Costumes ------------------------------------------------------------------------------------------------------
costume1.svg
//----- Sounds --------------------------------------------------------------------------------------------------------
vsine1.wav
vsine2.wav
vsine3.wav
vsine4.wav
vsine5.wav
vsine6.wav
vsine7.wav
vsine8.wav
vsine9.wav
vsine10.wav
vsine11.wav
vsine12.wav
vsine13.wav
vsine14.wav
vsine15.wav
vsine16.wav
vsine17.wav
vsine18.wav
vsine19.wav
vsine20.wav
vsine21.wav
vsine22.wav
vsine23.wav
vsine24.wav
vsine25.wav
vsine26.wav
vsine27.wav
vsine28.wav
vsine29.wav
vsine30.wav
vsine31.wav
vsine32.wav
vsine33.wav
vsine34.wav
vsine35.wav
vsine36.wav
vsine37.wav
vsine38.wav
vsine39.wav
vsine40.wav
vsine41.wav
vsine42.wav
vsine43.wav
vsine44.wav
vsine45.wav
vsine46.wav
vsine47.wav
vsine48.wav
vsine49.wav
vsine50.wav
vsine51.wav
vsine52.wav
vsine53.wav
vsine54.wav
vsine55.wav
vsine56.wav
vsine57.wav
vsine58.wav
vsine59.wav
vsine60.wav
vsine61.wav
vsine62.wav
vsine63.wav
vsine64.wav