]> _ Git - colon3sampler.git/commitdiff
fix some bugs
authorparking_turkeys <roya1060wien@gmail.com>
Mon, 19 Oct 2026 21:43:07 +0000 (17:43 -0400)
committerparking_turkeys <roya1060wien@gmail.com>
Mon, 19 Oct 2026 21:43:07 +0000 (17:43 -0400)
Makefile
change_length.c
get_phoneme.c
main.c

index abac15b..f1b17c6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,8 @@
+win:
+       $(CC) *.h *.c -Werror -Wall -Wno-unused-label -lm -o colon3sampler.exe -std=c99
+win-test: win
+       @echo "testing the thing with an UTAU + oto stuff"
+       ./colon3sampler.exe test/a.wav test/a_out.wav F4 100 / 24.0 21000 56 73 100 0 !120
 linux:
        $(CC) *.h *.c -Werror -Wall -Wno-unused-label -lm -o colon3sampler -std=c99
 linux-test: linux
index 2e19107..984fae5 100644 (file)
@@ -1,13 +1,57 @@
 #include "colon3sampler.h"
 
+#define END 2900
+#define LOOPBEFORE 1
+
+static int loop_after_co(int16_t w[], int w_B, int16_t ow[], int co, int ow_B);
+static int loop_b4_co(int16_t w[], int w_B, int16_t ow[], int co, int ow_B);
+
 int change_wave_len(int16_t w[], int w_B, int16_t ow[], int co, int ow_B)
 {
+       if (LOOPBEFORE) {
+               loop_b4_co(w, w_B, ow, co, ow_B);
+       } else {
+               loop_after_co(w, w_B, ow, co, ow_B);
+       };
+       return 1;
+
+};
+
+static int loop_after_co(int16_t w[], int w_B, int16_t ow[], int co, int ow_B)
+{
+
+       if (w_B == ow_B) return 0;
+       int w_i = 0;
+       for (int i = 0; i < ow_B/2; i++) {
+               ow[i] = 0;
+       };
+       int i = 0;
+       for (i = 0; (i < (ow_B/2 - END)); i++) {
+               if (ow[i] == 0) {
+                       ow[i] = w[w_i++];
+               } else {
+                       ow[i] = ow[i]/2;
+                       ow[i] += w[w_i++]/2;
+               };
+               if (w_i == w_B/2-END) {
+                       w_i = co;
+               };
+       };
+       for (i = i; i < ow_B/2; i++) {
+               ow[i] = w[w_i++];
+       };
+
+       return 1;
+};
+
+static int loop_b4_co(int16_t w[], int w_B, int16_t ow[], int co, int ow_B)
+{      
        if (w_B == ow_B) return 0;
        int end_samples = (w_B/2) - co;
        int half_samples = co/2;
        int i = 0;
 anfang:
-       for (i = 0; (i < half_samples) && (i < ow_B/2-end_samples); i++) {
+       for (i = 0; (i < half_samples) && (i < ow_B/2); i++) {
                ow[i] = w[i];
        };
        if (w_B < ow_B) goto loop_co;
@@ -21,15 +65,15 @@ loop_co:
        goto append_end;
 cut_wave:
        if (end_samples >= (ow_B/2)) goto append_end;
-       for (i = i; i < (ow_B/2-end_samples); i++) {
+       for (i = i; i < ((ow_B/2)-end_samples); i++) {
                ow[i] = w[i];
        };
        goto append_end;
 append_end:
        
-       for (i = i; (i < end_samples) && (i < (ow_B/2)); i++) {
+       for (i = i; (co < w_B/2) && (i < (ow_B/2)); i++) {
                ow[i] = w[co++];
        };
+       if (i < ow_B/2) printf("Ugh, didn't wave long enough\n");
        return 1;
 };
-
index 291218c..fa941a9 100644 (file)
@@ -5,13 +5,12 @@ int get_important_wave(int16_t ow[], int w_B, int16_t b[],
        /* idk */
 get_length:
        int end_length_B = 0;
-       end_length_B = ((cut-off)*44.100) * 2;
+       end_length_B = w_B - (((cut-off)*44.100) * 2);
        if (end_length_B < 1) goto error;
        if (b == NULL) goto tell_length;
-       if ((cut * 88.200) > w_B) goto error;
 write_wave:
        int b_i = 0;
-       for (int i = (off*44.100); i < (cut*44.100); i++) {
+       for (int i = (off*44.100); i < ((w_B/2) - (cut*44.100)); i++) {
                b[b_i++] = ow[i];
        };
        goto tell_cons;
diff --git a/main.c b/main.c
index bf05a03..e17ac2f 100644 (file)
--- a/main.c
+++ b/main.c
@@ -49,8 +49,8 @@
  * 5: Flags (nothing)
  * 6: 17.0 (oto[1]) (offset)
  * 7: 550 (desired output length ig??)
- * 8: 238 (oto[2]) (Part to loop)
- * 9: 46 (oto[3]) (End)
+ * 8: 238 (oto[2]) (Part to loop) 
+ * 9: 46 (oto[3]) (End) (FROM RIGHT ????)
  * 10: 100 (volume ?)
  * 11: 0 (modulation ?)
  * 12: !120 (the tempo)