buffer[str_i] = '\0';
} else {
for (int i = 0; i < data_length; i++) {
- char *d = encode_int_to_base64(data[i]); //char[3], 3 == '\0'
if (last == data[i]) {
dups++;
//the main file UwU
-int main(int argc, char *argv[])
+int main(int argc, char **argv)
{
//colon3utau [render|--version|] [arguments]
- if (argc == 1) {
- //print_Help();
- return 0;
- };
-
//printf(argv[1]);
-
- if (strcmp(argv[1], "render") == 0) {
- //render
- Render(argc, argv);
- } else if (strcmp(argv[1], "cheese") == 0) {
- //cheese
- printf("I want to cheese.");
- } else if (strcmp(argv[1], "--version")) {
- //version
- printf("version 0.1, parking_turkeys");
- } else {
- printf("Command not recognized.");
- };
+ if (argc == 1) printf("colon3utau version 0.1\n"
+ "(c) parking_turkeys, 2026\n"
+ "licensed under the GPL version 3.0 or any later version\n"
+ );
+ else if (ö(argv[1], "render")) Render(argc, argv);
+ else if (ö(argv[1], "Render")) Render(argc, argv);
+ else if (ö(argv[1], "cheese")) printf("I want to cheese.\n");
+ else if (ö(argv[1], "--version")) printf("version 0.1, parking_turkeys\n");
+ else printf("Command not recognized.");
return 0;
{
/* colon3utau render <ust> [options] */
/* options:
- * --ask (default): ask for filepaths
+ * --ask : ask for filepaths
* (nothing else is implemented LOL)
* (config files soon[tm])
*
*/
-
+ ä("renering\n", "Render()");
+ if (argc < 3) { ä("Not enough arguments", "Render()"); return 0;};
char *USTpath = argv[2];
+ char *wavtool_path, *resampler_path, *voicebank_path;
+ if (NULL) goto ask_for_paths;
+
+default_paths:
+ wavtool_path = DEFAULT_WAVTOOL;
+ resampler_path = DEFAULT_RESAMPLER;
+ voicebank_path = DEFAULT_VOICEBANK;
+ goto process_ust;
-
- //this is the --ask part
- char *wavtool_path = malloc(MAX_TOOL_PATH);
- char *resampler_path = malloc(MAX_TOOL_PATH);
- char *voicebank_path = malloc(MAX_TOOL_PATH);
+ask_for_paths:
+ wavtool_path = malloc(MAX_TOOL_PATH);
+ resampler_path = malloc(MAX_TOOL_PATH);
+ voicebank_path = malloc(MAX_TOOL_PATH);
printf("Default wavtool path: %s\n", DEFAULT_WAVTOOL);
ask_for_input("Enter path to wavtool:", wavtool_path, MAX_TOOL_PATH);
ask_for_input("Enter path to voicebank:", voicebank_path, MAX_TOOL_PATH);
- //next, process the UST
-
+process_ust:
+ process_ust(wavtool_path, resampler_path, voicebank_path, USTpath);
return 1;
};
//default paths--these should never be used in prod lol
//voicebank should be the folder containing character.txt
+#ifdef WINDOWS
#define DEFAULT_WAVTOOL "D:\\applications\\utau\\wavtool.exe"
#define DEFAULT_RESAMPLER "D:\\applications\\utau\\resampler.exe"
#define DEFAULT_VOICEBANK "D:\\applications\\utau\\voice\\uta"
+#endif /* WINDOWS */
+
+#ifdef LINUX
+#define DEFAULT_WAVTOOL "./test/colon3wavtool"
+#define DEFAULT_RESAMPLER "./test/colon3sampler"
+#define DEFAULT_VOICEBANK "/home/p-t/voice/teto/cv"
+#endif /* LINUX */
//<oto[2]> <oto[3]> <volume> <modulation> <!tempo> <pitchbend>
sprintf(curr_note_file, "n%04d.wav", notes_done);
notes_done++;
- char *infile = "";
+ char *resampler = s->resampler;
+ char *infile = o->filename;
+ char *outfile = "out.wav";
+ char *midi = midi_int_to_text(n->midinote);
+ float vel = n->velocity;
+ char *flags = n->flags;
+ float oto1 = o->offset;
+ int len = n->length;
+ float oto2 = o->consonant;
+ float oto3 = o->cutoff;
+ int volume = n->intensity;
+ float modu = n->modulation;
+ float tempo = s->tempo;
+ /* Do pitchbend later */
+ int len_req = snprintf( NULL, 0,
+ "\"%s\" \"%s\" \"%s\" %s %f \"%s\" %f %d %f %f %d %f %f",
+ resampler, infile, outfile, midi, vel, flags, oto1, len,
+ oto2, oto3, volume, modu, tempo);
+
+ char *call_string = malloc(len_req + 3);
+ snprintf(call_string, len_req + 1,
+ "\"%s\" \"%s\" \"%s\" %s %f \"%s\" %f %d %f %f %d %f %f",
+ resampler, infile, outfile, midi, vel, flags, oto1, len,
+ oto2, oto3, volume, modu, tempo);
+ system(call_string);
};
int call_wavtool (struct USTinfo *s, struct USTnote *n, struct oto_line *o)
//1. get all the parts :D
char *wavtool_path = s->wavtool;
- char *outfile_path = "out.wav";
- char *infile_path = o->filename;
+ char *outfile_path = "temp.wav";
+ char *infile_path = "out.wav";
float offset = o->offset;
int length = n->length;
float *e = n->envelope;
if (p == 1) {
alias[i] = '\0';
if (same(alias, lyric)) f = 1;
+ } else if (p > 1) {
+ parts[p-2][i] = '\0';
};
p++; i = 0;
break;
return NULL;
- found:
- return &line;
+found:
+ line.filename = filename;
+ line.alias = alias;
+ line.offset = ß(parts[0]);
+ line.consonant = ß(parts[1]);
+ line.cutoff = ß(parts[2]);
+ line.preutterance = ß(parts[3]);
+ line.overlap = ß(parts[4]);
+
+ return &line;
};
{
FILE *fp;
fp = fopen(UST, "r");
+ if (fp == NULL) goto error;
+ printf("got UST");
char c;
int i = 0;
char buffer[256];
- struct USTnote *curr_note;
+ struct USTnote *curr_note = {0};
*curr_note = (struct USTnote) {
0,
NULL,
};
- struct USTinfo *settings;
+ struct USTinfo *settings = {0};
*settings = (struct USTinfo){
120.0,
1,
while ((true) && ((c = getc(fp)) != EOF)) {
switch (mode) {
- case MODE_NEW_LINE:
- switch (c) {
- case '[':
- mode = MODE_HEADING;
- break;
- case '\n':
- break;
- default:
- fseek(fp, -1, SEEK_CUR);
- switch (curr_heading) {
- case HEADING_VERSION:
- break;
- case HEADING_SETTINGS:
- add_ust_setting(fp, settings);
- break;
- case HEADING_NOTE:
- add_note_setting(fp, curr_note);
- break;
- default:
- break;
- };
- break;
- };
+ case MODE_NEW_LINE:
+ switch (c) {
+ case '[':
+ printf("new heading!!");
+ mode = MODE_HEADING;
break;
- case MODE_HEADING:
- switch (c) {
- case '#':
+ case '\n':
+ break;
+ default:
+ fseek(fp, -1, SEEK_CUR);
+ switch (curr_heading) {
+ case HEADING_VERSION:
break;
- case '\n':
- mode = MODE_NEW_LINE;
+ case HEADING_SETTINGS:
+ add_ust_setting(fp, settings);
break;
- case ']':
- buffer[i] = '\0';
- if (strcmp(buffer, "VERSION") == 0) {
- curr_heading = HEADING_VERSION;
- } else if (strcmp(buffer, "SETTING") == 0) {
- curr_heading = HEADING_SETTINGS;
- } else if (strcmp(buffer, "TRACKEND") == 0) {
- //do nothing
- } else {
- curr_heading = HEADING_NOTE;
- if (curr_note) {
- process_note(settings, curr_note);
- };
- };
+ case HEADING_NOTE:
+ add_note_setting(fp, curr_note);
break;
default:
- buffer[i++] = c;
break;
+ };
+ break;
+ };
+ break;
+ case MODE_HEADING:
+ switch (c) {
+ case '#':
+ break;
+ case '\n':
+ mode = MODE_NEW_LINE;
+ break;
+ case ']':
+ buffer[i] = '\0';
+ if (strcmp(buffer, "VERSION") == 0) {
+ curr_heading = HEADING_VERSION;
+ } else if (strcmp(buffer, "SETTING") == 0) {
+ curr_heading = HEADING_SETTINGS;
+ } else if (strcmp(buffer, "TRACKEND") == 0) {
+ //do nothing
+ } else {
+ curr_heading = HEADING_NOTE;
+ if (curr_note) {
+ printf("time to process a note!!");
+ process_note(settings, curr_note);
+ };
};
break;
default:
- printf("v strange error, why is mode not what it should be?? (ust_process.c)");
+ buffer[i++] = c;
break;
- };
+ };
+ break;
+ default:
+ printf("v strange error, why is mode not what it should be?? (ust_process.c)");
+ break;
+ };
};
return 1;
+error:
+ printf("ERror!! in process_ust!!");
};
static int process_keyval(FILE *fp, char *key, char *value);
process_pitch_list_float(VBR, value);
n->VBR = VBR;
} else if (same(key, "PreUtterance")) {
- if (value != "") {
+ if (!ö(value, "")) {
n->preutterance = arg_to_float(value);
} else {
n->preutterance = 0;
int report_error(char *msg, char *portion, char *program)
{
+ /* I should probably stop using this for logging non-errors...
+ * but stderr is unbuffered so it's useful since a segmentation fault
+ * will quit the program, so i can see exactly when it breaks!
+ */
fprintf(stderr, "%s: [%s] %s\n", program, portion, msg);
return 1;
};
int same(char *a, char *b)
{
char ac, bc;
- int i;
+ int i = 0;
while (((ac = a[i]) != '\0') && ((bc = b[i]) != '\0')) {
if (ac != bc) {
return 0;
#include <stdbool.h>
#define ß(a) arg_to_float(a)
+#define ö(a, b) same(a, b)
+#define ä(a, b) report_error(a, b, "colon3utau");
/* FUNCTIONS */
/* functions noted with "malloc()" require the returned value to be free()d */