abcjs 6.4.2 → 6.4.3

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.
@@ -1,5 +1,5 @@
1
1
  /**!
2
- Copyright (c) 2009-2023 Paul Rosen and Gregory Dyke
2
+ Copyright (c) 2009-2024 Paul Rosen and Gregory Dyke
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**!
2
- Copyright (c) 2009-2023 Paul Rosen and Gregory Dyke
2
+ Copyright (c) 2009-2024 Paul Rosen and Gregory Dyke
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
package/license.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**!
2
- Copyright (c) 2009-2023 Paul Rosen and Gregory Dyke
2
+ Copyright (c) 2009-2024 Paul Rosen and Gregory Dyke
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abcjs",
3
- "version": "6.4.2",
3
+ "version": "6.4.3",
4
4
  "description": "Renderer for abc music notation",
5
5
  "main": "index.js",
6
6
  "types": "types/index.d.ts",
package/plugin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**!
2
- Copyright (c) 2009-2023 Paul Rosen and Gregory Dyke
2
+ Copyright (c) 2009-2024 Paul Rosen and Gregory Dyke
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
@@ -551,6 +551,8 @@ var Tune = function() {
551
551
 
552
552
  this.getBpm = function(tempo) {
553
553
  var bpm;
554
+ if (!tempo)
555
+ tempo = this.metaText ? this.metaText.tempo : null;
554
556
  if (tempo) {
555
557
  bpm = tempo.bpm;
556
558
  var beatLength = this.getBeatLength();
@@ -615,23 +615,38 @@ var letter_to_chord = function(line, i) {
615
615
  chord[1] = chord[1].substring(1);
616
616
  chord[2] = 'right';
617
617
  } else if (chord[0] > 0 && chord[1].length > 0 && chord[1][0] === '@') {
618
- // @-15,5.7
619
- chord[1] = chord[1].substring(1);
620
- var x = tokenizer.getFloat(chord[1]);
621
- if (x.digits === 0)
622
- warn("Missing first position in absolutely positioned annotation.", line , i);
623
- chord[1] = chord[1].substring(x.digits);
624
- if (chord[1][0] !== ',')
625
- warn("Missing comma absolutely positioned annotation.", line , i);
626
- chord[1] = chord[1].substring(1);
627
- var y = tokenizer.getFloat(chord[1]);
628
- if (y.digits === 0)
629
- warn("Missing second position in absolutely positioned annotation.", line , i);
630
- chord[1] = chord[1].substring(y.digits);
631
- var ws = tokenizer.skipWhiteSpace(chord[1]);
632
- chord[1] = chord[1].substring(ws);
633
- chord[2] = null;
634
- chord[3] = { x: x.value, y: y.value };
618
+ // @-15,5.7
619
+ chord[1] = chord[1].substring(1);
620
+ var x = tokenizer.getFloat(chord[1]);
621
+ if (x.digits === 0){
622
+ warn("Missing first position in absolutely positioned annotation.", line, i);
623
+ chord[1] = chord[1].replace("@","");
624
+ chord[2] = 'above';
625
+ return chord;
626
+ }
627
+ chord[1] = chord[1].substring(x.digits);
628
+ if (chord[1][0] !== ','){
629
+ warn("Missing comma absolutely positioned annotation.", line, i);
630
+ chord[1] = chord[1].replace("@","");
631
+ chord[2] = 'above';
632
+ return chord;
633
+ }
634
+ chord[1] = chord[1].substring(1);
635
+ var y = tokenizer.getFloat(chord[1]);
636
+ if (y.digits === 0){
637
+ warn("Missing second position in absolutely positioned annotation.", line, i);
638
+ chord[1] = chord[1].replace("@","");
639
+ chord[2] = 'above';
640
+ return chord;
641
+ }
642
+ chord[1] = chord[1].substring(y.digits);
643
+ var ws = tokenizer.skipWhiteSpace(chord[1]);
644
+ chord[1] = chord[1].substring(ws);
645
+ chord[2] = null;
646
+ chord[3] = {
647
+ x: x.value,
648
+ y: y.value
649
+ };
635
650
  } else {
636
651
  if (multilineVars.freegchord !== true) {
637
652
  chord[1] = chord[1].replace(/([ABCDEFG0-9])b/g, "$1♭");
@@ -198,6 +198,15 @@ ChordTrack.prototype.interpretChord = function (name) {
198
198
  while (chordTranspose > 8)
199
199
  chordTranspose -= 12;
200
200
  bass += chordTranspose;
201
+
202
+ // MAE 31 Aug 2024 - For visual transpose backup range issue
203
+ // If transposed below A or above G, bring it back in the normal backup range
204
+ if (bass < 33){
205
+ bass += 12;
206
+ }
207
+ else if (bass > 44){
208
+ bass -= 12;
209
+ }
201
210
 
202
211
  // MAE 17 Jun 2024 - Supporting octave shifted bass and chords
203
212
  var unshiftedBass = bass;
@@ -225,4 +225,30 @@ TieElem.prototype.avoidCollisionAbove = function () {
225
225
  }
226
226
  };
227
227
 
228
+ TieElem.prototype.getYBounds = function () {
229
+ var lineStartX = 10 // TODO-PER: I'm not sure where to get this number from but it probably doesn't matter much
230
+ var lineEndX = 1000 // TODO-PER: I'm not sure where to get this number from but it probably doesn't matter much
231
+ if (this.isTie) {
232
+ this.calcTieDirection();
233
+ this.calcX(lineStartX, lineEndX);
234
+ this.calcTieY();
235
+
236
+ } else {
237
+ this.calcSlurDirection();
238
+ this.calcX(lineStartX, lineEndX);
239
+ this.calcSlurY();
240
+ }
241
+ var top;
242
+ var bottom;
243
+ // TODO-PER: It's hard to tell how far the arc is, so I'm just using 3 as the max
244
+ if (this.above) {
245
+ bottom = Math.min(this.startY, this.endY)
246
+ top = bottom + 3
247
+ } else {
248
+ top = Math.min(this.startY, this.endY)
249
+ bottom = top - 3
250
+ }
251
+ return [ top, bottom ]
252
+ };
253
+
228
254
  module.exports = TieElem;
@@ -128,6 +128,14 @@ function setUpperAndLowerVoiceElements(positionY, voice, spacing) {
128
128
  case 'EndingElem':
129
129
  setUpperAndLowerEndingElements(positionY, abselem);
130
130
  break;
131
+ case 'TieElem':
132
+ // If a tie element is the highest or lowest thing then space might need to make room for it.
133
+ var yBounds = abselem.getYBounds()
134
+ voice.staff.top = Math.max(voice.staff.top, yBounds[0])
135
+ voice.staff.top = Math.max(voice.staff.top, yBounds[1])
136
+ voice.staff.bottom = Math.min(voice.staff.bottom, yBounds[0])
137
+ voice.staff.bottom = Math.min(voice.staff.bottom, yBounds[1])
138
+ break;
131
139
  }
132
140
  }
133
141
  }
package/test.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**!
2
- Copyright (c) 2009-2023 Paul Rosen and Gregory Dyke
2
+ Copyright (c) 2009-2024 Paul Rosen and Gregory Dyke
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
package/types/index.d.ts CHANGED
@@ -886,7 +886,7 @@ declare module 'abcjs' {
886
886
  getBarLength: NumberFunction;
887
887
  getBeatLength: NumberFunction;
888
888
  getBeatsPerMeasure: NumberFunction;
889
- getBpm: NumberFunction;
889
+ getBpm: (tempo?:TempoProperties) => number;
890
890
  getMeter: () => Meter;
891
891
  getMeterFraction: () => MeterFraction;
892
892
  getPickupLength: NumberFunction;
package/version.js CHANGED
@@ -1,3 +1,3 @@
1
- var version = '6.4.2';
1
+ var version = '6.4.3';
2
2
 
3
3
  module.exports = version;
package/temp.txt DELETED
@@ -1,12 +0,0 @@
1
- commit 747c5538cdfbb37eb6234356944b05855ff2921a
2
- Author: paulrosen <junk@paulrosen.net>
3
- Date: Sun Aug 4 10:08:14 2024 -0400
4
-
5
-
6
-
7
- commit 5b3d3d0f3f951e6dea3c22ded60b6baa9776e64c
8
- Author: paulrosen <junk@paulrosen.net>
9
- Date: Sun Jul 28 19:20:32 2024 -0400
10
-
11
- Start to refactor tablature and flatten the structure.
12
-