]> _ Git - colon3utau.git/commitdiff
Work on fixing bugs; start on calling programs; etc idk
authorparking_turkeys <roya1060wien@gmail.com>
Tue, 27 Oct 2026 16:16:36 +0000 (12:16 -0400)
committerparking_turkeys <roya1060wien@gmail.com>
Tue, 27 Oct 2026 16:16:36 +0000 (12:16 -0400)
render/render.h
render/tools.c
render/ust_process.c
useful.c
utau.h

index fbb5926..47ffcf6 100644 (file)
@@ -19,7 +19,7 @@ int process_ust(char *wavtool_path, char *resampler_path, char *voicebank_path,
                char *UST_path);
 
 //tools.c
-int process_note(struct USTinfo *settings, struct USTnote *note);
+int process_note(USTinfo *settings, USTnote *note);
 //int call_wavtool(char *wavtool_path, struct USTinfo *ust_settings, struct 
                //USTnote *note, char *oto_path);
 //int call_resampler(char *resampler_path, struct USTinfo *ust_settings, struct
index f9a0c01..37912ce 100644 (file)
@@ -1,45 +1,61 @@
 #include "render.h"
 
-static int call_wavtool  (struct USTinfo *ust_settings, struct USTnote *note, char *oto);
-static int call_resampler(struct USTinfo *ust_settings, struct USTnote *note, char *oto);
+static int call_wavtool  (struct USTinfo *ust_settings, struct USTnote *note, struct oto_line *oto);
+static int call_resampler(struct USTinfo *ust_settings, struct USTnote *note, struct oto_line *oto);
 
-struct oto_line find_oto_line(char *oto_dir, char *lyric);
+struct oto_line *find_oto_line(char *oto_dir, char *lyric);
 
 static char curr_note_file[10]; // n0000.wav\0
 static int notes_done = 0;
 
 int process_note  (struct USTinfo *settings, struct USTnote *note)
 {
-       char *oto = find_oto_line(settings->voicedir, note->lyric);
+       struct oto_line *oto = find_oto_line(settings->voicedir, note->lyric);
        call_resampler(settings, note, oto);
        call_wavtool  (settings, note, oto);
 
        return 1;
 };
 
-int call_resampler(struct USTinfo *s, struct USTnote *n)
+int call_resampler(USTinfo *s, USTnote *n, struct oto_line *o)
 {
        //resampler <in> <out> <midi> <velocity> <flags> <oto[1]> <length>
        //<oto[2]> <oto[3]> <volume> <modulation> <!tempo> <pitchbend>
        sprintf(curr_note_file, "n%04d.wav", notes_done);
        notes_done++;
-       char *infile = 
+       char *infile = "";
+};
 
-int call_wavtool  (struct USTinfo *s, struct USTnote *n)
+int call_wavtool  (struct USTinfo *s, struct USTnote *n, struct oto_line *o)
 {
        //wavtool <outfile> <infile> <offset> <length> p1 p2 p3 v1 v2 v3 v4 ovr p4 p5 v5
        
        //1. get all the parts :D
        char *wavtool_path = s->wavtool;
        char *outfile_path = "out.wav";
-       char *infile_path = 
+       char *infile_path = o->filename;
+       float offset = o->offset;
+       int length = n->length;
+       float *e = n->envelope; 
+       //2. make string
+       int len_req = snprintf( NULL, 0, 
+                       "\"%s\" \"%s\" \"%s\" %f %d %f %f %f %f %f %f %f %f %f %f",
+                       wavtool_path, outfile_path, infile_path, offset, length,
+                       e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], e[8], e[9]);
+       char *call_string  = malloc(len_req + 3);
+       snprintf(call_string, len_req + 1,
+               "\"%s\" \"%s\" \"%s\" %f %d %f %f %f %f %f %f %f %f %f %f",
+               wavtool_path, outfile_path, infile_path, offset, length,
+               e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], e[8], e[9]);
+       system(call_string);
+       
 };
 
