From: parking_turkeys Date: Sat, 15 Aug 2026 19:27:21 +0000 (-0400) Subject: StartPoint (STP) X-Git-Tag: horizons~2 X-Git-Url: http://git.p-t.hackclub.app/?a=commitdiff_plain;h=0fcd087fd330a41bb7dcb29dedacf63e473cdd3b;p=colon3wavtool.git StartPoint (STP) --- diff --git a/main.c b/main.c index 9f3a7be..1dbc9d9 100644 --- a/main.c +++ b/main.c @@ -7,7 +7,6 @@ */ #include "wavtool.h" -#include #define LOGFILE L"C:\\projects\\colon3wavtool\\log.txt" @@ -19,13 +18,14 @@ int main(int argc, char *argv[]) int input_wave_length = 0; // in bytes int16_t *input_wave = NULL; char *error_msg = "unknown error in main()"; + int STP = ceil(arg_to_float(argv[3])); //test ver: just like. log the arguments lol!! log_args(argc, argv); fix_filename(argv[1]); fix_filename(argv[2]); //ok. if (argc >= 3) { - input_wave_length = readWave(argv[2], NULL); + input_wave_length = readWave(argv[2], NULL, STP); } else { error_msg = "not enough arguments"; goto error; @@ -53,7 +53,7 @@ int main(int argc, char *argv[]) int errored = 0; if (input_wave != NULL) { - errored = readWave(argv[2], input_wave); + errored = readWave(argv[2], input_wave, STP); } else { error_msg = "[main()] malloc()/calloc() failed"; goto error; @@ -99,7 +99,7 @@ int log_args(int argc, char *argv[]) //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) + //3: stp, the amount (in ms) of the start of the note that should be CUT OFF. //4: length, the length of the note (in ms) //3-end: some envelope shit idk. Unimportant probably /j diff --git a/modifywave.c b/modifywave.c index ce81aa9..d2c9ad3 100644 --- a/modifywave.c +++ b/modifywave.c @@ -42,4 +42,9 @@ int modifyWave(int16_t w[], int w_B, int argc, char *argv[]) * ove - overlap of the prior note?? not entirely sure tbh (ill do ts last :p) * * well that was long + * + * OH also p sure the envelope defines like volume LMAO */ + //so the best way to do this is math probably?? + return 1; +}; diff --git a/readwave.c b/readwave.c index 455dac1..d236734 100644 --- a/readwave.c +++ b/readwave.c @@ -1,11 +1,13 @@ #include "wavtool.h" -int readWave(char *filename, int16_t buffer[]) //if buffer is NULL it only returns the length requried??? +int readWave(char *filename, int16_t buffer[], int STP_ms) //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 FILE *fp; char *error_msg = "unknown error in reading wave file"; + + int STP_samples = ceil(STP_ms * 44100 * 0.001); printf("input file: %s \n", filename); @@ -91,7 +93,8 @@ int readWave(char *filename, int16_t buffer[]) //if buffer is NULL it only retur int sample_count = data_length/2; if (buffer != NULL) { - fread(buffer, 2, sample_count, fp); + fseek(fp, STP_samples*2, SEEK_CUR); + fread(buffer, 2,sample_count - STP_samples, fp); }; if (ferror(fp)) { perror("Error!"); @@ -100,7 +103,7 @@ int readWave(char *filename, int16_t buffer[]) //if buffer is NULL it only retur fclose(fp); - return data_length; + return data_length - (STP_samples*2); error: report_error(error_msg, "readWave()", "colon3wavtool"); diff --git a/wavtool.h b/wavtool.h index 9221dbc..b3197d5 100644 --- a/wavtool.h +++ b/wavtool.h @@ -9,6 +9,7 @@ #include #include #include +#include #define SAMPLING_RATE 44100 @@ -23,7 +24,7 @@ float length_arg_to_float(char *arg); //returns float of SECONDS. >:( int report_error(char *error_msg, char *portion, char *program); //in a function so that it's possible to change it more easily uwu //ok so first read the whole file into a thingy -int readWave(char *filename, int16_t buffer[]); +int readWave(char *filename, int16_t buffer[], int STP); //then edit the wave based on argv (do this later!!) int modifyWave(int16_t wave[], int wave_length_bytes, int argc, char *argv[]);