]> _ Git - colon3sampler.git/commitdiff
i think it works? but there's a bug i think ill change the writewave stuff...
authorparking_turkeys <roya1060wien@gmail.com>
Mon, 19 Oct 2026 17:17:31 +0000 (13:17 -0400)
committerparking_turkeys <roya1060wien@gmail.com>
Mon, 19 Oct 2026 17:17:31 +0000 (13:17 -0400)
change_length.c [new file with mode: 0644]
colon3sampler.h
main.c

diff --git a/change_length.c b/change_length.c
new file mode 100644 (file)
index 0000000..218c319
--- /dev/null
@@ -0,0 +1,30 @@
+#include "colon3sampler.h"
+
+int change_wave_len(int16_t w[], int w_B, int16_t ow[], int co, int ow_B)
+{
+       int end_samples = (w_B/2) - co;
+       int i = 0;
+       if (w_B < ow_B) goto loop_co;
+       if (w_B > ow_B) goto cut_wave;
+       return 0;
+loop_co:
+       int co_i = 0;
+       for (i = 0; i < (ow_B/2-end_samples); i++) {
+               ow[i] = w[co_i++];
+               if (co_i == co) co_i = 0;
+       };
+       goto append_end;
+cut_wave:
+       if (end_samples >= (ow_B/2)) goto append_end;
+       for (i = 0; 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++) {
+               ow[i] = w[co++];
+       };
+       return 1;
+};
+
index b5f6dbc..29275a4 100644 (file)
@@ -17,6 +17,8 @@ float midi_to_hz(char *note);
 int change_pitch(int16_t wave[], int w_B, float pitch_multiplier,
                int16_t out_wave[]); /* Give NULL for length */
 int write_wave(char *out_filename, int16_t wave[], int w_B);
+int change_wave_len(int16_t wave[], int w_B, int16_t out_wave[], int consonant,
+               int out_len_B); /* out length in bytes*/
 
 
 /* From other things */
diff --git a/main.c b/main.c
index bf92c28..4e1ef7e 100644 (file)
--- a/main.c
+++ b/main.c
@@ -149,15 +149,25 @@ int main(int argc, char *argv[])
                printf("The pitch is %f Hz.\n", pitch_Hz);
        change_pitch:
                float pitch_mult = pitch_Hz/midi_to_hz(argv[3]);
+               pitch_mult = 2.0; /* testing */
                printf("%f", pitch_mult);
                int resampled_len = change_pitch(phoneme, ph_B, pitch_mult, NULL);
                int16_t *resampled = malloc(resampled_len);
                change_pitch(phoneme, ph_B, pitch_mult, resampled);
        change_length:
                /* tba */
+               int final_B = (int)ceil(ß(argv[7]) * 88.200); /* have to set
+                                                                calculate
+                                                                length on UI
+                                                                frontend for
+                                                                this to work
+                                                                */
+               int16_t *final = malloc(final_B);
+               change_wave_len(resampled, resampled_len, final,
+                               (int) ceil(cons_i/pitch_mult), final_B);
        write_wave:
                /* change what u write later */
-               write_wave(argv[2], resampled, resampled_len);
+               write_wave(argv[2], final, final_B);
        cleanup:
                free(wave);
                free(phoneme);