<commit_before>#include "wav.h"

#include <stdlib.h>
#include <string.h>
#include <errno.h>

bool wav_find_chunk(FILE* fd, const char* magic) {
    char curr[5] = {0};
    while(strcmp(curr, magic) != 0) {
        u32 read = (u32) fread(curr, 1, 4, fd);
        if(read == 0) {
            return false;
        }
    }

    fseek(fd, -4, SEEK_CUR);
    return true;
}

WAV* wav_read(FILE* fd) {
    if(!fd) {
        printf("ERROR: Could not open WAV file: %s\n", strerror(errno));
        return NULL;<commit_msg>Search for WAV chunk headers from each byte.<commit_after>#include "wav.h"

#include <stdlib.h>
#include <string.h>
#include <errno.h>

bool wav_find_chunk(FILE* fd, const char* magic) {
    char curr[5] = {0};
    for(long pos = ftell(fd); strcmp(curr, magic) != 0; pos++) {
        fseek(fd, pos, SEEK_SET);
        size_t read = fread(curr, 1, 4, fd);
        if(read <= 0) {
            return false;
        }
    }

    fseek(fd, -4, SEEK_CUR);
    return true;
}

WAV* wav_read(FILE* fd) {
    if(!fd) {
        printf("ERROR: Could not open WAV file: %s\n", strerror(errno));
        return NULL;
{'fraction_non_alphanumeric': 0.16353887399463807, 'fraction_numerical': 0.0160857908847185, 'mean_word_length': 2.5220125786163523, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6465493', 'n_tokens_mistral': 446, 'n_tokens_neox': 430, 'n_words': 112}