]> _ Git - colon3wavtool.git/commitdiff
actually do real programming instead of trying to figure out how UTAU works
authorparking_turkeys <roya1060wien@gmail.com>
Fri, 7 Aug 2026 21:04:46 +0000 (17:04 -0400)
committerparking_turkeys <roya1060wien@gmail.com>
Fri, 7 Aug 2026 21:04:46 +0000 (17:04 -0400)
main.c
readwave.c [new file with mode: 0644]
wavtool.h [new file with mode: 0644]

diff --git a/main.c b/main.c
index 1c98a5c..bfa6ff3 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,5 +1,12 @@
-#include <math.h>
-#include <windows.h>
+/*
+ * insert funny copyright notice here
+ * gpl license stuff 
+ * yeahh it's colone3wavtool the really cool and functional wavtool for UTAU singing synthesis program :D
+ * gay
+ *
+ */
+
+#include "wavtool.h"
 
 #define LOGFILE L"C:\\projects\\colon3wavtool\\log.txt"
 
@@ -7,61 +14,42 @@ static int log_args(int argc, char *argv[]);
 
 int main(int argc, char *argv[])
 {
+       int input_wave_length = 0;
+       int16_t *input_wave = NULL;
        //test ver: just like. log the arguments lol!!
        log_args(argc, argv);
+
+       //ok. 
+       if (argc >= 3) {
+               input_wave_length = readWave(argv[2], NULL);
+       } else { goto error; };
+
+       if (input_wave_length > 0) {
+               input_wave = GlobalAlloc(0, input_wave_length);
+       } else { goto error; }
+       
+       if (input_wave != NULL) {
+               readWave(argv[2], input_wave);
+       };
+
+       error:
+               MessageBox(NULL, "Lmao error w", "colon3wavtool errored", MB_OK | MB_ICONWARNING);
        
        return 0;
 };
 
 int log_args(int argc, char *argv[])
 {
-       /* Doesnt work??
-       HANDLE hFile;
-
-       hFile = CreateFileW(
-                       LOGFILE, //name of file (*wchar_t)
-                       GENERIC_WRITE,
-                       0, NULL,
-                       OPEN_ALWAYS,
-                       FILE_ATTRIBUTE_NORMAL,
-                       NULL
-                  );
-
-       char *c = " ";
-       DWORD dwWritten;
-       for (int i = 1; i < argc; i++) {
-               for (int n = 0; (*c = argv[i][n]) != '\0'; n++) {
-                       WriteFile(
-                                       hFile,
-                                       c,
-                                       8,
-                                       &dwWritten,
-                                       NULL
-                                );
-               };
-               c = " ";
-               WriteFile(
-                               hFile,
-                               c,
-                               8,
-                               &dwWritten,
-                               NULL
-                        );
-       };
-       c = "\n";
-       WriteFile(
-                       hFile,
-                       c,
-                       8,
-                       &dwWritten,
-                       NULL
-                );
-        */
-
-
+       /*
        for (int i = 1; i < argc; i++) {
                MessageBoxA(NULL, argv[i], "argument :3", MB_OK);
        };
+       */
+       //so im p sure it's like this:
+       //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-end: some envelope shit idk. Unimportant probably /j
 
 
        return 1;
diff --git a/readwave.c b/readwave.c
new file mode 100644 (file)
index 0000000..0c6d2cd
--- /dev/null
@@ -0,0 +1,43 @@
+#include "wavtool.h"
+
+int readWave(char *filename, int16_t buffer[]) //if buffer is NULL it only returns the length requried???
+{
+       //haha
+       //ok so expect 16-bit samples, and also the length required should be in BYTES
+       HANDLE fp;
+       char *error_msg = "unknown error in reading wave file";
+       fp = CreateFileA(
+                       filename,
+                       GENERIC_READ,
+                       0,
+                       NULL,
+                       OPEN_EXISTING, //if it doesnt exist it's bad :>
+                       FILE_ATTRIBUTE_NORMAL,
+                       NULL
+                       );
+
+       if (fp == INVALID_HANDLE_VALUE) {
+               error_msg = "error opening input wave file";
+               goto error;
+       };
+
+       //get file length and load it ig...
+       DWORD filesize = 0;
+       filesize = GetFileSize(fp, NULL);
+       long unsigned int bytes_read = 0;
+       //ok so first the header...
+       char chunk_id[5] = "    ";
+       ReadFile(fp, chunk_id, 4, &bytes_read, NULL);
+       if (strcmp("RIFF", chunk_id)) { 
+               error_msg = "input wave file not good :<";
+               goto error;
+       };
+
+
+       return 0;
+
+       error:
+               MessageBoxA(NULL, error_msg, "colon3wavtool error :(((", MB_OK | MB_ICONWARNING);
+               return -1;
+
+};
diff --git a/wavtool.h b/wavtool.h
new file mode 100644 (file)
index 0000000..ab7a293
--- /dev/null
+++ b/wavtool.h
@@ -0,0 +1,19 @@
+/*
+ * UTAU wavtool in C
+ * gpl v3+ licensed uwu
+ * by parking_turkeys, Copyright 2026
+ *
+ */
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdint.h>
+
+struct riff_chunk {
+       char ckID[4];//NOT ZERO TERMINATED
+       uint32_t ckSize;
+       uint8_t ckData[];//length == ckSize
+};
+
+//ok so first read the whole file into a thingy
+int readWave(char *filename, int16_t buffer[]);