<commit_before>// This is the version written out to sound files. We maintain backwards
// compatibility with files written by older versions where possible, but
// refuse to read files written by newer versions. Only bump the version number
// if older versions of jfxr would be unable to correctly interpret files
// written by this version.
jfxr.VERSION = 1;

jfxrApp.controller('JfxrCtrl', ['context', 'Player', '$scope', '$timeout', 'localStorage', 'fileStorage', 'synthFactory', function(
      context, Player, $scope, $timeout, localStorage, fileStorage, synthFactory) {
  var player = new Player();

  this.buffer = null;
  this.synth = null;

  this.sounds = [];
  for (var i = 0;; i++) {
    var str = localStorage.get('sounds[' + i + ']', undefined);
    if (!str) {
      break;
    }
    var sound = new jfxr.Sound();
    sound.parse(str);
    this.sounds.push(sound);
  }

  var addSound = function(sound) {
    this.sounds.unshift(sound);
    this.soundIndex = 0;
  }.bind(this);

  var getFreeName = function(basename) {
    var max = 0;
    for (var i = 0; i < this.sounds.length; i++) {
      var m = this.sounds[i].name.match('^' + basename + ' (\\d+)$');
      if (m) {
         max = Math.max(max, parseInt(m[1]));
      }
    }
    return basename + ' ' + (max + 1);
  }.bind(this);

  var maybeAddDefaultSound = function() {
    if (this.sounds.length === 0) {
      this.newSound();
    }
  }.bind(this);

  this.soundIndex = jfxr.Math.clamp(0, this.sounds.length - 1, localStorage.get('soundIndex', 0));

  this.analyserEnabled = localStorage.get('analyserEnabled', true);
  this.autoplay = localStorage.get('autoplayEnabled', true);

  this.presets = jfxr.Preset.all;

  this.getSound = function() {
    return this.sounds[this.soundIndex];
  };

  this.deleteSound = function(index) {
    this.sounds.splice(index, 1);
    maybeAddDefaultSound();
    if (this.soundIndex >= this.sounds.length) {
      this.soundIndex = this.sounds.length - 1;
    }
  };

  this.isPlaying = function() {
    return player.playing;
  };

  this.togglePlay = function() {
    if (player.playing) {
      player.stop();
    } else {
      player.play(this.buffer);<commit_msg>Fix presets<commit_after>// This is the version written out to sound files. We maintain backwards
// compatibility with files written by older versions where possible, but
// refuse to read files written by newer versions. Only bump the version number
// if older versions of jfxr would be unable to correctly interpret files
// written by this version.
jfxr.VERSION = 1;

jfxrApp.controller('JfxrCtrl', ['context', 'Player', '$scope', '$timeout', 'localStorage', 'fileStorage', 'synthFactory', 'allPresets', function(
      context, Player, $scope, $timeout, localStorage, fileStorage, synthFactory, allPresets) {
  var player = new Player();

  this.buffer = null;
  this.synth = null;

  this.sounds = [];
  for (var i = 0;; i++) {
    var str = localStorage.get('sounds[' + i + ']', undefined);
    if (!str) {
      break;
    }
    var sound = new jfxr.Sound();
    sound.parse(str);
    this.sounds.push(sound);
  }

  var addSound = function(sound) {
    this.sounds.unshift(sound);
    this.soundIndex = 0;
  }.bind(this);

  var getFreeName = function(basename) {
    var max = 0;
    for (var i = 0; i < this.sounds.length; i++) {
      var m = this.sounds[i].name.match('^' + basename + ' (\\d+)$');
      if (m) {
         max = Math.max(max, parseInt(m[1]));
      }
    }
    return basename + ' ' + (max + 1);
  }.bind(this);

  var maybeAddDefaultSound = function() {
    if (this.sounds.length === 0) {
      this.newSound();
    }
  }.bind(this);

  this.soundIndex = jfxr.Math.clamp(0, this.sounds.length - 1, localStorage.get('soundIndex', 0));

  this.analyserEnabled = localStorage.get('analyserEnabled', true);
  this.autoplay = localStorage.get('autoplayEnabled', true);

  this.presets = allPresets;

  this.getSound = function() {
    return this.sounds[this.soundIndex];
  };

  this.deleteSound = function(index) {
    this.sounds.splice(index, 1);
    maybeAddDefaultSound();
    if (this.soundIndex >= this.sounds.length) {
      this.soundIndex = this.sounds.length - 1;
    }
  };

  this.isPlaying = function() {
    return player.playing;
  };

  this.togglePlay = function() {
    if (player.playing) {
      player.stop();
    } else {
      player.play(this.buffer);
{'fraction_non_alphanumeric': 0.15402141717931192, 'fraction_numerical': 0.005923900660742766, 'mean_word_length': 3.0875232774674117, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3979906', 'n_tokens_mistral': 1489, 'n_tokens_neox': 1434, 'n_words': 364}