]> _ Git - colon3utau.git/commitdiff
basic setup + base64 stuff from openutau lmao
authorparking_turkeys <roya1060wien@gmail.com>
Wed, 19 Aug 2026 17:59:44 +0000 (13:59 -0400)
committerparking_turkeys <roya1060wien@gmail.com>
Wed, 19 Aug 2026 17:59:44 +0000 (13:59 -0400)
base64.c [new file with mode: 0644]
main.c [new file with mode: 0644]
useful.c [new file with mode: 0644]
utau.h [new file with mode: 0644]

diff --git a/base64.c b/base64.c
new file mode 100644 (file)
index 0000000..489ad69
--- /dev/null
+++ b/base64.c
@@ -0,0 +1,53 @@
+#include "utau.h"
+
+//mainly based off of openUtau lol
+
+
+const base_64_key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+char *encode_pitch_array_base_64(int data[], int data_length) //from openUtau, rewritten;
+{
+       char *result = malloc(data_length * sizeof(char) * 2);
+       int last = NULL;
+       int dups = 0;
+       int str_i = 0; //string index
+
+       for (i = 0; i < data_length; i++) {
+               char d = encode_int_to_base64(data[i]); //char[3], 3 == '\0'
+               
+               if (last == data[i]) {
+                       dups++;
+               } else if (dups == 0) {
+
+                       //result[str_i] = d;
+                       result[str_i] = d[0];
+                       str_i++;
+                       result[str_i] = d[1];
+                       str_i++;
+
+               } else {
+
+                       result[str_i] = '#';
+                       str_i++;
+                       result[str_i] = 
+
+
+       };
+
+       return result;
+};
+
+char *encode_int_to_base64(int i) //basically entirely from open utau ww
+{
+       if (i < 0) {
+               data += 4096;
+       }; //no idea why buy openutau does that haha
+
+       char *base_64 = "AA";
+
+       base_64[0] = base64_key[(data >> 6) & 0x003F];
+       base_64[1] = base64_key[data & 0x003F];
+
+       return base_64;
+};
+
diff --git a/main.c b/main.c
new file mode 100644 (file)
index 0000000..aac4212
--- /dev/null
+++ b/main.c
@@ -0,0 +1,9 @@
+#include "utau.h"
+
+//the main file UwU
+
+void main(int argc, char *argv[])
+{
+       //colon3utau [render] [arguments]
+       
+
diff --git a/useful.c b/useful.c
new file mode 100644 (file)
index 0000000..8807c03
--- /dev/null
+++ b/useful.c
@@ -0,0 +1,127 @@
+#include "utau.h"
+
+//from colon3wavtool
+
+float length_arg_to_float(char *arg)
+{
+       //formatted in a weird af way
+       //from looking at other ppls code (gh/m13253/wavtool-yawu) + what i can tell:
+       //it is
+       //x@y[+-]z
+       //x == "ticks" (in yawu code) (idk what this means tbh) [INT] [POSSIBLY FLOAT?]
+       //y == tempo [INT] [UNLESS TEMPO IS FLOAT]
+       //z == divided by 1000 and then added to note_length in yawu.. (yes im just basing it off of there i cant figure ts out :((()
+       //so yawu finds note_length by ticks/tempo/8, and note_length seems to be in ... idk tbh LMAO
+       //uhh idk what a tick is tbh but for my (1/4) rest note ticks = 480 and tempo = 120 (z = 19.0)
+       //480/120/8 = 4/8 = 1/2
+       //ok for a full rest (4/4) it's 1920@120-71.0
+       //that's 1920/120/8 = 16/8 = 2
+       // so a 1/4 note is 1/2, a 4/4 note is 2, a 1/2 note is presumably 1
+       //in 120 tempo
+       //when in 120 tempo thats uhh 2 1/4 a second  i think
+       //so that answer is in SECONDS. yay.
+       //and just adding the second part in i guess... shouldnt it be minused??
+       //actually no idea why the second part exists so im skipping it for now lmao
+       //tyty yawu code author. otherwise i would be COOKED
+
+       //OK NEW THING FIGURED OUT
+       //IF "calculate legnth on ui" is checked then uh
+       // the length thing is in MILLISECONDS. Yeah
+       int i = 0;
+       char c = 'x';
+       char buffer[50] = {'\0'}; //who is making smth with a longer number tbh
+       int b_i = 0;
+
+       float x = 0;
+       float y = 0;
+       float z = 0;
+
+       float sign = 1.0; //-1.0 for negative uwu
+
+       while ((c = arg[i++]) != '\0') {
+               switch (c) {
+                       case '@':
+                               //first break
+                               x = arg_to_float(buffer);
+                               b_i = 0;
+                               break;
+                       case '+':
+                               //second break :p
+                               y = arg_to_float(buffer);
+                               b_i = 0;
+                               break;
+                       case '-':
+                               //second break but NEGATIVE
+                               y = arg_to_float(buffer);
+                               b_i = 0;
+                               sign = -1.0;
+                               break;
+                       case '\0':
+                               //end
+                               z = sign * arg_to_float(buffer);
+                               b_i = 0;
+                               break;
+                       default:
+                               buffer[b_i] = c;
+                               b_i ++;
+                               buffer[b_i] = '\0';
+                               break;
+               };
+                                               
+       };
+       z = sign * arg_to_float(buffer);
+       float result = x/y/8 + z/1000;
+       if (x == 0 || y == 0) {
+               //length calculated on UI
+               result = z/1000;
+       };
+       return result;
+};
+
+float arg_to_float(char *arg)
+{
+       //get digit from ascii by subtracting 48
+       char c;
+       float r = 0.0; //result
+       int d = 0; //i of decimal point if after decimal point
+       int i = 0;
+       while ((c = arg[i++]) != '\0') {
+               switch (c) {
+               case '.':
+                       //decimal point
+                       d = i;
+                       break;
+               default:
+                       //must be a digit
+                       if (!d) {
+                               r = r * 10.0;
+                               r += (float)c - 48.0;
+                       } else {
+                               float t = (float)c - 48.0;
+                               for (int n = 0; n <= (i - d); n++) {
+                                       t = t/10;
+                               };
+                               r += t;
+                       };
+                       break;
+               };
+       };
+       return r;
+};
+
+int report_error(char *msg, char *portion, char *program)
+{
+       fprintf(stderr, "%s: [%s] %s\n", program, portion, msg);
+       return 1;       
+};
+
+//from here [colon3utau]
+
+void add_str_onto_str(char *input, char *output)
+{
+       char c = ' ';
+       for (int i = 0; ((c = input[i]) != '\0') && (output[i] != '\0'); i++) {
+               output[i] = c;
+       };
+       return;
+};
diff --git a/utau.h b/utau.h
new file mode 100644 (file)
index 0000000..ccd5b07
--- /dev/null
+++ b/utau.h
@@ -0,0 +1,25 @@
+/* GNU GPLv3.0+, (c) 2026 parking_turkeys
+ *
+ * a program to render, edit, and create USTs
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+/* FUNCTIONS */
+
+//useful.c
+float length_arg_to_float(char *arg);
+float arg_to_float(char *arg);
+int report_error(char *msg, char *portion, char *program);
+
+void add_str_onto_str(char *input, char *output);
+
+//base64.c
+char *encode_pitch_array_base_64(int data[], int data_length);
+char *encode_int_to_base64(int i);
+
+
+//render
+int Render(int argc, char *argv[]);