-char *find_oto_line(char *oto_dir, char *lyric)
+struct oto_line *find_oto_line(char *oto_dir, char *lyric)
 {
-       char filename[256]; //reasonable length (in same folder usually)
-       char alias[256]; //bit much but who knows lol 
-       struct oto_line line = {
+       static char filename[256]; //reasonable length (in same folder usually)
+       static char alias[256]; //bit much but who knows lol 
+       static struct oto_line line = {
                filename,
                alias,
                0,
@@ -48,7 +64,7 @@ char *find_oto_line(char *oto_dir, char *lyric)
                0,
                0
        };
-       char part[64]; //wtf are you doing with a longer number tbh
+       char parts[5][64]; //wtf are you doing with a longer number tbh
        FILE *fp;
 
        char *oto_path = malloc(snprintf(NULL, 0, "%s/oto.ini", oto_dir));
@@ -56,15 +72,50 @@ char *find_oto_line(char *oto_dir, char *lyric)
 
        fp = fopen(oto_path, "r");
 
-       char c; int i = 0;
+       char c; int f = 0; int i = 0; int p = 0; /* p is the part */
        while ((c = getc(fp)) != EOF) {
-               
+               /* read in each line until it's wrong */
+               /* fn=alias,offset,consonant,cutoff,pre,ove */
+               switch (c) {
+                       case '\n':
+                               i = 0; p = 0;
+                               if (f==1) goto found;
+                               break;
+                       case '=':
+                               filename[i] = '\0';
+                               p++; i =0;
+                               break;
+                       case ',':
+                               if (p == 1) {
+                                       alias[i] = '\0';
+                                       if (same(alias, lyric)) f = 1;
+                               };
+                               p++; i = 0;
+                               break;
+                       default:
+                               switch (p) {
+                                       case 0:
+                                               filename[i] = c;
+                                               break;
+                                       case 1:
+                                               alias[i] = c;
+                                               break;
+                                       default:
+                                               parts[p-2][i] = c;
+                                               break;
+                               };
+               };
+                               
+
+               i++;
+
        };
 
        return NULL;
 
        found:
-               return line;
+               return &line;
+};
 
 
 
index 0f2482c..8f84b4e 100644 (file)
@@ -35,20 +35,20 @@ int process_ust(char *wavtool, char *resampler, char *voice, char *UST)
                NULL,
                0,
                0,
+               0,
                NULL,
+               0,
                NULL,
                NULL,
+               0,
                NULL,
+               0,
                NULL,
+               0,
                NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               NULL
+               0,
+               0,
+               0
 
        };
 
@@ -72,7 +72,7 @@ int process_ust(char *wavtool, char *resampler, char *voice, char *UST)
                                        case '[':
                                                mode = MODE_HEADING;
                                                break;
-                                       case '\n'
+                                       case '\n':
                                                break;
                                        default:
                                                fseek(fp, -1, SEEK_CUR);
@@ -109,7 +109,7 @@ int process_ust(char *wavtool, char *resampler, char *voice, char *UST)
                                                } else {
                                                        curr_heading = HEADING_NOTE;
                                                        if (curr_note) {
-                                                               process_note(curr_note, USTinfo);
+                                                               process_note(settings, curr_note);
                                                        };
                                                };
                                                break;
@@ -154,6 +154,45 @@ int process_pitch_list_float(float stuff[], char *list);
 int process_pitch_list_char (char  stuff[], char *list);
 float *process_envelope_list(char *list);
 
