error_msg = "input wave file not good :<";
goto error;
};
+ uint32_t riff_length = 0; //length of the rest of the file
+ ReadFile(fp, &riff_length, 4, &bytes_read, NULL);
+ if (bytes_read != 4) {
+ error_msg = "file ended before the 8th byte?? wha";
+ goto error;
+ };
+ //now the WAVE chunk id
+ ReadFile(fp, chunk_id, 4, &bytes_read, NULL);
+ if (strcmp("WAVE", chunk_id)) {
+ error_msg = "not a WAVE file :<";
+ goto error;
+ };
+ //now the 'fmt ' chunk id
+ ReadFile(fp, chunk_id, 4, &bytes_read, NULL);
+ if (strcmp("fmt ", chunk_id)) {
+ error_msg = "fmt chunk not first chunk :(";
+ goto error;
+ };
+ //length
+ uint32_t fmt_length = 0;
+ ReadFile(fp, &fmt_length, 4, &bytes_read, NULL);
+ if (bytes_read != 4) {
+ error_msg = "couldn't read length of 'fmt ' chunk in input wave file";
+ goto error;
+ };
+ //now the format tag
+ uint16_t format_tag = 0;
+ ReadFile(fp, &format_tag, 2, &bytes_read, NULL);
+ if (format_tag != 1) {
+ error_msg = "not the format i like...";
+ goto error;
+ };
+ uint16_t channel_count = 0;
+ ReadFile(fp, &channel_count, 2, &bytes_read, NULL);
+ if (channel_count != 1) {
+ error_msg = "input wave file not mono";
+ goto error;
+ };
+ uint32_t sampling_rate = 0;
+ ReadFile(fp, &sampling_rate, 4, &bytes_read, NULL);
+ if (sampling_rate != SAMPLING_RATE) {
+ error_msg = "incorrect sampling rate (should be 44100)";
+ goto error;
+ };
+ uint8_t boring[6] = {0};
+ ReadFile(fp, boring, 6, &bytes_read, NULL);
+ if (bytes_read != 6) {
+ error_msg = "input file ended unexpectedly in 'fmt ' chunk";
+ goto error;
+ };
+ uint16_t bitsPerSample = 0;
+ ReadFile(fp, &bitsPerSample, 2, &bytes_read, NULL);
+ if (bitsPerSample != 16) {
+ error_msg = "input file has non-16-bit samples";
+ goto error;
+ };
+ ReadFile(fp, &chunk_id, 4, &bytes_read, NULL);
+ if (strcmp(chunk_id, "data")) {
+ error_msg = "input file does not have data chunk right after fmt chunk";
+ goto error;
+ };
+
+
+
+
+
return 0;