git ssb

0+

kode54 / syntrax-c



Tree: ff356ac03b9201b62881c0c01ab0b732d81ebb2f

Files: ff356ac03b9201b62881c0c01ab0b732d81ebb2f / src / syntrax / syntrax.c

71607 bytesRaw
1#include <stdint.h>
2#include <math.h>
3
4#include "syntrax.h"
5#include "file.h"
6
7
8int16_t *silentBuffer;
9uint8_t m_LastNotes[SE_MAXCHANS];
10
11uint32_t *freqTable;
12int16_t *dynamorphTable;
13
14int isPaused;
15Song *synSong;
16TuneChannel *tuneChannels;
17Voice *voices;
18
19int samplesPerBeat;
20int otherSamplesPerBeat;
21int someCounter;
22int channelNumber;
23int sePmSong;
24int16_t *overlapBuff;
25int16_t *delayBufferR;
26int16_t *delayBufferL;
27
28int bkpDelayPos;
29int delayPos;
30int gainPos;
31int overlapPos;
32
33int ISWLKT;
34int WDTECTE;
35int PQV;
36int AMVM;
37int PENIS;
38int posCoarse;
39int AMYGPFQCHSW;
40int posFine;
41int8_t mutedChans[SE_MAXCHANS];
42
43int selectedSubsong;
44Subsong *curSubsong;
45
46//local pointers to song structures
47Row *rows;
48char **patternNames;
49Instrument *instruments;
50Subsong *subsongs;
51int8_t *arpTable;
52int16_t **samples;
53
54uint bufflen;
55
56int noAutoplay = 1;
57
58
59
60
61
62void reset(void)
63{
64 int i, j;
65
66 if (delayBufferL && delayBufferR){
67 memset(delayBufferL, 0, 65536 *2);
68 memset(delayBufferR, 0, 65536 *2);
69 }
70 if (tuneChannels){
71
72 for (i = 0; i < SE_MAXCHANS; i++) {
73 TuneChannel *tc = &tuneChannels[i];
74
75 tc->EQMIWERPIF = 0;
76 tc->LJHG = 0;
77 tc->insNum = -1;
78 tc->HFRLJCG = 0;
79 tc->ACKCWV = 0;
80 tc->ELPHLDR = 0;
81 tc->TVORFCC = 0;
82 tc->freq = 0;
83 tc->BNWIGU = 0;
84 tc->UHYDBDDI = 0;
85 tc->XESAWSO = 0;
86 tc->JOEEPJCI = 0;
87 tc->fmDelay = 0;
88 tc->sampleBuffer = NULL;
89 tc->smpLoopEnd = 0;
90 //tc->smpLength = 0;
91 tc->sampPos = 0;
92 tc->EYRXAB = 0;
93 tc->volume = 0;
94 tc->panning = 0;
95 tc->VNVJPDIWAJQ = 0;
96 tc->smpLoopStart = 0;
97 tc->hasLoop = 0;
98 tc->hasBidiLoop = 0;
99 tc->isPlayingBackward = 0;
100 tc->hasLooped = 0;
101
102 for (j = 0; j < 4; j++) {
103 VoiceEffect *vc = &tc->effects[j];
104
105 vc->QOMCBTRPXF = 0;
106 vc->TIPUANVVR = 0;
107 vc->MFATTMREMVP = 0;
108 vc->MDTMBBIQHRQ = 0;
109 vc->RKF = 0;
110 vc->DQVLFV = 0;
111 vc->ILHG = 0;
112 vc->YLKJB = 0;
113 vc->VMBNMTNBQU = 0;
114 vc->ABJGHAUY = 0;
115 vc->SPYK = 0;
116
117 }
118
119 memset(tc->synthBuffers, 0, 0x100 * 16 *2 + 2);
120 }
121 }
122}
123
124void generateTables(void)
125{
126 int i, j;
127
128 dynamorphTable = malloc(0x100 *2);
129 for (i = 0; i < 0x0100; i++ ) {
130 dynamorphTable[i] = (sin(((M_PI * i) / 128)) * 32760);
131 }
132
133 //debug Asscilloscope says 0xF8 to 0x61FFB
134 //we probably don't have uint24_t at our disposal
135 //uint32_t it is, then
136 freqTable = malloc(SE_NROFFINETUNESTEPS * 128 *4);
137 for (i = 0; i < SE_NROFFINETUNESTEPS; i++) {
138 double x;
139 for (j = 0; j < 128; j++) {
140 x = (((j + 3) * 16) - i);
141 x = (x / 192);
142 x = pow(2, x);
143 x = (x * 220) + 0.5;
144 freqTable[i* 128 + j] = int(x);
145 }
146 }
147}
148
149void constructor(void)
150{
151 int i, j;
152
153 bufflen = BUFFERLENGTH;
154 generateTables();
155
156 overlapPos = 0;
157
158 silentBuffer = malloc(0x0100 *2);
159 memset(silentBuffer, 0, 0x0100 *2);
160
161 ISWLKT = 0;
162 posCoarse = 0;
163 posFine = 0;
164 bkpDelayPos = 0;
165 PENIS = 0;
166 AMYGPFQCHSW = 0;
167 selectedSubsong = 0;
168 curSubsong = NULL;
169 PQV = 0;
170 isPaused = 0;
171 someCounter = 0;
172 WDTECTE = 0;
173 sePmSong = SE_PM_SONG;
174 AMVM = 0x0100;
175 channelNumber = 0;
176
177 otherSamplesPerBeat = 2200;
178 samplesPerBeat = 2200;
179
180 overlapBuff = malloc(SE_OVERLAP * 2 *2 + 2);
181 delayBufferL = malloc(65536 *2);
182 delayBufferR = malloc(65536 *2);
183
184 tuneChannels = malloc(SE_MAXCHANS *sizeof(TuneChannel));
185 voices = malloc(SE_MAXCHANS *sizeof(Voice));
186
187 reset();
188 delayPos = 0;
189 //synSong = malloc(sizeof(Song));
190}
191
192/*
193 public function destructor():void
194 {
195 var _local1:int;
196 arpTable = null;
197 silentBuffer = null;
198 overlapBuff = null;
199 delayBufferL = null;
200 delayBufferR = null;
201 freqTable = null;
202 tuneChannels = null;
203 silentBuffer = null;
204 arpTable = null;
205 }
206
207 private function clearSongData():void
208 {
209 synSong.rows = null;
210 synSong.patternNames = null;
211 synSong.instruments = null;
212 synSong.subsongs = null;
213 }
214*/
215
216void instrEffect(int chanNum)
217{
218 //TODO: minimize all the vars
219 //too many of them
220 int i, j;
221 int _local3;
222 int destWave;
223 int16_t *destBuff;
224 int pos;
225 int srcWave1;
226 int _local10;
227 int srcWave2;
228 int16_t *srcBuff1;
229 int16_t *srcBuff2;
230 double _local16;
231 double _local17;
232 double _local18;
233 int oscWave;
234 int16_t *oscBuff;
235 int _local21;
236 int _local22;
237 int _local23;
238 int _local25;
239 int _local26;
240 int _local27;
241 int var1;
242 int var2;
243 double _local30;
244 double _local31;
245 int _local32;
246 int _local33;
247 int _local34;
248 int _local35;
249 int _local36;
250 int _local37;
251 int _local38;
252 int _local39;
253 int _local40;
254 int _local43;
255
256 TuneChannel *tc = &tuneChannels[chanNum];
257 Instrument *ins = &instruments[tc->insNum];
258
259 for (i = 0; i < 4; i++ ) {
260 InstrumentEffect *ie = &ins->effects[i];
261 VoiceEffect *ve = &tc->effects[i];
262
263 ve->MFATTMREMVP = (ve->MFATTMREMVP + ie->oscSpeed);
264 ve->MFATTMREMVP = (ve->MFATTMREMVP & 0xFF);
265 switch (ie->effectType) {
266
267 //NONE
268 case 0:
269 break;
270
271 //NEGATE
272 case 1:
273 destWave = ie->destWave;
274 _local3 = ie->fxSpeed;
275 pos = ve->QOMCBTRPXF;
276 destBuff = &tc->synthBuffers[destWave];
277
278 for (j = 0; j < _local3; j++ ) {
279 pos++;
280 pos = (pos & 0xFF);
281 destBuff[pos] = (0 - destBuff[pos]);
282
283 }
284 ve->QOMCBTRPXF = pos;
285 break;
286
287 //SWEEP
288 case 2:
289 destWave = ie->destWave;
290 _local3 = ie->fxSpeed;
291 destBuff = &tc->synthBuffers[destWave];
292
293
294 for (pos = 0, j = 0; j < 0x0100; j++ ) {
295 destBuff[j] = (destBuff[j] + pos);
296 destBuff[j] = (destBuff[j] + 0x8000);
297 destBuff[j] = (destBuff[j] & 0xFFFF);
298 destBuff[j] = (destBuff[j] - 0x8000);
299 pos = (pos + _local3);
300
301 }
302 break;
303
304 //AVERAGER
305 case 3:
306 destWave = ie->destWave;
307 srcWave1 = ie->srcWave1;
308 destBuff = &tc->synthBuffers[destWave];
309 srcBuff1 = &tc->synthBuffers[srcWave1];
310 _local3 = ie->fxSpeed;
311 pos = 0;
312 if (_local3 > 12){
313 _local3 = 12;
314 }
315
316 for (_local10 = 0; _local10 < _local3; _local10++ ) {
317 destBuff[0] = ((srcBuff1[0xFF] + srcBuff1[1]) >> 1);
318
319 for (j = 1; j < 0xFF; j++ ) {
320 destBuff[j] = ((srcBuff1[j - 1] + srcBuff1[j + 1]) >> 1);
321
322 }
323 destBuff[0xFF] = ((srcBuff1[254] + srcBuff1[0]) >> 1);
324
325 }
326 break;
327
328 //WAVEMIX
329 case 4:
330 destWave = ie->destWave;
331 srcWave1 = ie->srcWave1;
332 srcWave2 = ie->srcWave2;
333 destBuff = &tc->synthBuffers[destWave];
334 srcBuff1 = &tc->synthBuffers[srcWave1];
335 srcBuff2 = &tc->synthBuffers[srcWave2];
336 _local3 = ie->fxSpeed;
337 ve->QOMCBTRPXF = (ve->QOMCBTRPXF + _local3);
338 ve->QOMCBTRPXF = (ve->QOMCBTRPXF & 0xFF);
339 pos = ve->QOMCBTRPXF;
340
341 for (j = 0; j < 0x0100; j++ ) {
342 destBuff[j] = ((srcBuff1[j] + srcBuff2[pos]) >> 1);
343 pos++;
344 pos = (pos & 0xFF);
345
346 }
347 break;
348
349 //FILTER
350 case 5:
351 destWave = ie->destWave;
352 srcWave1 = ie->srcWave1;
353 srcWave2 = ie->oscWave - 1;
354 destBuff = &tc->synthBuffers[destWave];
355
356 srcBuff1 = &tc->synthBuffers[srcWave1];
357 srcBuff2 = srcWave2 >= 0 ? &tc->synthBuffers[srcWave2] : NULL;
358 pos = ve->MFATTMREMVP;
359
360 if (ie->oscWave == 0){
361 _local16 = double((ie->variable1 * 20));
362 _local17 = double((ie->variable2 * 16));
363 } else {
364 if (ie->oscSelect){
365 _local16 = double((ie->variable1 * 20));
366 _local17 = (double((srcBuff2[pos] + 0x8000)) / 16);
367 } else {
368 _local16 = (double((srcBuff2[pos] + 0x8000)) / 13);
369 _local17 = double((ie->variable2 * 16));
370 }
371 }
372 ve->DQVLFV = exp((-((2 * M_PI)) * (_local17 / 22000)));
373 ve->RKF = (((-4 * ve->DQVLFV) / (1 + ve->DQVLFV)) * cos(((2 * M_PI) * (_local16 / 22000))));
374 ve->MDTMBBIQHRQ = ((1 - ve->DQVLFV) * sqrt((1 - ((ve->RKF * ve->RKF) / (4 * ve->DQVLFV)))));
375
376 for (j = 0; j < 0x0100; j++) {
377 _local18 = (((ve->MDTMBBIQHRQ * (double(srcBuff1[j]) / 0x8000)) - (ve->RKF * ve->ILHG)) - (ve->DQVLFV * ve->YLKJB));
378 ve->YLKJB = ve->ILHG;
379 ve->ILHG = _local18;
380 if (_local18 > 0.9999){
381 _local18 = 0.9999;
382 }
383 if (_local18 < -0.9999){
384 _local18 = -0.9999;
385 }
386 destBuff[j] = (_local18 * 0x8000);
387
388 }
389 break;
390
391 //FILTWHISTLE
392 case 6:
393 destWave = ie->destWave;
394 srcWave1 = ie->srcWave1;
395 srcWave2 = ie->oscWave - 1;
396 destBuff = &tc->synthBuffers[destWave];
397
398 srcBuff1 = &tc->synthBuffers[srcWave1];
399 srcBuff2 = srcWave2 >= 0 ? &tc->synthBuffers[srcWave2] : NULL;
400 pos = ve->MFATTMREMVP;
401
402 if (ie->oscWave == 0){
403 _local16 = double((ie->variable1 * 20));
404 _local17 = double((ie->variable2 * 16));
405 } else {
406 if (ie->oscSelect){
407 _local16 = double((ie->variable1 * 20));
408 _local17 = (double((srcBuff2[pos] + 0x8000)) / 16);
409 } else {
410 _local16 = (double((srcBuff2[pos] + 0x8000)) / 13);
411 _local17 = double((ie->variable2 * 16));
412 }
413 }
414 ve->DQVLFV = exp((-((2 * M_PI)) * (_local17 / 22000)));
415 ve->RKF = (((-4 * ve->DQVLFV) / (1 + ve->DQVLFV)) * cos(((2 * M_PI) * (_local16 / 22000))));
416 ve->MDTMBBIQHRQ = ((1 - ve->DQVLFV) * sqrt((1 - ((ve->RKF * ve->RKF) / (4 * ve->DQVLFV)))));
417 ve->DQVLFV = (ve->DQVLFV * 1.2);
418
419 for (j = 0; j < 0x0100; j++ ) {
420 _local18 = (((ve->MDTMBBIQHRQ * (double(srcBuff1[j]) / 0x8000)) - (ve->RKF * ve->ILHG)) - (ve->DQVLFV * ve->YLKJB));
421 ve->YLKJB = ve->ILHG;
422 ve->ILHG = _local18;
423 if (_local18 > 0.9999){
424 _local18 = 0.9999;
425 }
426 if (_local18 < -0.9999){
427 _local18 = -0.9999;
428 }
429 destBuff[j] = (_local18 * 0x8000);
430
431 }
432 break;
433
434 //MORPH
435 case 7:
436 destWave = ie->destWave;
437 srcWave1 = ie->srcWave1;
438 srcWave2 = ie->srcWave2;
439 oscWave = ie->oscWave - 1;
440 destBuff = &tc->synthBuffers[destWave];
441
442 srcBuff1 = &tc->synthBuffers[srcWave1];
443 srcBuff2 = &tc->synthBuffers[srcWave2];
444 oscBuff = oscWave >= 0 ? &tc->synthBuffers[oscWave] : NULL;
445 pos = ve->MFATTMREMVP;
446
447 if (ie->oscWave == 0){
448 _local21 = ie->variable1;
449 } else {
450 if (ie->oscSelect){
451 _local21 = ie->variable1;
452 } else {
453 _local21 = ((oscBuff[pos] + 0x8000) / 0x0100);
454 }
455 }
456 _local22 = (0xFF - _local21);
457
458 for (j = 0; j < 0x0100; j++) {
459 _local23 = (((srcBuff1[j] * _local21) / 0x0100) + ((srcBuff2[j] * _local22) / 0x0100));
460 destBuff[j] = _local23;
461
462 }
463 break;
464
465 //DYNAMORPH
466 case 8:
467 destWave = ie->destWave;
468 srcWave1 = ie->srcWave1;
469 srcWave2 = ie->srcWave2;
470 oscWave = ie->oscWave - 1;
471 destBuff = &tc->synthBuffers[destWave];
472
473 srcBuff1 = &tc->synthBuffers[srcWave1];
474 srcBuff2 = &tc->synthBuffers[srcWave2];
475 oscBuff = oscWave >= 0 ? &tc->synthBuffers[oscWave] : NULL;
476 pos = ve->MFATTMREMVP;
477
478 if (ie->oscWave == 0){
479 _local25 = ie->variable1;
480 } else {
481 if (ie->oscSelect){
482 _local25 = ie->variable1;
483 } else {
484 _local25 = ((oscBuff[pos] + 0x8000) / 0x0100);
485 }
486 }
487
488 for (j = 0; j < 0x0100; j++) {
489 _local21 = ((dynamorphTable[_local25] >> 8) + 128);
490 _local22 = (0xFF - _local21);
491 _local23 = (((srcBuff1[j] * _local21) / 0x0100) + ((srcBuff2[j] * _local22) / 0x0100));
492 destBuff[j] = _local23;
493 _local25++;
494 _local25 = (_local25 & 0xFF);
495
496 }
497 break;
498
499 //DISTORTION
500 case 9:
501 destWave = ie->destWave;
502 srcWave1 = ie->srcWave1;
503 oscWave = ie->oscWave - 1;
504 destBuff = &tc->synthBuffers[destWave];
505
506 srcBuff1 = &tc->synthBuffers[srcWave1];
507 oscBuff = oscWave >= 0 ? &tc->synthBuffers[oscWave] : NULL;
508 pos = ve->MFATTMREMVP;
509
510 if (ie->oscWave == 0){
511 _local21 = ie->variable1;
512 } else {
513 if (ie->oscSelect){
514 _local21 = ie->variable1;
515 } else {
516 _local21 = ((oscBuff[pos] + 0x8000) / 0x0100);
517 }
518 }
519
520 for (j = 0; j < 0x0100; j++) {
521 _local23 = ((srcBuff1[j] * _local21) / 16);
522 _local23 = (_local23 + 0x8000);
523 if (_local23 < 0){
524 _local23 = -(_local23);
525 }
526 _local23 = (_local23 % 131072);
527 if (_local23 > 0xFFFF){
528 _local23 = (131071 - _local23);
529 }
530 _local23 = (_local23 & 0xFFFF);
531 _local23 = (_local23 - 0x8000);
532 destBuff[j] = _local23;
533
534 }
535 break;
536
537 //SCROLL LEFT
538 case 10:
539 destWave = ie->destWave;
540 destBuff = &tc->synthBuffers[destWave];
541 _local10 = destBuff[0];
542
543 for (j = 0; j < 0xFF; j++) {
544 destBuff[j] = destBuff[j + 1];
545
546 }
547 destBuff[0xFF] = _local10;
548 break;
549
550 //UPSAMPLE
551 case 11:
552 pos = ve->QOMCBTRPXF;
553 if (pos != 0){
554 ve->QOMCBTRPXF--;
555 break;
556 }
557 ve->QOMCBTRPXF = ie->variable1;
558 destWave = ie->destWave;
559 destBuff = &tc->synthBuffers[destWave];
560
561 for (j = 0; j < 128; j++) {
562 destBuff[j] = destBuff[j * 2];
563
564 }
565
566 for (j = 0; j < 128; j++) {
567 destBuff[j + 128] = destBuff[j];
568
569 }
570 break;
571
572 //CLIPPER
573 case 12:
574 destWave = ie->destWave;
575 srcWave1 = ie->srcWave1;
576 oscWave = ie->oscWave - 1;
577 destBuff = &tc->synthBuffers[destWave];
578
579 srcBuff1 = &tc->synthBuffers[srcWave1];
580 oscBuff = oscWave >= 0 ? &tc->synthBuffers[oscWave] : NULL;
581 pos = ve->MFATTMREMVP;
582
583 if (ie->oscWave == 0){
584 _local21 = ie->variable1;
585 } else {
586 if (ie->oscSelect){
587 _local21 = ie->variable1;
588 } else {
589 _local21 = ((oscBuff[pos] + 0x8000) / 0x0100);
590 }
591 }
592
593 for (j = 0; j < 0x0100; j++) {
594 _local23 = ((srcBuff1[j] * _local21) / 16);
595 if (_local23 < -32767){
596 _local23 = -32767;
597 }
598 if (_local23 > 32767){
599 _local23 = 32767;
600 }
601 destBuff[j] = _local23;
602
603 }
604 break;
605
606 //LOWPASS
607 case 13:
608 destWave = ie->destWave;
609 srcWave1 = ie->srcWave1;
610 srcWave2 = ie->oscWave - 1;
611 destBuff = &tc->synthBuffers[destWave];
612
613 srcBuff1 = &tc->synthBuffers[srcWave1];
614 srcBuff2 = srcWave2 >= 0 ? &tc->synthBuffers[srcWave2] : NULL;
615 pos = ve->MFATTMREMVP;
616
617 if (ie->oscWave == 0){
618 var1 = ie->variable1;
619 var2 = ie->variable2;
620 var1 = var1 * 16;
621 } else {
622 if (ie->oscSelect){
623 var1 = ie->variable1;
624 var2 = ((srcBuff2[pos] + 0x8000) >> 8);
625 var1 = (var1 * 16);
626 } else {
627 //_local28 = ((_local14->data[_local7] + 0x8000) / 16);
628 var1 = ((srcBuff2[pos] + 0x8000) >> 4);
629 var2 = ie->variable2;
630 }
631 }
632 _local30 = (var1 - 920);
633 _local31 = (228 + var1);
634 _local26 = int(((2 * M_PI) * _local31));
635 _local27 = (707 + ((1000 * var2) / 128));
636 _local36 = ve->ABJGHAUY;
637 _local37 = ve->SPYK;
638 _local38 = ve->VMBNMTNBQU;
639 _local40 = 8;
640
641 for (j = 0; j < 0x0100; j++) {
642 _local32 = ((_local26 * _local40) / 100);
643 _local39 = srcBuff1[j];
644 _local33 = ((((_local36 * 1000) / _local27) - _local37) + _local39);
645 _local34 = (_local36 - ((_local32 * (_local38 / 100)) / 100));
646 _local35 = (_local37 - ((_local32 * (_local36 / 100)) / 100));
647 _local38 = _local33;
648 _local36 = _local34;
649 _local37 = _local35;
650 _local3 = _local37;
651 if (_local3 > 32767){
652 _local3 = 32767;
653 }
654 if (_local3 < -32767){
655 _local3 = -32767;
656 }
657 destBuff[j] = _local3;
658
659 }
660 ve->ABJGHAUY = _local36;
661 ve->SPYK = _local37;
662 ve->VMBNMTNBQU = _local38;
663 break;
664
665 //HIGHPASS
666 case 14:
667 destWave = ie->destWave;
668 srcWave1 = ie->srcWave1;
669 srcWave2 = ie->oscWave - 1;
670 destBuff = &tc->synthBuffers[destWave];
671
672 srcBuff1 = &tc->synthBuffers[srcWave1];
673 srcBuff2 = srcWave2 >= 0 ? &tc->synthBuffers[srcWave2] : NULL;
674 pos = ve->MFATTMREMVP;
675
676 if (ie->oscWave == 0){
677 var1 = ie->variable1;
678 var2 = ie->variable2;
679 var1 = (var1 * 32);
680 } else {
681 if (ie->oscSelect) {
682 var1 = ie->variable1;
683 var2 = ((srcBuff2[pos] + 0x8000) >> 8);
684 var1 = (var1 * 32);
685 } else {
686 //checked with IDA against windows ver. of Syntrax(v1.03)
687 //It's possible that the effect has changed along the way(v2.xx)
688 //same for lowpass
689 //_local28 = ((_local14->data[_local7] + 0x8000) / 16);
690 var1 = ((srcBuff2[pos] + 0x8000) >> 3);
691 var2 = ie->variable2;
692 }
693 }
694 _local30 = (var1 - 920);
695 _local31 = (228 + var1);
696 _local26 = int(((2 * M_PI) * _local31));
697 _local27 = (707 + ((1000 * var2) / 128));
698 _local36 = ve->ABJGHAUY;
699 _local37 = ve->SPYK;
700 _local38 = ve->VMBNMTNBQU;
701 _local40 = 8;
702
703 for (j = 0; j < 0x0100; j++) {
704 _local32 = ((_local26 * _local40) / 100);
705 _local39 = srcBuff1[j];
706 _local33 = ((((_local36 * 1000) / _local27) - _local37) + _local39);
707 _local34 = (_local36 - ((_local32 * (_local38 / 100)) / 100));
708 _local35 = (_local37 - ((_local32 * (_local36 / 100)) / 100));
709 _local38 = _local33;
710 _local36 = _local34;
711 _local37 = _local35;
712 _local3 = _local38;
713 if (_local3 > 32767){
714 _local3 = 32767;
715 }
716 if (_local3 < -32767){
717 _local3 = -32767;
718 }
719 destBuff[j] = _local3;
720
721 }
722 ve->ABJGHAUY = _local36;
723 ve->SPYK = _local37;
724 ve->VMBNMTNBQU = _local38;
725 break;
726
727 //BANDPASS
728 case 15:
729 destWave = ie->destWave;
730 srcWave1 = ie->srcWave1;
731 srcWave2 = ie->oscWave - 1;
732 destBuff = &tc->synthBuffers[destWave];
733
734 srcBuff1 = &tc->synthBuffers[srcWave1];
735 srcBuff2 = srcWave2 >= 0 ? &tc->synthBuffers[srcWave2] : NULL;
736 pos = ve->MFATTMREMVP;
737
738 if (ie->oscWave == 0){
739 var1 = ie->variable1;
740 var2 = ie->variable2;
741 var1 = var1 * 16;
742 } else {
743 if (ie->oscSelect){
744 var1 = ie->variable1;
745 var2 = ((srcBuff2[pos] + 0x8000) >> 8);
746 var1 = var1 * 16;
747 } else {
748 var1 = ((srcBuff2[pos] + 0x8000) / 16);
749 var2 = ie->variable2;
750 }
751 }
752 _local30 = (var1 - 920);
753 _local31 = (228 + var1);
754 _local26 = int(((2 * M_PI) * _local31));
755 _local27 = (707 + ((1000 * var2) / 128));
756 _local36 = ve->ABJGHAUY;
757 _local37 = ve->SPYK;
758 _local38 = ve->VMBNMTNBQU;
759 _local40 = 8;
760
761 for (j = 0; j < 0x0100; j++) {
762 _local32 = ((_local26 * _local40) / 100);
763 _local39 = srcBuff1[j];
764 _local33 = ((((_local36 * 1000) / _local27) - _local37) + _local39);
765 _local34 = (_local36 - ((_local32 * (_local38 / 100)) / 100));
766 _local35 = (_local37 - ((_local32 * (_local36 / 100)) / 100));
767 _local38 = _local33;
768 _local36 = _local34;
769 _local37 = _local35;
770 _local3 = _local36;
771 if (_local3 > 32767){
772 _local3 = 32767;
773 }
774 if (_local3 < -32767){
775 _local3 = -32767;
776 }
777 destBuff[j] = _local3;
778
779 }
780 ve->ABJGHAUY = _local36;
781 ve->SPYK = _local37;
782 ve->VMBNMTNBQU = _local38;
783 break;
784
785 //METALNOISE
786 case 16:
787 destWave = ie->destWave;
788 destBuff = &tc->synthBuffers[destWave];
789 for (j = 0; j < 0x0100; j++ ) {
790 //Something very bad happens here
791 //I think it's fixed now.
792 destBuff[j] = ((random() * 65530) - 0x8000);
793
794 }
795 break;
796
797 //SQUASH
798 case 17:
799 destWave = ie->destWave;
800 srcWave1 = ie->srcWave1;
801 oscWave = ie->oscWave - 1;
802 destBuff = &tc->synthBuffers[destWave];
803
804 srcBuff1 = &tc->synthBuffers[srcWave1];
805
806 oscBuff = oscWave >= 0 ? &tc->synthBuffers[oscWave] : NULL;
807 pos = ve->MFATTMREMVP;
808
809 if (ie->oscWave == 0){
810 var1 = ie->variable1;
811 var2 = ie->variable2;
812 } else {
813 if (ie->oscSelect){
814 var1 = ie->variable1;
815 var2 = ((oscBuff[pos] + 0x8000) >> 8);
816 } else {
817 var1 = ((oscBuff[pos] + 0x8000) >> 8);
818 var2 = ie->variable2;
819 }
820 }
821
822 var2 = (var2 << 8);
823 var1 = (var1 + var2);
824 _local22 = 0;
825
826 int butt, ron, pat, buf2, buf1;
827 for (j = 0; j < 0x0100; j++ ) {
828 //Hex Rays decompiler is lovely tool.
829 //butt = (butt & 0xFFFF0000) | (_local22 & 0x0000FFFF);
830 butt = _local22 & 0xFFFF;
831 _local22 += var1;
832 //ron = (ron & 0xFFFFFF00) | ( butt & 0x000000FF);
833 ron = butt & 0xFF;
834 butt >>= 8;
835 buf1 = srcBuff1[butt];
836 //overflow warning
837 buf2 = srcBuff1[butt + 1];
838 pat = (255 - ron) * buf1;
839 destBuff[j] = (ron * buf2 >> 8) + (pat >> 8);
840 }
841 break;
842 }
843 }
844}
845
846void channelSomethingElse(int chanNum)
847{
848 int _local3;
849 int _local4;
850 int _local5;
851 int _local6;
852
853 TuneChannel *tc = &tuneChannels[chanNum];
854 Instrument *ins = &instruments[tc->insNum];
855
856 if (ins->amWave == 0){
857 _local3 = 0;
858 } else {
859 tc->HFRLJCG = (tc->HFRLJCG + ins->amSpeed);
860 if (tc->HFRLJCG >= 0x0100){
861 tc->HFRLJCG = (tc->HFRLJCG - 0x0100);
862 tc->HFRLJCG = (tc->HFRLJCG + ins->amLoopPoint);
863 if (tc->HFRLJCG >= 0x0100){
864 tc->HFRLJCG = ins->amLoopPoint;
865 }
866 }
867 _local3 = tc->synthBuffers[ins->amWave - 1][tc->HFRLJCG];
868 _local3 = (_local3 + 0x8000);
869 _local3 = (_local3 / 6);
870 _local3 = -(_local3);
871 if (_local3 < -10000){
872 _local3 = -10000;
873 }
874 }
875 _local3 = (_local3 + 10000);
876 _local3 = (_local3 * ins->masterVolume);
877 _local3 = (_local3 >> 8);
878 _local3 = (_local3 * AMVM);
879 _local3 = (_local3 >> 8);
880 _local3 = (_local3 - 10000);
881 tc->volume = _local3;
882 if (ins->panWave == 0){
883 _local5 = 0;
884 } else {
885 tc->ELPHLDR = (tc->ELPHLDR + ins->panSpeed);
886 if (tc->ELPHLDR >= 0x0100){
887 tc->ELPHLDR = (tc->ELPHLDR - 0x0100);
888 tc->ELPHLDR = (tc->ELPHLDR + ins->panLoopPoint);
889 if (tc->ELPHLDR >= 0x0100){
890 tc->ELPHLDR = ins->panLoopPoint;
891 }
892 }
893 _local5 = tc->synthBuffers[ins->panWave - 1][tc->ELPHLDR];
894 _local5 = (_local5 >> 7);
895 }
896 tc->panning = _local5;
897 _local6 = 0;
898 _local6 = arpTable[(ins->arpIndex * 16) + tc->ACKCWV];
899 tc->ACKCWV++;
900 tc->ACKCWV = (tc->ACKCWV & 15);
901 _local4 = freqTable[ins->finetune*128 + (_local6 + tc->TVORFCC)];
902 if (tc->fmDelay){
903 tc->fmDelay--;
904 } else {
905 if (ins->fmWave != 0){
906 tc->JOEEPJCI = (tc->JOEEPJCI + ins->fmSpeed);
907 if (tc->JOEEPJCI >= 0x0100){
908 tc->JOEEPJCI = (tc->JOEEPJCI - 0x0100);
909 tc->JOEEPJCI = (tc->JOEEPJCI + ins->fmLoopPoint);
910 if (tc->JOEEPJCI >= 0x0100){
911 tc->JOEEPJCI = ins->fmLoopPoint;
912 }
913 }
914 _local4 -= tc->synthBuffers[ins->fmWave - 1][tc->JOEEPJCI];
915 }
916 }
917 _local4 = (_local4 + tc->BNWIGU);
918 tc->freq = _local4;
919 if (tc->XESAWSO != 0){
920 if (tc->XESAWSO > 0){
921 if (tc->BNWIGU < tc->UHYDBDDI){
922 tc->BNWIGU = (tc->BNWIGU + tc->XESAWSO);
923 if (tc->BNWIGU > tc->UHYDBDDI){
924 tc->BNWIGU = tc->UHYDBDDI;
925 }
926 }
927 } else {
928 if (tc->BNWIGU > tc->UHYDBDDI){
929 tc->BNWIGU = (tc->BNWIGU + tc->XESAWSO);
930 if (tc->BNWIGU < tc->UHYDBDDI){
931 tc->BNWIGU = tc->UHYDBDDI;
932 }
933 }
934 }
935 }
936}
937
938void playInstrument(int chanNum, int instrNum, int note) //note: 1-112
939{
940 int j;
941 int i;
942
943 if (instrNum > synSong->h.instrNum){
944 return;
945 }
946 if ((((tuneChannels[chanNum].insNum == -1)) && ((instrNum == 0)))){
947 return;
948 }
949
950 TuneChannel *tc = &tuneChannels[chanNum];
951 Voice *v = &voices[chanNum];
952
953 tc->ACKCWV = 0;
954 tc->HFRLJCG = 0;
955 tc->ELPHLDR = 0;
956 tc->JOEEPJCI = 0;
957 tc->TVORFCC = note;
958 tc->freq = 0;
959 tc->VNVJPDIWAJQ = note;
960 tc->BNWIGU = 0;
961 tc->UHYDBDDI = 0;
962 tc->XESAWSO = 0;
963 m_LastNotes[chanNum] = note;
964
965 Instrument *ins;
966 if (instrNum != 0) {
967 ins = &instruments[instrNum - 1];
968
969 if (ins->shareSmpDataFromInstr == 0){
970 tc->sampleBuffer = samples[instrNum - 1];
971 } else {
972 tc->sampleBuffer = samples[ins->shareSmpDataFromInstr - 1];
973 }
974 tc->sampPos = ins->smpStartPoint << 8;
975 tc->smpLoopStart = ins->smpLoopPoint << 8;
976 tc->smpLoopEnd = ins->smpEndPoint << 8;
977 tc->hasLoop = ins->hasLoop;
978 tc->hasBidiLoop = ins->hasBidiLoop;
979 tc->hasLooped = 0;
980 tc->isPlayingBackward = 0;
981 tc->EYRXAB = -1;
982 tc->fmDelay = ins->fmDelay;
983
984 for (i = 0; i < 16; i++) {
985 if (ins->m_ResetWave[i]){
986 //ins->synthBuffers[i].copyTo(tc.synthBuffers[i]);
987 memcpy(&tc->synthBuffers[i], &ins->synthBuffers[i], 0x100 *2);
988 }
989 }
990 tc->insNum = instrNum - 1;
991 }
992 ins = &instruments[tc->insNum];
993
994 for (j = 0; j < 4; j++) {
995 if (ins->effects[j].effectType != 0){
996 if (ins->effects[j].resetEffect) {
997 VoiceEffect *ve = &tc->effects[j];
998
999 ve->MFATTMREMVP = 0;
1000 ve->QOMCBTRPXF = 0;
1001 ve->TIPUANVVR = 0;
1002 ve->YLKJB = 0;
1003 ve->ILHG = 0;
1004 ve->VMBNMTNBQU = 0;
1005 ve->ABJGHAUY = 0;
1006 ve->SPYK = 0;
1007 }
1008 }
1009 }
1010}
1011
1012void patEffect(int note, int command, int dest, int spd, int chanNum)
1013{
1014 TuneChannel *tc = &tuneChannels[chanNum];
1015 Instrument *ins = &instruments[tc->insNum];
1016
1017 if (tc->insNum == -1) return;
1018 int off;
1019 double tempo;
1020 switch (command) {
1021
1022 //NONE
1023 case 0:
1024 default:
1025 return;
1026
1027 //PITCHBEND
1028 case 1:
1029 if (tc->VNVJPDIWAJQ){
1030 off = freqTable[ins->finetune*128 + tc->VNVJPDIWAJQ];
1031 tc->TVORFCC = tc->VNVJPDIWAJQ;
1032 } else {
1033 off = freqTable[ins->finetune*128 + note];
1034 }
1035 tc->BNWIGU = 0;
1036 tc->UHYDBDDI = (freqTable[ins->finetune*128 + dest] - off);
1037 tc->XESAWSO = (spd * 20);
1038 tc->VNVJPDIWAJQ = dest;
1039 break;
1040
1041 //CHNG WAVEFORM
1042 case 2:
1043 if (dest > 15){
1044 dest = 15;
1045 }
1046 ins->waveform = dest;
1047 break;
1048
1049 //CHNG WAVELENGTH
1050 case 3:
1051 if (dest > 192){
1052 dest = 0x0100;
1053 } else {
1054 if (dest > 96){
1055 dest = 128;
1056 } else {
1057 if (dest > 48){
1058 dest = 64;
1059 } else {
1060 dest = 32;
1061 }
1062 }
1063 }
1064 ins->wavelength = dest;
1065 break;
1066
1067 //CHNG MASTER VOL
1068 case 4:
1069 ins->masterVolume = dest;
1070 break;
1071
1072 //CHNG AMWAVE
1073 case 5:
1074 if (dest > 15){
1075 dest = 15;
1076 }
1077 ins->amWave = dest;
1078 break;
1079
1080 //CHNG AMSPD
1081 case 6:
1082 ins->amSpeed = dest;
1083 break;
1084
1085 //CHNG AMLPPOINT
1086 case 7:
1087 ins->amLoopPoint = dest;
1088 break;
1089
1090 //CHNG FINETUNE
1091 case 8:
1092 if (dest > 15){
1093 dest = 15;
1094 }
1095 ins->finetune = dest;
1096 break;
1097
1098 //CHNG FMWAVE
1099 case 9:
1100 if (dest > 15){
1101 dest = 15;
1102 }
1103 ins->fmWave = dest;
1104 break;
1105
1106 //CHNG FMSPD
1107 case 10:
1108 ins->fmSpeed = dest;
1109 break;
1110
1111 //CHNG FMLPPOINT
1112 case 11:
1113 ins->fmLoopPoint = dest;
1114 break;
1115
1116 //CHNG FMDELAY
1117 case 12:
1118 ins->fmDelay = dest;
1119 break;
1120
1121 //CHNG ARPEGGIO
1122 case 13:
1123 if (dest > 15){
1124 dest = 15;
1125 }
1126 ins->arpIndex = dest;
1127 break;
1128
1129 //CHNG EFF#1 DESTWAVE
1130 case 14:
1131 if (dest > 15){
1132 dest = 15;
1133 }
1134 ins->effects[0].destWave = dest;
1135 break;
1136
1137 //CHNG EFF#1 SRCWAVE1
1138 case 15:
1139 if (dest > 15){
1140 dest = 15;
1141 }
1142 ins->effects[0].srcWave1 = dest;
1143 break;
1144
1145 //CHNG EFF#1 SRCWAVE2
1146 case 16:
1147 if (dest > 15){
1148 dest = 15;
1149 }
1150 ins->effects[0].srcWave2 = dest;
1151 break;
1152
1153 //CHNG EFF#1 OSCWAVE
1154 case 17:
1155 if (dest > 15){
1156 dest = 15;
1157 }
1158 ins->effects[0].oscWave = dest;
1159 break;
1160
1161 //CHNG EFF#1 VARIABLE1
1162 case 18:
1163 ins->effects[0].variable1 = dest;
1164 break;
1165
1166 //CHNG EFF#1 VARIABLE2
1167 case 19:
1168 ins->effects[0].variable2 = dest;
1169 break;
1170
1171 //CHNG EFF#1 FXSPEED
1172 case 20:
1173 ins->effects[0].fxSpeed = dest;
1174 break;
1175
1176 //CHNG EFF#1 OSCSPEED
1177 case 21:
1178 ins->effects[0].oscSpeed = dest;
1179 break;
1180
1181 //CHNG EFF#1 OSCSELECT
1182 case 22:
1183 if (dest > 1){
1184 dest = 1;
1185 }
1186 ins->effects[0].oscSelect = dest;
1187 break;
1188
1189 //CHNG EFF#1 TYPE
1190 case 23:
1191 if (dest >= SE_NROFEFFECTS){
1192 dest = (SE_NROFEFFECTS - 1);
1193 }
1194 ins->effects[0].effectType = dest;
1195 break;
1196
1197 //CHNG EFF#1 RESETEFFECT
1198 case 24:
1199 if (dest > 1){
1200 dest = 1;
1201 }
1202 ins->effects[0].resetEffect = dest;
1203 break;
1204
1205 //CHNG EFF#2 DESTWAVE
1206 case 25:
1207 if (dest > 15){
1208 dest = 15;
1209 }
1210 ins->effects[1].destWave = dest;
1211 break;
1212
1213 //CHNG EFF#2 SRCWAVE1
1214 case 26:
1215 if (dest > 15){
1216 dest = 15;
1217 }
1218 ins->effects[1].srcWave1 = dest;
1219 break;
1220
1221 //CHNG EFF#2 SRCWAVE2
1222 case 27:
1223 if (dest > 15){
1224 dest = 15;
1225 }
1226 //Good god! SrcEffect2 is left unplugged. I could guess what it was.
1227 //Luckly, I'm saved by one of the later effects.
1228 ins->effects[1].srcWave2 = dest;
1229 break;
1230
1231 //CHNG EFF#2 OSCWAVE
1232 case 28:
1233 if (dest > 15){
1234 dest = 15;
1235 }
1236 ins->effects[1].oscWave = dest;
1237 break;
1238
1239 //CHNG EFF#2 VARIABLE1
1240 case 29:
1241 ins->effects[1].variable1 = dest;
1242 break;
1243
1244 //CHNG EFF#2 VARIABLE2
1245 case 30:
1246 ins->effects[1].variable2 = dest;
1247 break;
1248
1249 //CHNG EFF#2 FXSPEED
1250 case 31:
1251 ins->effects[1].fxSpeed = dest;
1252 break;
1253
1254 //CHNG EFF#2 OSCSPEED
1255 case 32:
1256 ins->effects[1].oscSpeed = dest;
1257 break;
1258
1259 //CHNG EFF#2 OSCSELECT
1260 case 33:
1261 if (dest > 1){
1262 dest = 1;
1263 }
1264 ins->effects[1].oscSelect = dest;
1265 break;
1266
1267 //CHNG EFF#2 TYPE
1268 case 34:
1269 if (dest >= SE_NROFEFFECTS){
1270 dest = (SE_NROFEFFECTS - 1);
1271 }
1272 ins->effects[1].effectType = dest;
1273 break;
1274
1275 //CHNG EFF#2 RESETEFFECT
1276 case 35:
1277 if (dest > 1){
1278 dest = 1;
1279 }
1280 ins->effects[1].resetEffect = dest;
1281 break;
1282
1283 //CHNG EFF#3 DESTWAVE
1284 case 36:
1285 if (dest > 15){
1286 dest = 15;
1287 }
1288 ins->effects[2].destWave = dest;
1289 break;
1290
1291 //CHNG EFF#3 SRCWAVE1
1292 case 37:
1293 if (dest > 15){
1294 dest = 15;
1295 }
1296 ins->effects[2].srcWave1 = dest;
1297 break;
1298
1299 //CHNG EFF#3 SRCWAVE2
1300 case 38:
1301 if (dest > 15){
1302 dest = 15;
1303 }
1304 ins->effects[2].srcWave2 = dest;
1305 break;
1306
1307 //CHNG EFF#3 OSCWAVE
1308 case 39:
1309 if (dest > 15){
1310 dest = 15;
1311 }
1312 ins->effects[2].oscWave = dest;
1313 break;
1314
1315 //CHNG EFF#3 VARIABLE1
1316 case 40:
1317 ins->effects[2].variable1 = dest;
1318 break;
1319
1320 //CHNG EFF#3 VARIABLE2
1321 case 41:
1322 ins->effects[2].variable2 = dest;
1323 break;
1324
1325 //CHNG EFF#3 FXSPEED
1326 case 42:
1327 ins->effects[2].fxSpeed = dest;
1328 break;
1329
1330 //CHNG EFF#3 OSCSPEED
1331 case 43:
1332 ins->effects[2].oscSpeed = dest;
1333 break;
1334
1335 //CHNG EFF#3 OSCSELECT
1336 case 44:
1337 if (dest > 1){
1338 dest = 1;
1339 }
1340 ins->effects[2].oscSelect = dest;
1341 break;
1342
1343 //CHNG EFF#3 TYPE
1344 case 45:
1345 if (dest >= SE_NROFEFFECTS){
1346 dest = (SE_NROFEFFECTS - 1);
1347 }
1348 ins->effects[2].effectType = dest;
1349 break;
1350
1351 //CHNG EFF#3 RESETEFFECT
1352 case 46:
1353 if (dest > 1){
1354 dest = 1;
1355 }
1356 ins->effects[2].resetEffect = dest;
1357 break;
1358
1359 //CHNG EFF#4 DESTWAVE
1360 case 47:
1361 if (dest > 15){
1362 dest = 15;
1363 }
1364 ins->effects[3].destWave = dest;
1365 break;
1366
1367 //CHNG EFF#4 SRCWAVE1
1368 case 48:
1369 if (dest > 15){
1370 dest = 15;
1371 }
1372 ins->effects[3].srcWave1 = dest;
1373 break;
1374
1375 //CHNG EFF#4 SRCWAVE2
1376 case 49:
1377 if (dest > 15){
1378 dest = 15;
1379 }
1380 ins->effects[3].srcWave2 = dest;
1381 break;
1382
1383 //CHNG EFF#4 OSCWAVE
1384 case 50:
1385 if (dest > 15){
1386 dest = 15;
1387 }
1388 ins->effects[3].oscWave = dest;
1389 break;
1390
1391 //CHNG EFF#4 VARIABLE1
1392 case 51:
1393 ins->effects[3].variable1 = dest;
1394 break;
1395
1396 //CHNG EFF#4 VARIABLE2
1397 case 52:
1398 ins->effects[3].variable2 = dest;
1399 break;
1400
1401 //CHNG EFF#4 FXSPEED
1402 case 53:
1403 ins->effects[3].fxSpeed = dest;
1404 break;
1405
1406 //CHNG EFF#4 OSCSPEED
1407 case 54:
1408 ins->effects[3].oscSpeed = dest;
1409 break;
1410
1411 //CHNG EFF#4 OSCSELECT
1412 case 55:
1413 if (dest > 1){
1414 dest = 1;
1415 }
1416 ins->effects[3].oscSelect = dest;
1417 break;
1418
1419 //CHNG EFF#4 TYPE
1420 case 56:
1421 if (dest >= SE_NROFEFFECTS){
1422 dest = (SE_NROFEFFECTS - 1);
1423 }
1424 ins->effects[3].effectType = dest;
1425 break;
1426
1427 //CHNG EFF#4 RESETEFFECT
1428 case 57:
1429 if (dest > 1){
1430 dest = 1;
1431 }
1432 ins->effects[3].resetEffect = dest;
1433 break;
1434
1435 //CHNG RESET WAVE #1
1436 case 58:
1437 if (dest > 1){
1438 dest = 1;
1439 }
1440 ins->m_ResetWave[0] = dest;
1441 break;
1442
1443 //CHNG RESET WAVE #2
1444 case 59:
1445 if (dest > 1){
1446 dest = 1;
1447 }
1448 ins->m_ResetWave[1] = dest;
1449 break;
1450
1451 //CHNG RESET WAVE #3
1452 case 60:
1453 if (dest > 1){
1454 dest = 1;
1455 }
1456 ins->m_ResetWave[2] = dest;
1457 break;
1458
1459 //CHNG RESET WAVE #4
1460 case 61:
1461 if (dest > 1){
1462 dest = 1;
1463 }
1464 ins->m_ResetWave[3] = dest;
1465 break;
1466
1467 //CHNG RESET WAVE #5
1468 case 62:
1469 if (dest > 1){
1470 dest = 1;
1471 }
1472 ins->m_ResetWave[4] = dest;
1473 break;
1474
1475 //CHNG RESET WAVE #6
1476 case 63:
1477 if (dest > 1){
1478 dest = 1;
1479 }
1480 ins->m_ResetWave[5] = dest;
1481 break;
1482
1483 //CHNG RESET WAVE #7
1484 case 64:
1485 if (dest > 1){
1486 dest = 1;
1487 }
1488 ins->m_ResetWave[6] = dest;
1489 break;
1490
1491 //CHNG RESET WAVE #8
1492 case 65:
1493 if (dest > 1){
1494 dest = 1;
1495 }
1496 ins->m_ResetWave[7] = dest;
1497 break;
1498
1499 //CHNG RESET WAVE #9
1500 case 66:
1501 if (dest > 1){
1502 dest = 1;
1503 }
1504 ins->m_ResetWave[8] = dest;
1505 break;
1506
1507 //CHNG RESET WAVE #10
1508 case 67:
1509 if (dest > 1){
1510 dest = 1;
1511 }
1512 ins->m_ResetWave[9] = dest;
1513 break;
1514
1515 //CHNG RESET WAVE #11
1516 case 68:
1517 if (dest > 1){
1518 dest = 1;
1519 }
1520 ins->m_ResetWave[10] = dest;
1521 break;
1522
1523 //CHNG RESET WAVE #12
1524 case 69:
1525 if (dest > 1){
1526 dest = 1;
1527 }
1528 ins->m_ResetWave[11] = dest;
1529 break;
1530
1531 //CHNG RESET WAVE #13
1532 case 70:
1533 if (dest > 1){
1534 dest = 1;
1535 }
1536 ins->m_ResetWave[12] = dest;
1537 break;
1538
1539 //CHNG RESET WAVE #14
1540 case 71:
1541 if (dest > 1){
1542 dest = 1;
1543 }
1544 ins->m_ResetWave[13] = dest;
1545 break;
1546
1547 //CHNG RESET WAVE #15
1548 case 72:
1549 if (dest > 1){
1550 dest = 1;
1551 }
1552 ins->m_ResetWave[14] = dest;
1553 break;
1554
1555 //CHNG RESET WAVE #16
1556 case 73:
1557 if (dest > 1){
1558 dest = 1;
1559 }
1560 ins->m_ResetWave[15] = dest;
1561 break;
1562
1563 //CHNG BPM
1564 case 74:
1565 if (dest <= 10){
1566 dest = 10;
1567 }
1568 if (dest > 220){
1569 dest = 220;
1570 }
1571 curSubsong->tempo = dest;
1572 tempo = double(curSubsong->tempo);
1573 tempo = (tempo / 60);
1574 tempo = (tempo * 32);
1575 samplesPerBeat = int(44100 / tempo);
1576 break;
1577
1578 //CHNG GROOVE
1579 case 75:
1580 if (dest > 3){
1581 dest = 3;
1582 }
1583 curSubsong->groove = dest;
1584 break;
1585
1586 //FIRE EXTERNAL EVENT
1587 case 76:
1588 //this effect is for controlling external code
1589 //like animation and whatnot
1590 //similar to how 8xx is used in Travolta's 'testlast' .mod
1591
1592 //do take note of audio latency when dealing with this.
1593
1594 //This is called UserEvent in ocx player doc, I think
1595 break;
1596 }
1597}
1598
1599void channelSomething(int chanNum)
1600{
1601 int _local2;
1602 int _local3;
1603 int note;
1604 int dest;
1605 int contrScript;
1606 int spd;
1607
1608 if (isPaused) return;
1609 if (!PQV) return;
1610 if (someCounter != WDTECTE) return;
1611
1612 if (sePmSong == SE_PM_PATTERN){
1613 if (chanNum > 0) return;
1614 _local2 = AMYGPFQCHSW;
1615 _local3 = ISWLKT;
1616 } else {
1617 if (curSubsong->mutedChans[chanNum] == 1) return;
1618
1619 _local3 = tuneChannels[chanNum].LJHG;
1620 _local2 = curSubsong->orders[chanNum][tuneChannels[chanNum].EQMIWERPIF].patIndex;
1621 }
1622 note = rows[(_local2 * 64) + _local3].note;
1623 if (note != 0) {
1624 playInstrument(chanNum, rows[(_local2 * 64) + _local3].instr, note);
1625 }
1626 contrScript = rows[(_local2 * 64) + _local3].command;
1627 dest = rows[(_local2 * 64) + _local3].dest;
1628 spd = rows[(_local2 * 64) + _local3].spd;
1629 patEffect(note, contrScript, dest, spd, chanNum);
1630}
1631
1632void ABH(void)
1633{
1634 int i, j0, j1;
1635 int _local2;
1636 Order *_local3;
1637 int _local4;
1638 bool _local5;
1639 int _local6;
1640 Order *_local9;
1641 int _local10;
1642 int _local11;
1643
1644 if (!PQV) return;
1645 if (isPaused) return;
1646
1647 someCounter--;
1648 if (someCounter == 0){
1649 if (sePmSong == SE_PM_PATTERN){
1650 if (!(ISWLKT & 1)){
1651 WDTECTE = (8 - curSubsong->groove);
1652 } else {
1653 WDTECTE = (8 + curSubsong->groove);
1654 }
1655 } else {
1656 if (!(posFine & 1)){
1657 WDTECTE = (8 - curSubsong->groove);
1658 } else {
1659 WDTECTE = (8 + curSubsong->groove);
1660 }
1661 }
1662 someCounter = WDTECTE;
1663 if (sePmSong == SE_PM_PATTERN){
1664 ISWLKT++;
1665 ISWLKT = (ISWLKT % PENIS);
1666 } else {
1667
1668 for (i = 0; i < channelNumber; i++) {
1669 TuneChannel *tc = &tuneChannels[i];
1670
1671 tc->LJHG++;
1672 _local3 = &curSubsong->orders[i];
1673 _local4 = tc->EQMIWERPIF;
1674 if (_local4 == -1){
1675 _local4 = 0;
1676 }
1677 _local2 = &_local3[_local4].patLen;
1678 if ((((tc->LJHG == _local2)) || ((tc->EQMIWERPIF == -1)))){
1679 tc->LJHG = 0;
1680 tc->EQMIWERPIF++;
1681 curSubsong->mutedChans[i] = mutedChans[i];
1682 }
1683
1684 }
1685 posFine++;
1686 if (posFine == 64){
1687 posFine = 0;
1688 posCoarse++;
1689 }
1690 if ((((posCoarse == curSubsong->endPosCoarse)) && ((posFine == curSubsong->endPosFine)))){
1691 if (curSubsong->isLooping){
1692 _local5 = false;
1693
1694 for (j0 = 0; j0 < SE_MAXCHANS; j0++) {
1695 _local6 = 0;
1696
1697 _local11 = 0;
1698 _local9 = &curSubsong->orders[j0];
1699 _local10 = ((curSubsong->loopPosCoarse * 64) + curSubsong->loopPosFine);
1700 for (j1 = 0; j1 < 0x0100; j1++) {
1701 if (_local6 > _local10){
1702 if (j1 != _local10){
1703 j1--;
1704 }
1705 break;
1706 }
1707 _local11 = _local6;
1708 _local6 = (_local6 + _local9[j1].patLen);
1709
1710 }
1711 if (j1 == 0x0100){
1712 PQV = 0;
1713 _local5 = true;
1714 break;
1715 }
1716 _local10 = (_local10 - _local11);
1717 _local10 = (_local10 & 63);
1718 tuneChannels[j0].EQMIWERPIF = j1;
1719 tuneChannels[j0].LJHG = _local10;
1720
1721 }
1722 if (_local5 == false){
1723 posCoarse = curSubsong->loopPosCoarse;
1724 posFine = curSubsong->loopPosFine;
1725 }
1726 } else {
1727 PQV = 0;
1728 isPaused = 0;
1729 sePmSong = SE_PM_SONG;
1730 posCoarse = curSubsong->startPosCoarse;
1731 posFine = curSubsong->startPosFine;
1732 }
1733 }
1734 }
1735 }
1736}
1737
1738void advanceTick()
1739{
1740 int i;
1741 ABH();
1742
1743 for (i = 0; i < channelNumber; i++) {
1744 channelSomething(i);
1745 if (tuneChannels[i].insNum != -1) {
1746 channelSomethingElse(i);
1747 instrEffect(i);
1748 }
1749 }
1750}
1751
1752void mixChunk(int16_t *outBuff, uint playbackBufferSize)
1753{
1754
1755 int i, j;
1756 uint sampleNum;
1757 int amp, smp, pos;
1758 int16_t audioMainR, audioMainL;
1759 int16_t audioDelayR, audioDelayL;
1760 uint otherDelayTime;
1761 Voice *v;
1762 TuneChannel *tc;
1763
1764 //We just don't know!
1765 uint dword_6632774C = 0;
1766
1767 if ( channelNumber > 0 )
1768 {
1769 if ( playbackBufferSize & 1) playbackBufferSize--;
1770 if ( playbackBufferSize <= 0 ) return;
1771
1772 while ( playbackBufferSize > 0 )
1773 {
1774 if ( otherSamplesPerBeat >= playbackBufferSize )
1775 {
1776 otherSamplesPerBeat = otherSamplesPerBeat - playbackBufferSize;
1777 sampleNum = playbackBufferSize;
1778 }
1779 else
1780 {
1781 sampleNum = otherSamplesPerBeat;
1782 otherSamplesPerBeat = samplesPerBeat * SAMPLEFREQUENCY / 44100;
1783 }
1784 playbackBufferSize -= sampleNum;
1785
1786 for (i=0; i < channelNumber; ++i )
1787 {
1788 v = &voices[i]; tc = &tuneChannels[i];
1789
1790 int insNum = tc->insNum;
1791 if ( insNum == -1 )
1792 {
1793 v->waveBuff = &silentBuffer;
1794 v->isSample = 0;
1795 }
1796 else if ( !tc->sampleBuffer )
1797 {
1798 int waveNum = instruments[insNum].waveform;
1799 v->wavelength = (instruments[insNum].wavelength << 8) - 1;
1800 v->waveBuff = &tc->synthBuffers[waveNum];
1801 v->isSample = 0;
1802 }
1803 else
1804 {
1805 v->waveBuff = &tc->sampleBuffer;
1806 v->sampPos = tc->sampPos;
1807 v->smpLoopStart = tc->smpLoopStart;
1808 v->smpLoopEnd = tc->smpLoopEnd;
1809 v->hasLoop = tc->hasLoop;
1810 v->hasBidiLoop = tc->hasBidiLoop;
1811 v->isPlayingBackward = tc->isPlayingBackward;
1812 v->hasLooped = tc->hasLooped;
1813 v->isSample = 1;
1814 }
1815
1816 if ( tc->freq < 10 )
1817 tc->freq = 10;
1818
1819 v->gain = (tc->volume + 10000) / 39;
1820 v->delta = (tc->freq << 8) / SAMPLEFREQUENCY;
1821
1822 if ( v->gain > 0x100 )
1823 v->gain = 0x100;
1824 if ( tc->panning )
1825 {
1826 if ( tc->panning <= 0 )
1827 {
1828 v->gainRight = 0x100;
1829 v->gainLeft = 0x100 + tc->panning;
1830 }
1831 else
1832 {
1833 v->gainLeft = 0x100;
1834 v->gainRight = 0x100 - tc->panning;
1835 }
1836 }
1837 else
1838 {
1839 v->gainRight = 0x100;
1840 v->gainLeft = 0x100;
1841 }
1842 if ( dword_6632774C )
1843 {
1844 //v->gainDelay = word_6632B9F4[i];
1845 }
1846 else
1847 {
1848 v->gainDelay = curSubsong->chanDelayAmt[i];
1849 }
1850 v->gainRight = (v->gain * v->gainRight) >> 8;
1851 v->gainLeft = (v->gain * v->gainLeft) >> 8;
1852 v->gainDelayRight = (v->gainDelay * v->gainRight) >> 8;
1853 v->gainDelayLeft = (v->gainDelay * v->gainLeft) >> 8;
1854 }
1855 if ( dword_6632774C )
1856 {
1857 //amp = word_6632B964;
1858 //otherDelayTime = word_6632BB24;
1859 }
1860 else
1861 {
1862 amp = curSubsong->amplification;
1863 otherDelayTime = curSubsong->delayTime / (44100 / SAMPLEFREQUENCY);
1864 }
1865 if ( outBuff )
1866 {
1867 if ( sampleNum > 0 )
1868 {
1869 for(i = 0; i < sampleNum; i++)
1870 {
1871 audioMainR = 0;
1872 audioMainL = 0;
1873 audioDelayR = 0;
1874 audioDelayL = 0;
1875 if ( channelNumber > 0 )
1876 {
1877 for (j = 0; j < channelNumber; ++j)
1878 {
1879 v = &voices[j];
1880 if ( v->isSample == 1 )
1881 {
1882 if ( v->sampPos != -1 )
1883 {
1884 //interpolation
1885 //smp = intp->interpSamp(v);
1886 smp = v->waveBuff[v->sampPos>>8];
1887
1888 audioMainR += (smp * v->gainRight) >> 8;
1889 audioMainL += (smp * v->gainLeft) >> 8;
1890 audioDelayR += (smp * v->gainDelayRight) >> 8;
1891 audioDelayL += (smp * v->gainDelayLeft) >> 8;
1892 if ( v->isPlayingBackward )
1893 {
1894 v->sampPos -= v->delta;
1895 if ( v->sampPos <= v->smpLoopStart )
1896 {
1897 v->isPlayingBackward = 0;
1898 v->sampPos += v->delta;
1899 }
1900 }
1901 else
1902 {
1903 v->sampPos += v->delta;
1904 if ( v->sampPos >= v->smpLoopEnd )
1905 {
1906 if ( v->hasLoop )
1907 {
1908 v->hasLooped = 1;
1909 if ( v->hasBidiLoop )
1910 {
1911 v->isPlayingBackward = 1;
1912 v->sampPos -= v->delta;
1913 }
1914 else
1915 {
1916 v->sampPos += v->smpLoopStart - v->smpLoopEnd;
1917 }
1918 }
1919 else
1920 {
1921 v->sampPos = -1;
1922 }
1923 }
1924 }
1925 }
1926 }
1927 else
1928 {
1929 //interpolation
1930 //smp = intp->interpSynt(v);
1931 smp = v->waveBuff[v->synthPos>>8];
1932
1933 audioMainR += (smp * v->gainRight) >> 8;
1934 audioMainL += (smp * v->gainLeft) >> 8;
1935 audioDelayR += (smp * v->gainDelayRight) >> 8;
1936 audioDelayL += (smp * v->gainDelayLeft) >> 8;
1937 v->synthPos += v->delta;
1938 v->synthPos &= v->wavelength;
1939 }
1940 }
1941 }
1942
1943 audioMainL = (delayBufferL[delayPos] + audioMainL / channelNumber) / 2;
1944 audioMainR = (delayBufferR[delayPos] + audioMainR / channelNumber) / 2;
1945 audioMainR = audioMainR * amp / 100;
1946 audioMainL = audioMainL * amp / 100;
1947 //clip audio
1948 if ( audioMainR < -32760 ) audioMainR = -32760;
1949 if ( audioMainR > 32760 ) audioMainR = 32760;
1950 if ( audioMainL < -32760 ) audioMainL = -32760;
1951 if ( audioMainL > 32760 ) audioMainL = 32760;
1952
1953 //interleaved buffer
1954 if ( overlapPos < SE_OVERLAP )
1955 {
1956 audioMainR = overlapPos * audioMainR / 100;
1957 audioMainR += (SE_OVERLAP - overlapPos) * overlapBuff[overlapPos*2] / 100;
1958 audioMainL = overlapPos * audioMainL / 100;
1959 audioMainL += (SE_OVERLAP - overlapPos) * overlapBuff[overlapPos*2+1] / 100;
1960 ++overlapPos;
1961 }
1962
1963 //output
1964 *outBuff++ = audioMainR;
1965 *outBuff++ = audioMainL;
1966
1967 delayBufferL[delayPos] = (((audioDelayL / channelNumber) + delayBufferL[delayPos]) / 2);
1968 delayBufferR[delayPos] = (((audioDelayR / channelNumber) + delayBufferR[delayPos]) / 2);
1969 delayPos = ++delayPos % otherDelayTime;
1970 }
1971 }
1972 }
1973
1974 if ( channelNumber > 0 )
1975 {
1976 for (i = 0; i < channelNumber; ++i)
1977 {
1978 v = &voices[i]; tc = &tuneChannels[i];
1979 if ( v->isSample )
1980 {
1981 tc->sampPos = v->sampPos;
1982 tc->isPlayingBackward = v->isPlayingBackward;
1983 tc->hasLooped = v->hasLooped;
1984 }
1985 }
1986 }
1987 if ( otherSamplesPerBeat == (samplesPerBeat * SAMPLEFREQUENCY) / 44100 )
1988 {
1989 bkpDelayPos = delayPos;
1990 for (i = 0; i < channelNumber; i++) voices[i].bkpSynthPos = voices[i].synthPos;
1991
1992 overlapPos = 0;
1993 if ( outBuff )
1994 {
1995 for (i = 0; i < SE_OVERLAP; i++)
1996 {
1997 audioMainR = 0;
1998 audioMainL = 0;
1999 audioDelayR = 0;
2000 audioDelayL = 0;
2001 if ( channelNumber > 0 )
2002 {
2003 for (j = 0; j < channelNumber; j++)
2004 {
2005 v = &voices[j];
2006 if ( v->isSample == 1 )
2007 {
2008 if ( v->sampPos != -1 )
2009 {
2010 //interpolation
2011 //smp = intp->interpSamp(v);
2012 smp = v->waveBuff[v->sampPos>>8];
2013
2014 audioMainR += (smp * v->gainRight) >> 8;
2015 audioMainL += (smp * v->gainLeft) >> 8;
2016 audioDelayR += (smp * v->gainDelayRight) >> 8;
2017 audioDelayL += (smp * v->gainDelayLeft) >> 8;
2018 if ( v->isPlayingBackward )
2019 {
2020 v->sampPos -= v->delta;
2021 if ( v->sampPos <= v->smpLoopStart )
2022 {
2023 v->isPlayingBackward = 0;
2024 v->sampPos += v->delta;
2025 }
2026 }
2027 else
2028 {
2029 v->sampPos += v->delta;
2030 if ( v->sampPos >= v->smpLoopEnd )
2031 {
2032 if ( v->hasLoop )
2033 {
2034 v->hasLooped = 1;
2035 if ( v->hasBidiLoop )
2036 {
2037 v->isPlayingBackward = 1;
2038 v->sampPos -= v->delta;
2039 }
2040 else
2041 {
2042 v->sampPos += v->smpLoopStart - v->smpLoopEnd;
2043 }
2044 }
2045 else
2046 {
2047 v->sampPos = -1;
2048 }
2049 }
2050 }
2051 }
2052 }
2053 else
2054 {
2055 //interpolation
2056 //smp = intp->interpSynt(v);
2057 smp = v->waveBuff[v->synthPos>>8];
2058
2059 audioMainR += (smp * v->gainRight) >> 8;
2060 audioMainL += (smp * v->gainLeft) >> 8;
2061 audioDelayR += (smp * v->gainDelayRight) >> 8;
2062 audioDelayL += (smp * v->gainDelayLeft) >> 8;
2063 v->synthPos += v->delta;
2064 v->synthPos &= v->wavelength;
2065 }
2066 }
2067 }
2068
2069 audioMainL = (delayBufferL[delayPos] + audioMainL / channelNumber) / 2;
2070 audioMainR = (delayBufferR[delayPos] + audioMainR / channelNumber) / 2;
2071 audioMainR = audioMainR * amp / 100;
2072 audioMainL = audioMainL * amp / 100;
2073 //clip audio
2074 if ( audioMainR < -32760 ) audioMainR = -32760;
2075 if ( audioMainR > 32760 ) audioMainR = 32760;
2076 if ( audioMainL < -32760 ) audioMainL = -32760;
2077 if ( audioMainL > 32760 ) audioMainL = 32760;
2078
2079 overlapBuff[i * 2] = audioMainR;
2080 overlapBuff[i*2+1] = audioMainL;
2081
2082 delayPos = ++delayPos % otherDelayTime;
2083 }
2084 }
2085 delayPos = bkpDelayPos;
2086 for (i = 0; i < channelNumber; i++) voices[i].synthPos = voices[i].bkpSynthPos;
2087
2088 //dword_66327200 = 2 * sampleNum;
2089 advanceTick();
2090 }
2091 }
2092 return;
2093 }
2094 if ( playbackBufferSize <= 0 ) return;
2095 //blank write to playback buffer
2096 memset(outBuff, 0, playbackBufferSize * 2 *2);
2097}
2098
2099void pausePlay(void)
2100{
2101 isPaused = 1;
2102}
2103
2104void resumePlay(void)
2105{
2106 isPaused = 0;
2107}
2108
2109 /*void newSong(void)
2110 {
2111 var _local1:int;
2112 var i:int;
2113 var j:int;
2114 var _local4:Order;
2115 var _local6:Vector.<Order>;
2116 var _local7:Row;
2117
2118 reset();
2119 AMYGPFQCHSW = 1;
2120 selectedSubsong = 0;
2121 WDTECTE = 8;
2122 AMVM = 0x100;
2123 synSong.h.subsongNum = 1;
2124 synSong.h.version = 3457;
2125 subsongs = new Vector.<Subsong>();
2126 subsongs.push(new Subsong());
2127 var subs0:Subsong = subsongs[0];
2128 curSubsong = subsongs[selectedSubsong];
2129
2130 subs0.tempo = 120;
2131 subs0.groove = 0;
2132 subs0.startPosCoarse = 0;
2133 subs0.startPosFine = 0;
2134 subs0.loopPosCoarse = 0;
2135 subs0.loopPosFine = 0;
2136 subs0.endPosCoarse = 1;
2137 subs0.endPosFine = 0;
2138 subs0.channelNumber = 4;
2139 subs0.delayTime = 0x8000;
2140 subs0.amplification = 400;
2141 subs0.chanDelayAmt = new Vector.<int>(SE_MAXCHANS, true);
2142
2143 subs0.m_Name = "Empty";
2144 subs0.mutedChans = new Vector.<int>(SE_MAXCHANS, true);
2145
2146
2147 subs0.orders = Tools.malloc_2DVector(Order, SE_MAXCHANS, 0x0100, true, true);
2148 for (i = 0; i < SE_MAXCHANS; i++) {
2149 _local6 = subs0.orders[i];
2150 for (j = 0; j < 0x0100; j++) {
2151 _local6[j].patIndex = 0;
2152 _local6[j].patLen = 0;
2153 }
2154 }
2155
2156 synSong.h.patNum = 2;
2157 synSong.rows = Tools.malloc_1DVector(Row, 64 * synSong.h.patNum);
2158
2159 for (i = 0; i < (64 * synSong.h.patNum); i++) {
2160 rows[i].dest = 0;
2161 rows[i].note = 0;
2162 rows[i].instr = 0;
2163 rows[i].command = 0;
2164 rows[i].spd = 0;
2165
2166 }
2167 patternNames = new Vector.<String>();
2168 patternNames.push("Empty");
2169 patternNames.push("Pat1");
2170 synSong.h.instrNum = 1;
2171 synSong.instruments = new Vector.<Instrument>();
2172 synSong.instruments.push(new Instrument());
2173
2174 mutedChans = new Vector.<int>(SE_MAXCHANS, true);
2175 }*/
2176
2177void AAUCAPQW(void)
2178{
2179 //What is this even for?
2180
2181 PQV = 0;
2182 isPaused = 0;
2183 sePmSong = SE_PM_SONG;
2184 if (subsongs){
2185 posCoarse = curSubsong->startPosCoarse;
2186 posFine = curSubsong->startPosFine;
2187 }
2188}
2189
2190void IMXFLSSMB(int _arg1)
2191{
2192 PQV = 1;
2193 AMYGPFQCHSW = _arg1;
2194 ISWLKT = 63;
2195 someCounter = 1;
2196 sePmSong = SE_PM_PATTERN;
2197 WDTECTE = subsongs[0].tempo - subsongs[0].groove;
2198}
2199
2200void initSubsong(int num)
2201{
2202 int _local2;
2203 int i, j;
2204 Order *_local5;
2205 bool _local6;
2206 int _local7;
2207 int _local8;
2208 double tempo;
2209
2210 if (num >= synSong->h.subsongNum) return;
2211
2212 selectedSubsong = num;
2213 curSubsong = &subsongs[selectedSubsong];
2214 channelNumber = curSubsong->channelNumber;
2215 reset();
2216 _local6 = false;
2217
2218 for (i = 0; i < SE_MAXCHANS; i++) {
2219 m_LastNotes[i] = 0;
2220 _local2 = 0;
2221
2222 _local8 = 0;
2223 _local5 = &curSubsong->orders[i];
2224 _local7 = (((curSubsong->startPosCoarse * 64) + curSubsong->startPosFine) - 1);
2225 for (j = 0; j < 0x0100; j++) {
2226 if (_local2 >= _local7){
2227 if (j != _local7){
2228 j--;
2229 }
2230 break;
2231 }
2232 _local8 = _local2;
2233 _local2 = (_local2 + _local5[j].patLen);
2234
2235 }
2236 if (j == 0x0100){
2237 _local6 = true;
2238 break;
2239 }
2240 _local7 = (_local7 - _local8);
2241 _local7 = (_local7 & 63);
2242 tuneChannels[i].EQMIWERPIF = j;
2243 tuneChannels[i].LJHG = _local7;
2244 curSubsong->mutedChans[i] = mutedChans[i];
2245
2246 }
2247 if (_local6 == false){
2248 someCounter = 1;
2249 sePmSong = SE_PM_SONG;
2250 PQV = 1;
2251 isPaused = noAutoplay;
2252 WDTECTE = (8 + curSubsong->groove);
2253 if (curSubsong->tempo){
2254 tempo = double(curSubsong->tempo);
2255 tempo = (tempo / 60);
2256 tempo = (tempo * 32);
2257 samplesPerBeat = int((44100 / tempo));
2258 otherSamplesPerBeat = samplesPerBeat;
2259 }
2260 if (curSubsong->startPosFine == 0){
2261 posCoarse = curSubsong->startPosCoarse - 1;
2262 } else {
2263 posCoarse = curSubsong->startPosCoarse;
2264 }
2265 posFine = curSubsong->startPosFine - 1;
2266 posFine = posFine & 63;
2267 }
2268}
2269
2270Song* loadSongFromFile(char *path)
2271{
2272 int i;
2273
2274 AAUCAPQW();
2275 reset();
2276 clearSongData();
2277 synSong = File_loadSong(path);
2278
2279 //pass things locally
2280 //not much purpouse here
2281 //nor in AS3
2282 //why did I do it
2283 rows = synSong->rows;
2284 patternNames = synSong->patternNames;
2285 instruments = synSong->instruments;
2286 subsongs = synSong->subsongs;
2287 arpTable = synSong->arpTable;
2288 samples = synSong->samples;
2289
2290 for (i = 0; i < SE_MAXCHANS; i++) {
2291 mutedChans[i] = synSong->subsongs[0].mutedChans[i];
2292 }
2293 initSubsong(0);
2294
2295 return synSong;
2296}
2297
2298//<kode54> int16_t ** samples;
2299//<kode54> then you (re)alloc sizeof(int16_t*)*n for samples, then sizeof(int16_t)*n for samples[y]
2300

Built with git-ssb-web