+int process_pitch_list_char(char stuff[], char *list)
+{
+       stuff[0] = 0;
+       return 1;
+};
+
+int process_pitch_list_float(float stuff[], char *list)
+{
+       stuff[0] = 0;
+       return 1;
+};
+
+float *process_envelope_list(char *l)
+{
+       static float ol[10] = {0};
+       char parts[10][64]; int p_i = 0;
+       int p = 0; char c = ' '; 
+       for (int i = 0;(c = l[i]) != '\0'; i++) {
+               switch (c) {
+                       case ',':
+                               parts[p][p_i] = '\0';
+                               p++; p_i = 0;
+                               break;
+                       default:
+                               parts[p][p_i] = c;
+                               break;
+               };
+               p_i++;
+       };
+       parts[p][++p_i] = '\0';
+       for (int i = 0; i < 10; i++) {
+               ol[i] = ß(parts[i]);
+       };
+       return ol;
+};
+
+
+               
+
 int add_note_setting(FILE *fp, USTnote *n)
 {
        char key[128];
@@ -178,7 +217,7 @@ int add_note_setting(FILE *fp, USTnote *n)
        } else if (same(key, "NoteNum")) {
                n->midinote = (int)arg_to_float(value);
        } else if (same(key, "Envelope")) {
-               n->midinote = process_envelope_list(value);
+               n->envelope = process_envelope_list(value);
        } else if (same(key, "PBS")) {
                n->PBSlength = process_pitch_list_float(PBS, value);
        } else if (same(key, "PBW")) {
@@ -196,7 +235,7 @@ int add_note_setting(FILE *fp, USTnote *n)
                if (value != "") {
                        n->preutterance = arg_to_float(value);
                } else {
-                       n->preutterance = NULL;
+                       n->preutterance = 0;
                };
        } else if (same(key, "Intensity")) {
                n->intensity = (int)arg_to_float(value);
index 6327ae0..3578a06 100644 (file)
--- a/useful.c
+++ b/useful.c
@@ -166,7 +166,7 @@ const char *midi_key[128] = {
        "C9", "C#9", "D9", "D#9", "E9", "F9", "F#9", "G9"
 };
 
-int midi_int_to_text(int *midi) {
+char *midi_int_to_text(int midi) {
        return midi_key[midi];
 };
        
diff --git a/utau.h b/utau.h
index 0eff124..867390e 100644 (file)
--- a/utau.h
+++ b/utau.h
@@ -9,7 +9,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <stdbool.h>
 
+#define ß(a) arg_to_float(a)
 
 /* FUNCTIONS */
 /* functions noted with "malloc()" require the returned value to be free()d */
@@ -20,10 +22,10 @@ float arg_to_float(char *arg);
 int report_error(char *msg, char *portion, char *program);
 
 int add_str_onto_str(char *input, char *output);
-char *ask_for_input(char *prompt); //DO NOT FREE RETURNED MEMORY, USE IMMEDIATELY
+int ask_for_input(char *prompt, char *buffer, int MAX_INPUT);
 int same(char *a, char *b);
 int   midi_text_to_int(char *midi);
-char *midi_int_to_text(int  *midi);
+char *midi_int_to_text(int   midi);
 
 //base64.c
 int encode_pitch_array_base_64(char buffer[],int data[], int data_length);
@@ -47,29 +49,30 @@ struct USTinfo {
        char *resampler; //path
        int mode2; //true|false
 };
-
+typedef struct USTinfo USTinfo;
 struct USTnote {
        int length;
        char *lyric;
        int midinote;
-       float envelope[10]; (excluding %)
+       float *envelope; //10 long, (excluding %)
        float overlap;
        float velocity;
        float preutterance; //ALWAYS THERE even if blank
        char *flags;
        float STP;
-       float VBR[8];
-       float PBS[];
+       float *VBR; //8 long
+       float *PBS;
        int PBSlength;
-       float PBW[];
+       float *PBW;
        int PBWlength;
-       float PBY[];
+       float *PBY;
        int PBYlength;
-       char PBM[];
+       char *PBM;
        int PBMlength;
        int intensity;
        float modulation;
 };
+typedef struct USTnote USTnote;
 
 struct oto_line {
        char *filename;