#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,
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));
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;
+};
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
};
case '[':
mode = MODE_HEADING;
break;
- case '\n'
+ case '\n':
break;
default:
fseek(fp, -1, SEEK_CUR);
} else {
curr_heading = HEADING_NOTE;
if (curr_note) {
- process_note(curr_note, USTinfo);
+ process_note(settings, curr_note);
};
};
break;
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];
} 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")) {
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);
#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 */
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);
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;