function lichessOrchestra() {

  var soundDir = lichess.assetUrl('/assets/sound/instrument/', true);

  var instruments = {
      celesta: [],
      clav: [],
      swells: []
    },
    noteOverlap = 15,
    noteTimeout = 300,
    currentNotes = 0,
    maxPitch = 23;

  // load celesta and clav sounds
  for (var i = 1; i <= 24; i++) {
    if (i > 9) fn = 'c0' + i;
    else fn = 'c00' + i;
    instruments.celesta.push(new Howl({
      src: [soundDir + 'celesta/' + fn + '.ogg', soundDir + 'celesta/' + fn + '.mp3'],
      volume: 0.3
    }));
    instruments.clav.push(new Howl({
      src: [soundDir + 'clav/' + fn + '.ogg', soundDir + 'clav/' + fn + '.mp3'],
      volume: 0.2
    }));
  }
  // load swell sounds
  for (var i = 1; i <= 3; i++) {
    instruments.swells.push(new Howl({
      src: [soundDir + 'swells/swell' + i + '.ogg', soundDir + 'swells/swell' + i + '.mp3'],
      volume: 0.8
    }));
  }

  var play = function(instrument, pitch) {
    pitch = Math.round(Math.max(0, Math.min(maxPitch, pitch)));
    if (instrument === 'swells') pitch = Math.floor(pitch / 8);
    if (currentNotes < noteOverlap) {
      currentNotes++;
      instruments[instrument][pitch].play();
      setTimeout(function() {
        currentNotes--;
      }, noteTimeout);
    }
  };

  play('swells', 0);

  return {
    play: play
  };
}

@@ -91,13 +91,138 @@
 /', 
-true)
+%7BnoVersion:true%7D);%0A%0A  var makeSoundPair = function(sound) %7B%0A    return %5BsoundDir + sound + '.ogg', soundDir + sound + '.mp3'%5D;%0A  %7D
 ;%0A%0A 
@@ -566,57 +566,22 @@
 rc: 
-%5BsoundDir + 'celesta/' + fn + '.ogg', soundDir + 
+makeSoundPair(
 'cel
@@ -587,34 +587,25 @@
 lesta/' + fn
- + '.mp3'%5D
+)
 ,%0A      volu
@@ -673,54 +673,22 @@
 rc: 
-%5BsoundDir + 'clav/' + fn + '.ogg', soundDir + 
+makeSoundPair(
 'cla
@@ -695,26 +695,17 @@
 v/' + fn
- + '.mp3'%5D
+)
 ,%0A      
@@ -839,60 +839,22 @@
 rc: 
-%5BsoundDir + 'swells/swell' + i + '.ogg', soundDir + 
+makeSoundPair(
 'swe
@@ -867,26 +867,17 @@
 ell' + i
- + '.mp3'%5D
+)
 ,%0A      

fix music generation