<commit_before>const context = new AudioContext();

const wait = (ms) => new Promise((resolve, reject) => setTimeout(resolve, ms));

let startTime = Date.now();

async function playNote(note, length) {
  if(note === ``) return await wait(length * 1000 * 0.75);
  const oscillator = context.createOscillator();
  const gain = context.createGain();
  gain.gain.value = 1.1 - Math.min(1,(Date.now()-startTime)/3000);

  oscillator.connect(gain);

  oscillator.type = `sawtooth`;
  oscillator.frequency.value = note;
  gain.connect(context.destination);
  oscillator.start(0);
  
  gain.gain.exponentialRampToValueAtTime(
    0.00001, context.currentTime + length
  );

  await wait(length * 1000 * 0.75);
}

async function playSong(music) {
  let i = -1;
  let h = -1;
  while(++i < music.length) {
    const [note, length] = music[i];
    if(Array.isArray(note)) {
      while(++h < note.length - 1) {
        playNote(note[h], Array.isArray(length) ? length[h] : length);
      }
      playNote(note[h], Array.isArray(length) ? length[h] : length);
      await wait((Array.isArray(length) ? Math.min(...length) : length) * 1000 * 0.75);<commit_msg>switch wave type from sawtooth -> square<commit_after>const context = new AudioContext();

const wait = (ms) => new Promise((resolve, reject) => setTimeout(resolve, ms));

let startTime = Date.now();

async function playNote(note, length) {
  if(note === ``) return await wait(length * 1000 * 0.75);
  const oscillator = context.createOscillator();
  const gain = context.createGain();
  gain.gain.value = 1.1 - Math.min(1,(Date.now()-startTime)/3000);

  oscillator.connect(gain);

  oscillator.type = `square`;
  oscillator.frequency.value = note;
  gain.connect(context.destination);
  oscillator.start(0);
  
  gain.gain.exponentialRampToValueAtTime(
    0.00001, context.currentTime + length
  );

  await wait(length * 1000 * 0.75);
}

async function playSong(music) {
  let i = -1;
  let h = -1;
  while(++i < music.length) {
    const [note, length] = music[i];
    if(Array.isArray(note)) {
      while(++h < note.length - 1) {
        playNote(note[h], Array.isArray(length) ? length[h] : length);
      }
      playNote(note[h], Array.isArray(length) ? length[h] : length);
      await wait((Array.isArray(length) ? Math.min(...length) : length) * 1000 * 0.75);
{'fraction_non_alphanumeric': 0.1673134971970677, 'fraction_numerical': 0.032772746873652434, 'mean_word_length': 3.6963562753036436, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, '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': '4572699', 'n_tokens_mistral': 844, 'n_tokens_neox': 796, 'n_words': 168}