abcjs 6.1.7 → 6.1.8

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.
@@ -1628,6 +1628,7 @@ var Tune = function Tune() {
1628
1628
  var height = bottom - top;
1629
1629
  var voices = group.voices;
1630
1630
  for (var v = 0; v < voices.length; v++) {
1631
+ if (voices[v].staff && voices[v].staff.isTabStaff) continue;
1631
1632
  var noteFound = false;
1632
1633
  if (!voicesArr[v]) voicesArr[v] = [];
1633
1634
  if (measureNumber[v] === undefined) measureNumber[v] = 0;
@@ -2787,6 +2788,7 @@ var Parse = function Parse() {
2787
2788
  type: 'treble',
2788
2789
  verticalPos: 0
2789
2790
  };
2791
+ this.octave = 0;
2790
2792
  this.next_note_duration = 0;
2791
2793
  this.start_new_line = true;
2792
2794
  this.is_in_header = true;
@@ -5949,6 +5951,28 @@ var parseKeyVoice = {};
5949
5951
  multilineVars.clef.staffscale = tokens[0].floatt;
5950
5952
  tokens.shift();
5951
5953
  break;
5954
+ case "octave":
5955
+ tokens.shift();
5956
+ if (tokens.length === 0) {
5957
+ warn("Expected = after octave", str, 0);
5958
+ return ret;
5959
+ }
5960
+ token = tokens.shift();
5961
+ if (token.token !== "=") {
5962
+ warn("Expected = after octave", str, token.start);
5963
+ break;
5964
+ }
5965
+ if (tokens.length === 0) {
5966
+ warn("Expected parameter after octave=", str, 0);
5967
+ return ret;
5968
+ }
5969
+ if (tokens[0].type !== 'number') {
5970
+ warn("Expected number after octave", str, tokens[0].start);
5971
+ break;
5972
+ }
5973
+ multilineVars.octave = tokens[0].intt;
5974
+ tokens.shift();
5975
+ break;
5952
5976
  case "style":
5953
5977
  tokens.shift();
5954
5978
  if (tokens.length === 0) {
@@ -6250,7 +6274,6 @@ var parseKeyVoice = {};
6250
6274
  addNextTokenToVoiceInfo(id, 'staffscale', 'number');
6251
6275
  break;
6252
6276
  case 'octave':
6253
- // TODO-PER: This is accepted, but not implemented, yet.
6254
6277
  addNextTokenToVoiceInfo(id, 'octave', 'number');
6255
6278
  break;
6256
6279
  case 'volume':
@@ -7352,6 +7375,7 @@ var getCoreNote = function getCoreNote(line, index, el, canHaveBrokenRhythm) {
7352
7375
  case 'g':
7353
7376
  if (state === 'startSlur' || state === 'sharp2' || state === 'flat2' || state === 'pitch') {
7354
7377
  el.pitch = pitches[line.charAt(index)];
7378
+ el.pitch += 7 * (multilineVars.currentVoice && multilineVars.currentVoice.octave !== undefined ? multilineVars.currentVoice.octave : multilineVars.octave);
7355
7379
  el.name = line.charAt(index);
7356
7380
  if (el.accidental) el.name = accMap[el.accidental] + el.name;
7357
7381
  transpose.note(multilineVars, el);
@@ -14589,7 +14613,19 @@ var pitchMap = {
14589
14613
  f13: "_b",
14590
14614
  n13: "=b",
14591
14615
  s13: "^b",
14592
- x13: "b"
14616
+ x13: "b",
14617
+ f14: "_c'",
14618
+ n14: "=c'",
14619
+ s14: "^c'",
14620
+ x14: "c'",
14621
+ f15: "_d'",
14622
+ n15: "=d'",
14623
+ s15: "^d'",
14624
+ x15: "d'",
14625
+ f16: "_e'",
14626
+ n16: "=e'",
14627
+ s16: "^e'",
14628
+ x16: "e'"
14593
14629
  };
14594
14630
  function pitchesToPerc(pitchObj) {
14595
14631
  var pitch = (pitchObj.accidental ? pitchObj.accidental[0] : 'x') + pitchObj.verticalPos;
@@ -15330,7 +15366,7 @@ function handleChordNotes(self, notes) {
15330
15366
  }
15331
15367
  function noteToNumber(self, note, stringNumber, secondPosition, firstSize) {
15332
15368
  var strings = self.strings;
15333
- note.checkKeyAccidentals(self.accidentals);
15369
+ note.checkKeyAccidentals(self.accidentals, self.measureAccidentals);
15334
15370
  if (secondPosition) {
15335
15371
  strings = secondPosition;
15336
15372
  }
@@ -15357,6 +15393,15 @@ function noteToNumber(self, note, stringNumber, secondPosition, firstSize) {
15357
15393
  return null;
15358
15394
  }
15359
15395
  function toNumber(self, note) {
15396
+ if (note.isAltered || note.natural) {
15397
+ var acc;
15398
+ if (note.isFlat) {
15399
+ if (note.isDouble) acc = "__";else acc = "_";
15400
+ } else if (note.isSharp) {
15401
+ if (note.isDouble) acc = "^^";else acc = "^";
15402
+ } else if (note.natural) acc = "=";
15403
+ self.measureAccidentals[note.name.toUpperCase()] = acc;
15404
+ }
15360
15405
  var num = null;
15361
15406
  var str = 0;
15362
15407
  var lowestString = self.strings[self.strings.length - 1];
@@ -15475,6 +15520,7 @@ function StringPatterns(plugin) {
15475
15520
  // override default
15476
15521
  this.highestNote = highestNote;
15477
15522
  }
15523
+ this.measureAccidentals = {};
15478
15524
  this.capo = 0;
15479
15525
  if (capo) {
15480
15526
  this.capo = capo;
@@ -15668,7 +15714,27 @@ TabNote.prototype.isLowerThan = function (note) {
15668
15714
  if (noteComparator.indexOf(thisName) < noteComparator.indexOf(noteName)) return true;
15669
15715
  return false;
15670
15716
  };
15671
- TabNote.prototype.checkKeyAccidentals = function (accidentals) {
15717
+ TabNote.prototype.checkKeyAccidentals = function (accidentals, measureAccidentals) {
15718
+ if (this.isAltered || this.natural) return;
15719
+ if (measureAccidentals[this.name.toUpperCase()]) {
15720
+ switch (measureAccidentals[this.name.toUpperCase()]) {
15721
+ case "__":
15722
+ this.acc = -2;
15723
+ return;
15724
+ case "_":
15725
+ this.acc = -1;
15726
+ return;
15727
+ case "=":
15728
+ this.acc = 0;
15729
+ return;
15730
+ case "^":
15731
+ this.acc = 1;
15732
+ return;
15733
+ case "^^":
15734
+ this.acc = 2;
15735
+ return;
15736
+ }
15737
+ }
15672
15738
  if (accidentals) {
15673
15739
  var curNote = this.name;
15674
15740
  for (var iii = 0; iii < accidentals.length; iii++) {
@@ -16008,6 +16074,8 @@ function cloneAbsolute(absSrc) {
16008
16074
  cloneObject(returned.abcelem, absSrc.abcelem);
16009
16075
  if (returned.abcelem.el_type === "note") returned.abcelem.el_type = 'tabNumber';
16010
16076
  }
16077
+ // TODO-PER: This fixes the classes because the element isn't created at the right time.
16078
+ absSrc.cloned = returned;
16011
16079
  return returned;
16012
16080
  }
16013
16081
  function cloneAbsoluteAndRelatives(absSrc, plugin) {
@@ -16199,6 +16267,7 @@ TabAbsoluteElements.prototype.build = function (plugin, staffAbsolute, tabVoice,
16199
16267
  }
16200
16268
  break;
16201
16269
  case 'bar':
16270
+ plugin.semantics.strings.measureAccidentals = {};
16202
16271
  var lastBar = false;
16203
16272
  if (ii === source.children.length - 1) {
16204
16273
  // used for final line bar drawing
@@ -16552,6 +16621,7 @@ TabRenderer.prototype.doLayout = function () {
16552
16621
  for (var ii = 0; ii < nbVoices; ii++) {
16553
16622
  var tabVoice = new VoiceElement(0, 0);
16554
16623
  var nameHeight = buildTabName(this, tabVoice) / spacing.STEP;
16624
+ nameHeight = Math.max(nameHeight, 1); // If there is no label for the tab line, then there needs to be a little padding
16555
16625
  staffGroup.staffs[this.staffIndex].top += nameHeight;
16556
16626
  staffGroup.height += nameHeight * spacing.STEP;
16557
16627
  tabVoice.staff = staffGroupInfos;
@@ -21118,6 +21188,10 @@ Classes.prototype.generate = function (c) {
21118
21188
  if (!this.shouldAddClasses) return "";
21119
21189
  var ret = [];
21120
21190
  if (c && c.length > 0) ret.push(c);
21191
+ if (c === "tab-number")
21192
+ // TODO-PER-HACK! straighten out the tablature
21193
+ return ret.join(' ');
21194
+ if (c === "text instrument-name") return "abcjs-text abcjs-instrument-name";
21121
21195
  if (this.lineNumber !== null) ret.push("l" + this.lineNumber);
21122
21196
  if (this.measureNumber !== null) ret.push("m" + this.measureNumber);
21123
21197
  if (this.measureNumber !== null) ret.push("mm" + this.measureTotal()); // measureNumber is null between measures so this is still the test for measureTotal
@@ -21178,6 +21252,14 @@ function drawAbsolute(renderer, params, bartop, selectables, staffPos) {
21178
21252
  }
21179
21253
  var g = elementGroup.endGroup(klass, params.type);
21180
21254
  if (g) {
21255
+ // TODO-PER-HACK! This corrects the classes because the tablature is not being created at the right time.
21256
+ if (params.cloned) {
21257
+ params.cloned.overrideClasses = g.className.baseVal;
21258
+ }
21259
+ if (params.overrideClasses) {
21260
+ var type = g.classList && g.classList.length > 0 ? g.classList[0] + ' ' : '';
21261
+ g.setAttribute("class", type + params.overrideClasses);
21262
+ }
21181
21263
  if (isTempo) {
21182
21264
  params.startChar = params.abcelem.startChar;
21183
21265
  params.endChar = params.abcelem.endChar;
@@ -25448,7 +25530,7 @@ module.exports = unhighlight;
25448
25530
  \********************/
25449
25531
  /***/ (function(module) {
25450
25532
 
25451
- var version = '6.1.7';
25533
+ var version = '6.1.8';
25452
25534
  module.exports = version;
25453
25535
 
25454
25536
  /***/ })