<commit_before>﻿
///Real-time audio output.
///Provide the following callback functions:
///
///  audioOutputStart(sampleRate);  <- called when audio output is about to start
///  audioOutputRender(float32array);  <- called when more audio data is needed
///
function AudioOutput(audioOutputStart, audioOutputRender)
{
  var sampleRate = 44100;
  var audioContext = null;

  if(typeof AudioContext == "function")
  {
    audioContext = new AudioContext(); //try Web Audio API
  }
  else if(typeof webkitAudioContext == "function")
  {
    audioContext = new webkitAudioContext(); //didn't exist, so try with prefix
  }

  if(audioContext)
  {
    sampleRate = audioContext.sampleRate;
    audioOutputStart(sampleRate);
    var node = audioContext.createJavaScriptNode(4096, 1, 1);
    node.onaudioprocess = function(event) { audioOutputRender(event.outputBuffer.getChannelData(0)); } //specify callback
    node.connect(audioContext.destination);
  }
  else
  {
    if(typeof Audio == "function") //try Audio Data API
    {
      audioContext = new Audio();
    }
    if(audioContext && typeof audioContext.mozSetup == "function")
    {
      audioContext.mozSetup(1, sampleRate);
      audioOutputStart(sampleRate);

      var prebufferSize = sampleRate / 2;
      var tailPosition, tail = null;
      var writePosition = 0;

      setInterval(function()<commit_msg>Update audio_output.js<commit_after>﻿
///Real-time audio output.
///Provide the following callback functions:
///
///  audioOutputStart(sampleRate);  <- called when audio output is about to start
///  audioOutputRender(float32array);  <- called when more audio data is needed
///
function AudioOutput(audioOutputStart, audioOutputRender)
{
  var sampleRate = 48000;
  var audioContext = null;

  if(typeof AudioContext == "function")
  {
    audioContext = new AudioContext(); //try Web Audio API
  }
  else if(typeof webkitAudioContext == "function")
  {
    audioContext = new webkitAudioContext(); //didn't exist, so try with prefix
  }

  if(audioContext)
  {
    sampleRate = audioContext.sampleRate;
    audioOutputStart(sampleRate);
    var node = audioContext.createScriptProcessor(4096, 1, 1);
    node.onaudioprocess = function(event) { audioOutputRender(event.outputBuffer.getChannelData(0)); } //specify callback
    node.connect(audioContext.destination);
    
    // check if we run on iOS and need a dummy oscillator
    if(navigator.userAgent.match(/(iPad|iPhone|iPod)/g))
    {
	    var osc = context.createOscillator();
	    osc.type = 0;
	    osc.connect(node);
	    osc.noteOn(0);
    }
  }
  else
  {
    if(typeof Audio == "function") //try Audio Data API
    {
      audioContext = new Audio();
    }
    if(audioContext && typeof audioContext.mozSetup == "function")
    {
      audioContext.mozSetup(1, sampleRate);
      audioOutputStart(sampleRate);

      var prebufferSize = sampleRate / 2;
      var tailPosition, tail = null;
      var writePosition = 0;

      setInterval(function()
{'fraction_non_alphanumeric': 0.11435278336686787, 'fraction_numerical': 0.012072434607645875, 'mean_word_length': 3.373900293255132, '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': '1404380', 'n_tokens_mistral': 905, 'n_tokens_neox': 856, 'n_words': 225}