<commit_before>function lichessReplayMusic() {

  var orchestra;

  lichess.loadScript('/assets/javascripts/music/orchestra.js').then(function() {
    orchestra = lichessOrchestra();
    $.sound.disable();
  });

  var isPawn = function(san) {
    return san[0] !== san[0].toLowerCase();
  };

  var hasCheck = function(san) {
    return san.indexOf('+') !== -1;
  };
  var hasMate = function(san) {
    return san.indexOf('#') !== -1;
  };
  var hasCapture = function(san) {
    return san.indexOf('x') !== -1;
  };

  // a -> 0
  // c -> 2
  var fileToRank = function(file) {
    return 'abcdefgh'.indexOf(file) + 1;
  };

  // c7 = 2 * 8 + 7 = 23
  var keyToInt = function(key) {
    return fileToRank(key[0]) * 8 + parseInt(key[1]);
  };

  var uciToInt = function(uci) {
    return keyToInt(uci.slice(0, 2)) * 64 + keyToInt(uci.slice(2));
  };

  var jump = function(path, node) {
    if (node.san) {
      var pitch = uciToInt(node.uci) / (4096 / 24);
      orchestra.play(isPawn(node.san) ? 'clav' : 'celesta', pitch);
      if (hasCheck(node.san)) orchestra.play('swells', 23 - pitch);
      else if (hasCapture(node.san)) orchestra.play('swells', 23 - pitch);
      else if (hasMate(node.san)) orchestra.play('swells', 23 - pitch);
    } else {
      orchestra.play('swells', 0);
    }
  }

  return {
    jump: function(path, node) {
      if (!orchestra) return;
      jump(path, node);
    }
  };
};<commit_msg>maybe improve analysis music<commit_after>function lichessReplayMusic() {

  var orchestra;

  lichess.loadScript('/assets/javascripts/music/orchestra.js').then(function() {
    orchestra = lichessOrchestra();
    $.sound.disable();
  });

  var isPawn = function(san) {
    return san[0] !== san[0].toLowerCase();
  };

  var hasCastle = function(san) {
    return san.indexOf('O-O') === 0;
  };
  var hasCheck = function(san) {
    return san.indexOf('+') !== -1;
  };
  var hasMate = function(san) {
    return san.indexOf('#') !== -1;
  };
  var hasCapture = function(san) {
    return san.indexOf('x') !== -1;
  };

  // a -> 0
  // c -> 2
  var fileToInt = function(file) {
    return 'abcdefgh'.indexOf(file);
  };

  // c7 = 2 * 8 + 7 = 23
  var keyToInt = function(key) {
    return fileToInt(key[0]) * 8 + parseInt(key[1]) - 1;
  };

  // var uciBase = 4096;
  var uciBase = 64;
  var uciToInt = function(uci) {
    // return keyToInt(uci.slice(0, 2)) * 64 + keyToInt(uci.slice(2));
    return keyToInt(uci.slice(2));
  };

  var uciToPitch = function(uci) {
    return uciToInt(uci) / (uciBase / 23)
  };

  var jump = function(path, node) {
    if (node.san) {
      var pitch = uciToPitch(node.uci);
      orchestra.play(isPawn(node.san) ? 'clav' : 'celesta', pitch);
      if (hasCastle(node.san)) orchestra.play('swells', pitch);
      else if (hasCheck(node.san)) orchestra.play('swells', pitch);
      else if (hasCapture(node.san)) orchestra.play('swells', pitch);
      else if (hasMate(node.san)) orchestra.play('swells', pitch);
    } else {
      orchestra.play('swells', 0);
    }
  };

//   var delay = 500;
//   for (file = 0; file < 8; file++) {
//     for (rank = 0; rank < 8; rank++) {
//       var uci = 'a1' + 'abcdefgh'[file] + (rank + 1);
//       (function(u) {
//         setTimeout(function() {
//         orchestra.play('celesta', uciToPitch(u));
//         console.log(u, uciToPitch(u));
//         }, delay);
//       })(uci);
//       delay += 500;
//     }
//   }

  return {
    jump: function(path, node) {
      if (!orchestra) return;
      jump(path, node);
    }
  };
};
{'fraction_non_alphanumeric': 0.19186210794009606, 'fraction_numerical': 0.022605255721955354, 'mean_word_length': 2.6307692307692307, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5982260', 'n_tokens_mistral': 1385, 'n_tokens_neox': 1312, 'n_words': 267}