abcjs 6.1.8 → 6.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2543,8 +2543,14 @@ var create;
2543
2543
  case 'program':
2544
2544
  var pan = 0;
2545
2545
  if (options.pan && options.pan.length > i) pan = options.pan[i];
2546
- midi.setChannel(event.channel, pan);
2547
- midi.setInstrument(event.instrument);
2546
+ if (event.instrument === 128) {
2547
+ // If we're using the percussion voice, change to Channel 10
2548
+ midi.setChannel(9, pan);
2549
+ midi.setInstrument(0);
2550
+ } else {
2551
+ midi.setChannel(event.channel, pan);
2552
+ midi.setInstrument(event.instrument);
2553
+ }
2548
2554
  break;
2549
2555
  case 'note':
2550
2556
  var gapLengthInBeats = event.gap * beatsPerSecond;
@@ -6978,7 +6984,7 @@ function durationOfMeasure(multilineVars) {
6978
6984
  if (!meter.value || meter.value.length === 0) return 1;
6979
6985
  return parseInt(meter.value[0].num, 10) / parseInt(meter.value[0].den, 10);
6980
6986
  }
6981
- var legalAccents = ["trill", "lowermordent", "uppermordent", "mordent", "pralltriller", "accent", "fermata", "invertedfermata", "tenuto", "0", "1", "2", "3", "4", "5", "+", "wedge", "open", "thumb", "snap", "turn", "roll", "breath", "shortphrase", "mediumphrase", "longphrase", "segno", "coda", "D.S.", "D.C.", "fine", "beambr1", "beambr2", "slide", "marcato", "upbow", "downbow", "/", "//", "///", "////", "trem1", "trem2", "trem3", "trem4", "turnx", "invertedturn", "invertedturnx", "trill(", "trill)", "arpeggio", "xstem", "mark", "umarcato", "style=normal", "style=harmonic", "style=rhythm", "style=x", "style=triangle"];
6987
+ var legalAccents = ["trill", "lowermordent", "uppermordent", "mordent", "pralltriller", "accent", "fermata", "invertedfermata", "tenuto", "0", "1", "2", "3", "4", "5", "+", "wedge", "open", "thumb", "snap", "turn", "roll", "breath", "shortphrase", "mediumphrase", "longphrase", "segno", "coda", "D.S.", "D.C.", "fine", "beambr1", "beambr2", "slide", "marcato", "upbow", "downbow", "/", "//", "///", "////", "trem1", "trem2", "trem3", "trem4", "turnx", "invertedturn", "invertedturnx", "trill(", "trill)", "arpeggio", "xstem", "mark", "umarcato", "style=normal", "style=harmonic", "style=rhythm", "style=x", "style=triangle", "D.C.alcoda", "D.C.alfine", "D.S.alcoda", "D.S.alfine", "editorial", "courtesy"];
6982
6988
  var volumeDecorations = ["p", "pp", "f", "ff", "mf", "mp", "ppp", "pppp", "fff", "ffff", "sfz"];
6983
6989
  var dynamicDecorations = ["crescendo(", "crescendo)", "diminuendo(", "diminuendo)", "glissando(", "glissando)"];
6984
6990
  var accentPseudonyms = [["<", "accent"], [">", "accent"], ["tr", "trill"], ["plus", "+"], ["emphasis", "accent"], ["^", "umarcato"], ["marcato", "umarcato"]];
@@ -8932,7 +8938,15 @@ transpose.keySignature = function (multilineVars, keyName, root, acc, localTrans
8932
8938
  baseKey += keyName[1];
8933
8939
  keyName = keyName.substr(2);
8934
8940
  } else keyName = keyName.substr(1);
8935
- var index = keyIndex[baseKey] + multilineVars.localTranspose;
8941
+ var thisKeyIndex = keyIndex[baseKey];
8942
+ var recognized = thisKeyIndex !== undefined;
8943
+ if (!recognized) {
8944
+ // Either the key sig is "none" or we don't recognize it. Either way we don't change it, and we assume key of C for the purposes of this calculation.
8945
+ thisKeyIndex = 0;
8946
+ baseKey = "C";
8947
+ keyName = "";
8948
+ }
8949
+ var index = thisKeyIndex + multilineVars.localTranspose;
8936
8950
  while (index < 0) {
8937
8951
  index += 12;
8938
8952
  }
@@ -8959,10 +8973,14 @@ transpose.keySignature = function (multilineVars, keyName, root, acc, localTrans
8959
8973
  }
8960
8974
  }
8961
8975
  if (multilineVars.localTranspose > 0) multilineVars.localTransposeVerticalMovement = distance + Math.floor(multilineVars.localTranspose / 12) * 7;else multilineVars.localTransposeVerticalMovement = distance + Math.ceil(multilineVars.localTranspose / 12) * 7;
8962
- return {
8976
+ if (recognized) return {
8963
8977
  accidentals: newKeySig,
8964
8978
  root: newKeyName[0],
8965
8979
  acc: newKeyName.length > 1 ? newKeyName[1] : ""
8980
+ };else return {
8981
+ accidentals: [],
8982
+ root: root,
8983
+ acc: acc
8966
8984
  };
8967
8985
  };
