*/
#include "wavtool.h"
+#include <math.h>
#define LOGFILE L"C:\\projects\\colon3wavtool\\log.txt"
if (input_wave_length > 0) {
input_wave = GlobalAlloc(0, input_wave_length);
} else {
+ /* expected for rests
error_msg = "input wave error || input wave length is 0";
goto error;
+ */
+ //MessageBox(NULL, argv[4], "rest length", MB_OK);
+ input_wave_length = ceil(44100 * length_arg_to_float(argv[4]) * 2);
+ printf("%d", input_wave_length);
+ input_wave = GlobalAlloc(GPTR,input_wave_length);//initializes to 0
+ //not working?! //got the wrong argument...
}
int errored = 0;
if (input_wave != NULL) {
//0: program path (obviously)
//1: some temp.wav to append the note to (relative. it doesnt exist at first)
//2: note wav file (full, not relative)
+ //3: stp, the time (in ms) the note should be shifted left (instead of just appending it uwu)
+ //4: length, the length of the note (in ms)
//3-end: some envelope shit idk. Unimportant probably /j
--- /dev/null
+#include "wavtool.h"
+
+
+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
+ 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);
+ return x/y/8 + z/1000;
+};
+
+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;
+};