Browse code

Fix xfading issues

Bad Diode authored on 10/10/2023 14:06:17 • neauoire committed on 03/11/2023 00:30:14
Showing 2 changed files
... ...
@@ -16,7 +16,6 @@
16 16
 
17 17
 |0000
18 18
 
19
-@progress0  $1
20 19
 @progress1  $1
21 20
 @progress2  $1
22 21
 @progress3  $1
... ...
@@ -31,6 +30,7 @@
31 30
 	( vectors )
32 31
 	;on-frame  .Screen/vector DEO2
33 32
 	;on-button .Controller/vector DEO2
33
+	#0000      .Audio1/vector DEO2
34 34
 	;on-audio1 .Audio1/vector DEO2
35 35
 	;on-audio2 .Audio2/vector DEO2
36 36
 	;on-audio3 .Audio3/vector DEO2
... ...
@@ -44,7 +44,6 @@
44 44
 	#f0     .Audio0/decay    DEO
45 45
 	#ff     .Audio0/sustain  DEO
46 46
 	#1e     .Audio0/release  DEO
47
-	#00e8   .Audio0/duration DEO2
48 47
 
49 48
 	;sine   .Audio1/addr     DEO2
50 49
 	#0054   .Audio1/length   DEO2
... ...
@@ -71,7 +70,7 @@
71 70
 	#f0     .Audio3/decay    DEO
72 71
 	#00     .Audio3/sustain  DEO
73 72
 	#1e     .Audio3/release  DEO
74
-	#03e0   .Audio3/duration DEO2
73
+	#00e8   .Audio3/duration DEO2
75 74
 BRK
76 75
 
77 76
 @on-button ( -> )
... ...
@@ -84,16 +83,6 @@ BRK
84 83
 	#3c     .Audio0/pitch    DEO
85 84
 BRK
86 85
 
87
-@on-audio0 ( -> )
88
-    ( load next note )
89
-	.progress0 LDZ
90
-	( increment note counter )
91
-	DUP INC #1f AND .progress0 STZ
92
-    ( play note )
93
-    GET-NOTE
94
-	.Audio0/pitch DEO
95
-BRK
96
-
97 86
 @on-audio1 ( -> )
98 87
     ( load next note )
99 88
 	.progress1 LDZ
... ...
@@ -2612,19 +2612,16 @@ audio_handler(void *ctx, Uint8 *out_stream, int len) {
2612 2612
         Uint8 *addr = &u->dev[device];
2613 2613
         if (channel[n].duration <= 0 && PEEK2(addr)) {
2614 2614
 			uxn_eval(u, PEEK2(addr));
2615
-            // printf("EVAL: %x\n", device);
2616
-            // printf("ADDR: %x\n", PEEK2(addr));
2617
-            // printf("----\n");
2618 2615
         }
2619 2616
         channel[n].duration -= SOUND_TIMER;
2620 2617
 
2621 2618
         int x = 0;
2622 2619
         if (channel[n].xfade) {
2623
-            float delta = 1.0f / (XFADE_SAMPLES);
2624
-            while (x < XFADE_SAMPLES * 2 && x < len / 2) {
2620
+            float delta = 1.0f / (XFADE_SAMPLES * 2);
2621
+            while (x < XFADE_SAMPLES * 2) {
2625 2622
                 float alpha = x * delta;
2626 2623
                 float beta = 1.0f - alpha;
2627
-                Sint16 next_a = next_a = next_sample(&channel[n].next_sample);
2624
+                Sint16 next_a = next_sample(&channel[n].next_sample);
2628 2625
                 Sint16 next_b = 0;
2629 2626
                 if (channel[n].sample.data != 0) {
2630 2627
                     next_b = next_sample(&channel[n].sample);
... ...
@@ -2637,7 +2634,6 @@ audio_handler(void *ctx, Uint8 *out_stream, int len) {
2637 2634
             channel[n].xfade = false;
2638 2635
         }
2639 2636
         Sample *sample = &channel[n].sample;
2640
-        int direction = 1;
2641 2637
         while (x < len / 2) {
2642 2638
             if (sample->data == 0) {
2643 2639
                 break;