<commit_before>//------------------------------------------------------------------------------
//  saudio-sapp.c
//  Test sokol-audio
//------------------------------------------------------------------------------
#include "sokol_app.h"
#include "sokol_gfx.h"
#include "sokol_audio.h"

sg_pass_action pass_action = {
    .colors[0] = { .action = SG_ACTION_CLEAR, .val = { 1.0f, 0.5f, 0.0f, 1.0f } }
};

void stream(float* buffer, int num_samples) {
    for (int i = 0; i < num_samples; i++) {
        buffer[i] = 0.0f;
    }
}

void init(void) {
    sg_setup(&(sg_desc){
        .mtl_device = sapp_metal_get_device(),
        .mtl_renderpass_descriptor_cb = sapp_metal_get_renderpass_descriptor,
        .mtl_drawable_cb = sapp_metal_get_drawable,
        .d3d11_device = sapp_d3d11_get_device(),
        .d3d11_device_context = sapp_d3d11_get_device_context(),
        .d3d11_render_target_view_cb = sapp_d3d11_get_render_target_view,
        .d3d11_depth_stencil_view_cb = sapp_d3d11_get_depth_stencil_view
    });
    saudio_setup(&(saudio_desc){
        .sample_rate = 44100,<commit_msg>saudio sample: play a simple square wave<commit_after>//------------------------------------------------------------------------------
//  saudio-sapp.c
//  Test sokol-audio
//------------------------------------------------------------------------------
#include "sokol_app.h"
#include "sokol_gfx.h"
#include "sokol_audio.h"

sg_pass_action pass_action = {
    .colors[0] = { .action = SG_ACTION_CLEAR, .val = { 1.0f, 0.5f, 0.0f, 1.0f } }
};

static uint32_t even_odd;
void stream(float* ptr, int num_samples) {
    for (int i = 0; i < num_samples; i++) {
        if (even_odd++ & (1<<5)) {
            ptr[i] = 0.5f;
        }
        else {
            ptr[i] = -0.5f;
        }
    }
}

void init(void) {
    sg_setup(&(sg_desc){
        .mtl_device = sapp_metal_get_device(),
        .mtl_renderpass_descriptor_cb = sapp_metal_get_renderpass_descriptor,
        .mtl_drawable_cb = sapp_metal_get_drawable,
        .d3d11_device = sapp_d3d11_get_device(),
        .d3d11_device_context = sapp_d3d11_get_device_context(),
        .d3d11_render_target_view_cb = sapp_d3d11_get_render_target_view,
        .d3d11_depth_stencil_view_cb = sapp_d3d11_get_depth_stencil_view
    });
    saudio_setup(&(saudio_desc){
        .sample_rate = 44100,
{'fraction_non_alphanumeric': 0.24197002141327623, 'fraction_numerical': 0.037687366167023555, 'mean_word_length': 1.8768472906403941, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '4966984', 'n_tokens_mistral': 898, 'n_tokens_neox': 848, 'n_words': 122}