<commit_before>/*
    Copyright 2012-2013 Samplecount S.L.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
*/

#ifndef METHCLA_FILE_H_INCLUDED
#define METHCLA_FILE_H_INCLUDED

#include <methcla/common.h>
#include <stddef.h>
#include <stdint.h>

#if defined(__cplusplus)
extern "C" {
#endif

typedef enum
{
    kMethcla_FileNoError,
    kMethcla_FileUnspecifiedError,
    kMethcla_FileInvalidArgument
} Methcla_FileError;

// Sound file interface

typedef enum
{
    kMethcla_Read,
    kMethcla_Write,
    kMethcla_ReadWrite
} Methcla_FileMode;

typedef struct
{
    int64_t      frames;
    unsigned int channels;
    unsigned int samplerate;
} Methcla_SoundFileInfo;

typedef struct Methcla_SoundFile Methcla_SoundFile;

struct Methcla_SoundFile
{
    void* handle;
    Methcla_FileError (*close)(const Methcla_SoundFile* file);
    Methcla_FileError (*seek)(const Methcla_SoundFile* file, int64_t numFrames);
    Methcla_FileError (*tell)(const Methcla_SoundFile* file, int64_t* numFrames);
    Methcla_FileError (*read_float)(const Methcla_SoundFile* file, float* buffer, size_t numFrames, size_t* outNumFrames);
};

typedef struct Methcla_SoundFileAPI Methcla_SoundFileAPI;

struct Methcla_SoundFileAPI
{
    void* handle;
    Methcla_FileError (*open)(const Methcla_SoundFileAPI* api, const char* path, Methcla_FileMode mode, Methcla_SoundFile** file, Methcla_SoundFileInfo* info);
    const char* (*error_message)(const struct Methcla_SoundFileAPI* api, Methcla_FileError error);
};

static inline const char* methcla_soundfile_error_message(const Methcla_SoundFileAPI* api, Methcla_FileError error)
{
    if ((api == NULL) || (api->error_message == NULL))
        return "Invalid argument";
    return api->error_message(api, error);<commit_msg>Fix order of soundfile API interface functions<commit_after>/*
    Copyright 2012-2013 Samplecount S.L.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
*/

#ifndef METHCLA_FILE_H_INCLUDED
#define METHCLA_FILE_H_INCLUDED

#include <methcla/common.h>
#include <stddef.h>
#include <stdint.h>

#if defined(__cplusplus)
extern "C" {
#endif

typedef enum
{
    kMethcla_FileNoError,
    kMethcla_FileUnspecifiedError,
    kMethcla_FileInvalidArgument
} Methcla_FileError;

// Sound file interface

typedef enum
{
    kMethcla_Read,
    kMethcla_Write,
    kMethcla_ReadWrite
} Methcla_FileMode;

typedef struct
{
    int64_t      frames;
    unsigned int channels;
    unsigned int samplerate;
} Methcla_SoundFileInfo;

typedef struct Methcla_SoundFile Methcla_SoundFile;

struct Methcla_SoundFile
{
    void* handle;
    Methcla_FileError (*close)(const Methcla_SoundFile* file);
    Methcla_FileError (*seek)(const Methcla_SoundFile* file, int64_t numFrames);
    Methcla_FileError (*tell)(const Methcla_SoundFile* file, int64_t* numFrames);
    Methcla_FileError (*read_float)(const Methcla_SoundFile* file, float* buffer, size_t numFrames, size_t* outNumFrames);
};

typedef struct Methcla_SoundFileAPI Methcla_SoundFileAPI;

struct Methcla_SoundFileAPI
{
    void* handle;
    const char* (*error_message)(const Methcla_SoundFileAPI* api, Methcla_FileError error);
    Methcla_FileError (*open)(const Methcla_SoundFileAPI* api, const char* path, Methcla_FileMode mode, Methcla_SoundFile** file, Methcla_SoundFileInfo* info);
};

static inline const char* methcla_soundfile_error_message(const Methcla_SoundFileAPI* api, Methcla_FileError error)
{
    if ((api == NULL) || (api->error_message == NULL))
        return "Invalid argument";
    return api->error_message(api, error);
{'fraction_non_alphanumeric': 0.07682177348551361, 'fraction_numerical': 0.007901668129938543, 'mean_word_length': 4.7105263157894735, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3840654', 'n_tokens_mistral': 1571, 'n_tokens_neox': 1468, 'n_words': 418}