Parcourir la source

Merge branch 'develop' of https://github.com/opensheetmusicdisplay/opensheetmusicdisplay into develop

Matthias il y a 9 ans
Parent
commit
fffc7eed46

+ 1 - 1
Gruntfile.js

@@ -173,7 +173,7 @@ module.exports = function (grunt) {
     grunt.registerTask('lint',      ['jshint', 'tslint']);
     grunt.registerTask('start',     ['typings']);
     grunt.registerTask('all',       ['typings', 'default']);
-    grunt.registerTask('default',   ['browserify:dist', 'uglify']);
+    grunt.registerTask('default',   ['browserify', 'uglify']);
     grunt.registerTask('npm-test',  ['typings', 'test']);
     grunt.registerTask('test',      ['browserify:debug', 'lint', 'karma:ci']);
     grunt.registerTask('fast-test', ['browserify:debug', 'karma:ci']);

+ 0 - 31
experiments/canvas_memory_test.html

@@ -1,31 +0,0 @@
-<!--This file executes some benchmarks with HTML Canvas and VexFlow rendering-->
-<!DOCTYPE html><html><head><meta charset="UTF-8"><script defer="defer">(function(){
-//----------------------------------------------------------------------------->
-
-window.onload = function() {
-  window.title = "[OSMD] Canvas Memory Test"
-  window.setTimeout(test2, 1);
-}
-
-var test1 = function() {
-  var canvas = document.createElement("canvas");
-  canvas.style.border = "1px solid red";
-  canvas.width = 1920;
-  canvas.height = 1080 * 30;
-  document.body.appendChild(canvas);
-}
-
-var test2 = function() {
-  var canvas = document.createElement("canvas");
-  canvas.style.border = "1px solid red";
-  canvas.width = 1920;
-  canvas.height = 1080 * 30;
-  var ctx = canvas.getContext("2d");
-  ctx.fillStyle = "red";
-  ctx.fillRect(0, 0, canvas.width, canvas.height);
-  document.body.appendChild(canvas);
-}
-
-//----------------------------------------------------------------------------->
-}());</script><!--------------------------------------------------------------->
-</head></html><!--------------------------------------------------------------->

+ 0 - 465
experiments/canvas_performance.html

@@ -1,465 +0,0 @@
-<!--This file executes some benchmarks with HTML Canvas and VexFlow rendering-->
-<!DOCTYPE html><html><head><meta charset="UTF-8"><script defer="defer">(function(){
-//----------------------------------------------------------------------------->
-
-// TODO
-// * More complex VexFlow systems
-
-var start = function () {
-  document.title = "HTML Canvas Performance Tests";
-  write("<h1>[OSMD] HTML Canvas Performance Tests</h1>");
-  var t = timer();
-  // Run the tests
-  repeat(
-    "Canvas creation", 100,
-    "create an empty huge 1920 x (1080*30) canvas.",
-    function(){
-      var canvas = document.createElement("canvas");
-      canvas.width = 1920;
-      canvas.height = 1080 * 30;
-    }
-  );
-  repeat(
-    "Fill canvas with white", 10,
-    "create a huge canvas and fill it completely with white.",
-    function(){
-      var canvas = document.createElement("canvas");
-      canvas.width = 1920;
-      canvas.height = 1080 * 30;
-      var ctx = canvas.getContext("2d");
-      ctx.fillRect(0, 0, canvas.width, canvas.height);
-    }
-  );
-  repeat(
-    "[VexFlow] Draw systems", 100,
-    "Draw 20 empty staves on a normal (1920x200) canvas (one instrument).",
-    function(){
-      var canvas = document.createElement("canvas");
-      canvas.width = 1920;
-      canvas.height = 200;
-      var renderer = new Vex.Flow.Renderer(canvas, Vex.Flow.Renderer.Backends.CANVAS);
-      var ctx = renderer.getContext();
-      for (var j=0; j < 20; j++)
-        (new Vex.Flow.Stave(
-          Math.floor(Math.random()*canvas.width),
-          Math.floor(Math.random()*canvas.height),
-          Math.floor(Math.random()*canvas.width)
-        )).addClef("treble")
-          .setContext(ctx)
-          .draw();
-    }
-  );
-  repeat(
-    "[VexFlow] Draw systems", 100,
-    "Draw 20 empty staves on a big (1920x1080) canvas (one instrument).",
-    function(){
-      var canvas = document.createElement("canvas");
-      canvas.width = 1920;
-      canvas.height = 1080;
-      var renderer = new Vex.Flow.Renderer(canvas, Vex.Flow.Renderer.Backends.CANVAS);
-      var ctx = renderer.getContext();
-      for (var j=0; j < 20; j++)
-        (new Vex.Flow.Stave(
-          Math.floor(Math.random()*canvas.width),
-          Math.floor(Math.random()*canvas.height),
-          Math.floor(Math.random()*canvas.width)
-        )).addClef("treble")
-          .setContext(ctx)
-          .draw();
-    }
-  );
-  repeat(
-    "[VexFlow] Draw systems", 50,
-    "Draw 20 empty staves on a huge canvas (one instrument).",
-    function(){
-      var canvas = document.createElement("canvas");
-      canvas.width = 1920;
-      canvas.height = 1080 * 30;
-      var renderer = new Vex.Flow.Renderer(canvas, Vex.Flow.Renderer.Backends.CANVAS);
-      var ctx = renderer.getContext();
-      for (var j=0; j < 20; j++)
-        (new Vex.Flow.Stave(
-          Math.floor(Math.random()*canvas.width),
-          Math.floor(Math.random()*canvas.height),
-          Math.floor(Math.random()*canvas.width)
-        )).addClef("treble")
-          .setContext(ctx)
-          .draw();
-    }
-  );
-  repeat(
-    "[VexFlow] Format & draw complex system", 50,
-    "Draw 20 staves with one voice, ties and beams on a big canvas.",
-    function(){
-      var canvas = document.createElement("canvas");
-      canvas.width = 1920;
-      canvas.height = 1080;
-      var renderer = new Vex.Flow.Renderer(canvas, Vex.Flow.Renderer.Backends.CANVAS);
-      var ctx = renderer.getContext();
-      for (var j=0; j < 20; j++) {
-        var stave = new Vex.Flow.Stave(10, 0, 500);
-
-        // From the VexFlow Tutorial:
-        stave.addClef("treble");
-        stave.setContext(ctx).draw();
-
-        var notes = [
-          new Vex.Flow.StaveNote({ keys: ["e##/5"], duration: "8d" }).
-            addAccidental(0, new Vex.Flow.Accidental("##")).addDotToAll(),
-          new Vex.Flow.StaveNote({ keys: ["b/4"], duration: "16" }).
-            addAccidental(0, new Vex.Flow.Accidental("b"))
-        ];
-
-        var notes2 = [
-          new Vex.Flow.StaveNote({ keys: ["b/4"], duration: "8" }),
-          new Vex.Flow.StaveNote({ keys: ["d/4"], duration: "16" }),
-          new Vex.Flow.StaveNote({ keys: ["c/4", "e/4"], duration: "16" }).
-            addAccidental(0, new Vex.Flow.Accidental("b"))
-        ];
-
-        var notes3 = [
-          new Vex.Flow.StaveNote({ keys: ["c/4", "e/4"], duration: "8" }),
-          new Vex.Flow.StaveNote({ keys: ["e/4"], duration: "8" }).
-            addAccidental(0, new Vex.Flow.Accidental("#"))
-        ];
-
-        var notes4 = [
-          new Vex.Flow.StaveNote({ keys: ["d/4"], duration: "8" }),
-          new Vex.Flow.StaveNote({ keys: ["e/4"], duration: "8" }),
-        ];
-
-        // Create the beams
-        var beam = new Vex.Flow.Beam(notes);
-        var beam2 = new Vex.Flow.Beam(notes2);
-        var beam3 = new Vex.Flow.Beam(notes3);
-        var beam4 = new Vex.Flow.Beam(notes4);
-
-        // Create a tie between the last note of the first group and the
-        // first note of the last group.
-        var tie = new Vex.Flow.StaveTie({
-          first_note: notes[1],
-          last_note: notes2[0],
-          first_indices: [0],
-          last_indices: [0]
-        });
-
-        // Create another tie between the two chords in the tune
-        var tie2 = new Vex.Flow.StaveTie({
-          first_note: notes2[2],
-          last_note: notes3[0],
-          first_indices: [0, 1],
-          last_indices: [0, 1]
-        });
-
-        var all_notes = notes.concat(notes2).concat(notes3).concat(notes4);
-
-        // Helper function to justify and draw a 4/4 voice
-        Vex.Flow.Formatter.FormatAndDraw(ctx, stave, all_notes);
-
-        // Render beams
-        beam.setContext(ctx).draw();
-        beam2.setContext(ctx).draw();
-        beam3.setContext(ctx).draw();
-        beam4.setContext(ctx).draw();
-
-        // Render ties
-        tie.setContext(ctx).draw();
-        tie2.setContext(ctx).draw();
-      }
-    }
-  );
-  repeat(
-    "[VexFlow|big] Format & draw 20 staves 5 voices each.", 50,
-    "...",
-    function(){
-      var canvas = document.createElement("canvas");
-      canvas.width = 1920;
-      canvas.height = 1080;
-      var renderer = new Vex.Flow.Renderer(canvas, Vex.Flow.Renderer.Backends.CANVAS);
-      var ctx = renderer.getContext();
-      for (var j=0; j < 20; j++) {
-        var stave = new Vex.Flow.Stave(
-          Math.floor(Math.random()*canvas.width),
-          Math.floor(Math.random()*canvas.height),
-          Math.floor(Math.random()*canvas.width)
-        );
-        stave.addClef("treble");
-        stave.setContext(ctx).draw();
-        var voices = [];
-        for (var i = 0, voice; i < 5; i++) {
-          voice = new Vex.Flow.Voice({
-            num_beats: 4,
-            beat_value: 4,
-            resolution: Vex.Flow.RESOLUTION
-          });
-          voice.addTickables(randomNotes());
-          voices.push(voice);
-        }
-        var formatter = new Vex.Flow.Formatter().
-        joinVoices(voices).format(voices, 500);
-        for (var i = 0; i < 5; i++) {
-          voices[i].draw(ctx, stave);
-        }
-      }
-    }
-  );
-  repeat(
-    "[VexFlow|huge] Format & draw 20 staves with 5 voices each.", 50,
-    "...",
-    function(){
-      var canvas = document.createElement("canvas");
-      canvas.width = 1920;
-      canvas.height = 1080 * 30;
-      var renderer = new Vex.Flow.Renderer(canvas, Vex.Flow.Renderer.Backends.CANVAS);
-      var ctx = renderer.getContext();
-      for (var j=0; j < 20; j++) {
-        var stave = new Vex.Flow.Stave(
-          Math.floor(Math.random()*canvas.width),
-          Math.floor(Math.random()*canvas.height),
-          Math.floor(Math.random()*canvas.width)
-        );
-        stave.addClef("treble");
-        stave.setContext(ctx).draw();
-        var voices = [];
-        for (var i = 0, voice; i < 5; i++) {
-          voice = new Vex.Flow.Voice({
-            num_beats: 4,
-            beat_value: 4,
-            resolution: Vex.Flow.RESOLUTION
-          });
-          voice.addTickables(randomNotes());
-          voices.push(voice);
-        }
-        var formatter = new Vex.Flow.Formatter().
-        joinVoices(voices).format(voices, 500);
-        for (var i = 0; i < 5; i++) {
-          voices[i].draw(ctx, stave);
-        }
-      }
-    }
-  );
-
-  var tmp_canvas = document.createElement("canvas");
-  tmp_canvas.width = 1920;
-  tmp_canvas.height = 1080;
-  var tmp_renderer = new Vex.Flow.Renderer(tmp_canvas, Vex.Flow.Renderer.Backends.CANVAS);
-  var ctx = tmp_renderer.getContext();
-  repeat(
-    "[VexFlow|big] Format & draw system", 50,
-    "Draw a measure with a voice.",
-    function(){
-      var stave = new Vex.Flow.Stave(
-        Math.floor(Math.random()*tmp_canvas.width),
-        Math.floor(Math.random()*tmp_canvas.height),
-        Math.floor(Math.random()*tmp_canvas.width)
-      );
-
-      // From the VexFlow Tutorial:
-      stave.addClef("treble");
-      stave.setContext(ctx).draw();
-
-      var notes = [
-        new Vex.Flow.StaveNote({ keys: ["e##/5"], duration: "8d" }).
-        addAccidental(0, new Vex.Flow.Accidental("##")).addDotToAll(),
-        new Vex.Flow.StaveNote({ keys: ["b/4"], duration: "16" }).
-        addAccidental(0, new Vex.Flow.Accidental("b"))
-      ];
-
-      var notes2 = [
-        new Vex.Flow.StaveNote({ keys: ["b/4"], duration: "8" }),
-        new Vex.Flow.StaveNote({ keys: ["d/4"], duration: "16" }),
-        new Vex.Flow.StaveNote({ keys: ["c/4", "e/4"], duration: "16" }).
-        addAccidental(0, new Vex.Flow.Accidental("b"))
-      ];
-
-      var notes3 = [
-        new Vex.Flow.StaveNote({ keys: ["c/4", "e/4"], duration: "8" }),
-        new Vex.Flow.StaveNote({ keys: ["e/4"], duration: "8" }).
-        addAccidental(0, new Vex.Flow.Accidental("#"))
-      ];
-
-      var notes4 = [
-        new Vex.Flow.StaveNote({ keys: ["d/4"], duration: "8" }),
-        new Vex.Flow.StaveNote({ keys: ["e/4"], duration: "8" }),
-      ];
-
-      // Create the beams
-      var beam = new Vex.Flow.Beam(notes);
-      var beam2 = new Vex.Flow.Beam(notes2);
-      var beam3 = new Vex.Flow.Beam(notes3);
-      var beam4 = new Vex.Flow.Beam(notes4);
-
-      // Create a tie between the last note of the first group and the
-      // first note of the last group.
-      var tie = new Vex.Flow.StaveTie({
-        first_note: notes[1],
-        last_note: notes2[0],
-        first_indices: [0],
-        last_indices: [0]
-      });
-
-      // Create another tie between the two chords in the tune
-      var tie2 = new Vex.Flow.StaveTie({
-        first_note: notes2[2],
-        last_note: notes3[0],
-        first_indices: [0, 1],
-        last_indices: [0, 1]
-      });
-
-      var all_notes = notes.concat(notes2).concat(notes3).concat(notes4);
-
-      // Helper function to justify and draw a 4/4 voice
-      Vex.Flow.Formatter.FormatAndDraw(ctx, stave, all_notes);
-
-      // Render beams
-      beam.setContext(ctx).draw();
-      beam2.setContext(ctx).draw();
-      beam3.setContext(ctx).draw();
-      beam4.setContext(ctx).draw();
-
-      // Render ties
-      tie.setContext(ctx).draw();
-      tie2.setContext(ctx).draw();
-    }
-  );
-  var tmp_c1 = document.createElement("canvas");
-  tmp_c1.width = 1920;
-  tmp_c1.height = 1080 * 30;
-  repeat(
-    "[VexFlow | huge] Format & draw 20 staves with 5 voices each, reusing the canvas.", 50,
-    "...",
-    function(){
-      var canvas = tmp_c1;
-      var renderer = new Vex.Flow.Renderer(canvas, Vex.Flow.Renderer.Backends.CANVAS);
-      var ctx = renderer.getContext();
-      for (var j=0; j < 20; j++) {
-        var stave = new Vex.Flow.Stave(
-          Math.floor(Math.random()*canvas.width),
-          Math.floor(Math.random()*canvas.height),
-          Math.floor(Math.random()*canvas.width)
-        );
-        stave.addClef("treble");
-        stave.setContext(ctx).draw();
-        var voices = [];
-        for (var i = 0, voice; i < 5; i++) {
-          voice = new Vex.Flow.Voice({
-            num_beats: 4,
-            beat_value: 4,
-            resolution: Vex.Flow.RESOLUTION
-          });
-          voice.addTickables(randomNotes());
-          voices.push(voice);
-        }
-        var formatter = new Vex.Flow.Formatter().
-        joinVoices(voices).format(voices, 500);
-        for (var i = 0; i < 5; i++) {
-          voices[i].draw(ctx, stave);
-        }
-      }
-    }
-  );
-
-  var tmp_c1 = document.createElement("canvas");
-  tmp_c1.width = 1920;
-  tmp_c1.height = 100;
-  repeat(
-    "[VexFlow | normal] Format & draw 20 staves with 5 voices each, reusing the canvas.", 50,
-    "...",
-    function(){
-      var canvas = tmp_c1;
-      var renderer = new Vex.Flow.Renderer(canvas, Vex.Flow.Renderer.Backends.CANVAS);
-      var ctx = renderer.getContext();
-      for (var j=0; j < 20; j++) {
-        var stave = new Vex.Flow.Stave(
-          Math.floor(Math.random()*canvas.width),
-          Math.floor(Math.random()*canvas.height),
-          Math.floor(Math.random()*canvas.width)
-        );
-        stave.addClef("treble");
-        stave.setContext(ctx).draw();
-        var voices = [];
-        for (var i = 0, voice; i < 5; i++) {
-          voice = new Vex.Flow.Voice({
-            num_beats: 4,
-            beat_value: 4,
-            resolution: Vex.Flow.RESOLUTION
-          });
-          voice.addTickables(randomNotes());
-          voices.push(voice);
-        }
-        var formatter = new Vex.Flow.Formatter().
-        joinVoices(voices).format(voices, 500);
-        for (var i = 0; i < 5; i++) {
-          voices[i].draw(ctx, stave);
-        }
-      }
-    }
-  );
-
-  finish(t);
-}
-
-//----------------------------------------------------------------------------->
-// Helper functions
-
-// Init function
-window.onload = function () {
-  window.setTimeout(start, 0);
-}
-
-var randomNotes = function () {
-  var notes = [];
-  for (var i = 0, note, key; i < 8; i ++) {
-    key = ("abcdefg".charAt(Math.floor(Math.random()*7))) + "/" + Math.floor(Math.random()*3+2);
-    note = new Vex.Flow.StaveNote({ keys: [key], duration: "8" });
-    notes.push(note);
-  }
-  return notes;
-}
-
-
-//----------------------------------------------------------------------------->
-var finish = function (t) {
-  window.setTimeout(function(){
-    write("<hr><p><b>Total Elapsed Time: ~" + Math.floor(t()/1000) + " seconds.</b></p>");
-    document.close();
-  }, 0);
-}
-
-
-// Display the result of a test on the page
-function formatResult(label, descr, times, elapsed) {
-  write("<p><b>" + label + "</b>: " + descr + "<br>");
-  write("<i>Elapsed time: " + (elapsed/times) + "ms each (" + times + " iterations)</i></Op>");
-}
-
-// A simple timer
-var timer = function() {
-    var start = new Date();
-    return function() {
-      return (new Date()).getTime() - start.getTime();
-    }
-}
-
-// Repeat a test
-var repeat0 = function(label, times, descr, func) {
-  //debugger;
-  var t = timer();
-  for (var i = 0; i < times; i++) func();
-  formatResult(label, descr, times, t());
-}
-var repeat = function(label, times, descr, func) {
-  window.setTimeout(function(){
-    repeat0(label, times, descr, func);
-  }, 0);
-}
-
-var write = function(x) {
-  var div = document.createElement("div");
-  div.innerHTML = x;
-  document.body.appendChild(div);
-}
-//----------------------------------------------------------------------------->
-}());</script><!--------------------------------------------------------------->
-<script src="../node_modules/vexflow/releases/vexflow-min.js"></script><!------>
-</head></html><!--------------------------------------------------------------->

+ 0 - 206
experiments/cursor.html

@@ -1,206 +0,0 @@
-<!doctype html>
-<html>
-<head>
-  <title>Playback &gt; Cursor Experiment</title>
-  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
-  <style>
-    html, body {
-      padding: 0; margin: 0;
-    }
-    div.big {
-      font-size: 10em;
-      text-align: center;
-      background: url('cat.png');
-      text-shadow: 1px 1px 1px black;
-      color: white;
-    }
-    div.rep1 {
-      position: fixed;
-      top: 0;
-      left: 0; right: 0;
-      overflow: hidden;
-      box-shadow: 0 0 20px black;
-      background-color: white;
-    }
-  </style>
-
-<script>(function(){
-// The layers
-var rep1, main;
-var lines = [];
-var nlines = 3 + Math.floor(Math.random() * 4);
-var current = 0; // current line
-var currentWidth = 0; // the width of current line
-var currentHeight = 0;
-var heightSum = 0;
-var currentX = 0; // x of the cursor
-var dx = 20;
-var cursor;
-var interval;
-
-function Cursor() {
-  var cursor1 = document.createElement("img");
-  var cursor2 = document.createElement("img");
-  // Public
-  this.cursor1 = cursor1;
-  this.cursor2 = cursor2;
-  // Set position
-  cursor1.style.position = "absolute";
-  cursor2.style.position = "fixed";
-  // Set z-indices
-  cursor1.style.zIndex = "-1";
-  cursor2.style.zIndex = "-1";
-
-  // Generate a gradient
-  this.style = function (width, height, color) {
-    var c = document.createElement("canvas");
-    c.width = width; c.height = height;
-    var ctx = c.getContext("2d");
-    ctx.globalAlpha = 0.5
-    // Generate the gradient
-    var gradient = ctx.createLinearGradient(0, 0, width, 0);
-    gradient.addColorStop(0, "transparent");
-    gradient.addColorStop(0.5, color);
-    gradient.addColorStop(1, "transparent");
-    ctx.fillStyle = gradient;
-    ctx.fillRect(0, 0, width, height);
-    // Set the images
-    cursor1.src = cursor2.src = c.toDataURL('image/png');
-    cursor1.width  = cursor2.width  = width ;
-    cursor1.height = cursor2.height = height;
-  }
-
-  // Set positions
-  this.set = function (x, y) {
-    cursor1.style.top = heightSum + "px";
-    cursor1.style.left = currentX + "px";
-    cursor2.style.top = heightSum + "px";
-    cursor2.style.left = currentX + "px";
-  }
-  // Display
-  this.show2 = function (vis) {
-    if (vis) {
-      cursor2.style.display = "block";
-    } else {
-      cursor2.style.display = "none";
-    }
-  }
-}
-
-window.onload = function() {
-  window.resizeTo(650, 650);
-
-  cursor = new Cursor();
-
-  rep1 = document.createElement("div");
-  rep1.className = "rep1";
-
-  var helper = document.createElement("div");
-  helper.className = "helper";
-
-  rep1.appendChild(cursor.cursor2);
-  rep1.appendChild(helper);
-
-  main = document.createElement("div");
-  main.className = "main";
-
-  document.body.appendChild(cursor.cursor1);
-  document.body.appendChild(main);
-  document.body.appendChild(rep1);
-
-  //rep1.style.display = "none";
-  // z-indices
-  //main.style.zIndex = "1";
-  //rep1.style.zIndex = "1";
-  //main.style.background = "green";
-  //
-  lines = [];
-  var els = [main, helper];
-  // fix div colors
-  for (var i = 0; i < nlines; i++)
-    for (var j = 0; j < els.length; j ++) {
-    var div = document.createElement("div");
-    div.className = "big";
-    if (j === 0)
-      lines.push(div);
-    els[j].appendChild(div);
-    div.innerHTML = (i ? "&nbsp;" : ":") + (i + 1) + (i !== nlines - 1 ? "&nbsp;" : ":");
-  }
-  // Initialize variabels
-  heightSum = 0;
-  currentX = 0; currentWidth = -1; current = -1;
-  currentHeight = 0;
-  window.setTimeout(init, 1);
-}
-
-function init() {
-  // Fix height
-  rep1.style.height = Math.floor(window.innerHeight / 2) + "px";
-  // start animation
-  interval = window.setInterval(step, 20);
-}
-
-function step () {
-  currentX += dx;
-  // We need to go to another staff line
-  if (currentX > currentWidth) {
-    heightSum += currentHeight;
-    currentX = 0;
-    current += 1;
-    if (current == lines.length) {
-      //window.clearInterval(interval);
-      //return false;
-      current = 0;
-      heightSum = 0;
-    }
-    if (current === lines.length - 1) {
-      console.log("Last line: repeat");
-      showRep1(0);
-    }
-    var thenHideSep1 = (current === 0);
-    window.setTimeout(function(){scrollToLine(current, thenHideSep1);}, 0);
-    currentWidth = lines[current].offsetWidth - 20;
-    currentHeight = lines[current].offsetHeight;
-    // Re-generate cursor
-    cursor.style(20, currentHeight, "black");
-  }
-  cursor.set(heightSum, currentX);
-}
-
-function scrollToLine(line, thenHideSep1) {
-  var height = lines[line].offsetHeight;
-  var windowHeight = window.innerHeight;
-  var top = Math.max(0, (windowHeight - height) >> 1);
-  //window.scrollTo(0, heightSum + top);
-  if (thenHideSep1) {
-    // Put the cursor on Sep1
-    cursor.show2(true);
-    $('html, body').animate({
-          scrollTop: heightSum - top
-      }, 500, function() {
-        showRep1();
-      });
-  } else {
-    $('html, body').animate({
-          scrollTop: heightSum - top
-      }, 500);
-  }
-}
-
-// Show or hide repetition view
-function showRep1(line) {
-  if (typeof line !== "undefined") {
-    rep1.scrollTop = 0;
-    //rep1.style.display = "block";
-    $(rep1).fadeIn("slow");
-  } else {
-    // rep1.style.display = "none";
-    $(rep1).fadeOut("fast");
-    cursor.show2(false);
-  }
-}
-
-}());
-</script>
-</head>
-</html>

+ 0 - 181
extras/macrogen.py

@@ -1,181 +0,0 @@
-import xml.etree.ElementTree as ET
-import re, sys, os
-
-replace = (
-    ("Math\\.Max\\(", "Math.max("),
-    ("Math\\.Min\\(", "Math.min("),
-    ("Math\\.Sqrt\\(", "Math.sqrt("),
-    ("Math\\.Abs\\(", "Math.abs("),
-    ("Math\\.Pow\\(", "Math.pow("),
-    ("Math\\.Ceiling", "Math.ceil"),
-    ("Math\\.Floor", "Math.floor"),
-
-    ("var ", "let "),
-
-    # Lists --> Arrays
-    ("new List<List<([a-zA-Z]*)>>\(\)", "[]"),
-    ("List<List<([a-zA-Z]*)>>", "$1[][]"),
-    ("new List<([a-zA-Z]*)>\(\)", "[]"),
-    ("List<([a-zA-Z]*)>", "$1[]"),
-
-    # Dictionaries:
-    ("new Dictionary<number, ([a-zA-Z0-9\\[\\]\\.]*)>\\(\\)", "{}"),
-    ("Dictionary<number, ([a-zA-Z0-9\\[\\]\\.]*)>", "{ [_: number]: $1; }"),
-    ("new Dictionary<string, ([a-zA-Z0-9\\[\\]\\.]*)>\\(\\)", "{}"),
-    ("Dictionary<string, ([a-zA-Z0-9\\[\\]\\.]*)>", "{ [_: string]: $1; }"),
-
-    ("IEnumerable<([a-zA-Z0-9]+)>", "$1[]"),
-
-    ("\\.Count", ".length"),
-    ("\\.Length", ".length"),
-    ("\\.Add\(", ".push("),
-    ("\\.First\(\)", "[0]"),
-
-    ("\\.Insert\((.*), (.*)\)", ".splice($1, 0, $2)"),
-    ("\\.RemoveAt\(([a-z|0-9]+)\)", ".splice($1, 1)"),
-    ("\\.Clear\(\);", ".length = 0;"),
-    ("\\.IndexOf", ".indexOf"),
-    ("\\.ToArray\\(\\)", ""),
-    ("\\.ContainsKey", ".hasOwnProperty"),
-
-    ("\\.Contains\(([a-zA-Z0-9.]+)\)", ".indexOf($1) !== -1"),
-
-    ("for each(?:[ ]*)\(([a-z|0-9]+) ([a-z|0-9]+) in ([a-z|0-9]+)\)", "for ($2 of $3)"),
-    (", len([0-9]*) = ", ", len$1: number = "),
-
-    (" == ", " === "),
-    (" != ", " !== "),
-    ("null", "undefined"),
-
-    ("\\.ToLower\(\)", ".toLowerCase()"),
-
-    ("Logger\\.DefaultLogger\\.LogError\(LogLevel\\.DEBUG,(?:[ ]*)", "Logging.debug("),
-    ("Logger\\.DefaultLogger\\.LogError\(LogLevel\\.NORMAL,(?:[ ]*)", "Logging.log("),
-    ("Logger\\.DefaultLogger\\.LogError\(PhonicScore\\.Common\\.Enums\\.LogLevel\\.NORMAL,(?:[ ]*)", "Logging.log("),
-
-    ("Fraction\\.CreateFractionFromFraction\(([a-z|0-9]+)\)", "$1.clone()"),
-
-    ("(\d{1})f([,;)\]} ])", "$1$2"),
-    ("number\\.MaxValue", "Number.MAX_VALUE"),
-    ("Int32\\.MaxValue", "Number.MAX_VALUE"),
-    ("number\\.MinValue", "Number.MIN_VALUE"),
-
-    ("__as__<([A-Za-z|0-9]+)>\(([A-Za-z|0-9.]+), ([A-Za-z|0-9]+)\)", "($2 as $3)"),
-
-    ("new Dictionary<number, number>\(\)", "{}"),
-    (": Dictionary<number, number>", ": {[_: number]: number; }"),
-
-    ("String\\.Empty", '""'),
-    ("return\\n", "return;\n"),
-
-    ("}(\n[ ]*)else ", "} else "),
-
-    ("\\.IdInMusicSheet", ".idInMusicSheet"),
-    ("F_2D", "F2D"),
-    ("List<Tuple<Object\\[\\], Object>>", "[Object[], Object][]")
-)
-
-def checkForIssues(filename, content):
-    if ".Last()" in content:
-        print("      !!! Warning: .Last() found !!!")
-
-def applyAll():
-    root = sys.argv[1]
-    filenames = []
-    recurse(root, filenames)
-    # if os.path.isdir(root):
-    #     recurse(root, filenames)
-    # else:
-    #     filenames.append(root)
-
-    print("Apply replacements to:")
-    for filename in filenames:
-        print("  >>> " + os.path.basename(filename))
-        content = None
-        with open(filename) as f:
-            content = f.read()
-        checkForIssues(filename, content)
-        for rep in replace:
-            content = re.sub(rep[0], pythonic(rep[1]), content)
-        with open(filename, "w") as f:
-            f.write(content)
-    print("Done.")
-
-def recurse(folder, files):
-    if os.path.isfile(folder):
-        files.append(folder)
-    if os.path.isdir(folder):
-        for i in os.listdir(folder):
-            recurse(os.path.join(folder, i), files)
-
-def keycode(c):
-    if len(c) > 1:
-        return ";".join(keycode(i) for i in c)
-    if c.isalpha():
-        return str(ord(c.upper())) + ":" + ("1" if c.isupper() else "0")
-    if c.isdigit():
-        return str(48 + int(c)) + ":0"
-    return {'!': '49:1', '#': '51:1', '%': '53:1', '$': '52:1', "'": '222:0', '&': '55:1', ')': '48:1', '(': '57:1', '+': '61:1', '*': '56:1', '-': '45:0', ',': '44:0', '/': '47:0', '.': '46:0', ';': '59:0', ':': '59:1', '=': '61:0', '@': '50:1', '[': '91:0', ']': '93:0', '\\': '92:0', '_': '45:1', '^': '54:1', 'a': '65:0', '<': '44:1', '>': '46', ' ': "32:0", "|": "92:1", "?": "47:1", "{": "91:1", "}": "93:1"}[c]
-
-def escape(s):
-    return s
-    return s.replace("&", "&amp;").replace(">", "&gt;").replace("<", "&lt;")
-
-def generate():
-    N = 0
-    macroName = "TypeScript'ing Replacements"
-    macro = ET.Element("macro")
-    macro.set("name", macroName)
-    replace = (("ABCDEfGHIJKL", "ABCDEfGHIJKL"),) + replace
-    for rep in replace:
-        N += 1
-        # result.append('<macro name="%d">' % N)
-        ET.SubElement(macro, "action").set("id", "$SelectAll")
-        ET.SubElement(macro, "action").set("id", "Replace")
-        for s in rep[0]:
-            t = ET.SubElement(macro, "typing")
-            t.set("text-keycode", keycode(s))
-            t.text = escape(s)
-        ET.SubElement(macro, "shortuct").set("text", "TAB")
-        for s in rep[1]:
-            t = ET.SubElement(macro, "typing")
-            t.set("text-keycode", keycode(s))
-            t.text = escape(s)
-        # result.append('<action id="EditorEnter" />' * 50)
-        for i in range(50):
-            ET.SubElement(macro, "shortuct").set("text", "ENTER")
-        ET.SubElement(macro, "shortuct").set("text", "ESCAPE")
-
-
-    path = '/Users/acondolu/Library/Preferences/WebStorm11/options/macros.xml'
-    tree = None
-    try:
-        tree = ET.parse(path)
-    except IOError:
-        print("Cannot find macro file.")
-        sys.exit(1)
-    component = tree.getroot().find("component")
-    assert component.get("name") == "ActionMacroManager"
-    found = None
-    for m in component.iter("macro"):
-        if m.get("name") == macroName:
-            found = m
-            break
-    if found is not None:
-        component.remove(found)
-
-    component.append(macro)
-
-    tree.write(path)
-    print("Macro written on " + path)
-
-def pythonic(s):
-    return s.replace("$", "\\")
-
-if __name__ == "__main__":
-    if len(sys.argv) != 2:
-        print("Usage: python macrogen.py path/to/files")
-        sys.exit(1)
-        # generate()
-    else:
-        applyAll()

+ 1 - 0
src/OSMD/Cursor.ts

@@ -27,6 +27,7 @@ export class Cursor {
 
     public init(manager: MusicPartManager, graphic: GraphicalMusicSheet): void {
         this.iterator = manager.getIterator();
+        this.iterator.moveToNext();
         this.graphic = graphic;
         this.hidden = true;
         this.hide();