<commit_before>#include "main.hpp"

#include "Renderer.hpp"
#include "SampleBuffer.hpp"

namespace sound {

static void sdlAudioCallback(void *userdata, Uint8 *stream, int len) {
  static_cast<Renderer *>(userdata)->audioCallback(stream, len);
}

bool Renderer::create() {
  {
    SDL_AudioSpec desiredAudioSpec;
    desiredAudioSpec.freq = 48000;
    desiredAudioSpec.format = AUDIO_F32SYS;
    desiredAudioSpec.channels = 2;
    desiredAudioSpec.samples = 512;
    desiredAudioSpec.callback = sdlAudioCallback;
    desiredAudioSpec.userdata = this;

    audioDevice =
        SDL_OpenAudioDevice(nullptr, 0, &desiredAudioSpec, &audioSpec, 0);
    if (!audioDevice) {
      SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
                               "Could not open audio device", SDL_GetError(),
                               NULL);
      return false;
    }
  }

  std::cout << "Audio:\n"
      << "\tsamplerate: " << audioSpec.freq << "\n"
      << "\tchannels: " << (int)audioSpec.channels << "\n"
      << "\tsamples: " << audioSpec.samples << "\n";

  assert(std::atomic_is_lock_free(&voices[0].sampleBuffer));
  assert(std::atomic_is_lock_free(&voices[0].state));
  assert(std::atomic_is_lock_free(&voices[0].cursor));

  for (auto &voice : voices) {<commit_msg>Increase audio buffer size to fix dropouts on my MacMini<commit_after>#include "main.hpp"

#include "Renderer.hpp"
#include "SampleBuffer.hpp"

namespace sound {

static void sdlAudioCallback(void *userdata, Uint8 *stream, int len) {
  static_cast<Renderer *>(userdata)->audioCallback(stream, len);
}

bool Renderer::create() {
  {
    SDL_AudioSpec desiredAudioSpec;
    desiredAudioSpec.freq = 48000;
    desiredAudioSpec.format = AUDIO_F32SYS;
    desiredAudioSpec.channels = 2;
    desiredAudioSpec.samples = 1024;
    desiredAudioSpec.callback = sdlAudioCallback;
    desiredAudioSpec.userdata = this;

    audioDevice =
        SDL_OpenAudioDevice(nullptr, 0, &desiredAudioSpec, &audioSpec, 0);
    if (!audioDevice) {
      SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
                               "Could not open audio device", SDL_GetError(),
                               NULL);
      return false;
    }
  }

  std::cout << "Audio:\n"
      << "\tsamplerate: " << audioSpec.freq << "\n"
      << "\tchannels: " << (int)audioSpec.channels << "\n"
      << "\tsamples: " << audioSpec.samples << "\n";

  assert(std::atomic_is_lock_free(&voices[0].sampleBuffer));
  assert(std::atomic_is_lock_free(&voices[0].state));
  assert(std::atomic_is_lock_free(&voices[0].cursor));

  for (auto &voice : voices) {
{'fraction_non_alphanumeric': 0.13745173745173744, 'fraction_numerical': 0.013513513513513514, 'mean_word_length': 3.4366438356164384, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 7, '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': '6580745', 'n_tokens_mistral': 858, 'n_tokens_neox': 829, 'n_words': 151}