*/
#include "wavtool.h"
-#include <math.h>
#define LOGFILE L"C:\\projects\\colon3wavtool\\log.txt"
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;
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;
//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
* 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;
+};
#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);
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!");
fclose(fp);
- return data_length;
+ return data_length - (STP_samples*2);
error:
report_error(error_msg, "readWave()", "colon3wavtool");
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#define SAMPLING_RATE 44100
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[]);