8968
8986
  transpose.chordName = function (multilineVars, chord) {
@@ -9014,7 +9032,7 @@ var accidentals3 = {
9014
9032
  "1": "^",
9015
9033
  "2": "^^"
9016
9034
  };
9017
- var count = 0;
9035
+ //var count = 0
9018
9036
  transpose.note = function (multilineVars, el) {
9019
9037
  // the "el" that is passed in has el.name, el.accidental, and el.pitch. "pitch" is the vertical position (0=middle C)
9020
9038
  // localTranspose is the number of half steps
@@ -12692,7 +12710,7 @@ var parseCommon = __webpack_require__(/*! ../parse/abc_common */ "./src/parse/ab
12692
12710
  (function () {
12693
12711
  "use strict";
12694
12712
 
12695
- var measureLength;
12713
+ var measureLength = 1; // This should be set by the meter, but just in case that is missing, we'll take a guess.
12696
12714
  // The abc is provided to us line by line. It might have repeats in it. We want to re arrange the elements to
12697
12715
  // be an array of voices with all the repeats embedded, and no lines. Then it is trivial to go through the events
12698
12716
  // one at a time and turn it into midi.
@@ -18829,7 +18847,7 @@ var stackedDecoration = function stackedDecoration(decoration, width, abselem, y
18829
18847
  }
18830
18848
  return y;
18831
18849
  }
18832
- function textDecoration(text, placement) {
18850
+ function textDecoration(text, placement, anchor) {
18833
18851
  var y = getPlacement(placement);
18834
18852
  var textFudge = 2;
18835
18853
  var textHeight = 5;
@@ -18837,7 +18855,8 @@ var stackedDecoration = function stackedDecoration(decoration, width, abselem, y
18837
18855
  abselem.addFixedX(new RelativeElement(text, width / 2, 0, y + textFudge, {
18838
18856
  type: "decoration",
18839
18857
  klass: 'ornament',
18840
- thickness: 3
18858
+ thickness: 3,
18859
+ anchor: anchor
18841
18860
  }));
18842
18861
  incrementPlacement(placement, textHeight);
18843
18862
  }
@@ -18894,11 +18913,27 @@ var stackedDecoration = function stackedDecoration(decoration, width, abselem, y
18894
18913
  case "5":
18895
18914
  case "D.C.":
18896
18915
  case "D.S.":
18897
- textDecoration(decoration[i], positioning);
18916
+ textDecoration(decoration[i], positioning, 'middle');
18917
+ hasOne = true;
18918
+ break;
18919
+ case "D.C.alcoda":
18920
+ textDecoration("D.C. al coda", positioning, 'left');
18921
+ hasOne = true;
18922
+ break;
18923
+ case "D.C.alfine":
18924
+ textDecoration("D.C. al fine", positioning, 'left');
18925
+ hasOne = true;
18926
+ break;
18927
+ case "D.S.alcoda":
18928
+ textDecoration("D.S. al coda", positioning, 'left');
18929
+ hasOne = true;
18930
+ break;
18931
+ case "D.S.alfine":
18932
+ textDecoration("D.S. al fine", positioning, 'left');
18898
18933
  hasOne = true;
18899
18934
  break;
18900
18935
  case "fine":
18901
- textDecoration("FINE", positioning);
18936
+ textDecoration("FINE", positioning, 'middle');
18902
18937
  hasOne = true;
18903
18938
  break;
18904
18939
  case "+":
@@ -20049,6 +20084,7 @@ var RelativeElement = function RelativeElement(c, dx, w, pitch, opt) {
20049
20084
  this.pitch2 = opt.pitch2;
20050
20085
  this.linewidth = opt.linewidth;
20051
20086
  this.klass = opt.klass;
20087
+ this.anchor = opt.anchor ? opt.anchor : 'middle';
20052
20088
  this.top = pitch;
20053
20089
  if (this.pitch2 !== undefined && this.pitch2 > this.top) this.top = this.pitch2;
20054
20090
  this.bottom = pitch;
@@ -22171,7 +22207,7 @@ function drawRelativeElement(renderer, params, bartop) {
22171
22207
  text: params.c,
22172
22208
  type: 'annotationfont',
22173
22209
  klass: renderer.controller.classes.generate("annotation"),
22174
- anchor: "middle",
22210
+ anchor: params.anchor,
22175
22211
  centerVertically: true,
22176
22212
  dim: params.dim
22177
22213
  }, false);
@@ -24566,9 +24602,15 @@ function setupSelection(engraver, svgs) {
24566
24602
  }
24567
24603
  }
24568
24604
  for (var i = 0; i < svgs.length; i++) {
24569
- svgs[i].addEventListener('touchstart', mouseDown.bind(engraver));
24570
- svgs[i].addEventListener('touchmove', mouseMove.bind(engraver));
24571
- svgs[i].addEventListener('touchend', mouseUp.bind(engraver));
24605
+ svgs[i].addEventListener('touchstart', mouseDown.bind(engraver), {
24606
+ passive: true
24607
+ });
24608
+ svgs[i].addEventListener('touchmove', mouseMove.bind(engraver), {
24609
+ passive: true
24610
+ });
24611
+ svgs[i].addEventListener('touchend', mouseUp.bind(engraver), {
24612
+ passive: true
24613
+ });
24572
24614
  svgs[i].addEventListener('mousedown', mouseDown.bind(engraver));
24573
24615
  svgs[i].addEventListener('mousemove', mouseMove.bind(engraver));
24574
24616
  svgs[i].addEventListener('mouseup', mouseUp.bind(engraver));
@@ -25530,7 +25572,7 @@ module.exports = unhighlight;
25530
25572
  \********************/
25531
25573
  /***/ (function(module) {
25532
25574
 
25533
- var version = '6.1.8';
25575
+ var version = '6.1.9';
25534
25576
  module.exports = version;
25535
25577
 
25536
25578
  /***/ })