@tspro/web-music-score 3.2.0 → 4.0.1

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +38 -10
  2. package/README.md +189 -331
  3. package/dist/audio/index.d.mts +40 -1
  4. package/dist/audio/index.d.ts +40 -1
  5. package/dist/audio/index.js +1 -1
  6. package/dist/audio/index.mjs +2 -2
  7. package/dist/audio-cg/index.d.mts +3 -0
  8. package/dist/audio-cg/index.d.ts +3 -0
  9. package/dist/audio-cg/index.js +1 -1
  10. package/dist/audio-cg/index.mjs +2 -2
  11. package/dist/{chunk-LCTM7BID.mjs → chunk-YFPLOHP2.mjs} +2 -2
  12. package/dist/core/index.d.mts +12 -0
  13. package/dist/core/index.d.ts +12 -0
  14. package/dist/core/index.js +3 -2
  15. package/dist/core/index.mjs +4 -3
  16. package/dist/guitar-CaZJDA05.d.ts +35 -0
  17. package/dist/guitar-DdexKdN6.d.mts +35 -0
  18. package/dist/iife/index.global.js +11 -11
  19. package/dist/{interface-Bn5HFt_U.d.mts → music-objects-DJQ4d2OA.d.mts} +640 -136
  20. package/dist/{interface-BlNl69uT.d.ts → music-objects-Dc3kR-XF.d.ts} +640 -136
  21. package/dist/note-eA2xPPiG.d.mts +294 -0
  22. package/dist/note-eA2xPPiG.d.ts +294 -0
  23. package/dist/pieces/index.d.mts +22 -3
  24. package/dist/pieces/index.d.ts +22 -3
  25. package/dist/pieces/index.js +7 -7
  26. package/dist/pieces/index.mjs +11 -11
  27. package/dist/react-ui/index.d.mts +166 -17
  28. package/dist/react-ui/index.d.ts +166 -17
  29. package/dist/react-ui/index.js +78 -1
  30. package/dist/react-ui/index.mjs +79 -2
  31. package/dist/scale-B2Icbetz.d.ts +230 -0
  32. package/dist/scale-BbDJTbrG.d.mts +230 -0
  33. package/dist/score/index.d.mts +359 -39
  34. package/dist/score/index.d.ts +359 -39
  35. package/dist/score/index.js +1252 -594
  36. package/dist/score/index.mjs +1255 -599
  37. package/dist/tempo-CtUhvJbr.d.mts +369 -0
  38. package/dist/tempo-Dt8aHpol.d.ts +369 -0
  39. package/dist/theory/index.d.mts +29 -13
  40. package/dist/theory/index.d.ts +29 -13
  41. package/dist/theory/index.js +583 -96
  42. package/dist/theory/index.mjs +580 -94
  43. package/package.json +2 -2
  44. package/dist/guitar-C2Cp71NZ.d.ts +0 -17
  45. package/dist/guitar-DggbM2UL.d.mts +0 -17
  46. package/dist/note-BFa43I86.d.mts +0 -85
  47. package/dist/note-BFa43I86.d.ts +0 -85
  48. package/dist/scale-DRR-t4Kr.d.mts +0 -74
  49. package/dist/scale-ebJm37q1.d.ts +0 -74
  50. package/dist/tempo-B4h5Ktob.d.mts +0 -104
  51. package/dist/tempo-DgqDEsn0.d.ts +0 -104
@@ -1,4 +1,4 @@
1
- /* WebMusicScore v3.2.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
1
+ /* WebMusicScore v4.0.1 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
2
  "use strict";
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
@@ -39,6 +39,7 @@ __export(score_exports, {
39
39
  Connective: () => Connective,
40
40
  DivRect: () => DivRect,
41
41
  DocumentBuilder: () => DocumentBuilder,
42
+ DynamicsAnnotation: () => DynamicsAnnotation,
42
43
  Fermata: () => Fermata,
43
44
  Label: () => Label,
44
45
  MAccidental: () => MAccidental,
@@ -80,6 +81,7 @@ __export(score_exports, {
80
81
  ScoreStaffPosEvent: () => ScoreStaffPosEvent,
81
82
  StaffPreset: () => StaffPreset,
82
83
  Stem: () => Stem,
84
+ TempoAnnotation: () => TempoAnnotation,
83
85
  TieType: () => TieType,
84
86
  VerticalPosition: () => VerticalPosition,
85
87
  getStringNumbers: () => getStringNumbers,
@@ -361,16 +363,16 @@ var DivRect = class _DivRect {
361
363
  };
362
364
 
363
365
  // src/score/pub/document-builder.ts
364
- var import_ts_utils_lib11 = require("@tspro/ts-utils-lib");
366
+ var import_ts_utils_lib13 = require("@tspro/ts-utils-lib");
365
367
 
366
368
  // src/score/pub/types.ts
367
369
  var StaffPreset = /* @__PURE__ */ ((StaffPreset3) => {
368
- StaffPreset3[StaffPreset3["Treble"] = 1] = "Treble";
369
- StaffPreset3[StaffPreset3["Bass"] = 2] = "Bass";
370
- StaffPreset3[StaffPreset3["Grand"] = 3] = "Grand";
371
- StaffPreset3[StaffPreset3["GuitarTreble"] = 4] = "GuitarTreble";
372
- StaffPreset3[StaffPreset3["GuitarTab"] = 8] = "GuitarTab";
373
- StaffPreset3[StaffPreset3["GuitarCombined"] = 12] = "GuitarCombined";
370
+ StaffPreset3["Treble"] = "treble";
371
+ StaffPreset3["Bass"] = "bass";
372
+ StaffPreset3["Grand"] = "grand";
373
+ StaffPreset3["GuitarTreble"] = "guitarTreble";
374
+ StaffPreset3["GuitarTab"] = "guitarTab";
375
+ StaffPreset3["GuitarCombined"] = "guitarCombined";
374
376
  return StaffPreset3;
375
377
  })(StaffPreset || {});
376
378
  var Clef = /* @__PURE__ */ ((Clef2) => {
@@ -385,77 +387,98 @@ function getStringNumbers() {
385
387
  return [1, 2, 3, 4, 5, 6];
386
388
  }
387
389
  var Stem = /* @__PURE__ */ ((Stem2) => {
388
- Stem2[Stem2["Auto"] = 0] = "Auto";
389
- Stem2[Stem2["Up"] = 1] = "Up";
390
- Stem2[Stem2["Down"] = 2] = "Down";
390
+ Stem2["Auto"] = "auto";
391
+ Stem2["Up"] = "up";
392
+ Stem2["Down"] = "down";
391
393
  return Stem2;
392
394
  })(Stem || {});
393
395
  var Arpeggio = /* @__PURE__ */ ((Arpeggio2) => {
394
- Arpeggio2[Arpeggio2["Up"] = 0] = "Up";
395
- Arpeggio2[Arpeggio2["Down"] = 1] = "Down";
396
+ Arpeggio2["Up"] = "up";
397
+ Arpeggio2["Down"] = "down";
396
398
  return Arpeggio2;
397
399
  })(Arpeggio || {});
398
400
  var TieType = /* @__PURE__ */ ((TieType2) => {
399
- TieType2[TieType2["Stub"] = -1] = "Stub";
400
- TieType2[TieType2["ToMeasureEnd"] = -2] = "ToMeasureEnd";
401
+ TieType2["Stub"] = "stub";
402
+ TieType2["ToMeasureEnd"] = "toMeasureEnd";
401
403
  return TieType2;
402
404
  })(TieType || {});
403
405
  var NoteAnchor = /* @__PURE__ */ ((NoteAnchor2) => {
404
- NoteAnchor2[NoteAnchor2["Auto"] = 0] = "Auto";
405
- NoteAnchor2[NoteAnchor2["Above"] = 1] = "Above";
406
- NoteAnchor2[NoteAnchor2["Center"] = 2] = "Center";
407
- NoteAnchor2[NoteAnchor2["Below"] = 3] = "Below";
408
- NoteAnchor2[NoteAnchor2["StemTip"] = 4] = "StemTip";
406
+ NoteAnchor2["Auto"] = "auto";
407
+ NoteAnchor2["Above"] = "above";
408
+ NoteAnchor2["Center"] = "center";
409
+ NoteAnchor2["Below"] = "below";
410
+ NoteAnchor2["StemTip"] = "stemTip";
409
411
  return NoteAnchor2;
410
412
  })(NoteAnchor || {});
411
413
  var Connective = /* @__PURE__ */ ((Connective2) => {
412
- Connective2[Connective2["Tie"] = 0] = "Tie";
413
- Connective2[Connective2["Slur"] = 1] = "Slur";
414
- Connective2[Connective2["Slide"] = 2] = "Slide";
414
+ Connective2["Tie"] = "tie";
415
+ Connective2["Slur"] = "slur";
416
+ Connective2["Slide"] = "slide";
415
417
  return Connective2;
416
418
  })(Connective || {});
417
419
  var VerticalPosition = /* @__PURE__ */ ((VerticalPosition4) => {
418
- VerticalPosition4[VerticalPosition4["Above"] = 0] = "Above";
419
- VerticalPosition4[VerticalPosition4["Below"] = 1] = "Below";
420
- VerticalPosition4[VerticalPosition4["Both"] = 2] = "Both";
421
- VerticalPosition4[VerticalPosition4["Auto"] = 3] = "Auto";
420
+ VerticalPosition4["Auto"] = "auto";
421
+ VerticalPosition4["Above"] = "above";
422
+ VerticalPosition4["Below"] = "below";
423
+ VerticalPosition4["Both"] = "both";
422
424
  return VerticalPosition4;
423
425
  })(VerticalPosition || {});
424
- var PlayState = /* @__PURE__ */ ((PlayState2) => {
425
- PlayState2[PlayState2["Playing"] = 0] = "Playing";
426
- PlayState2[PlayState2["Paused"] = 1] = "Paused";
427
- PlayState2[PlayState2["Stopped"] = 2] = "Stopped";
428
- return PlayState2;
429
- })(PlayState || {});
430
426
  var Fermata = /* @__PURE__ */ ((Fermata2) => {
431
- Fermata2[Fermata2["AtNote"] = 0] = "AtNote";
432
- Fermata2[Fermata2["AtMeasureEnd"] = 1] = "AtMeasureEnd";
427
+ Fermata2["AtNote"] = "atNote";
428
+ Fermata2["AtMeasureEnd"] = "atMeasureEnd";
433
429
  return Fermata2;
434
430
  })(Fermata || {});
435
431
  var Navigation = /* @__PURE__ */ ((Navigation2) => {
436
- Navigation2[Navigation2["DC_al_Fine"] = 0] = "DC_al_Fine";
437
- Navigation2[Navigation2["DC_al_Coda"] = 1] = "DC_al_Coda";
438
- Navigation2[Navigation2["DS_al_Fine"] = 2] = "DS_al_Fine";
439
- Navigation2[Navigation2["DS_al_Coda"] = 3] = "DS_al_Coda";
440
- Navigation2[Navigation2["Coda"] = 4] = "Coda";
441
- Navigation2[Navigation2["toCoda"] = 5] = "toCoda";
442
- Navigation2[Navigation2["Segno"] = 6] = "Segno";
443
- Navigation2[Navigation2["Fine"] = 7] = "Fine";
444
- Navigation2[Navigation2["StartRepeat"] = 8] = "StartRepeat";
445
- Navigation2[Navigation2["EndRepeat"] = 9] = "EndRepeat";
446
- Navigation2[Navigation2["Ending"] = 10] = "Ending";
432
+ Navigation2["DC_al_Fine"] = "D.C. al Fine";
433
+ Navigation2["DC_al_Coda"] = "D.C. al Coda";
434
+ Navigation2["DS_al_Fine"] = "D.S. al Fine";
435
+ Navigation2["DS_al_Coda"] = "D.S. al Coda";
436
+ Navigation2["Coda"] = "Coda";
437
+ Navigation2["toCoda"] = "toCoda";
438
+ Navigation2["Segno"] = "Segno";
439
+ Navigation2["Fine"] = "Fine";
440
+ Navigation2["StartRepeat"] = "startRepeat";
441
+ Navigation2["EndRepeat"] = "endRepeat";
442
+ Navigation2["Ending"] = "ending";
447
443
  return Navigation2;
448
444
  })(Navigation || {});
449
445
  var Annotation = /* @__PURE__ */ ((Annotation2) => {
450
- Annotation2[Annotation2["Dynamics"] = 0] = "Dynamics";
451
- Annotation2[Annotation2["Tempo"] = 1] = "Tempo";
446
+ Annotation2["Dynamics"] = "dynamics";
447
+ Annotation2["Tempo"] = "tempo";
452
448
  return Annotation2;
453
449
  })(Annotation || {});
450
+ var DynamicsAnnotation = /* @__PURE__ */ ((DynamicsAnnotation2) => {
451
+ DynamicsAnnotation2["cresc"] = "cresc.";
452
+ DynamicsAnnotation2["decresc"] = "decresc.";
453
+ DynamicsAnnotation2["dim"] = "dim.";
454
+ DynamicsAnnotation2["ppp"] = "ppp";
455
+ DynamicsAnnotation2["pp"] = "pp";
456
+ DynamicsAnnotation2["p"] = "p";
457
+ DynamicsAnnotation2["mp"] = "mp";
458
+ DynamicsAnnotation2["m"] = "m";
459
+ DynamicsAnnotation2["mf"] = "mf";
460
+ DynamicsAnnotation2["f"] = "f";
461
+ DynamicsAnnotation2["ff"] = "ff";
462
+ DynamicsAnnotation2["fff"] = "fff";
463
+ return DynamicsAnnotation2;
464
+ })(DynamicsAnnotation || {});
465
+ var TempoAnnotation = /* @__PURE__ */ ((TempoAnnotation2) => {
466
+ TempoAnnotation2["accel"] = "accel.";
467
+ TempoAnnotation2["rit"] = "rit.";
468
+ TempoAnnotation2["a_tempo"] = "a tempo";
469
+ return TempoAnnotation2;
470
+ })(TempoAnnotation || {});
454
471
  var Label = /* @__PURE__ */ ((Label2) => {
455
- Label2[Label2["Note"] = 0] = "Note";
456
- Label2[Label2["Chord"] = 1] = "Chord";
472
+ Label2["Note"] = "note";
473
+ Label2["Chord"] = "chord";
457
474
  return Label2;
458
475
  })(Label || {});
476
+ var PlayState = /* @__PURE__ */ ((PlayState2) => {
477
+ PlayState2[PlayState2["Playing"] = 0] = "Playing";
478
+ PlayState2[PlayState2["Paused"] = 1] = "Paused";
479
+ PlayState2[PlayState2["Stopped"] = 2] = "Stopped";
480
+ return PlayState2;
481
+ })(PlayState || {});
459
482
 
460
483
  // src/score/engine/music-object.ts
461
484
  var MusicObjectLink = class {
@@ -954,10 +977,10 @@ var Renderer = class {
954
977
 
955
978
  // src/score/engine/obj-staff-and-tab.ts
956
979
  var import_core15 = require("@tspro/web-music-score/core");
957
- var import_ts_utils_lib9 = require("@tspro/ts-utils-lib");
980
+ var import_ts_utils_lib11 = require("@tspro/ts-utils-lib");
958
981
 
959
982
  // src/score/engine/obj-measure.ts
960
- var import_ts_utils_lib8 = require("@tspro/ts-utils-lib");
983
+ var import_ts_utils_lib10 = require("@tspro/ts-utils-lib");
961
984
  var import_theory9 = require("@tspro/web-music-score/theory");
962
985
  var import_theory10 = require("@tspro/web-music-score/theory");
963
986
 
@@ -1546,7 +1569,7 @@ var ObjSignature = class extends MusicObject {
1546
1569
  };
1547
1570
 
1548
1571
  // src/score/engine/player.ts
1549
- var import_ts_utils_lib5 = require("@tspro/ts-utils-lib");
1572
+ var import_ts_utils_lib6 = require("@tspro/ts-utils-lib");
1550
1573
  var import_theory7 = require("@tspro/web-music-score/theory");
1551
1574
  var Audio = __toESM(require("@tspro/web-music-score/audio"));
1552
1575
 
@@ -1576,8 +1599,8 @@ var ObjArpeggio = class extends MusicObject {
1576
1599
  }
1577
1600
  layout(renderer) {
1578
1601
  let { unitSize } = renderer;
1579
- this.topArrowHeight = this.arpeggioDir === 0 /* Up */ ? unitSize : 0;
1580
- this.bottomArrowHeight = this.arpeggioDir === 1 /* Down */ ? unitSize : 0;
1602
+ this.topArrowHeight = this.arpeggioDir === "up" /* Up */ ? unitSize : 0;
1603
+ this.bottomArrowHeight = this.arpeggioDir === "down" /* Down */ ? unitSize : 0;
1581
1604
  let top = this.line.getTopLineY();
1582
1605
  let bottom = this.line.getBottomLineY();
1583
1606
  this.cycleHeight = unitSize * 2;
@@ -1643,7 +1666,7 @@ var ObjStaffRest = class extends MusicObject {
1643
1666
  this.staff = staff;
1644
1667
  this.rest = rest;
1645
1668
  __publicField(this, "restRect", new DivRect());
1646
- __publicField(this, "dotRect");
1669
+ __publicField(this, "dotRects", []);
1647
1670
  __publicField(this, "mi");
1648
1671
  staff.addObject(this);
1649
1672
  this.mi = new MStaffRest(this);
@@ -1655,21 +1678,18 @@ var ObjStaffRest = class extends MusicObject {
1655
1678
  return this.getRect().contains(x, y) ? [this] : [];
1656
1679
  }
1657
1680
  offset(dx, dy) {
1658
- var _a;
1659
1681
  this.restRect.offsetInPlace(dx, dy);
1660
- (_a = this.dotRect) == null ? void 0 : _a.offsetInPlace(dx, dy);
1682
+ this.dotRects.forEach((r) => r.offsetInPlace(dx, dy));
1661
1683
  this.requestRectUpdate();
1662
1684
  this.rest.requestRectUpdate();
1663
1685
  }
1664
1686
  updateRect() {
1665
1687
  this.rect = this.restRect.copy();
1666
- if (this.dotRect) {
1667
- this.rect.expandInPlace(this.dotRect);
1668
- }
1688
+ this.dotRects.forEach((r) => this.rect.expandInPlace(r));
1669
1689
  }
1670
1690
  };
1671
1691
  var ObjRest = class extends MusicObject {
1672
- constructor(col, voiceId, noteLength, options) {
1692
+ constructor(col, voiceId, noteLength, options, tupletRatio) {
1673
1693
  var _a, _b;
1674
1694
  super(col);
1675
1695
  this.col = col;
@@ -1678,6 +1698,7 @@ var ObjRest = class extends MusicObject {
1678
1698
  __publicField(this, "ownDiatonicId");
1679
1699
  __publicField(this, "color");
1680
1700
  __publicField(this, "hide");
1701
+ __publicField(this, "oldStyleTriplet");
1681
1702
  __publicField(this, "rhythmProps");
1682
1703
  __publicField(this, "beamGroup");
1683
1704
  __publicField(this, "staffObjects", []);
@@ -1701,7 +1722,9 @@ var ObjRest = class extends MusicObject {
1701
1722
  }
1702
1723
  this.color = (_a = options == null ? void 0 : options.color) != null ? _a : "black";
1703
1724
  this.hide = (_b = options == null ? void 0 : options.hide) != null ? _b : false;
1704
- this.rhythmProps = new import_theory3.RhythmProps(noteLength, options == null ? void 0 : options.dotted, options == null ? void 0 : options.triplet);
1725
+ this.oldStyleTriplet = tupletRatio === void 0 && ((options == null ? void 0 : options.triplet) === true || import_theory3.NoteLengthProps.get(noteLength).isTriplet);
1726
+ let dotCount = typeof (options == null ? void 0 : options.dotted) === "number" ? options.dotted > 0 ? options.dotted : void 0 : (options == null ? void 0 : options.dotted) === true ? 1 : void 0;
1727
+ this.rhythmProps = import_theory3.RhythmProps.get(noteLength, dotCount, (tupletRatio != null ? tupletRatio : this.oldStyleTriplet) ? import_theory3.Tuplet.Triplet : void 0);
1705
1728
  this.mi = new MRest(this);
1706
1729
  }
1707
1730
  getMusicInterface() {
@@ -1719,15 +1742,9 @@ var ObjRest = class extends MusicObject {
1719
1742
  get noteLength() {
1720
1743
  return this.rhythmProps.noteLength;
1721
1744
  }
1722
- get dotted() {
1723
- return this.rhythmProps.dotted;
1724
- }
1725
1745
  get stemDir() {
1726
1746
  return this.beamGroup ? this.beamGroup.stemDir : this.ownStemDir;
1727
1747
  }
1728
- get triplet() {
1729
- return this.rhythmProps.triplet;
1730
- }
1731
1748
  getStaticObjects(line) {
1732
1749
  let staticObjects = [];
1733
1750
  this.staffObjects.forEach((obj) => {
@@ -1752,8 +1769,8 @@ var ObjRest = class extends MusicObject {
1752
1769
  getBeamGroup() {
1753
1770
  return this.beamGroup;
1754
1771
  }
1755
- setBeamGroup(beam) {
1756
- this.beamGroup = beam;
1772
+ setBeamGroup(beamGroup) {
1773
+ this.beamGroup = beamGroup;
1757
1774
  }
1758
1775
  resetBeamGroup() {
1759
1776
  this.beamGroup = void 0;
@@ -1762,7 +1779,7 @@ var ObjRest = class extends MusicObject {
1762
1779
  return this.staffObjects.map((obj) => {
1763
1780
  let staff = obj.staff;
1764
1781
  let x = obj.getRect().centerX;
1765
- let y = this.stemDir === 1 /* Up */ ? obj.getRect().top : obj.getRect().bottom;
1782
+ let y = this.stemDir === "up" /* Up */ ? obj.getRect().top : obj.getRect().bottom;
1766
1783
  let stemHeight = Math.abs(obj.getRect().centerY - y);
1767
1784
  return { staff, x, y, stemHeight };
1768
1785
  });
@@ -1803,7 +1820,7 @@ var ObjRest = class extends MusicObject {
1803
1820
  }
1804
1821
  let { unitSize } = renderer;
1805
1822
  let { ownDiatonicId } = this;
1806
- let { noteLength, dotted, flagCount } = this.rhythmProps;
1823
+ let { noteLength, dotCount, flagCount } = this.rhythmProps;
1807
1824
  let leftw = 0;
1808
1825
  let rightw = 0;
1809
1826
  let toph = 0;
@@ -1836,11 +1853,11 @@ var ObjRest = class extends MusicObject {
1836
1853
  }
1837
1854
  let obj = new ObjStaffRest(staff, this);
1838
1855
  obj.restRect = new DivRect(-leftw, 0, rightw, -toph, 0, bottomh);
1839
- if (dotted) {
1856
+ for (let i = 0; i < dotCount; i++) {
1840
1857
  let dotWidth = DocumentSettings.DotSize * unitSize;
1841
- let dotX = rightw + (DocumentSettings.RestDotSpace + DocumentSettings.DotSize / 2) * unitSize;
1858
+ let dotX = rightw + (DocumentSettings.RestDotSpace + DocumentSettings.DotSize * unitSize) + i * DocumentSettings.DotSize * unitSize * 1.5;
1842
1859
  let dotY = this.getRestDotVerticalDisplacement(noteLength) * unitSize;
1843
- obj.dotRect = DivRect.createCentered(dotX, dotY, dotWidth, dotWidth);
1860
+ obj.dotRects.push(DivRect.createCentered(dotX, dotY, dotWidth, dotWidth));
1844
1861
  }
1845
1862
  obj.offset(0, staff.getDiatonicIdY(ownDiatonicId));
1846
1863
  this.staffObjects.push(obj);
@@ -1874,7 +1891,7 @@ var ObjRest = class extends MusicObject {
1874
1891
  ctx.strokeStyle = ctx.fillStyle = color;
1875
1892
  ctx.lineWidth = lineWidth;
1876
1893
  this.staffObjects.forEach((obj) => {
1877
- let { dotRect, restRect } = obj;
1894
+ let { dotRects, restRect } = obj;
1878
1895
  let x = restRect.centerX;
1879
1896
  let y = restRect.centerY;
1880
1897
  if (noteLength === import_theory3.NoteLength.Whole) {
@@ -1939,9 +1956,9 @@ var ObjRest = class extends MusicObject {
1939
1956
  ctx.fill();
1940
1957
  }
1941
1958
  }
1942
- if (dotRect) {
1943
- renderer.fillCircle(dotRect.centerX, dotRect.centerY, dotRect.width / 2);
1944
- }
1959
+ dotRects.forEach((r) => {
1960
+ renderer.fillCircle(r.centerX, r.centerY, r.width / 2);
1961
+ });
1945
1962
  });
1946
1963
  }
1947
1964
  };
@@ -1989,8 +2006,8 @@ var ObjStaffBeamGroup = class extends MusicObject {
1989
2006
  super(staff);
1990
2007
  this.staff = staff;
1991
2008
  this.beamGroup = beamGroup;
1992
- __publicField(this, "tripletNumber");
1993
- __publicField(this, "tripletNumberOffsetY", 0);
2009
+ __publicField(this, "tupletNumber");
2010
+ __publicField(this, "tupletNumberOffsetY", 0);
1994
2011
  __publicField(this, "points", []);
1995
2012
  __publicField(this, "mi");
1996
2013
  staff.addObject(this);
@@ -2005,48 +2022,47 @@ var ObjStaffBeamGroup = class extends MusicObject {
2005
2022
  offset(dx, dy) {
2006
2023
  var _a;
2007
2024
  this.points.forEach((p) => p.offset(dx, 0));
2008
- (_a = this.tripletNumber) == null ? void 0 : _a.offset(dx, dy);
2025
+ (_a = this.tupletNumber) == null ? void 0 : _a.offset(dx, dy);
2009
2026
  this.requestRectUpdate();
2010
2027
  this.beamGroup.requestRectUpdate();
2011
2028
  }
2012
2029
  updateRect() {
2013
2030
  if (this.points.length > 0) {
2014
2031
  this.rect = this.points[0].getRect().copy();
2015
- } else if (this.tripletNumber) {
2016
- this.rect = this.tripletNumber.getRect().copy();
2032
+ } else if (this.tupletNumber) {
2033
+ this.rect = this.tupletNumber.getRect().copy();
2017
2034
  }
2018
2035
  this.points.forEach((pt) => this.rect.expandInPlace(pt.getRect()));
2019
- if (this.tripletNumber) {
2020
- this.rect.expandInPlace(this.tripletNumber.getRect());
2036
+ if (this.tupletNumber) {
2037
+ this.rect.expandInPlace(this.tupletNumber.getRect());
2021
2038
  }
2022
2039
  }
2023
2040
  };
2024
2041
  var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2025
- constructor(symbols, triplet) {
2042
+ constructor(symbols, tupletRatio) {
2026
2043
  super(symbols[0].measure);
2027
2044
  this.symbols = symbols;
2045
+ this.tupletRatio = tupletRatio;
2028
2046
  __publicField(this, "mi");
2029
2047
  __publicField(this, "type");
2030
2048
  __publicField(this, "staffObjects", []);
2031
2049
  this.mi = new MBeamGroup(this);
2050
+ let beamGroupName = tupletRatio ? "Tuplet" : "BeamGroup";
2032
2051
  if (!symbols.every((s) => s.measure === symbols[0].measure)) {
2033
- throw new import_core6.MusicError(import_core6.MusicErrorType.Score, "All beam group symbols are not in same measure.");
2052
+ throw new import_core6.MusicError(import_core6.MusicErrorType.Score, `All ${beamGroupName} symbols are not in same measure.`);
2034
2053
  } else if (symbols.length < 2) {
2035
- throw new import_core6.MusicError(import_core6.MusicErrorType.Score, "Beam group need minimum 2 symbols, but " + symbols.length + " given.");
2054
+ throw new import_core6.MusicError(import_core6.MusicErrorType.Score, `${beamGroupName} needs minimum 2 symbols, but ${symbols.length} given.`);
2036
2055
  }
2037
- if (triplet) {
2038
- if (!symbols.every((s) => s.triplet)) {
2039
- throw new import_core6.MusicError(import_core6.MusicErrorType.Score, "Not every symbol's triplet property is true.");
2040
- }
2056
+ if (tupletRatio !== void 0) {
2041
2057
  let isGroup = symbols.length < 3 || symbols.some((s) => !(s instanceof ObjNoteGroup)) || symbols.some((s) => s.rhythmProps.flagCount !== symbols[0].rhythmProps.flagCount);
2042
- if (symbols.length === 3 && symbols[0] instanceof ObjNoteGroup && symbols[symbols.length - 1] instanceof ObjNoteGroup && symbols[0].rhythmProps.flagCount === symbols[symbols.length - 1].rhythmProps.flagCount) {
2058
+ if (symbols.length >= 3 && symbols[0] instanceof ObjNoteGroup && symbols[symbols.length - 1] instanceof ObjNoteGroup && symbols[0].rhythmProps.flagCount === symbols[symbols.length - 1].rhythmProps.flagCount) {
2043
2059
  isGroup = false;
2044
2060
  }
2045
- if (symbols.some((s) => s.rhythmProps.noteLength >= import_theory4.NoteLength.Quarter)) {
2061
+ if (symbols.some((s) => import_theory4.NoteLengthProps.cmp(s.rhythmProps.noteLength, import_theory4.NoteLength.Quarter) >= 0)) {
2046
2062
  isGroup = true;
2047
2063
  }
2048
- this.type = isGroup ? 2 /* TripletGroup */ : 1 /* TripletBeam */;
2049
- ObjNoteGroup.setTripletBeamCounts(this);
2064
+ this.type = isGroup ? 2 /* TupletGroup */ : 1 /* TupletBeam */;
2065
+ ObjNoteGroup.setTupletBeamCounts(this);
2050
2066
  } else {
2051
2067
  this.type = 0 /* RegularBeam */;
2052
2068
  }
@@ -2054,29 +2070,35 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2054
2070
  symbols.forEach((s) => s.setBeamGroup(this));
2055
2071
  symbols[0].measure.addBeamGroup(this);
2056
2072
  } else {
2057
- throw new import_core6.MusicError(import_core6.MusicErrorType.Score, "Cannot add beam group because some symbol already has one.");
2073
+ throw new import_core6.MusicError(import_core6.MusicErrorType.Score, `Cannot add ${beamGroupName} because some symbol already has one.`);
2058
2074
  }
2059
2075
  }
2076
+ get showTupletRatio() {
2077
+ var _a;
2078
+ return ((_a = this.tupletRatio) == null ? void 0 : _a.showRatio) === true;
2079
+ }
2060
2080
  static createBeam(noteGroups) {
2061
2081
  if (noteGroups.length > 1) {
2062
- new _ObjBeamGroup(noteGroups, false);
2082
+ new _ObjBeamGroup(noteGroups, void 0);
2063
2083
  }
2064
2084
  }
2065
- static createTriplet(symbols) {
2066
- let MaxTripletNoteLenght = import_theory4.NoteLength.Half;
2067
- let len = symbols.map((s) => s.rhythmProps.noteLength);
2068
- if (symbols.length == 2) {
2069
- if (len[0] <= MaxTripletNoteLenght && len[1] === len[0] / 2 && len[0] / 2 >= import_theory4.MinNoteLength || len[1] <= MaxTripletNoteLenght && len[0] === len[1] / 2 && len[1] / 2 >= import_theory4.MinNoteLength) {
2070
- new _ObjBeamGroup(symbols, true);
2071
- return true;
2072
- }
2073
- } else if (symbols.length === 3) {
2074
- if (len[0] <= MaxTripletNoteLenght && len.every((l) => l === len[0])) {
2075
- new _ObjBeamGroup(symbols, true);
2076
- return true;
2077
- }
2085
+ static createOldStyleTriplet(symbols) {
2086
+ let s2 = symbols.slice(0, 2);
2087
+ let n2 = s2.map((s) => s.rhythmProps.noteSize);
2088
+ if (s2.length === 2 && s2.every((s) => s.oldStyleTriplet && s.getBeamGroup() === void 0) && (n2[0] * 2 === n2[1] || n2[1] * 2 === n2[0])) {
2089
+ new _ObjBeamGroup(s2, import_theory4.Tuplet.Triplet);
2090
+ return 2;
2078
2091
  }
2079
- return false;
2092
+ let s3 = symbols.slice(0, 3);
2093
+ let n3 = s3.map((s) => s.rhythmProps.noteSize);
2094
+ if (s3.length === 3 && s3.every((s) => s.oldStyleTriplet && s.getBeamGroup() === void 0) && n3.every((n) => n === n3[0])) {
2095
+ new _ObjBeamGroup(s3, import_theory4.Tuplet.Triplet);
2096
+ return 3;
2097
+ }
2098
+ return 0;
2099
+ }
2100
+ static createTuplet(symbols, tupletRatio) {
2101
+ new _ObjBeamGroup(symbols, tupletRatio);
2080
2102
  }
2081
2103
  getMusicInterface() {
2082
2104
  return this.mi;
@@ -2102,8 +2124,8 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2102
2124
  getType() {
2103
2125
  return this.type;
2104
2126
  }
2105
- isTriplet() {
2106
- return this.type === 1 /* TripletBeam */ || this.type === 2 /* TripletGroup */;
2127
+ isTuplet() {
2128
+ return this.type === 1 /* TupletBeam */ || this.type === 2 /* TupletGroup */;
2107
2129
  }
2108
2130
  getSymbols() {
2109
2131
  return this.symbols;
@@ -2165,10 +2187,10 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2165
2187
  }
2166
2188
  let leftStemHeight = (_a = symbolStemHeight[0]) != null ? _a : 0;
2167
2189
  let rightStemHeight = (_b = symbolStemHeight[symbolStemHeight.length - 1]) != null ? _b : 0;
2168
- if (this.type !== 2 /* TripletGroup */) {
2190
+ if (this.type !== 2 /* TupletGroup */) {
2169
2191
  let leftDy = leftStemHeight < rightStemHeight ? Math.sqrt(rightStemHeight - leftStemHeight) : 0;
2170
2192
  let rightDy = rightStemHeight < leftStemHeight ? Math.sqrt(leftStemHeight - rightStemHeight) : 0;
2171
- if (stemDir === 1 /* Up */) {
2193
+ if (stemDir === "up" /* Up */) {
2172
2194
  leftDy *= -1;
2173
2195
  rightDy *= -1;
2174
2196
  }
@@ -2181,7 +2203,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2181
2203
  symbolY[symbolY.length - 1] += rightDy;
2182
2204
  }
2183
2205
  }
2184
- let groupLineDy = unitSize * 2 * (stemDir === 1 /* Up */ ? -1 : 1);
2206
+ let groupLineDy = unitSize * 2 * (stemDir === "up" /* Up */ ? -1 : 1);
2185
2207
  let centerY = (rightY + leftY) / 2;
2186
2208
  let halfDy = adjustBeamAngle(rightX - leftX, rightY - leftY) / 2;
2187
2209
  leftY = centerY - halfDy;
@@ -2192,9 +2214,9 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2192
2214
  if (symX !== void 0 && symY !== void 0) {
2193
2215
  let beamY = import_ts_utils_lib3.Utils.Math.interpolateY(leftX, leftY, rightX, rightY, symX);
2194
2216
  let raiseY = symY - beamY;
2195
- if (stemDir === 1 /* Up */ && raiseY < 0) {
2217
+ if (stemDir === "up" /* Up */ && raiseY < 0) {
2196
2218
  raiseBeamY = Math.min(raiseBeamY, raiseY);
2197
- } else if (stemDir === 2 /* Down */ && raiseY > 0) {
2219
+ } else if (stemDir === "down" /* Down */ && raiseY > 0) {
2198
2220
  raiseBeamY = Math.max(raiseBeamY, raiseY);
2199
2221
  }
2200
2222
  }
@@ -2203,21 +2225,21 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2203
2225
  rightY += raiseBeamY;
2204
2226
  symbolY = symbolY.map((y) => y === void 0 ? void 0 : y + raiseBeamY);
2205
2227
  let obj = new ObjStaffBeamGroup(mainStaff, this);
2206
- if (this.type === 2 /* TripletGroup */) {
2228
+ if (this.type === 2 /* TupletGroup */) {
2207
2229
  let ef = unitSize / (rightX - leftX);
2208
2230
  let l = import_ts_utils_lib3.Utils.Math.interpolateCoord(leftX, leftY + groupLineDy, rightX, rightY + groupLineDy, -ef);
2209
2231
  let r = import_ts_utils_lib3.Utils.Math.interpolateCoord(leftX, leftY + groupLineDy, rightX, rightY + groupLineDy, 1 + ef);
2210
2232
  obj.points.push(new BeamPoint(leftStaff, this, leftSymbol, l.x, l.y));
2211
2233
  obj.points.push(new BeamPoint(rightStaff, this, rightSymbol, r.x, r.y));
2212
- obj.tripletNumberOffsetY = 0;
2213
- } else if (this.type === 0 /* RegularBeam */ || this.type === 1 /* TripletBeam */) {
2234
+ obj.tupletNumberOffsetY = 0;
2235
+ } else if (this.type === 0 /* RegularBeam */ || this.type === 1 /* TupletBeam */) {
2214
2236
  raiseBeamY *= 0.5;
2215
2237
  let { beamThickness } = renderer;
2216
2238
  const beamHeight = (i) => {
2217
2239
  let sym = symbols[i];
2218
2240
  if (sym instanceof ObjNoteGroup) {
2219
2241
  let beamCount = sym instanceof ObjNoteGroup ? Math.max(sym.getLeftBeamCount(), sym.getRightBeamCount()) : 0;
2220
- return DocumentSettings.BeamSeparation * unitSize * (this.stemDir === 1 /* Up */ ? beamCount - 1 : 0);
2242
+ return DocumentSettings.BeamSeparation * unitSize * (this.stemDir === "up" /* Up */ ? beamCount - 1 : 0);
2221
2243
  } else {
2222
2244
  return 0;
2223
2245
  }
@@ -2228,17 +2250,18 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2228
2250
  let symY = symbolY[i];
2229
2251
  if (symStaff && symX !== void 0 && symY !== void 0) {
2230
2252
  let pt = new BeamPoint(symStaff, this, sym, symX, symY);
2231
- pt.topBeamsHeight = beamThickness / 2 + (stemDir === 2 /* Down */ ? beamHeight(i) : 0);
2232
- pt.bottomBeamsHeight = beamThickness / 2 + (stemDir === 1 /* Up */ ? beamHeight(i) : 0);
2253
+ pt.topBeamsHeight = beamThickness / 2 + (stemDir === "down" /* Down */ ? beamHeight(i) : 0);
2254
+ pt.bottomBeamsHeight = beamThickness / 2 + (stemDir === "up" /* Up */ ? beamHeight(i) : 0);
2233
2255
  obj.points.push(pt);
2234
2256
  }
2235
2257
  });
2236
- obj.tripletNumberOffsetY = groupLineDy;
2258
+ obj.tupletNumberOffsetY = groupLineDy;
2237
2259
  }
2238
- if (this.isTriplet()) {
2239
- obj.tripletNumber = new ObjText(this, "3", 0.5, 0.5);
2240
- obj.tripletNumber.layout(renderer);
2241
- obj.tripletNumber.offset((leftX + rightX) / 2, (leftY + rightY) / 2 + obj.tripletNumberOffsetY);
2260
+ if (this.isTuplet() && this.tupletRatio) {
2261
+ let txt = this.showTupletRatio ? String(this.tupletRatio.parts) + ":" + String(this.tupletRatio.inTimeOf) : String(this.tupletRatio.parts);
2262
+ obj.tupletNumber = new ObjText(this, txt, 0.5, 0.5);
2263
+ obj.tupletNumber.layout(renderer);
2264
+ obj.tupletNumber.offset((leftX + rightX) / 2, (leftY + rightY) / 2 + obj.tupletNumberOffsetY);
2242
2265
  }
2243
2266
  if (obj.points.length >= 2) {
2244
2267
  this.staffObjects.push(obj);
@@ -2260,7 +2283,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2260
2283
  this.staffObjects.forEach((obj) => {
2261
2284
  let left = obj.points[0];
2262
2285
  let right = obj.points[obj.points.length - 1];
2263
- if (this.type !== 2 /* TripletGroup */) {
2286
+ if (this.type !== 2 /* TupletGroup */) {
2264
2287
  obj.points.forEach((pt) => {
2265
2288
  if (pt.symbol instanceof ObjNoteGroup) {
2266
2289
  if (pt !== left && pt !== right) {
@@ -2270,9 +2293,9 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2270
2293
  }
2271
2294
  });
2272
2295
  }
2273
- if (obj.tripletNumber) {
2274
- let y = (left.y + right.y) / 2 + obj.tripletNumberOffsetY;
2275
- obj.tripletNumber.offset(0, -obj.tripletNumber.getRect().centerY + y);
2296
+ if (obj.tupletNumber) {
2297
+ let y = (left.y + right.y) / 2 + obj.tupletNumberOffsetY;
2298
+ obj.tupletNumber.offset(0, -obj.tupletNumber.getRect().centerY + y);
2276
2299
  }
2277
2300
  });
2278
2301
  }
@@ -2284,21 +2307,21 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2284
2307
  let { unitSize, beamThickness, lineWidth } = renderer;
2285
2308
  let color = "black";
2286
2309
  this.staffObjects.forEach((obj) => {
2287
- if (this.type === 2 /* TripletGroup */) {
2310
+ if (this.type === 2 /* TupletGroup */) {
2288
2311
  let l = obj.points[0];
2289
2312
  let r = obj.points[obj.points.length - 1];
2290
2313
  if (l && r) {
2291
- let tf = obj.tripletNumber ? obj.tripletNumber.getRect().width / (r.x - l.x) * 1.2 : 0;
2314
+ let tf = obj.tupletNumber ? obj.tupletNumber.getRect().width / (r.x - l.x) * 1.2 : 0;
2292
2315
  let lc = import_ts_utils_lib3.Utils.Math.interpolateCoord(l.x, l.y, r.x, r.y, 0.5 - tf / 2);
2293
2316
  let rc = import_ts_utils_lib3.Utils.Math.interpolateCoord(l.x, l.y, r.x, r.y, 0.5 + tf / 2);
2294
- let tipH = this.stemDir === 1 /* Up */ ? unitSize : -unitSize;
2317
+ let tipH = this.stemDir === "up" /* Up */ ? unitSize : -unitSize;
2295
2318
  renderer.drawLine(l.x, l.y, lc.x, lc.y, color, lineWidth);
2296
2319
  renderer.drawLine(rc.x, rc.y, r.x, r.y, color, lineWidth);
2297
2320
  renderer.drawLine(l.x, l.y, l.x, l.y + tipH, color, lineWidth);
2298
2321
  renderer.drawLine(r.x, r.y, r.x, r.y + tipH, color, lineWidth);
2299
2322
  }
2300
- } else if (this.type === 0 /* RegularBeam */ || this.type === 1 /* TripletBeam */) {
2301
- let beamSeparation = DocumentSettings.BeamSeparation * unitSize * (this.stemDir === 1 /* Up */ ? 1 : -1);
2323
+ } else if (this.type === 0 /* RegularBeam */ || this.type === 1 /* TupletBeam */) {
2324
+ let beamSeparation = DocumentSettings.BeamSeparation * unitSize * (this.stemDir === "up" /* Up */ ? 1 : -1);
2302
2325
  let noteGroupPoints = obj.points.filter((p) => p.symbol instanceof ObjNoteGroup);
2303
2326
  for (let i = 0; i < noteGroupPoints.length - 1; i++) {
2304
2327
  let left = noteGroupPoints[i];
@@ -2325,8 +2348,8 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2325
2348
  }
2326
2349
  }
2327
2350
  }
2328
- if (obj.tripletNumber) {
2329
- obj.tripletNumber.draw(renderer);
2351
+ if (obj.tupletNumber) {
2352
+ obj.tupletNumber.draw(renderer);
2330
2353
  }
2331
2354
  });
2332
2355
  }
@@ -2334,6 +2357,12 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
2334
2357
 
2335
2358
  // src/score/engine/obj-note-group.ts
2336
2359
  var import_core7 = require("@tspro/web-music-score/core");
2360
+ function getStem(stem) {
2361
+ return import_ts_utils_lib4.Utils.Is.isEnumValue(stem, Stem) ? stem : void 0;
2362
+ }
2363
+ function getArpeggio(a) {
2364
+ return import_ts_utils_lib4.Utils.Is.isEnumValue(a, Arpeggio) ? a : a === true ? "up" /* Up */ : void 0;
2365
+ }
2337
2366
  function sortNoteStringData(notes, strings) {
2338
2367
  let stringArr = import_ts_utils_lib4.Utils.Arr.isArray(strings) ? strings : strings !== void 0 ? [strings] : [];
2339
2368
  let noteStringData = notes.map((note, i) => {
@@ -2345,9 +2374,6 @@ function sortNoteStringData(notes, strings) {
2345
2374
  strings: noteStringData.every((e) => e.string === void 0) ? void 0 : noteStringData.map((e) => e.string)
2346
2375
  };
2347
2376
  }
2348
- function solveArpeggio(a) {
2349
- return a === true || a === 0 /* Up */ ? 0 /* Up */ : a === 1 /* Down */ ? 1 /* Down */ : void 0;
2350
- }
2351
2377
  var ObjStaffNoteGroup = class extends MusicObject {
2352
2378
  constructor(staff, noteGroup) {
2353
2379
  super(staff);
@@ -2437,7 +2463,7 @@ var ObjTabNoteGroup = class extends MusicObject {
2437
2463
  }
2438
2464
  };
2439
2465
  var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2440
- constructor(col, voiceId, notes, noteLength, options) {
2466
+ constructor(col, voiceId, notes, noteLength, options, tupletRatio) {
2441
2467
  var _a, _b, _c;
2442
2468
  super(col);
2443
2469
  this.col = col;
@@ -2453,6 +2479,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2453
2479
  __publicField(this, "staccato");
2454
2480
  __publicField(this, "diamond");
2455
2481
  __publicField(this, "arpeggio");
2482
+ __publicField(this, "oldStyleTriplet");
2456
2483
  __publicField(this, "rhythmProps");
2457
2484
  __publicField(this, "startConnnectives", []);
2458
2485
  __publicField(this, "runningConnectives", []);
@@ -2470,13 +2497,15 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2470
2497
  this.minDiatonicId = this.notes[0].diatonicId;
2471
2498
  this.maxDiatonicId = this.notes[this.notes.length - 1].diatonicId;
2472
2499
  this.ownDiatonicId = this.measure.updateOwnDiatonicId(voiceId, Math.round((this.minDiatonicId + this.maxDiatonicId) / 2));
2473
- this.ownStemDir = this.measure.updateOwnStemDir(this, options == null ? void 0 : options.stem);
2500
+ this.ownStemDir = this.measure.updateOwnStemDir(this, getStem(options == null ? void 0 : options.stem));
2474
2501
  this.ownString = this.measure.updateOwnString(this, noteStringData.strings);
2475
2502
  this.color = (_a = options == null ? void 0 : options.color) != null ? _a : "black";
2476
2503
  this.staccato = (_b = options == null ? void 0 : options.staccato) != null ? _b : false;
2477
2504
  this.diamond = (_c = options == null ? void 0 : options.diamond) != null ? _c : false;
2478
- this.arpeggio = solveArpeggio(options == null ? void 0 : options.arpeggio);
2479
- this.rhythmProps = new import_theory5.RhythmProps(noteLength, options == null ? void 0 : options.dotted, options == null ? void 0 : options.triplet);
2505
+ this.arpeggio = getArpeggio(options == null ? void 0 : options.arpeggio);
2506
+ this.oldStyleTriplet = tupletRatio === void 0 && ((options == null ? void 0 : options.triplet) === true || import_theory5.NoteLengthProps.get(noteLength).isTriplet);
2507
+ let dotCount = typeof (options == null ? void 0 : options.dotted) === "number" ? options.dotted > 0 ? options.dotted : void 0 : (options == null ? void 0 : options.dotted) === true ? 1 : void 0;
2508
+ this.rhythmProps = import_theory5.RhythmProps.get(noteLength, dotCount, (tupletRatio != null ? tupletRatio : this.oldStyleTriplet) ? import_theory5.Tuplet.Triplet : void 0);
2480
2509
  this.mi = new MNoteGroup(this);
2481
2510
  }
2482
2511
  getMusicInterface() {
@@ -2494,16 +2523,13 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2494
2523
  get stemDir() {
2495
2524
  return this.beamGroup ? this.beamGroup.stemDir : this.ownStemDir;
2496
2525
  }
2497
- get triplet() {
2498
- return this.rhythmProps.triplet;
2499
- }
2500
2526
  enableConnective(line) {
2501
2527
  return line.containsVoiceId(this.voiceId) && (line instanceof ObjTab || line.containsDiatonicId(this.ownDiatonicId));
2502
2528
  }
2503
2529
  startConnective(connectiveProps) {
2504
- if (!this.row.hasStaff && connectiveProps.connective === 0 /* Tie */) {
2530
+ if (!this.row.hasStaff && connectiveProps.connective === "tie" /* Tie */) {
2505
2531
  throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Ties not implemented for guitar tabs alone, staff is required!");
2506
- } else if (!this.row.hasStaff && connectiveProps.connective === 1 /* Slur */) {
2532
+ } else if (!this.row.hasStaff && connectiveProps.connective === "slur" /* Slur */) {
2507
2533
  throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Slurs not implemented for guitar tabs alone, staff is required!");
2508
2534
  }
2509
2535
  this.startConnnectives.push(connectiveProps);
@@ -2562,7 +2588,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2562
2588
  let stemTip = obj.stemTip;
2563
2589
  let stemDir = this.stemDir;
2564
2590
  let hasStem = stemTip !== void 0;
2565
- let stemSide = !hasStem ? void 0 : stemDir === 1 /* Up */ ? "right" : "left";
2591
+ let stemSide = !hasStem ? void 0 : stemDir === "up" /* Up */ ? "right" : "left";
2566
2592
  let padding = noteHeadRect.height / 2;
2567
2593
  let centerX = noteHeadRect.centerX;
2568
2594
  let centerY = noteHeadRect.centerY;
@@ -2570,16 +2596,16 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2570
2596
  let rightX = noteHeadRect.right + padding;
2571
2597
  let aboveY = noteHeadRect.top - padding;
2572
2598
  let belowY = noteHeadRect.bottom + padding;
2573
- if (noteAnchor === 0 /* Auto */) {
2574
- noteAnchor = 3 /* Below */;
2575
- } else if (noteAnchor === 4 /* StemTip */ && !hasStem) {
2576
- noteAnchor = stemDir === 1 /* Up */ ? 1 /* Above */ : 3 /* Below */;
2599
+ if (noteAnchor === "auto" /* Auto */) {
2600
+ noteAnchor = "below" /* Below */;
2601
+ } else if (noteAnchor === "stemTip" /* StemTip */ && !hasStem) {
2602
+ noteAnchor = stemDir === "up" /* Up */ ? "above" /* Above */ : "below" /* Below */;
2577
2603
  }
2578
2604
  switch (noteAnchor) {
2579
- case 2 /* Center */:
2605
+ case "center" /* Center */:
2580
2606
  return side === "left" ? { x: rightX, y: centerY } : { x: leftX, y: centerY };
2581
- case 1 /* Above */:
2582
- if (!hasStem || stemDir === 2 /* Down */) {
2607
+ case "above" /* Above */:
2608
+ if (!hasStem || stemDir === "down" /* Down */) {
2583
2609
  return { x: centerX, y: aboveY };
2584
2610
  } else {
2585
2611
  return {
@@ -2587,8 +2613,8 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2587
2613
  y: aboveY
2588
2614
  };
2589
2615
  }
2590
- case 3 /* Below */:
2591
- if (!hasStem || stemDir === 1 /* Up */) {
2616
+ case "below" /* Below */:
2617
+ if (!hasStem || stemDir === "up" /* Up */) {
2592
2618
  return { x: centerX, y: belowY };
2593
2619
  } else {
2594
2620
  return {
@@ -2596,8 +2622,8 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2596
2622
  y: belowY
2597
2623
  };
2598
2624
  }
2599
- case 4 /* StemTip */:
2600
- return { x: centerX, y: stemTip.centerY + (stemDir === 1 /* Up */ ? -padding : padding) };
2625
+ case "stemTip" /* StemTip */:
2626
+ return { x: centerX, y: stemTip.centerY + (stemDir === "up" /* Up */ ? -padding : padding) };
2601
2627
  default:
2602
2628
  throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Invalid noteAnchor: " + noteAnchor);
2603
2629
  }
@@ -2612,7 +2638,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2612
2638
  let x = side === "right" ? r.left : r.right;
2613
2639
  let y;
2614
2640
  let s = 0.9;
2615
- if (connectiveProps.connective === 2 /* Slide */) {
2641
+ if (connectiveProps.connective === "slide" /* Slide */) {
2616
2642
  let leftFretNumber = connectiveProps.noteGroups[0].getFretNumber(obj, 0);
2617
2643
  let rightFretNumber = connectiveProps.noteGroups[1].getFretNumber(obj, 0);
2618
2644
  let slideUp = leftFretNumber === void 0 || rightFretNumber === void 0 || leftFretNumber <= rightFretNumber;
@@ -2666,7 +2692,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2666
2692
  this.runningConnectives = [];
2667
2693
  }
2668
2694
  getPlaySlur() {
2669
- let slurs = this.runningConnectives.filter((c) => c.connective === 1 /* Slur */).map((c) => c.startsWith(this) ? "first" : "slurred");
2695
+ let slurs = this.runningConnectives.filter((c) => c.connective === "slur" /* Slur */).map((c) => c.startsWith(this) ? "first" : "slurred");
2670
2696
  if (slurs.indexOf("first") >= 0) {
2671
2697
  return "first";
2672
2698
  } else if (slurs.indexOf("slurred") >= 0) {
@@ -2678,8 +2704,8 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2678
2704
  getBeamGroup() {
2679
2705
  return this.beamGroup;
2680
2706
  }
2681
- setBeamGroup(beam) {
2682
- this.beamGroup = beam;
2707
+ setBeamGroup(beamGroup) {
2708
+ this.beamGroup = beamGroup;
2683
2709
  }
2684
2710
  resetBeamGroup() {
2685
2711
  this.leftBeamCount = this.rightBeamCount = 0;
@@ -2690,19 +2716,19 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2690
2716
  var _a, _b, _c, _d;
2691
2717
  let staff = obj.staff;
2692
2718
  let x = (_b = (_a = obj.stemTip) == null ? void 0 : _a.centerX) != null ? _b : obj.noteHeadRects[0].centerX;
2693
- let y = (_d = (_c = obj.stemTip) == null ? void 0 : _c.centerY) != null ? _d : this.stemDir === 1 /* Up */ ? obj.getRect().top : obj.getRect().bottom;
2694
- let stemHeight = this.stemDir === 1 /* Up */ ? Math.abs(obj.noteHeadRects[0].centerY - y) : Math.abs(obj.noteHeadRects[obj.noteHeadRects.length - 1].centerY - y);
2719
+ let y = (_d = (_c = obj.stemTip) == null ? void 0 : _c.centerY) != null ? _d : this.stemDir === "up" /* Up */ ? obj.getRect().top : obj.getRect().bottom;
2720
+ let stemHeight = this.stemDir === "up" /* Up */ ? Math.abs(obj.noteHeadRects[0].centerY - y) : Math.abs(obj.noteHeadRects[obj.noteHeadRects.length - 1].centerY - y);
2695
2721
  return { staff, x, y, stemHeight };
2696
2722
  });
2697
2723
  }
2698
2724
  getStemHeight(renderer) {
2699
2725
  let { unitSize } = renderer;
2700
- let { noteLength, flagCount } = this.rhythmProps;
2701
- if (noteLength >= import_theory5.NoteLength.Whole) {
2702
- return 0;
2703
- } else {
2726
+ let { flagCount, hasStem } = this.rhythmProps;
2727
+ if (hasStem) {
2704
2728
  let addY = this.hasBeamCount() ? DocumentSettings.BeamSeparation : DocumentSettings.FlagSeparation;
2705
2729
  return (DocumentSettings.StemHeight + Math.max(0, flagCount - 1) * addY) * unitSize;
2730
+ } else {
2731
+ return 0;
2706
2732
  }
2707
2733
  }
2708
2734
  hasBeamCount() {
@@ -2721,13 +2747,13 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2721
2747
  return staff.containsVoiceId(this.voiceId) && this.staffObjects.some((obj) => obj instanceof ObjStaffNoteGroup && obj.staff === staff);
2722
2748
  }
2723
2749
  getPlayTicks(note) {
2724
- let tiedTicks = this.runningConnectives.filter((c) => c.connective === 0 /* Tie */).map((tie) => {
2750
+ let tiedTicks = this.runningConnectives.filter((c) => c.connective === "tie" /* Tie */).map((tie) => {
2725
2751
  let tieNoteGroups = tie.noteGroups;
2726
2752
  let j = tieNoteGroups.indexOf(this);
2727
2753
  if (j < 0) {
2728
2754
  return 0;
2729
2755
  }
2730
- if (tie.span === -1 /* Stub */ || tie.span === -2 /* ToMeasureEnd */) {
2756
+ if (tie.span === "stub" /* Stub */ || tie.span === "toMeasureEnd" /* ToMeasureEnd */) {
2731
2757
  return Math.max(this.rhythmProps.ticks, this.measure.getMeasureTicks() - this.col.positionTicks);
2732
2758
  }
2733
2759
  let prev = tieNoteGroups[j - 1];
@@ -2754,7 +2780,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2754
2780
  this.requestRectUpdate();
2755
2781
  let { unitSize } = renderer;
2756
2782
  let { row, stemDir } = this;
2757
- let { dotted, flagCount } = this.rhythmProps;
2783
+ let { dotCount, flagCount, hasStem } = this.rhythmProps;
2758
2784
  let dotWidth = DocumentSettings.DotSize * unitSize;
2759
2785
  let noteHeadWidth = (this.diamond ? DocumentSettings.DiamondNoteHeadSize : DocumentSettings.NoteHeadWidth) * unitSize;
2760
2786
  let noteHeadHeight = (this.diamond ? DocumentSettings.DiamondNoteHeadSize : DocumentSettings.NoteHeadHeight) * unitSize;
@@ -2774,10 +2800,10 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2774
2800
  let noteX = this.col.getNoteHeadDisplacement(this, note) * noteHeadWidth;
2775
2801
  let noteY = noteStaff.getDiatonicIdY(note.diatonicId);
2776
2802
  let isNoteOnLine = noteStaff.isLine(note.diatonicId);
2777
- if (isBottomNote && stemDir === 1 /* Up */) stemBaseStaff = noteStaff;
2778
- if (isTopNote && stemDir === 1 /* Up */) stemTipStaff = noteStaff;
2779
- if (isBottomNote && stemDir === 2 /* Down */) stemTipStaff = noteStaff;
2780
- if (isTopNote && stemDir === 2 /* Down */) stemBaseStaff = noteStaff;
2803
+ if (isBottomNote && stemDir === "up" /* Up */) stemBaseStaff = noteStaff;
2804
+ if (isTopNote && stemDir === "up" /* Up */) stemTipStaff = noteStaff;
2805
+ if (isBottomNote && stemDir === "down" /* Down */) stemTipStaff = noteStaff;
2806
+ if (isTopNote && stemDir === "down" /* Down */) stemBaseStaff = noteStaff;
2781
2807
  let noteHeadRect = obj.noteHeadRects[noteIndex] = DivRect.createCentered(noteX, noteY, noteHeadWidth, noteHeadHeight);
2782
2808
  noteStaff.addObject(noteHeadRect);
2783
2809
  if (accState.needAccidental(note)) {
@@ -2788,21 +2814,21 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2788
2814
  }
2789
2815
  noteStaff.addObject(acc);
2790
2816
  }
2791
- if (dotted) {
2792
- let dotX = noteHeadRect.right + DocumentSettings.NoteDotSpace * unitSize + dotWidth / 2;
2817
+ for (let i = 0; i < dotCount; i++) {
2818
+ let dotX = noteHeadRect.right + DocumentSettings.NoteDotSpace * unitSize + dotWidth / 2 + i * dotWidth * 1.5;
2793
2819
  let dotY = noteY + this.getDotVerticalDisplacement(staff, note.diatonicId, stemDir) * unitSize;
2794
2820
  let r = DivRect.createCentered(dotX, dotY, dotWidth, dotWidth);
2795
2821
  obj.dotRects.push(r);
2796
2822
  noteStaff.addObject(r);
2797
2823
  }
2798
2824
  if (this.staccato) {
2799
- if (stemDir === 1 /* Up */ && isBottomNote) {
2825
+ if (stemDir === "up" /* Up */ && isBottomNote) {
2800
2826
  let dotX = noteX;
2801
2827
  let dotY = noteY + unitSize * (isNoteOnLine ? 3 : 2);
2802
2828
  let r = DivRect.createCentered(dotX, dotY, dotWidth, dotWidth);
2803
2829
  obj.dotRects.push(r);
2804
2830
  stemBaseStaff.addObject(r);
2805
- } else if (stemDir === 2 /* Down */ && isTopNote) {
2831
+ } else if (stemDir === "down" /* Down */ && isTopNote) {
2806
2832
  let dotX = noteX;
2807
2833
  let dotY = noteY - unitSize * (isNoteOnLine ? 3 : 2);
2808
2834
  let r = DivRect.createCentered(dotX, dotY, dotWidth, dotWidth);
@@ -2813,11 +2839,11 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2813
2839
  });
2814
2840
  let bottomNoteY = obj.noteHeadRects[0].centerY;
2815
2841
  let topNoteY = obj.noteHeadRects[obj.noteHeadRects.length - 1].centerY;
2816
- let stemX = stemDir === 1 /* Up */ ? noteHeadWidth / 2 : -noteHeadWidth / 2;
2842
+ let stemX = stemDir === "up" /* Up */ ? noteHeadWidth / 2 : -noteHeadWidth / 2;
2817
2843
  let stemHeight = this.getStemHeight(renderer);
2818
- let stemTipY = stemDir === 1 /* Up */ ? topNoteY - stemHeight : bottomNoteY + stemHeight;
2819
- let stemBaseY = stemDir === 1 /* Up */ ? bottomNoteY : topNoteY;
2820
- if (this.rhythmProps.hasStem()) {
2844
+ let stemTipY = stemDir === "up" /* Up */ ? topNoteY - stemHeight : bottomNoteY + stemHeight;
2845
+ let stemBaseY = stemDir === "up" /* Up */ ? bottomNoteY : topNoteY;
2846
+ if (hasStem) {
2821
2847
  obj.stemTip = new DivRect(stemX, stemX, stemTipY, stemTipY);
2822
2848
  obj.stemBase = new DivRect(stemX, stemX, stemBaseY, stemBaseY);
2823
2849
  stemTipStaff.addObject(obj.stemTip);
@@ -2828,7 +2854,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2828
2854
  let flagHeight = flagCount === 0 ? 0 : DocumentSettings.FlagHeight * unitSize;
2829
2855
  for (let i = 0; i < flagCount; i++) {
2830
2856
  let flagAddY = i * unitSize * DocumentSettings.FlagSeparation;
2831
- let r = obj.flagRects[i] = stemDir === 1 /* Up */ ? new DivRect(stemX, stemX + flagWidth, stemTipY + flagAddY, stemTipY + flagHeight + flagAddY) : new DivRect(stemX, stemX + flagWidth, stemTipY - flagHeight - flagAddY, stemTipY - flagAddY);
2857
+ let r = obj.flagRects[i] = stemDir === "up" /* Up */ ? new DivRect(stemX, stemX + flagWidth, stemTipY + flagAddY, stemTipY + flagHeight + flagAddY) : new DivRect(stemX, stemX + flagWidth, stemTipY - flagHeight - flagAddY, stemTipY - flagAddY);
2832
2858
  stemTipStaff.addObject(r);
2833
2859
  }
2834
2860
  }
@@ -2841,7 +2867,6 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2841
2867
  }
2842
2868
  let obj = new ObjTabNoteGroup(tab, this);
2843
2869
  this.notes.forEach((note, noteIndex) => {
2844
- var _a, _b;
2845
2870
  if (this.ownString[noteIndex] !== void 0) {
2846
2871
  let stringId = this.ownString[noteIndex] - 1;
2847
2872
  let fretId = note.chromaticId - tab.getTuningStrings()[stringId].chromaticId;
@@ -2849,9 +2874,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2849
2874
  let fretNumber = new ObjText(this, { text: String(fretId), color, bgcolor: "white" }, 0.5, 0.5);
2850
2875
  obj.fretNumbers.push(fretNumber);
2851
2876
  fretNumber.layout(renderer);
2852
- let noteX = this.col.getNoteHeadDisplacement(this, note) * noteHeadWidth;
2853
- let stemX = (_b = (_a = this.staffObjects[0]) == null ? void 0 : _a.stemBase) == null ? void 0 : _b.centerX;
2854
- let x = stemX != null ? stemX : noteX;
2877
+ let x = this.col.getRect().centerX;
2855
2878
  let y = tab.getStringY(stringId);
2856
2879
  fretNumber.offset(x, y);
2857
2880
  }
@@ -2894,15 +2917,22 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2894
2917
  renderer.drawDebugRect(this.getRect());
2895
2918
  let { lineWidth } = renderer;
2896
2919
  let { color, stemDir } = this;
2897
- let { noteLength } = this.rhythmProps;
2920
+ let { isSolidNoteHead } = this.rhythmProps;
2898
2921
  this.staffObjects.forEach((obj) => {
2899
2922
  obj.accidentals.forEach((d) => d.draw(renderer));
2900
2923
  ctx.strokeStyle = ctx.fillStyle = color;
2901
2924
  ctx.lineWidth = lineWidth;
2902
2925
  obj.noteHeadRects.forEach((r) => {
2903
- let outlinedNoteHead = noteLength >= import_theory5.NoteLength.Half;
2904
2926
  if (this.diamond) {
2905
- if (outlinedNoteHead) {
2927
+ if (isSolidNoteHead) {
2928
+ ctx.beginPath();
2929
+ ctx.moveTo(r.centerX, r.top);
2930
+ ctx.lineTo(r.right, r.centerY);
2931
+ ctx.lineTo(r.centerX, r.bottom);
2932
+ ctx.lineTo(r.left, r.centerY);
2933
+ ctx.lineTo(r.centerX, r.top);
2934
+ ctx.fill();
2935
+ } else {
2906
2936
  ctx.beginPath();
2907
2937
  ctx.lineWidth = lineWidth * 2.5;
2908
2938
  ctx.moveTo(r.centerX, r.top);
@@ -2917,22 +2947,14 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2917
2947
  ctx.moveTo(r.centerX, r.top);
2918
2948
  ctx.lineTo(r.left, r.centerY);
2919
2949
  ctx.stroke();
2920
- } else {
2921
- ctx.beginPath();
2922
- ctx.moveTo(r.centerX, r.top);
2923
- ctx.lineTo(r.right, r.centerY);
2924
- ctx.lineTo(r.centerX, r.bottom);
2925
- ctx.lineTo(r.left, r.centerY);
2926
- ctx.lineTo(r.centerX, r.top);
2927
- ctx.fill();
2928
2950
  }
2929
2951
  } else {
2930
2952
  ctx.beginPath();
2931
2953
  ctx.ellipse(r.centerX, r.centerY, r.leftw, r.toph, -0.3, 0, Math.PI * 2);
2932
- if (outlinedNoteHead) {
2933
- ctx.stroke();
2934
- } else {
2954
+ if (isSolidNoteHead) {
2935
2955
  ctx.fill();
2956
+ } else {
2957
+ ctx.stroke();
2936
2958
  }
2937
2959
  }
2938
2960
  });
@@ -2947,8 +2969,8 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2947
2969
  let left = rect.left;
2948
2970
  let right = rect.right;
2949
2971
  let width = right - left;
2950
- let top = stemDir === 1 /* Up */ ? rect.top : rect.bottom;
2951
- let bottom = stemDir === 1 /* Up */ ? rect.bottom : rect.top;
2972
+ let top = stemDir === "up" /* Up */ ? rect.top : rect.bottom;
2973
+ let bottom = stemDir === "up" /* Up */ ? rect.bottom : rect.top;
2952
2974
  ctx.beginPath();
2953
2975
  ctx.moveTo(left, top);
2954
2976
  ctx.bezierCurveTo(
@@ -2962,13 +2984,13 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
2962
2984
  ctx.stroke();
2963
2985
  });
2964
2986
  });
2965
- this.tabObjects.forEach((obj) => {
2966
- obj.fretNumbers.forEach((fn) => fn.draw(renderer));
2967
- });
2987
+ this.tabObjects.forEach((obj) => obj.fretNumbers.forEach((fn) => fn.draw(renderer)));
2968
2988
  }
2969
2989
  static setBeamCounts(groupNotes) {
2970
2990
  const isADottedBHalf = (a, b) => {
2971
- return a.rhythmProps.noteLength === b.rhythmProps.noteLength * 2 && a.rhythmProps.dotted && !b.rhythmProps.dotted && a.rhythmProps.flagCount > 0 && b.rhythmProps.flagCount > 0;
2991
+ let { flagCount: aFlagCount, noteSize: aNoteSize, dotCount: aDotCount } = a.rhythmProps;
2992
+ let { flagCount: bFlagCount, noteSize: bNoteSize, dotCount: bDotCount } = b.rhythmProps;
2993
+ return aFlagCount > 0 && bFlagCount > 0 && aDotCount > 0 && bDotCount === 0 && aNoteSize * Math.pow(2, aDotCount) === bNoteSize;
2972
2994
  };
2973
2995
  for (let i = 0; i < groupNotes.length; i++) {
2974
2996
  let center = groupNotes[i];
@@ -3014,29 +3036,27 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
3014
3036
  }
3015
3037
  } while (fixAgain);
3016
3038
  }
3017
- static setTripletBeamCounts(triplet) {
3018
- let type = triplet.getType();
3019
- let symbols = triplet.getSymbols();
3020
- if (type === 1 /* TripletBeam */) {
3039
+ static setTupletBeamCounts(tuplet) {
3040
+ let type = tuplet.getType();
3041
+ let symbols = tuplet.getSymbols();
3042
+ if (type === 1 /* TupletBeam */) {
3021
3043
  symbols.forEach((s, i) => {
3022
3044
  if (s instanceof _ObjNoteGroup) {
3023
3045
  s.leftBeamCount = i === 0 ? 0 : s.rhythmProps.flagCount;
3024
3046
  s.rightBeamCount = i === symbols.length - 1 ? 0 : s.rhythmProps.flagCount;
3025
3047
  }
3026
3048
  });
3027
- } else if (type === 2 /* TripletGroup */) {
3049
+ } else if (type === 2 /* TupletGroup */) {
3028
3050
  symbols.forEach((s) => {
3029
3051
  if (s instanceof _ObjNoteGroup) {
3030
3052
  s.leftBeamCount = s.rightBeamCount = 0;
3031
3053
  }
3032
3054
  });
3033
- } else {
3034
- throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Cannot set triplet beam count because triplet beam group type is invalid.");
3035
3055
  }
3036
3056
  }
3037
3057
  getDotVerticalDisplacement(staff, diatonicId, stemDir) {
3038
3058
  if (staff.isLine(diatonicId)) {
3039
- return stemDir === 1 /* Up */ ? -1 : 1;
3059
+ return stemDir === "up" /* Up */ ? -1 : 1;
3040
3060
  } else {
3041
3061
  return 0;
3042
3062
  }
@@ -3061,7 +3081,7 @@ var import_core8 = require("@tspro/web-music-score/core");
3061
3081
  var noteHeadDataCompareFunc = (a, b) => {
3062
3082
  let cmp = import_theory6.Note.compareFunc(a.note, b.note);
3063
3083
  if (cmp === 0) {
3064
- cmp = a.noteGroup.stemDir === b.noteGroup.stemDir ? 0 : a.noteGroup.stemDir === 1 /* Up */ ? 1 : -1;
3084
+ cmp = a.noteGroup.stemDir === b.noteGroup.stemDir ? 0 : a.noteGroup.stemDir === "up" /* Up */ ? 1 : -1;
3065
3085
  }
3066
3086
  return cmp;
3067
3087
  };
@@ -3174,16 +3194,14 @@ var ObjRhythmColumn = class extends MusicObject {
3174
3194
  }
3175
3195
  getArpeggioDir() {
3176
3196
  var _a;
3177
- return (_a = this.arpeggioDir) != null ? _a : 0 /* Up */;
3197
+ return (_a = this.arpeggioDir) != null ? _a : "up" /* Up */;
3178
3198
  }
3179
3199
  setVoiceSymbol(voiceId, symbol) {
3180
3200
  validateVoiceId(voiceId);
3181
3201
  this.voiceSymbol[voiceId] = symbol;
3182
- if (symbol instanceof ObjRest) {
3183
- if (!symbol.hide && symbol.noteLength >= import_theory6.NoteLength.Half) {
3184
- this.minDiatonicId = this.minDiatonicId === void 0 ? symbol.ownDiatonicId : Math.min(this.minDiatonicId, symbol.ownDiatonicId);
3185
- this.maxDiatonicId = this.maxDiatonicId === void 0 ? symbol.ownDiatonicId : Math.max(this.maxDiatonicId, symbol.ownDiatonicId);
3186
- }
3202
+ if (symbol instanceof ObjRest && !symbol.hide) {
3203
+ this.minDiatonicId = this.minDiatonicId === void 0 ? symbol.ownDiatonicId : Math.min(this.minDiatonicId, symbol.ownDiatonicId);
3204
+ this.maxDiatonicId = this.maxDiatonicId === void 0 ? symbol.ownDiatonicId : Math.max(this.maxDiatonicId, symbol.ownDiatonicId);
3187
3205
  } else if (symbol instanceof ObjNoteGroup) {
3188
3206
  this.minDiatonicId = this.minDiatonicId === void 0 ? symbol.notes[0].diatonicId : Math.min(this.minDiatonicId, symbol.notes[0].diatonicId);
3189
3207
  this.maxDiatonicId = this.maxDiatonicId === void 0 ? symbol.notes[symbol.notes.length - 1].diatonicId : Math.max(this.maxDiatonicId, symbol.notes[symbol.notes.length - 1].diatonicId);
@@ -3199,15 +3217,18 @@ var ObjRhythmColumn = class extends MusicObject {
3199
3217
  return this.voiceSymbol[voiceId];
3200
3218
  }
3201
3219
  getMinWidth() {
3202
- let maxNoteLength = Math.max(...this.voiceSymbol.map((s) => s.rhythmProps.noteLength));
3220
+ let maxNoteSize = Math.max(...this.voiceSymbol.map((s) => s.rhythmProps.noteSize));
3203
3221
  let w = DocumentSettings.NoteHeadWidth;
3204
- switch (maxNoteLength) {
3205
- case import_theory6.NoteLength.Whole:
3222
+ switch (maxNoteSize) {
3223
+ case 1:
3206
3224
  return w * 5;
3207
- case import_theory6.NoteLength.Half:
3225
+ // whole note
3226
+ case 2:
3208
3227
  return w * 3;
3209
- case import_theory6.NoteLength.Quarter:
3228
+ // half note
3229
+ case 4:
3210
3230
  return w * 2;
3231
+ // quarter note
3211
3232
  default:
3212
3233
  return w;
3213
3234
  }
@@ -3239,7 +3260,7 @@ var ObjRhythmColumn = class extends MusicObject {
3239
3260
  if (cur.displacement !== void 0) {
3240
3261
  continue;
3241
3262
  }
3242
- let d = cur.noteGroup.stemDir === 2 /* Down */ ? -1 : 1;
3263
+ let d = cur.noteGroup.stemDir === "down" /* Down */ ? -1 : 1;
3243
3264
  if (prev && cur.note.diatonicId - prev.note.diatonicId <= 1) {
3244
3265
  cur.displacement = prev.displacement === 0 ? d : 0;
3245
3266
  } else if (next && next.note.diatonicId - cur.note.diatonicId <= 1) {
@@ -3293,7 +3314,7 @@ var ObjRhythmColumn = class extends MusicObject {
3293
3314
  }
3294
3315
  });
3295
3316
  playerNotes.sort((a, b) => import_theory6.Note.compareFunc(a.note, b.note));
3296
- if (this.hasArpeggio() && this.getArpeggioDir() === 1 /* Down */) {
3317
+ if (this.hasArpeggio() && this.getArpeggioDir() === "down" /* Down */) {
3297
3318
  playerNotes.reverse();
3298
3319
  }
3299
3320
  return playerNotes;
@@ -3410,6 +3431,12 @@ var ObjRhythmColumn = class extends MusicObject {
3410
3431
  }
3411
3432
  };
3412
3433
 
3434
+ // src/score/engine/extension.ts
3435
+ var import_core9 = require("@tspro/web-music-score/core");
3436
+
3437
+ // src/score/engine/element-data.ts
3438
+ var import_ts_utils_lib5 = require("@tspro/ts-utils-lib");
3439
+
3413
3440
  // src/score/engine/obj-special-text.ts
3414
3441
  var _ObjSpecialText = class _ObjSpecialText extends MusicObject {
3415
3442
  constructor(parent, text) {
@@ -3507,40 +3534,53 @@ __publicField(_ObjSpecialText, "Segno", "\u{1D10B}");
3507
3534
  var ObjSpecialText = _ObjSpecialText;
3508
3535
 
3509
3536
  // src/score/engine/element-data.ts
3510
- function getNavigationString(n) {
3511
- switch (n) {
3512
- case 1 /* DC_al_Coda */:
3537
+ function getNavigationString(navigation) {
3538
+ switch (navigation) {
3539
+ case "D.C. al Coda" /* DC_al_Coda */:
3513
3540
  return "D.C. al Coda";
3514
- case 0 /* DC_al_Fine */:
3541
+ case "D.C. al Fine" /* DC_al_Fine */:
3515
3542
  return "D.C. al Fine";
3516
- case 3 /* DS_al_Coda */:
3543
+ case "D.S. al Coda" /* DS_al_Coda */:
3517
3544
  return "D.S. al Coda";
3518
- case 2 /* DS_al_Fine */:
3545
+ case "D.S. al Fine" /* DS_al_Fine */:
3519
3546
  return "D.S. al Fine";
3520
- case 7 /* Fine */:
3547
+ case "Fine" /* Fine */:
3521
3548
  return "Fine";
3522
- case 6 /* Segno */:
3549
+ case "Segno" /* Segno */:
3523
3550
  return ObjSpecialText.Segno;
3524
- case 4 /* Coda */:
3551
+ case "Coda" /* Coda */:
3525
3552
  return ObjSpecialText.Coda;
3526
- case 5 /* toCoda */:
3553
+ case "toCoda" /* toCoda */:
3527
3554
  return ObjSpecialText.toCoda;
3528
3555
  default:
3529
- return Navigation[n];
3556
+ return navigation[0].toUpperCase() + navigation.substring(1);
3530
3557
  }
3531
3558
  }
3532
3559
  function isDynamicsText(text) {
3533
- return ["ppp", "pp", "p", "mp", "m", "mf", "f", "ff", "fff", "cresc.", "decresc.", "dim."].indexOf(text) >= 0;
3560
+ return import_ts_utils_lib5.Utils.Is.isEnumValue(text, DynamicsAnnotation);
3534
3561
  }
3535
- function isDynamicsLevelText(text) {
3536
- return ["ppp", "pp", "p", "mp", "m", "mf", "f", "ff", "fff"].indexOf(text) >= 0;
3562
+ function getDynamicsVolume(text) {
3563
+ if (/^(p+|f+|m|mp|mf)$/.test(text)) {
3564
+ let volume = 0.5 - import_ts_utils_lib5.Utils.Str.charCount(text, "p") * 0.1 + import_ts_utils_lib5.Utils.Str.charCount(text, "f") * 0.1;
3565
+ return import_ts_utils_lib5.Utils.Math.clamp(volume, 0, 1);
3566
+ } else {
3567
+ return void 0;
3568
+ }
3537
3569
  }
3538
3570
  function isTempoText(text) {
3539
- return ["accel.", "rit.", "a tempo"].indexOf(text) >= 0;
3571
+ return import_ts_utils_lib5.Utils.Is.isEnumValue(text, TempoAnnotation);
3572
+ }
3573
+ function getAnnotation(text) {
3574
+ if (import_ts_utils_lib5.Utils.Is.isEnumValue(text, DynamicsAnnotation)) {
3575
+ return "dynamics" /* Dynamics */;
3576
+ } else if (import_ts_utils_lib5.Utils.Is.isEnumValue(text, TempoAnnotation)) {
3577
+ return "tempo" /* Tempo */;
3578
+ } else {
3579
+ return void 0;
3580
+ }
3540
3581
  }
3541
3582
 
3542
3583
  // src/score/engine/extension.ts
3543
- var import_core9 = require("@tspro/web-music-score/core");
3544
3584
  function getTextAnchorY(linePos) {
3545
3585
  switch (linePos) {
3546
3586
  case "bottom":
@@ -3595,7 +3635,7 @@ var Extension = class extends MusicObjectLink {
3595
3635
  if (prevMeasure.hasEndSection() || prevMeasure.hasEndSong()) {
3596
3636
  return "section-break";
3597
3637
  }
3598
- let elemArr = [9 /* EndRepeat */, 10 /* Ending */];
3638
+ let elemArr = ["endRepeat" /* EndRepeat */, "ending" /* Ending */];
3599
3639
  for (let i = 0; i < elemArr.length; i++) {
3600
3640
  if (prevMeasure.hasNavigation(elemArr[i])) {
3601
3641
  return "section-break";
@@ -3656,35 +3696,12 @@ var RitardandoSpeedDiv = 2;
3656
3696
  var CrescendoVolumeAdd = 0.5;
3657
3697
  var DiminuendoVolumeSub = 0.5;
3658
3698
  function calcTicksDuration(ticks, tempo) {
3659
- let beatTicks = new import_theory7.RhythmProps(tempo.options.beatLength, tempo.options.dotted).ticks;
3699
+ let beatTicks = import_theory7.RhythmProps.get(tempo.options.beatLength, tempo.options.dotCount).ticks;
3660
3700
  let ticksPerMinute = tempo.beatsPerMinute * beatTicks;
3661
3701
  return 60 * ticks / ticksPerMinute;
3662
3702
  }
3663
- function getVolume(dynamicsLevelText) {
3664
- switch (dynamicsLevelText) {
3665
- case "fff":
3666
- return 0.9;
3667
- case "ff":
3668
- return 0.8;
3669
- case "f":
3670
- return 0.7;
3671
- case "mf":
3672
- return 0.6;
3673
- default:
3674
- case "m":
3675
- return 0.5;
3676
- case "mp":
3677
- return 0.4;
3678
- case "p":
3679
- return 0.3;
3680
- case "pp":
3681
- return 0.2;
3682
- case "ppp":
3683
- return 0.1;
3684
- }
3685
- }
3686
3703
  function getDefaultVolume() {
3687
- return getVolume("m");
3704
+ return getDynamicsVolume("m");
3688
3705
  }
3689
3706
  function adjustVolume(linearVolume) {
3690
3707
  return linearVolume * 1.25;
@@ -3712,7 +3729,7 @@ var PlayerColumnProps = class {
3712
3729
  return this.speed;
3713
3730
  }
3714
3731
  getTempo() {
3715
- let speed = import_ts_utils_lib5.Utils.Math.clamp(this.getSpeed(), 0.1, 10);
3732
+ let speed = import_ts_utils_lib6.Utils.Math.clamp(this.getSpeed(), 0.1, 10);
3716
3733
  return (0, import_theory7.alterTempoSpeed)(this.measure.getTempo(), speed);
3717
3734
  }
3718
3735
  setVolume(volume) {
@@ -3737,7 +3754,7 @@ var PlayerColumnProps = class {
3737
3754
  if (symbolsTicks.length === 0) {
3738
3755
  return 0;
3739
3756
  } else {
3740
- return import_ts_utils_lib5.Utils.Math.sum(symbolsTicks) / symbolsTicks.length;
3757
+ return import_ts_utils_lib6.Utils.Math.sum(symbolsTicks) / symbolsTicks.length;
3741
3758
  }
3742
3759
  }
3743
3760
  }
@@ -3800,34 +3817,34 @@ var Player = class _Player {
3800
3817
  continue;
3801
3818
  }
3802
3819
  measureSequence.push(curMeasure);
3803
- if (curMeasure.hasNavigation(8 /* StartRepeat */)) {
3820
+ if (curMeasure.hasNavigation("startRepeat" /* StartRepeat */)) {
3804
3821
  startRepeatMeasure = curMeasure;
3805
3822
  }
3806
- if (curMeasure.hasNavigation(6 /* Segno */)) {
3823
+ if (curMeasure.hasNavigation("Segno" /* Segno */)) {
3807
3824
  segnoMeasure = curMeasure;
3808
3825
  }
3809
- if (alCoda && curMeasure.hasNavigation(5 /* toCoda */)) {
3810
- while (curMeasure && !curMeasure.hasNavigation(4 /* Coda */)) {
3826
+ if (alCoda && curMeasure.hasNavigation("toCoda" /* toCoda */)) {
3827
+ while (curMeasure && !curMeasure.hasNavigation("Coda" /* Coda */)) {
3811
3828
  curMeasure = curMeasure.getNextMeasure();
3812
3829
  }
3813
- } else if (alFine && curMeasure.hasNavigation(7 /* Fine */)) {
3830
+ } else if (alFine && curMeasure.hasNavigation("Fine" /* Fine */)) {
3814
3831
  curMeasure = void 0;
3815
- } else if (curMeasure.hasNavigation(1 /* DC_al_Coda */)) {
3832
+ } else if (curMeasure.hasNavigation("D.C. al Coda" /* DC_al_Coda */)) {
3816
3833
  alCoda = true;
3817
3834
  curMeasure = this.doc.getFirstMeasure();
3818
- } else if (curMeasure.hasNavigation(0 /* DC_al_Fine */)) {
3835
+ } else if (curMeasure.hasNavigation("D.C. al Fine" /* DC_al_Fine */)) {
3819
3836
  alFine = true;
3820
3837
  curMeasure = this.doc.getFirstMeasure();
3821
- } else if (curMeasure.hasNavigation(3 /* DS_al_Coda */)) {
3838
+ } else if (curMeasure.hasNavigation("D.S. al Coda" /* DS_al_Coda */)) {
3822
3839
  alCoda = true;
3823
3840
  curMeasure = segnoMeasure;
3824
- } else if (curMeasure.hasNavigation(2 /* DS_al_Fine */)) {
3841
+ } else if (curMeasure.hasNavigation("D.S. al Fine" /* DS_al_Fine */)) {
3825
3842
  alFine = true;
3826
3843
  curMeasure = segnoMeasure;
3827
- } else if (curMeasure.hasNavigation(9 /* EndRepeat */)) {
3844
+ } else if (curMeasure.hasNavigation("endRepeat" /* EndRepeat */)) {
3828
3845
  let passage = curMeasure.getPassCount();
3829
3846
  let repeatCount = curMeasure.getEndRepeatPlayCount() - 1;
3830
- let cannotPassThrough = ((_a = curMeasure.getNextMeasure()) == null ? void 0 : _a.hasNavigation(10 /* Ending */)) === true;
3847
+ let cannotPassThrough = ((_a = curMeasure.getNextMeasure()) == null ? void 0 : _a.hasNavigation("ending" /* Ending */)) === true;
3831
3848
  if (passage <= repeatCount || cannotPassThrough) {
3832
3849
  curMeasure = startRepeatMeasure;
3833
3850
  } else {
@@ -3878,14 +3895,15 @@ var Player = class _Player {
3878
3895
  col.getAnchoredLayoutObjects().forEach((layoutObj) => {
3879
3896
  var _a2;
3880
3897
  let text = (_a2 = layoutObj.getTextContent()) != null ? _a2 : "";
3881
- if (text === "a tempo") {
3898
+ let vol;
3899
+ if (text === "a tempo" /* a_tempo */) {
3882
3900
  curSpeed = 1;
3883
- } else if (isDynamicsLevelText(text)) {
3884
- curVolume = getVolume(text);
3901
+ } else if ((vol = getDynamicsVolume(text)) !== void 0) {
3902
+ curVolume = vol;
3885
3903
  } else if (layoutObj.musicObj.getLink() instanceof Extension) {
3886
3904
  let extension = layoutObj.musicObj.getLink();
3887
3905
  let { columnRange, extensionBreakText } = extension.getExtensionRangeInfo();
3888
- let totalTicks = import_ts_utils_lib5.Utils.Math.sum(columnRange.map((c) => c.getTicksToNextColumn()));
3906
+ let totalTicks = import_ts_utils_lib6.Utils.Math.sum(columnRange.map((c) => c.getTicksToNextColumn()));
3889
3907
  switch (text) {
3890
3908
  case "accel." /* accel */: {
3891
3909
  let startSpeed = curSpeed;
@@ -3910,8 +3928,8 @@ var Player = class _Player {
3910
3928
  case "cresc." /* cresc */: {
3911
3929
  let startVol = curVolume;
3912
3930
  let endVol = startVol + CrescendoVolumeAdd;
3913
- if (extensionBreakText && isDynamicsLevelText(extensionBreakText) && getVolume(extensionBreakText) > startVol) {
3914
- endVol = getVolume(extensionBreakText);
3931
+ if (extensionBreakText && (vol = getDynamicsVolume(extensionBreakText)) !== void 0 && vol > startVol) {
3932
+ endVol = vol;
3915
3933
  }
3916
3934
  let accuTicks = 0;
3917
3935
  columnRange.forEach((c) => {
@@ -3924,8 +3942,8 @@ var Player = class _Player {
3924
3942
  case "dim." /* dim */: {
3925
3943
  let startVol = curVolume;
3926
3944
  let endVol = startVol - DiminuendoVolumeSub;
3927
- if (extensionBreakText && isDynamicsLevelText(extensionBreakText) && getVolume(extensionBreakText) < startVol) {
3928
- endVol = getVolume(extensionBreakText);
3945
+ if (extensionBreakText && (vol = getDynamicsVolume(extensionBreakText)) !== void 0 && vol < startVol) {
3946
+ endVol = vol;
3929
3947
  }
3930
3948
  let accuTicks = 0;
3931
3949
  columnRange.forEach((c) => {
@@ -3939,11 +3957,11 @@ var Player = class _Player {
3939
3957
  });
3940
3958
  let speedArr = (_a = speedMap.get(col)) != null ? _a : [];
3941
3959
  if (speedArr.length > 0) {
3942
- curSpeed = import_ts_utils_lib5.Utils.Math.sum(speedArr) / speedArr.length;
3960
+ curSpeed = import_ts_utils_lib6.Utils.Math.sum(speedArr) / speedArr.length;
3943
3961
  }
3944
3962
  let volumeArr = (_b = volumeMap.get(col)) != null ? _b : [];
3945
3963
  if (volumeArr.length > 0) {
3946
- curVolume = import_ts_utils_lib5.Utils.Math.sum(volumeArr) / volumeArr.length;
3964
+ curVolume = import_ts_utils_lib6.Utils.Math.sum(volumeArr) / volumeArr.length;
3947
3965
  }
3948
3966
  col.getPlayerProps().setSpeed(curSpeed);
3949
3967
  col.getPlayerProps().setVolume(curVolume);
@@ -3956,7 +3974,7 @@ var Player = class _Player {
3956
3974
  return m;
3957
3975
  }
3958
3976
  let next = m == null ? void 0 : m.getNextMeasure();
3959
- if (!m || m.hasEndSong() || m.hasEndSection() || !next || next.hasNavigation(8 /* StartRepeat */)) {
3977
+ if (!m || m.hasEndSong() || m.hasEndSection() || !next || next.hasNavigation("startRepeat" /* StartRepeat */)) {
3960
3978
  return void 0;
3961
3979
  }
3962
3980
  }
@@ -3981,11 +3999,11 @@ var Player = class _Player {
3981
3999
  } else {
3982
4000
  let playerNotes = col.getPlayerNotes();
3983
4001
  playerNotes.forEach((note, i) => {
3984
- let arpeggioDelayTicks = col.hasArpeggio() ? import_theory7.NoteLength.ThirtySecond * i : 0;
4002
+ let arpeggioDelayTicks = col.hasArpeggio() ? import_theory7.RhythmProps.get(import_theory7.NoteLength.ThirtySecond).ticks * i : 0;
3985
4003
  let noteSeconds = getDuration(note.ticks + fermataHoldTicks - arpeggioDelayTicks, tempo);
3986
4004
  if (noteSeconds > 0) {
3987
4005
  if (note.staccato) {
3988
- noteSeconds = Math.min(getDuration(import_theory7.NoteLength.Eighth, tempo) / 2, noteSeconds / 2);
4006
+ noteSeconds = Math.min(getDuration(import_theory7.RhythmProps.get(import_theory7.NoteLength.Eighth).ticks, tempo) / 2, noteSeconds / 2);
3989
4007
  }
3990
4008
  let volume = adjustVolume(col.getPlayerProps().getVolume());
3991
4009
  if (note.slur === "slurred") {
@@ -4223,8 +4241,8 @@ var ObjBarLineLeft = class extends ObjBarLine {
4223
4241
  solveBarLineType() {
4224
4242
  let m = this.measure;
4225
4243
  let prev = m.getPrevMeasure();
4226
- if (m.hasNavigation(8 /* StartRepeat */)) {
4227
- if (prev && prev.row === m.row && prev.hasNavigation(9 /* EndRepeat */)) {
4244
+ if (m.hasNavigation("startRepeat" /* StartRepeat */)) {
4245
+ if (prev && prev.row === m.row && prev.hasNavigation("endRepeat" /* EndRepeat */)) {
4228
4246
  return 0 /* None */;
4229
4247
  } else {
4230
4248
  return 4 /* StartRepeat */;
@@ -4251,8 +4269,8 @@ var ObjBarLineRight = class extends ObjBarLine {
4251
4269
  solveBarLineType() {
4252
4270
  let m = this.measure;
4253
4271
  let next = m.getNextMeasure();
4254
- if (m.hasNavigation(9 /* EndRepeat */)) {
4255
- if (next && next.row === m.row && next.hasNavigation(8 /* StartRepeat */)) {
4272
+ if (m.hasNavigation("endRepeat" /* EndRepeat */)) {
4273
+ if (next && next.row === m.row && next.hasNavigation("startRepeat" /* StartRepeat */)) {
4256
4274
  return 6 /* EndStartRepeat */;
4257
4275
  } else {
4258
4276
  return 5 /* EndRepeat */;
@@ -4262,10 +4280,10 @@ var ObjBarLineRight = class extends ObjBarLine {
4262
4280
  } else if (m.hasEndSection()) {
4263
4281
  return 2 /* Double */;
4264
4282
  }
4265
- if (m === m.row.getLastMeasure() && next && next.row === m.row.getNextRow() && next.hasNavigation(8 /* StartRepeat */)) {
4283
+ if (m === m.row.getLastMeasure() && next && next.row === m.row.getNextRow() && next.hasNavigation("startRepeat" /* StartRepeat */)) {
4266
4284
  return 2 /* Double */;
4267
4285
  }
4268
- if (next && next.hasNavigation(8 /* StartRepeat */)) {
4286
+ if (next && next.hasNavigation("startRepeat" /* StartRepeat */)) {
4269
4287
  return 0 /* None */;
4270
4288
  }
4271
4289
  return 1 /* Single */;
@@ -4273,7 +4291,7 @@ var ObjBarLineRight = class extends ObjBarLine {
4273
4291
  };
4274
4292
 
4275
4293
  // src/score/engine/obj-ending.ts
4276
- var import_ts_utils_lib6 = require("@tspro/ts-utils-lib");
4294
+ var import_ts_utils_lib7 = require("@tspro/ts-utils-lib");
4277
4295
  var import_core10 = require("@tspro/web-music-score/core");
4278
4296
  var ObjEnding = class extends MusicObject {
4279
4297
  constructor(measure, passages) {
@@ -4284,9 +4302,9 @@ var ObjEnding = class extends MusicObject {
4284
4302
  __publicField(this, "shapeRects", []);
4285
4303
  __publicField(this, "mi");
4286
4304
  this.mi = new MEnding(this);
4287
- if (!import_ts_utils_lib6.Utils.Is.isIntegerGte(passages.length, 1)) {
4305
+ if (!import_ts_utils_lib7.Utils.Is.isIntegerGte(passages.length, 1)) {
4288
4306
  throw new import_core10.MusicError(import_core10.MusicErrorType.Score, "Passages is empty.");
4289
- } else if (!this.passages.every((p) => import_ts_utils_lib6.Utils.Is.isIntegerGte(p, 1))) {
4307
+ } else if (!this.passages.every((p) => import_ts_utils_lib7.Utils.Is.isIntegerGte(p, 1))) {
4290
4308
  throw new import_core10.MusicError(import_core10.MusicErrorType.Score, "Invalid passages: " + this.passages);
4291
4309
  }
4292
4310
  this.passages.sort((a, b) => a - b);
@@ -4302,7 +4320,7 @@ var ObjEnding = class extends MusicObject {
4302
4320
  isSingleMeasureEnding() {
4303
4321
  let { measure } = this;
4304
4322
  let next = measure.getNextMeasure();
4305
- return (next == null ? void 0 : next.hasNavigation(10 /* Ending */)) === true || measure.hasNavigation(9 /* EndRepeat */) || measure.isLastMeasure();
4323
+ return (next == null ? void 0 : next.hasNavigation("ending" /* Ending */)) === true || measure.hasNavigation("endRepeat" /* EndRepeat */) || measure.isLastMeasure();
4306
4324
  }
4307
4325
  hasPassage(pass) {
4308
4326
  return this.passages.some((p) => p === pass);
@@ -4501,7 +4519,7 @@ var import_core13 = require("@tspro/web-music-score/core");
4501
4519
  var import_theory8 = require("@tspro/web-music-score/theory");
4502
4520
 
4503
4521
  // src/score/engine/obj-connective.ts
4504
- var import_ts_utils_lib7 = require("@tspro/ts-utils-lib");
4522
+ var import_ts_utils_lib8 = require("@tspro/ts-utils-lib");
4505
4523
  var import_core11 = require("@tspro/web-music-score/core");
4506
4524
  var ObjConnective = class extends MusicObject {
4507
4525
  constructor(connectiveProps, line, measure, leftNoteGroup, leftNoteId, ...args) {
@@ -4530,7 +4548,7 @@ var ObjConnective = class extends MusicObject {
4530
4548
  this.rightNoteGroup = args[0];
4531
4549
  this.rightNoteId = args[1];
4532
4550
  this.tieType = void 0;
4533
- } else if (import_ts_utils_lib7.Utils.Is.isEnumValue(args[0], TieType)) {
4551
+ } else if (import_ts_utils_lib8.Utils.Is.isEnumValue(args[0], TieType)) {
4534
4552
  this.rightNoteGroup = void 0;
4535
4553
  this.rightNoteId = void 0;
4536
4554
  this.tieType = args[0];
@@ -4561,7 +4579,7 @@ var ObjConnective = class extends MusicObject {
4561
4579
  if (rightNoteGroup !== void 0 && rightNoteId !== void 0) {
4562
4580
  rightPos = rightNoteGroup.getConnectiveAnchorPoint(connectiveProps, line, rightNoteId, noteAnchor, "right");
4563
4581
  } else {
4564
- rightPos = this.tieType === -2 /* ToMeasureEnd */ ? { x: measure.getColumnsContentRect().right, y: leftPos.y } : { x: leftPos.x + unitSize * DocumentSettings.StubTieLength, y: leftPos.y };
4582
+ rightPos = this.tieType === "toMeasureEnd" /* ToMeasureEnd */ ? { x: measure.getColumnsContentRect().right, y: leftPos.y } : { x: leftPos.x + unitSize * DocumentSettings.StubTieLength, y: leftPos.y };
4565
4583
  }
4566
4584
  let lx, ly, rx, ry;
4567
4585
  if (rightNoteGroup === void 0) {
@@ -4599,8 +4617,8 @@ var ObjConnective = class extends MusicObject {
4599
4617
  this.ly = ly;
4600
4618
  this.rx = rx;
4601
4619
  this.ry = ry;
4602
- this.arcHeight = this.connectiveProps.connective === 2 /* Slide */ ? 0 : arcHeight;
4603
- let { nx, ny } = import_ts_utils_lib7.Utils.Math.calcNormal(lx, ly, rx, ry);
4620
+ this.arcHeight = this.connectiveProps.connective === "slide" /* Slide */ ? 0 : arcHeight;
4621
+ let { nx, ny } = import_ts_utils_lib8.Utils.Math.calcNormal(lx, ly, rx, ry);
4604
4622
  this.cp1x = lx * 0.7 + rx * 0.3 + nx * this.arcHeight;
4605
4623
  this.cp1y = ly * 0.7 + ry * 0.3 + ny * this.arcHeight;
4606
4624
  this.cp2x = lx * 0.3 + rx * 0.7 + nx * this.arcHeight;
@@ -4661,6 +4679,7 @@ var ObjConnective = class extends MusicObject {
4661
4679
 
4662
4680
  // src/score/engine/connective-props.ts
4663
4681
  var import_core12 = require("@tspro/web-music-score/core");
4682
+ var import_ts_utils_lib9 = require("@tspro/ts-utils-lib");
4664
4683
  var ConnectiveProps = class {
4665
4684
  constructor(connective, span, noteAnchor, startNoteGroup) {
4666
4685
  this.connective = connective;
@@ -4682,7 +4701,7 @@ var ConnectiveProps = class {
4682
4701
  * @returns true if noteGroup was added, false if not.
4683
4702
  */
4684
4703
  addNoteGroup(noteGroup) {
4685
- if (this.span === -1 /* Stub */ || this.span === -2 /* ToMeasureEnd */) {
4704
+ if (this.span === "stub" /* Stub */ || this.span === "toMeasureEnd" /* ToMeasureEnd */) {
4686
4705
  return false;
4687
4706
  } else if (this.span > this.noteGroups.length) {
4688
4707
  this.noteGroups.push(noteGroup);
@@ -4692,29 +4711,29 @@ var ConnectiveProps = class {
4692
4711
  }
4693
4712
  }
4694
4713
  computeParams() {
4695
- let stemDir = this.noteGroups[0].stemDir;
4696
- let hasStem = this.noteGroups[0].rhythmProps.hasStem;
4697
- if (this.noteAnchor === 4 /* StemTip */) {
4698
- this.arcDir = stemDir === 1 /* Up */ ? "up" : "down";
4699
- } else if (this.noteAnchor === 0 /* Auto */) {
4700
- this.arcDir = stemDir === 1 /* Up */ || !hasStem ? "down" : "up";
4714
+ let { stemDir } = this.noteGroups[0];
4715
+ let { hasStem } = this.noteGroups[0].rhythmProps;
4716
+ if (this.noteAnchor === "stemTip" /* StemTip */) {
4717
+ this.arcDir = stemDir === "up" /* Up */ ? "up" : "down";
4718
+ } else if (this.noteAnchor === "auto" /* Auto */) {
4719
+ this.arcDir = stemDir === "up" /* Up */ || !hasStem ? "down" : "up";
4701
4720
  if (this.noteGroups[0].notes.length > 1) {
4702
- this.noteAnchor = 2 /* Center */;
4703
- } else if (this.connective === 2 /* Slide */) {
4704
- this.noteAnchor = 2 /* Center */;
4721
+ this.noteAnchor = "center" /* Center */;
4722
+ } else if (this.connective === "slide" /* Slide */) {
4723
+ this.noteAnchor = "center" /* Center */;
4705
4724
  } else if (this.arcDir === "up") {
4706
- this.noteAnchor = 1 /* Above */;
4725
+ this.noteAnchor = "above" /* Above */;
4707
4726
  } else {
4708
- this.noteAnchor = 3 /* Below */;
4727
+ this.noteAnchor = "below" /* Below */;
4709
4728
  }
4710
- } else if (this.noteAnchor === 2 /* Center */) {
4729
+ } else if (this.noteAnchor === "center" /* Center */) {
4711
4730
  let { row } = this.noteGroups[0].measure;
4712
4731
  let diatonicId = this.noteGroups[0].ownDiatonicId;
4713
4732
  let staff = row.getStaff(diatonicId);
4714
4733
  this.arcDir = !staff || diatonicId < staff.middleLineDiatonicId ? "down" : "up";
4715
- } else if (this.noteAnchor === 1 /* Above */) {
4734
+ } else if (this.noteAnchor === "above" /* Above */) {
4716
4735
  this.arcDir = "up";
4717
- } else if (this.noteAnchor === 3 /* Below */) {
4736
+ } else if (this.noteAnchor === "below" /* Below */) {
4718
4737
  this.arcDir = "down";
4719
4738
  }
4720
4739
  }
@@ -4729,8 +4748,8 @@ var ConnectiveProps = class {
4729
4748
  this.getStartNoteGroup().collectConnectiveProps();
4730
4749
  this.computeParams();
4731
4750
  let { connective, span } = this;
4732
- if (connective === 0 /* Tie */) {
4733
- if (span === -1 /* Stub */ || span === -2 /* ToMeasureEnd */) {
4751
+ if (connective === "tie" /* Tie */) {
4752
+ if (import_ts_utils_lib9.Utils.Is.isEnumValue(span, TieType)) {
4734
4753
  let leftNoteGroup = this.noteGroups[0];
4735
4754
  for (let noteId = 0; noteId < leftNoteGroup.notes.length; noteId++) {
4736
4755
  this.createObjConnectiveWithTieType(leftNoteGroup, noteId, span);
@@ -4747,13 +4766,13 @@ var ConnectiveProps = class {
4747
4766
  });
4748
4767
  }
4749
4768
  }
4750
- } else if (connective === 1 /* Slur */) {
4769
+ } else if (connective === "slur" /* Slur */) {
4751
4770
  if (typeof span === "number" && span >= 2 && this.noteGroups.length === span) {
4752
4771
  let leftNoteGroup = this.noteGroups[0];
4753
4772
  let rightNoteGroup = this.noteGroups[this.noteGroups.length - 1];
4754
4773
  this.createObjConnective(leftNoteGroup, 0, rightNoteGroup, 0);
4755
4774
  }
4756
- } else if (connective === 2 /* Slide */) {
4775
+ } else if (connective === "slide" /* Slide */) {
4757
4776
  if (this.noteGroups.length >= 2) {
4758
4777
  for (let i = 0; i < this.noteGroups.length - 1; i++) {
4759
4778
  let leftNoteGroup = this.noteGroups[i];
@@ -4783,7 +4802,7 @@ var ConnectiveProps = class {
4783
4802
  } else {
4784
4803
  let leftString = leftNoteGroup2.getFretNumberString(leftNoteId2);
4785
4804
  let rightString = rightNoteGroup2.getFretNumberString(rightNoteId2);
4786
- if (leftString !== void 0 && rightString !== void 0 && (leftString === rightString || this.connective === 1 /* Slur */)) {
4805
+ if (leftString !== void 0 && rightString !== void 0 && (leftString === rightString || this.connective === "slur" /* Slur */)) {
4787
4806
  new ObjConnective(this, line, measure, leftNoteGroup2, leftNoteId2, rightNoteGroup2, rightNoteId2);
4788
4807
  }
4789
4808
  }
@@ -4808,6 +4827,32 @@ function validateVoiceId(voiceId) {
4808
4827
  return voiceId;
4809
4828
  }
4810
4829
  }
4830
+ function getExtensionTicks(extensionLength) {
4831
+ if (typeof extensionLength === "string") {
4832
+ extensionLength = [extensionLength];
4833
+ }
4834
+ if (import_ts_utils_lib10.Utils.Is.isArray(extensionLength)) {
4835
+ let totalTicks = 0;
4836
+ for (let i = 0; i < extensionLength.length; ) {
4837
+ let str = extensionLength[i];
4838
+ let num = extensionLength[i + 1];
4839
+ if (typeof str === "string") {
4840
+ i++;
4841
+ let ticks = import_theory9.RhythmProps.get(str).ticks;
4842
+ if (typeof num === "number") {
4843
+ i++;
4844
+ ticks *= num;
4845
+ }
4846
+ totalTicks += ticks;
4847
+ } else {
4848
+ i++;
4849
+ }
4850
+ }
4851
+ return totalTicks;
4852
+ } else {
4853
+ return extensionLength;
4854
+ }
4855
+ }
4811
4856
  var _ObjMeasure = class _ObjMeasure extends MusicObject {
4812
4857
  constructor(row) {
4813
4858
  super(row);
@@ -4911,15 +4956,15 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
4911
4956
  if (setStemDir !== void 0) {
4912
4957
  this.useStemDir[voiceId] = setStemDir;
4913
4958
  } else if (this.useStemDir[voiceId] === void 0) {
4914
- this.useStemDir[voiceId] = (_b = (_a = this.getPrevMeasure()) == null ? void 0 : _a.useStemDir[voiceId]) != null ? _b : 0 /* Auto */;
4959
+ this.useStemDir[voiceId] = (_b = (_a = this.getPrevMeasure()) == null ? void 0 : _a.useStemDir[voiceId]) != null ? _b : "auto" /* Auto */;
4915
4960
  }
4916
4961
  let stemDir = this.useStemDir[voiceId];
4917
- if (stemDir === 0 /* Auto */ || stemDir === void 0) {
4962
+ if (stemDir === "auto" /* Auto */ || stemDir === void 0) {
4918
4963
  let staff = this.row.getStaff(symbol.ownDiatonicId);
4919
4964
  if (staff) {
4920
- return symbol.ownDiatonicId > staff.middleLineDiatonicId ? 2 /* Down */ : 1 /* Up */;
4965
+ return symbol.ownDiatonicId > staff.middleLineDiatonicId ? "down" /* Down */ : "up" /* Up */;
4921
4966
  } else {
4922
- return 1 /* Up */;
4967
+ return "up" /* Up */;
4923
4968
  }
4924
4969
  } else {
4925
4970
  return stemDir;
@@ -5026,6 +5071,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5026
5071
  // See MMeasure interface
5027
5072
  //setKeySignature(tonic: string, scaleType: ScaleType): void;
5028
5073
  //setKeySignature(keySignature: KeySignature): void;
5074
+ //setKeySignature(keySignature: string): void;
5029
5075
  //setKeySignature(scale: Scale): void;
5030
5076
  setKeySignature(...args) {
5031
5077
  var _a;
@@ -5034,13 +5080,17 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5034
5080
  this.alterKeySignature = args[0];
5035
5081
  } else if (args[0] instanceof import_theory9.Scale) {
5036
5082
  this.alterKeySignature = args[0];
5037
- } else {
5038
- try {
5039
- let tonic = "" + args[0];
5040
- let scaleType = (0, import_theory9.validateScaleType)("" + args[1]);
5041
- this.alterKeySignature = (0, import_theory9.getScale)(tonic, scaleType);
5042
- } catch (e) {
5043
- throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot set key signature because invalid args: " + args);
5083
+ } else if (import_ts_utils_lib10.Utils.Is.isNonEmptyString(args[0])) {
5084
+ if (args.length === 1) {
5085
+ this.alterKeySignature = (0, import_theory9.getScale)(args[0]);
5086
+ } else if (args.length === 2) {
5087
+ try {
5088
+ let tonic = "" + args[0];
5089
+ let scaleType = (0, import_theory9.validateScaleType)("" + args[1]);
5090
+ this.alterKeySignature = (0, import_theory9.getScale)(tonic, scaleType);
5091
+ } catch (e) {
5092
+ throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot set key signature because invalid args: " + args);
5093
+ }
5044
5094
  }
5045
5095
  }
5046
5096
  this.updateKeySignature();
@@ -5080,8 +5130,16 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5080
5130
  setTempo(beatsPerMinute, beatLength, dotted) {
5081
5131
  var _a;
5082
5132
  (_a = this.getPrevMeasure()) == null ? void 0 : _a.endSection();
5083
- let options = beatLength !== void 0 ? { beatLength, dotted } : void 0;
5084
- this.alterTempo = { beatsPerMinute, options };
5133
+ if (beatLength === void 0) {
5134
+ this.alterTempo = { beatsPerMinute };
5135
+ } else {
5136
+ let dotCount = typeof dotted === "number" && dotted > 0 ? dotted : dotted === true ? 1 : import_theory9.NoteLengthProps.get(beatLength).dotCount;
5137
+ let options = {
5138
+ beatLength: (0, import_theory9.validateNoteLength)(beatLength),
5139
+ dotCount: dotCount > 0 ? dotCount : void 0
5140
+ };
5141
+ this.alterTempo = { beatsPerMinute, options };
5142
+ }
5085
5143
  this.updateTempo();
5086
5144
  }
5087
5145
  updateTempo() {
@@ -5090,18 +5148,18 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5090
5148
  if (this.alterTempo) {
5091
5149
  let beatsPerMinute = this.alterTempo.beatsPerMinute;
5092
5150
  let beatLength;
5093
- let dotted;
5151
+ let dotCount;
5094
5152
  if (this.alterTempo.options) {
5095
5153
  beatLength = this.alterTempo.options.beatLength;
5096
- dotted = (_a = this.alterTempo.options.dotted) != null ? _a : false;
5154
+ dotCount = (_a = this.alterTempo.options.dotCount) != null ? _a : 0;
5097
5155
  } else if (this.alterTimeSignature) {
5098
5156
  beatLength = this.alterTimeSignature.beatLength;
5099
- dotted = false;
5157
+ dotCount = 0;
5100
5158
  } else {
5101
5159
  beatLength = this.tempo.options.beatLength;
5102
- dotted = this.tempo.options.dotted;
5160
+ dotCount = this.tempo.options.dotCount;
5103
5161
  }
5104
- this.tempo = { beatsPerMinute, options: { beatLength, dotted } };
5162
+ this.tempo = { beatsPerMinute, options: { beatLength, dotCount } };
5105
5163
  }
5106
5164
  if (this.nextMeasure) {
5107
5165
  this.nextMeasure.updateTempo();
@@ -5133,19 +5191,19 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5133
5191
  let grp = this.doc.getStaffGroup(staffTabOrGroup);
5134
5192
  if (grp && !prevGroups.includes(staffTabOrGroup)) {
5135
5193
  let curGroups = [...prevGroups, staffTabOrGroup];
5136
- (import_ts_utils_lib8.Utils.Is.isArray(grp.staffsTabsAndGroups) ? grp.staffsTabsAndGroups : [grp.staffsTabsAndGroups]).forEach((staffTabOrGroup2) => {
5194
+ (import_ts_utils_lib10.Utils.Is.isArray(grp.staffsTabsAndGroups) ? grp.staffsTabsAndGroups : [grp.staffsTabsAndGroups]).forEach((staffTabOrGroup2) => {
5137
5195
  switch (grp.verticalPosition) {
5138
- case 0 /* Above */:
5196
+ case "above" /* Above */:
5139
5197
  addToStaffTabOrGroup(staffTabOrGroup2, 0 /* Above */, curGroups);
5140
5198
  break;
5141
- case 1 /* Below */:
5199
+ case "below" /* Below */:
5142
5200
  addToStaffTabOrGroup(staffTabOrGroup2, 1 /* Below */, curGroups);
5143
5201
  break;
5144
- case 2 /* Both */:
5202
+ case "both" /* Both */:
5145
5203
  addToStaffTabOrGroup(staffTabOrGroup2, 0 /* Above */, curGroups);
5146
5204
  addToStaffTabOrGroup(staffTabOrGroup2, 1 /* Below */, curGroups);
5147
5205
  break;
5148
- case 3 /* Auto */:
5206
+ case "auto" /* Auto */:
5149
5207
  addToStaffTabOrGroup(staffTabOrGroup2, defaultVerticalPos, curGroups);
5150
5208
  break;
5151
5209
  }
@@ -5160,14 +5218,14 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5160
5218
  } else {
5161
5219
  addToStaffTabOrGroup(0, defaultVerticalPos);
5162
5220
  }
5163
- } else if (import_ts_utils_lib8.Utils.Is.isArray(staffTabOrGroups)) {
5221
+ } else if (import_ts_utils_lib10.Utils.Is.isArray(staffTabOrGroups)) {
5164
5222
  staffTabOrGroups.forEach((staffTabOrGroup) => addToStaffTabOrGroup(staffTabOrGroup, defaultVerticalPos));
5165
5223
  } else {
5166
5224
  addToStaffTabOrGroup(staffTabOrGroups, defaultVerticalPos);
5167
5225
  }
5168
5226
  }
5169
5227
  addFermata(staffTabOrGroups, fermata) {
5170
- let anchor = fermata === 1 /* AtMeasureEnd */ ? this.barLineRight : this.lastAddedRhythmColumn;
5228
+ let anchor = fermata === "atMeasureEnd" /* AtMeasureEnd */ ? this.barLineRight : this.lastAddedRhythmColumn;
5171
5229
  if (!anchor) {
5172
5230
  throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add Fermata because anchor is undefined.");
5173
5231
  }
@@ -5183,7 +5241,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5183
5241
  addNavigation(staffTabOrGroups, navigation, ...args) {
5184
5242
  let addLayoutObjectProps = void 0;
5185
5243
  switch (navigation) {
5186
- case 10 /* Ending */:
5244
+ case "ending" /* Ending */:
5187
5245
  if (this.navigationSet.has(navigation)) {
5188
5246
  throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add ending beasure measure already has one.");
5189
5247
  }
@@ -5195,10 +5253,10 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5195
5253
  defaultVerticalPos: 0 /* Above */
5196
5254
  };
5197
5255
  break;
5198
- case 1 /* DC_al_Coda */:
5199
- case 0 /* DC_al_Fine */:
5200
- case 3 /* DS_al_Coda */:
5201
- case 2 /* DS_al_Fine */: {
5256
+ case "D.C. al Coda" /* DC_al_Coda */:
5257
+ case "D.C. al Fine" /* DC_al_Fine */:
5258
+ case "D.S. al Coda" /* DS_al_Coda */:
5259
+ case "D.S. al Fine" /* DS_al_Fine */: {
5202
5260
  let anchor2 = this.barLineRight;
5203
5261
  let text = getNavigationString(navigation);
5204
5262
  addLayoutObjectProps = {
@@ -5206,11 +5264,11 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5206
5264
  layoutGroupId: 2 /* Navigation */,
5207
5265
  defaultVerticalPos: 0 /* Above */
5208
5266
  };
5209
- this.addNavigation(staffTabOrGroups, 9 /* EndRepeat */);
5267
+ this.addNavigation(staffTabOrGroups, "endRepeat" /* EndRepeat */);
5210
5268
  this.endSong();
5211
5269
  break;
5212
5270
  }
5213
- case 7 /* Fine */: {
5271
+ case "Fine" /* Fine */: {
5214
5272
  let anchor2 = this.barLineRight;
5215
5273
  let text = getNavigationString(navigation);
5216
5274
  addLayoutObjectProps = {
@@ -5220,8 +5278,8 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5220
5278
  };
5221
5279
  break;
5222
5280
  }
5223
- case 6 /* Segno */:
5224
- case 4 /* Coda */: {
5281
+ case "Segno" /* Segno */:
5282
+ case "Coda" /* Coda */: {
5225
5283
  let anchor2 = this.barLineLeft;
5226
5284
  let text = getNavigationString(navigation);
5227
5285
  addLayoutObjectProps = {
@@ -5231,7 +5289,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5231
5289
  };
5232
5290
  break;
5233
5291
  }
5234
- case 5 /* toCoda */: {
5292
+ case "toCoda" /* toCoda */: {
5235
5293
  let anchor2 = this.barLineRight;
5236
5294
  let text = getNavigationString(navigation);
5237
5295
  addLayoutObjectProps = {
@@ -5241,10 +5299,10 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5241
5299
  };
5242
5300
  break;
5243
5301
  }
5244
- case 9 /* EndRepeat */:
5302
+ case "endRepeat" /* EndRepeat */:
5245
5303
  if (args.length === 0) {
5246
5304
  this.endRepeatPlayCount = 2;
5247
- } else if (import_ts_utils_lib8.Utils.Is.isIntegerGte(args[0], 2)) {
5305
+ } else if (import_ts_utils_lib10.Utils.Is.isIntegerGte(args[0], 2)) {
5248
5306
  this.endRepeatPlayCount = args[0];
5249
5307
  } else {
5250
5308
  throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Invalid end repeat play count (should be 2 or greater integer): " + args[0]);
@@ -5280,17 +5338,18 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5280
5338
  let layoutGroupId;
5281
5339
  let defaultVerticalPos;
5282
5340
  switch (annotation) {
5283
- case 0 /* Dynamics */:
5341
+ case "dynamics" /* Dynamics */:
5284
5342
  layoutGroupId = 5 /* DynamicsAnnotation */;
5285
5343
  defaultVerticalPos = 0 /* Above */;
5286
5344
  textProps.italic = true;
5287
5345
  break;
5288
- case 1 /* Tempo */:
5346
+ case "tempo" /* Tempo */:
5289
5347
  layoutGroupId = 4 /* TempoAnnotation */;
5290
5348
  defaultVerticalPos = 0 /* Above */;
5291
5349
  textProps.italic = true;
5292
5350
  break;
5293
5351
  }
5352
+ this.disableExtension();
5294
5353
  this.forEachStaffGroup(staffTabOrGroups, defaultVerticalPos, (line, vpos) => {
5295
5354
  let textObj = new ObjText(anchor, textProps, 0.5, 1);
5296
5355
  this.addLayoutObject(textObj, line, layoutGroupId, vpos);
@@ -5308,15 +5367,16 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5308
5367
  let layoutGroupId;
5309
5368
  let defaultVerticalPos;
5310
5369
  switch (label) {
5311
- case 0 /* Note */:
5370
+ case "note" /* Note */:
5312
5371
  layoutGroupId = 1 /* NoteLabel */;
5313
5372
  defaultVerticalPos = 1 /* Below */;
5314
5373
  break;
5315
- case 1 /* Chord */:
5374
+ case "chord" /* Chord */:
5316
5375
  layoutGroupId = 6 /* ChordLabel */;
5317
5376
  defaultVerticalPos = 0 /* Above */;
5318
5377
  break;
5319
5378
  }
5379
+ this.disableExtension();
5320
5380
  this.forEachStaffGroup(staffTabOrGroups, defaultVerticalPos, (line, vpos) => {
5321
5381
  let textObj = new ObjText(anchor, textProps, 0.5, 1);
5322
5382
  this.addLayoutObject(textObj, line, layoutGroupId, vpos);
@@ -5328,17 +5388,17 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5328
5388
  if (!(anchor instanceof ObjNoteGroup)) {
5329
5389
  throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Connective can be added to note group only.");
5330
5390
  }
5331
- if (connective === 0 /* Tie */) {
5332
- let tieSpan = import_ts_utils_lib8.Utils.Is.isInteger(args[0]) || import_ts_utils_lib8.Utils.Is.isEnumValue(args[0], TieType) ? args[0] : 2;
5333
- let noteAnchor = import_ts_utils_lib8.Utils.Is.isEnumValue(args[1], NoteAnchor) ? args[1] : 0 /* Auto */;
5334
- anchor.startConnective(new ConnectiveProps(0 /* Tie */, tieSpan, noteAnchor, anchor));
5335
- } else if (connective === 1 /* Slur */) {
5336
- let slurSpan = import_ts_utils_lib8.Utils.Is.isInteger(args[0]) ? args[0] : 2;
5337
- let noteAnchor = import_ts_utils_lib8.Utils.Is.isEnumValue(args[1], NoteAnchor) ? args[1] : 0 /* Auto */;
5338
- anchor.startConnective(new ConnectiveProps(1 /* Slur */, slurSpan, noteAnchor, anchor));
5339
- } else if (connective === 2 /* Slide */) {
5340
- let noteAnchor = import_ts_utils_lib8.Utils.Is.isEnumValue(args[0], NoteAnchor) ? args[0] : 0 /* Auto */;
5341
- anchor.startConnective(new ConnectiveProps(2 /* Slide */, 2, noteAnchor, anchor));
5391
+ if (connective === "tie" /* Tie */) {
5392
+ let tieSpan = import_ts_utils_lib10.Utils.Is.isInteger(args[0]) || import_ts_utils_lib10.Utils.Is.isEnumValue(args[0], TieType) ? args[0] : 2;
5393
+ let noteAnchor = import_ts_utils_lib10.Utils.Is.isEnumValue(args[1], NoteAnchor) ? args[1] : "auto" /* Auto */;
5394
+ anchor.startConnective(new ConnectiveProps("tie" /* Tie */, tieSpan, noteAnchor, anchor));
5395
+ } else if (connective === "slur" /* Slur */) {
5396
+ let slurSpan = import_ts_utils_lib10.Utils.Is.isInteger(args[0]) ? args[0] : 2;
5397
+ let noteAnchor = import_ts_utils_lib10.Utils.Is.isEnumValue(args[1], NoteAnchor) ? args[1] : "auto" /* Auto */;
5398
+ anchor.startConnective(new ConnectiveProps("slur" /* Slur */, slurSpan, noteAnchor, anchor));
5399
+ } else if (connective === "slide" /* Slide */) {
5400
+ let noteAnchor = import_ts_utils_lib10.Utils.Is.isEnumValue(args[0], NoteAnchor) ? args[0] : "auto" /* Auto */;
5401
+ anchor.startConnective(new ConnectiveProps("slide" /* Slide */, 2, noteAnchor, anchor));
5342
5402
  }
5343
5403
  }
5344
5404
  addExtension(extensionLength, extensionVisible) {
@@ -5347,7 +5407,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5347
5407
  if (musicObj instanceof ObjText && anchor instanceof ObjRhythmColumn) {
5348
5408
  let lineStyle = "dashed";
5349
5409
  let linePos = "bottom";
5350
- let extension = new Extension(musicObj, anchor, extensionLength, extensionVisible, lineStyle, linePos);
5410
+ let extension = new Extension(musicObj, anchor, getExtensionTicks(extensionLength), extensionVisible, lineStyle, linePos);
5351
5411
  musicObj.setLink(extension);
5352
5412
  } else {
5353
5413
  throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add extension becaue no compatible music object to attach it to.");
@@ -5396,21 +5456,25 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5396
5456
  col.setVoiceSymbol(voiceId, symbol);
5397
5457
  this.getVoiceSymbols(voiceId);
5398
5458
  this.voiceSymbols[voiceId].push(symbol);
5399
- if (symbol.triplet) {
5459
+ if (symbol.oldStyleTriplet) {
5400
5460
  this.createOldStyleTriplets(voiceId);
5401
5461
  }
5402
5462
  this.requestBeamsUpdate();
5403
5463
  this.lastAddedRhythmColumn = col;
5404
5464
  this.lastAddedRhythmSymbol = symbol;
5405
5465
  }
5406
- addNoteGroup(voiceId, notes, noteLength, options) {
5407
- let notes2 = notes.map((note) => typeof note === "string" ? import_theory9.Note.getNote(note) : note);
5466
+ addNoteGroup(voiceId, notes, noteLength, options, tupletRatio) {
5467
+ let realNotes = notes.map((note) => typeof note === "string" ? import_theory9.Note.getNote(note) : note);
5408
5468
  let col = this.getRhythmColumn(voiceId);
5409
- this.addRhythmSymbol(voiceId, new ObjNoteGroup(col, voiceId, notes2, noteLength, options));
5469
+ let noteGroup = new ObjNoteGroup(col, voiceId, realNotes, noteLength, options, tupletRatio);
5470
+ this.addRhythmSymbol(voiceId, noteGroup);
5471
+ return noteGroup;
5410
5472
  }
5411
- addRest(voiceId, restLength, options) {
5473
+ addRest(voiceId, restLength, options, tupletRatio) {
5412
5474
  let col = this.getRhythmColumn(voiceId);
5413
- this.addRhythmSymbol(voiceId, new ObjRest(col, voiceId, restLength, options));
5475
+ let rest = new ObjRest(col, voiceId, restLength, options, tupletRatio);
5476
+ this.addRhythmSymbol(voiceId, rest);
5477
+ return rest;
5414
5478
  }
5415
5479
  /**
5416
5480
  *
@@ -5552,18 +5616,13 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5552
5616
  requestBeamsUpdate() {
5553
5617
  this.needBeamsUpdate = true;
5554
5618
  }
5619
+ // Create triplets by triplet property of NoteOptions/RestOptions.
5555
5620
  createOldStyleTriplets(voiceId) {
5556
5621
  let symbols = this.getVoiceSymbols(voiceId);
5557
- if (symbols.length <= 2) {
5558
- return;
5559
- }
5560
5622
  for (let i = 0; i < symbols.length; ) {
5561
- let s2 = symbols.slice(i, i + 2);
5562
- let s3 = symbols.slice(i, i + 3);
5563
- if (s2.length === 2 && s2.every((s) => s.triplet) && s2.every((s) => s.getBeamGroup() === void 0) && ObjBeamGroup.createTriplet(s2)) {
5564
- i += 2;
5565
- } else if (s3.length === 3 && s3.every((s) => s.triplet) && s3.every((s) => s.getBeamGroup() === void 0) && ObjBeamGroup.createTriplet(s3)) {
5566
- i += 3;
5623
+ if (symbols[i].oldStyleTriplet) {
5624
+ let n = ObjBeamGroup.createOldStyleTriplet(symbols.slice(i, i + 3));
5625
+ i += n === 0 ? 1 : n;
5567
5626
  } else {
5568
5627
  i++;
5569
5628
  }
@@ -5575,11 +5634,11 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5575
5634
  return;
5576
5635
  }
5577
5636
  this.beamGroups = this.beamGroups.filter((beamGroup) => {
5578
- if (beamGroup.getType() === 0 /* RegularBeam */) {
5637
+ if (beamGroup.isTuplet()) {
5638
+ return true;
5639
+ } else {
5579
5640
  beamGroup.detach();
5580
5641
  return false;
5581
- } else {
5582
- return true;
5583
5642
  }
5584
5643
  });
5585
5644
  getVoiceIds().forEach((voiceId) => {
@@ -5615,7 +5674,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5615
5674
  static setupBeamGroup(groupSymbols) {
5616
5675
  let groupNotes = groupSymbols.map((s) => {
5617
5676
  var _a;
5618
- return s instanceof ObjNoteGroup && ((_a = s.getBeamGroup()) == null ? void 0 : _a.isTriplet()) !== true ? s : void 0;
5677
+ return s instanceof ObjNoteGroup && ((_a = s.getBeamGroup()) == null ? void 0 : _a.isTuplet()) !== true ? s : void 0;
5619
5678
  });
5620
5679
  ObjNoteGroup.setBeamCounts(groupNotes);
5621
5680
  let beamNotes = [];
@@ -5647,36 +5706,32 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5647
5706
  if (this.getConsumedTicks() === 0) {
5648
5707
  this.completeRests(0);
5649
5708
  } else {
5650
- getVoiceIds().forEach((voiceId2) => {
5651
- if (this.getConsumedTicks(voiceId2) > 0) {
5652
- this.completeRests(voiceId2);
5653
- }
5654
- });
5709
+ this.completeRests(getVoiceIds().filter((id) => this.getConsumedTicks(id) > 0));
5655
5710
  }
5656
5711
  return;
5657
- }
5658
- let measureTicks = this.getMeasureTicks();
5659
- let consumedTicks = this.getConsumedTicks(voiceId);
5660
- let remainingTicks = measureTicks - consumedTicks;
5661
- let rests = [];
5662
- let noteLengthValues = import_ts_utils_lib8.Utils.Enum.getEnumValues(import_theory9.NoteLength);
5663
- while (remainingTicks > 0) {
5664
- noteLengthValues.forEach((restLength) => {
5665
- let restValue = new import_theory9.RhythmProps(restLength, false);
5666
- if (restValue.canDot()) {
5667
- let dottedRestValue = new import_theory9.RhythmProps(restLength, true);
5668
- while (dottedRestValue.ticks <= remainingTicks) {
5669
- rests.push(dottedRestValue);
5670
- remainingTicks -= dottedRestValue.ticks;
5712
+ } else if (import_ts_utils_lib10.Utils.Is.isArray(voiceId)) {
5713
+ voiceId.forEach((id) => this.completeRests(id));
5714
+ return;
5715
+ } else {
5716
+ validateVoiceId(voiceId);
5717
+ let measureTicks = this.getMeasureTicks();
5718
+ let consumedTicks = this.getConsumedTicks(voiceId);
5719
+ let remainingTicks = measureTicks - consumedTicks;
5720
+ let rests = [];
5721
+ while (remainingTicks > 0) {
5722
+ for (let noteSize = import_theory9.NoteLengthProps.LongestNoteSize; noteSize <= import_theory9.NoteLengthProps.ShortestNoteSize; noteSize *= 2) {
5723
+ let restLength = import_theory9.NoteLengthProps.create(noteSize).noteLength;
5724
+ for (let dotCount = import_theory9.NoteLengthProps.get(restLength).maxDotCount; dotCount >= 0; dotCount--) {
5725
+ let restProps = import_theory9.RhythmProps.get(restLength, dotCount);
5726
+ while (restProps.ticks <= remainingTicks) {
5727
+ rests.push(restProps);
5728
+ remainingTicks -= restProps.ticks;
5729
+ }
5671
5730
  }
5672
5731
  }
5673
- while (restValue.ticks <= remainingTicks) {
5674
- rests.push(restValue);
5675
- remainingTicks -= restValue.ticks;
5676
- }
5677
- });
5732
+ }
5733
+ rests.reverse().forEach((rest) => this.addRest(voiceId, rest.noteLength, { dotted: rest.dotCount }));
5678
5734
  }
5679
- rests.reverse().forEach((rest) => this.addRest(voiceId, rest.noteLength, { dotted: rest.dotted }));
5680
5735
  }
5681
5736
  requestLayout() {
5682
5737
  if (!this.needLayout) {
@@ -5769,7 +5824,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
5769
5824
  let columnsAreaLeft = this.rect.left + this.leftSolidAreaWidth;
5770
5825
  let columnsAreaRight = this.rect.right - this.rightSolidAreaWidth;
5771
5826
  let columnsAreaWidth = columnsAreaRight - columnsAreaLeft;
5772
- let columnsWidth = import_ts_utils_lib8.Utils.Math.sum(this.columns.map((col) => col.getRect().width));
5827
+ let columnsWidth = import_ts_utils_lib10.Utils.Math.sum(this.columns.map((col) => col.getRect().width));
5773
5828
  let columnScale = columnsAreaWidth / columnsWidth;
5774
5829
  let columnLeft = columnsAreaLeft;
5775
5830
  this.columns.forEach((col) => {
@@ -6109,10 +6164,12 @@ var ObjStaff = class extends ObjNotationLine4 {
6109
6164
  this.clefImageAsset = 0 /* TrebleClefPng */;
6110
6165
  this.clefLineDiatonicId = getDiatonicId("G4", staffConfig.isOctaveDown === true);
6111
6166
  this.middleLineDiatonicId = this.clefLineDiatonicId + 2;
6112
- } else {
6167
+ } else if (staffConfig.clef === "F" /* F */) {
6113
6168
  this.clefImageAsset = 1 /* BassClefPng */;
6114
6169
  this.clefLineDiatonicId = getDiatonicId("F3", staffConfig.isOctaveDown === true);
6115
6170
  this.middleLineDiatonicId = this.clefLineDiatonicId - 2;
6171
+ } else {
6172
+ throw new import_core15.MusicError(import_core15.MusicErrorType.Score, `Invalid staffConfig.clef ${staffConfig.clef}.`);
6116
6173
  }
6117
6174
  this.topLineDiatonicId = this.middleLineDiatonicId + 4;
6118
6175
  this.bottomLineDiatonicId = this.middleLineDiatonicId - 4;
@@ -6248,7 +6305,7 @@ var ObjTab = class extends ObjNotationLine4 {
6248
6305
  __publicField(this, "tuningName");
6249
6306
  __publicField(this, "tuningStrings");
6250
6307
  __publicField(this, "mi");
6251
- if (import_ts_utils_lib9.Utils.Is.isArray(tabConfig.tuning)) {
6308
+ if (import_ts_utils_lib11.Utils.Is.isArray(tabConfig.tuning)) {
6252
6309
  this.tuningName = void 0;
6253
6310
  this.tuningStrings = tabConfig.tuning.map((noteName) => import_theory11.Note.getNote(noteName)).reverse();
6254
6311
  } else if (typeof tabConfig.tuning === "string") {
@@ -6703,7 +6760,7 @@ var ObjHeader = class extends MusicObject {
6703
6760
  };
6704
6761
 
6705
6762
  // src/score/engine/obj-document.ts
6706
- var import_ts_utils_lib10 = require("@tspro/ts-utils-lib");
6763
+ var import_ts_utils_lib12 = require("@tspro/ts-utils-lib");
6707
6764
  var ObjDocument = class extends MusicObject {
6708
6765
  constructor() {
6709
6766
  super(void 0);
@@ -6724,35 +6781,35 @@ var ObjDocument = class extends MusicObject {
6724
6781
  return this.mi;
6725
6782
  }
6726
6783
  setScoreConfiguration(config) {
6727
- if (import_ts_utils_lib10.Utils.Is.isEnumValue(config, StaffPreset)) {
6784
+ if (import_ts_utils_lib12.Utils.Is.isEnumValue(config, StaffPreset)) {
6728
6785
  switch (config) {
6729
6786
  default:
6730
- case 1 /* Treble */:
6787
+ case "treble" /* Treble */:
6731
6788
  this.curScoreConfig = [{ type: "staff", clef: "G" /* G */ }];
6732
6789
  break;
6733
- case 2 /* Bass */:
6790
+ case "bass" /* Bass */:
6734
6791
  this.curScoreConfig = [{ type: "staff", clef: "F" /* F */ }];
6735
6792
  break;
6736
- case 3 /* Grand */:
6793
+ case "grand" /* Grand */:
6737
6794
  this.curScoreConfig = [
6738
6795
  { type: "staff", clef: "G" /* G */, isGrand: true },
6739
6796
  { type: "staff", clef: "F" /* F */, isGrand: true }
6740
6797
  ];
6741
6798
  break;
6742
- case 4 /* GuitarTreble */:
6799
+ case "guitarTreble" /* GuitarTreble */:
6743
6800
  this.curScoreConfig = [{ type: "staff", clef: "G" /* G */, isOctaveDown: true }];
6744
6801
  break;
6745
- case 8 /* GuitarTab */:
6802
+ case "guitarTab" /* GuitarTab */:
6746
6803
  this.curScoreConfig = [{ type: "tab", tuning: "Standard" }];
6747
6804
  break;
6748
- case 12 /* GuitarCombined */:
6805
+ case "guitarCombined" /* GuitarCombined */:
6749
6806
  this.curScoreConfig = [
6750
6807
  { type: "staff", clef: "G" /* G */, isOctaveDown: true },
6751
6808
  { type: "tab", tuning: "Standard" }
6752
6809
  ];
6753
6810
  break;
6754
6811
  }
6755
- } else if (import_ts_utils_lib10.Utils.Is.isArray(config)) {
6812
+ } else if (import_ts_utils_lib12.Utils.Is.isArray(config)) {
6756
6813
  this.curScoreConfig = config;
6757
6814
  } else {
6758
6815
  this.curScoreConfig = [config];
@@ -6994,180 +7051,318 @@ function isNote(note) {
6994
7051
  }
6995
7052
  }
6996
7053
  function isVoiceId(value) {
6997
- return import_ts_utils_lib11.Utils.Is.isNumber(value) && getVoiceIds().indexOf(value) >= 0;
7054
+ return import_ts_utils_lib13.Utils.Is.isNumber(value) && getVoiceIds().indexOf(value) >= 0;
6998
7055
  }
6999
7056
  function isStringNumber(value) {
7000
- return import_ts_utils_lib11.Utils.Is.isNumber(value) && getStringNumbers().indexOf(value) >= 0;
7057
+ return import_ts_utils_lib13.Utils.Is.isNumber(value) && getStringNumbers().indexOf(value) >= 0;
7001
7058
  }
7002
7059
  function assertStaffConfig(staffConfig) {
7003
- assertArg(import_ts_utils_lib11.Utils.Is.isObject(staffConfig), "staffConfig", staffConfig);
7060
+ assertArg(import_ts_utils_lib13.Utils.Is.isObject(staffConfig), "staffConfig", staffConfig);
7004
7061
  assertArg(staffConfig.type === "staff", "staffConfig.type", staffConfig.type);
7005
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(staffConfig.clef, Clef), "staffConfig.clef", staffConfig.clef);
7006
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(staffConfig.isOctaveDown), "staffConfig.isOctaveDown", staffConfig.isOctaveDown);
7007
- assertArg(import_ts_utils_lib11.Utils.Is.isUndefined(staffConfig.minNote) || isNote(staffConfig.minNote), "staffConfig.minNote", staffConfig.minNote);
7008
- assertArg(import_ts_utils_lib11.Utils.Is.isUndefined(staffConfig.maxNote) || isNote(staffConfig.maxNote), "staffConfig.maxNote", staffConfig.maxNote);
7009
- assertArg(import_ts_utils_lib11.Utils.Is.isUndefined(staffConfig.voiceIds) || import_ts_utils_lib11.Utils.Is.isArray(staffConfig.voiceIds) && staffConfig.voiceIds.every((voiceId) => import_ts_utils_lib11.Utils.Is.isNumber(voiceId)), "staffConfig.voiceIds", staffConfig.voiceIds);
7010
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(staffConfig.isGrand), "staffConfig.isGrand", staffConfig.isGrand);
7062
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(staffConfig.clef, Clef), "staffConfig.clef", staffConfig.clef);
7063
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(staffConfig.isOctaveDown), "staffConfig.isOctaveDown", staffConfig.isOctaveDown);
7064
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(staffConfig.minNote) || isNote(staffConfig.minNote), "staffConfig.minNote", staffConfig.minNote);
7065
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(staffConfig.maxNote) || isNote(staffConfig.maxNote), "staffConfig.maxNote", staffConfig.maxNote);
7066
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(staffConfig.voiceIds) || import_ts_utils_lib13.Utils.Is.isArray(staffConfig.voiceIds) && staffConfig.voiceIds.every((voiceId) => import_ts_utils_lib13.Utils.Is.isNumber(voiceId)), "staffConfig.voiceIds", staffConfig.voiceIds);
7067
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(staffConfig.isGrand), "staffConfig.isGrand", staffConfig.isGrand);
7011
7068
  }
7012
7069
  function assertTabConfig(tabConfig) {
7013
- assertArg(import_ts_utils_lib11.Utils.Is.isObject(tabConfig), "tabConfig", tabConfig);
7070
+ assertArg(import_ts_utils_lib13.Utils.Is.isObject(tabConfig), "tabConfig", tabConfig);
7014
7071
  assertArg(tabConfig.type === "tab", "tabConfig.type", tabConfig.type);
7015
7072
  if (typeof tabConfig.tuning === "string") {
7016
7073
  assertArg(import_theory13.TuningNameList.includes(tabConfig.tuning), "tabConfig.tuning", tabConfig.tuning);
7017
- } else if (import_ts_utils_lib11.Utils.Is.isArray(tabConfig.tuning)) {
7018
- assertArg(tabConfig.tuning.length === 6 && tabConfig.tuning.every((s) => isNote(s)), "tabConfig.tuning", tabConfig.tuning);
7074
+ } else if (import_ts_utils_lib13.Utils.Is.isArray(tabConfig.tuning)) {
7075
+ assertArg(tabConfig.tuning.length === getStringNumbers().length && tabConfig.tuning.every((s) => isNote(s)), "tabConfig.tuning", tabConfig.tuning);
7019
7076
  }
7020
- assertArg(import_ts_utils_lib11.Utils.Is.isUndefined(tabConfig.voiceIds) || import_ts_utils_lib11.Utils.Is.isArray(tabConfig.voiceIds) && tabConfig.voiceIds.every((voiceId) => import_ts_utils_lib11.Utils.Is.isNumber(voiceId)), "tabConfig.voiceIds", tabConfig.voiceIds);
7077
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(tabConfig.voiceIds) || import_ts_utils_lib13.Utils.Is.isArray(tabConfig.voiceIds) && tabConfig.voiceIds.every((voiceId) => import_ts_utils_lib13.Utils.Is.isNumber(voiceId)), "tabConfig.voiceIds", tabConfig.voiceIds);
7021
7078
  }
7022
7079
  function assertNoteOptions(options) {
7023
- assertArg(import_ts_utils_lib11.Utils.Is.isObject(options), "noteOptions", options);
7024
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(options.dotted), "noteOptions.dotted", options.dotted);
7025
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValueOrUndefined(options.stem, Stem), "noteOptions.stem", options.stem);
7026
- assertArg(import_ts_utils_lib11.Utils.Is.isStringOrUndefined(options.color), "noteOptions.color", options.color);
7027
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(options.arpeggio) || import_ts_utils_lib11.Utils.Is.isEnumValue(options.arpeggio, Arpeggio), "noteOptions.arpeggio", options.arpeggio);
7028
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(options.staccato), "noteOptions.staccato", options.staccato);
7029
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(options.diamond), "noteOptions.diamond", options.diamond);
7030
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(options.triplet), "noteOptions.triplet", options.triplet);
7031
- assertArg(import_ts_utils_lib11.Utils.Is.isUndefined(options.string) || isStringNumber(options.string) || import_ts_utils_lib11.Utils.Is.isArray(options.string) && options.string.length > 0 && options.string.every((string) => isStringNumber(string)), "noteOptions.string", options.string);
7080
+ assertArg(import_ts_utils_lib13.Utils.Is.isObject(options), "noteOptions", options);
7081
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.dotted) || import_ts_utils_lib13.Utils.Is.isIntegerGte(options.dotted, 0), "noteOptions.dotted", options.dotted);
7082
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValueOrUndefined(options.stem, Stem), "noteOptions.stem", options.stem);
7083
+ assertArg(import_ts_utils_lib13.Utils.Is.isStringOrUndefined(options.color), "noteOptions.color", options.color);
7084
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.arpeggio) || import_ts_utils_lib13.Utils.Is.isEnumValue(options.arpeggio, Arpeggio), "noteOptions.arpeggio", options.arpeggio);
7085
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.staccato), "noteOptions.staccato", options.staccato);
7086
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.diamond), "noteOptions.diamond", options.diamond);
7087
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.triplet), "noteOptions.triplet", options.triplet);
7088
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(options.string) || isStringNumber(options.string) || import_ts_utils_lib13.Utils.Is.isNonEmptyArray(options.string) && options.string.every((string) => isStringNumber(string)), "noteOptions.string", options.string);
7089
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(options.tieSpan), 'NoteOptions.tieSpan was removed. Use addConnective("tie", tieSpan)', "");
7090
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(options.slurSpan), 'NoteOptions.slurSpan was removed. Use addConnective("slur", slurSpan)', "");
7032
7091
  }
7033
7092
  function assertRestOptions(options) {
7034
- assertArg(import_ts_utils_lib11.Utils.Is.isObject(options), "restOptions", options);
7035
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(options.dotted), "restOptions.dotted", options.dotted);
7036
- assertArg(import_ts_utils_lib11.Utils.Is.isStringOrUndefined(options.staffPos) || import_ts_utils_lib11.Utils.Is.isInteger(options.staffPos) || options.staffPos instanceof import_theory13.Note, "restOptions.staffPos", options.staffPos);
7037
- assertArg(import_ts_utils_lib11.Utils.Is.isStringOrUndefined(options.color), "restOptions.color", options.color);
7038
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(options.hide), "restOptions.hide", options.hide);
7039
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(options.triplet), "restOptions.triplet", options.triplet);
7093
+ assertArg(import_ts_utils_lib13.Utils.Is.isObject(options), "restOptions", options);
7094
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.dotted) || import_ts_utils_lib13.Utils.Is.isIntegerGte(options.dotted, 0), "restOptions.dotted", options.dotted);
7095
+ assertArg(import_ts_utils_lib13.Utils.Is.isStringOrUndefined(options.staffPos) || import_ts_utils_lib13.Utils.Is.isInteger(options.staffPos) || options.staffPos instanceof import_theory13.Note, "restOptions.staffPos", options.staffPos);
7096
+ assertArg(import_ts_utils_lib13.Utils.Is.isStringOrUndefined(options.color), "restOptions.color", options.color);
7097
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.hide), "restOptions.hide", options.hide);
7098
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.triplet), "restOptions.triplet", options.triplet);
7040
7099
  }
7041
7100
  function assertStaffTabOrGRoups(staffTabOrGroups) {
7042
7101
  assertArg(
7043
- import_ts_utils_lib11.Utils.Is.isStringOrUndefined(staffTabOrGroups) || import_ts_utils_lib11.Utils.Is.isIntegerGte(staffTabOrGroups, 0) || import_ts_utils_lib11.Utils.Is.isArray(staffTabOrGroups) && staffTabOrGroups.every(
7044
- (staffTabOrGroup) => import_ts_utils_lib11.Utils.Is.isString(staffTabOrGroup) || import_ts_utils_lib11.Utils.Is.isIntegerGte(staffTabOrGroup, 0)
7102
+ import_ts_utils_lib13.Utils.Is.isStringOrUndefined(staffTabOrGroups) || import_ts_utils_lib13.Utils.Is.isIntegerGte(staffTabOrGroups, 0) || import_ts_utils_lib13.Utils.Is.isNonEmptyArray(staffTabOrGroups) && staffTabOrGroups.every(
7103
+ (staffTabOrGroup) => import_ts_utils_lib13.Utils.Is.isString(staffTabOrGroup) || import_ts_utils_lib13.Utils.Is.isIntegerGte(staffTabOrGroup, 0)
7045
7104
  ),
7046
7105
  "staffTabOrGroup",
7047
7106
  staffTabOrGroups
7048
7107
  );
7049
7108
  }
7109
+ function isNoteLength(noteLen) {
7110
+ try {
7111
+ (0, import_theory13.validateNoteLength)(noteLen);
7112
+ return true;
7113
+ } catch (e) {
7114
+ return false;
7115
+ }
7116
+ }
7117
+ function isTupletRatio(tupletRatio) {
7118
+ try {
7119
+ (0, import_theory13.validateTupletRatio)(tupletRatio);
7120
+ return true;
7121
+ } catch (e) {
7122
+ return false;
7123
+ }
7124
+ }
7050
7125
  var DocumentBuilder = class {
7126
+ /**
7127
+ * Create new document builder instance.
7128
+ */
7051
7129
  constructor() {
7052
7130
  __publicField(this, "doc");
7053
7131
  this.doc = new ObjDocument();
7054
7132
  }
7055
7133
  setScoreConfiguration(config) {
7056
- if (import_ts_utils_lib11.Utils.Is.isEnumValue(config, StaffPreset)) {
7057
- } else if (import_ts_utils_lib11.Utils.Is.isObject(config) && config.type === "staff") {
7134
+ if (import_ts_utils_lib13.Utils.Is.isEnumValue(config, StaffPreset)) {
7135
+ this.doc.setScoreConfiguration(config);
7136
+ } else if (import_ts_utils_lib13.Utils.Is.isObject(config) && config.type === "staff") {
7058
7137
  assertStaffConfig(config);
7059
- } else if (import_ts_utils_lib11.Utils.Is.isObject(config) && config.type === "tab") {
7138
+ this.doc.setScoreConfiguration(config);
7139
+ } else if (import_ts_utils_lib13.Utils.Is.isObject(config) && config.type === "tab") {
7060
7140
  assertTabConfig(config);
7061
- } else if (import_ts_utils_lib11.Utils.Is.isArray(config)) {
7062
- assertArg(config.length > 0, "config", config);
7141
+ this.doc.setScoreConfiguration(config);
7142
+ } else if (import_ts_utils_lib13.Utils.Is.isNonEmptyArray(config)) {
7063
7143
  config.forEach((c) => {
7064
- if (import_ts_utils_lib11.Utils.Is.isObject(c) && c.type === "staff") {
7144
+ if (import_ts_utils_lib13.Utils.Is.isObject(c) && c.type === "staff") {
7065
7145
  assertStaffConfig(c);
7066
- } else if (import_ts_utils_lib11.Utils.Is.isObject(c) && c.type === "tab") {
7146
+ } else if (import_ts_utils_lib13.Utils.Is.isObject(c) && c.type === "tab") {
7067
7147
  assertTabConfig(c);
7068
7148
  } else {
7069
7149
  assertArg(false, "config", config);
7070
7150
  }
7071
7151
  });
7152
+ this.doc.setScoreConfiguration(config);
7072
7153
  } else {
7073
7154
  assertArg(false, "config", config);
7074
7155
  }
7075
- this.doc.setScoreConfiguration(config);
7076
7156
  return this;
7077
7157
  }
7078
7158
  getMeasure() {
7079
7159
  var _a;
7080
7160
  return (_a = this.doc.getLastMeasure()) != null ? _a : this.doc.addMeasure();
7081
7161
  }
7162
+ /**
7163
+ * Get music document after finished building.
7164
+ * @returns - Music document.
7165
+ */
7082
7166
  getDocument() {
7083
7167
  return this.doc.getMusicInterface();
7084
7168
  }
7169
+ /**
7170
+ * Set header texts.
7171
+ * @param title - Title of this docmument/musical piece.
7172
+ * @param composer - Composer of this document/musical piece.
7173
+ * @param arranger - Arranger of this document/musical piece.
7174
+ * @returns - This document builder instance.
7175
+ */
7085
7176
  setHeader(title, composer, arranger) {
7086
- assertArg(import_ts_utils_lib11.Utils.Is.isStringOrUndefined(title), "title", title);
7087
- assertArg(import_ts_utils_lib11.Utils.Is.isStringOrUndefined(composer), "composer", composer);
7088
- assertArg(import_ts_utils_lib11.Utils.Is.isStringOrUndefined(arranger), "arranger", arranger);
7177
+ assertArg(import_ts_utils_lib13.Utils.Is.isStringOrUndefined(title), "title", title);
7178
+ assertArg(import_ts_utils_lib13.Utils.Is.isStringOrUndefined(composer), "composer", composer);
7179
+ assertArg(import_ts_utils_lib13.Utils.Is.isStringOrUndefined(arranger), "arranger", arranger);
7089
7180
  this.doc.setHeader(title, composer, arranger);
7090
7181
  return this;
7091
7182
  }
7183
+ /**
7184
+ * Automatically limit number of measures per score row.
7185
+ * @param measuresPerRow - Number of measures per row. Must be integer >=1 or Infinity.
7186
+ * @returns - This document builder instance.
7187
+ */
7092
7188
  setMeasuresPerRow(measuresPerRow) {
7093
- assertArg(import_ts_utils_lib11.Utils.Is.isIntegerGte(measuresPerRow, 1) || measuresPerRow === Infinity, "measuresPerRow", measuresPerRow);
7189
+ assertArg(import_ts_utils_lib13.Utils.Is.isIntegerGte(measuresPerRow, 1) || import_ts_utils_lib13.Utils.Is.isPosInfinity(measuresPerRow), "measuresPerRow", measuresPerRow);
7094
7190
  this.doc.setMeasuresPerRow(measuresPerRow);
7095
7191
  return this;
7096
7192
  }
7193
+ /**
7194
+ * Add new measure.
7195
+ * @returns - This document builder instance.
7196
+ */
7097
7197
  addMeasure() {
7098
7198
  this.doc.addMeasure();
7099
7199
  return this;
7100
7200
  }
7101
7201
  setKeySignature(...args) {
7102
- assertArg(args[0] instanceof import_theory13.Scale || args[0] instanceof import_theory13.KeySignature || import_ts_utils_lib11.Utils.Is.isString(args[0]) && import_ts_utils_lib11.Utils.Is.isEnumValue(args[1], import_theory13.ScaleType), "keySignature", args);
7202
+ assertArg(args[0] instanceof import_theory13.Scale || args[0] instanceof import_theory13.KeySignature || import_ts_utils_lib13.Utils.Is.isNonEmptyString(args[0]) && (args.length === 1 || import_ts_utils_lib13.Utils.Is.isEnumValue(args[1], import_theory13.ScaleType)), "keySignature", args);
7103
7203
  this.getMeasure().setKeySignature(...args);
7104
7204
  return this;
7105
7205
  }
7206
+ /**
7207
+ * Set time signature for current measure and forward.
7208
+ * @param timeSignature - TimeSignature object instance or string (e.g. "3/4").
7209
+ * @returns - This document builder instance.
7210
+ */
7106
7211
  setTimeSignature(timeSignature) {
7107
- assertArg(timeSignature instanceof import_theory13.TimeSignature || import_ts_utils_lib11.Utils.Is.isString(timeSignature), "timeSignature", timeSignature);
7212
+ assertArg(timeSignature instanceof import_theory13.TimeSignature || import_ts_utils_lib13.Utils.Is.isNonEmptyString(timeSignature), "timeSignature", timeSignature);
7108
7213
  this.getMeasure().setTimeSignature(timeSignature);
7109
7214
  return this;
7110
7215
  }
7111
7216
  setTempo(beatsPerMinute, beatLength, dotted) {
7112
- assertArg(import_ts_utils_lib11.Utils.Is.isIntegerGte(beatsPerMinute, 1), "beatsPerMinute", beatsPerMinute);
7217
+ assertArg(import_ts_utils_lib13.Utils.Is.isIntegerGte(beatsPerMinute, 1), "beatsPerMinute", beatsPerMinute);
7113
7218
  if (beatLength === void 0) {
7114
- assertArg(import_ts_utils_lib11.Utils.Is.isUndefined(dotted), "dotted", dotted);
7219
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(dotted), "dotted", dotted);
7115
7220
  } else {
7116
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(beatLength, import_theory13.NoteLength), "beatLength", beatLength);
7117
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(dotted), "dotted", dotted);
7221
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(beatLength, import_theory13.NoteLength) || isNoteLength(beatLength), "beatLength", beatLength);
7222
+ assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(dotted) || import_ts_utils_lib13.Utils.Is.isIntegerGte(dotted, 0), "dotted", dotted);
7118
7223
  }
7119
7224
  this.getMeasure().setTempo(beatsPerMinute, beatLength, dotted);
7120
7225
  return this;
7121
7226
  }
7227
+ /**
7228
+ * Add note o current measure.
7229
+ * @param voiceId - Voice id to add note to.
7230
+ * @param note - Note instance of Note or string (e.g. "D4").
7231
+ * @param noteLength - Note length (e.g. "4n").
7232
+ * @param options - Note options.
7233
+ * @returns - This document builder instance.
7234
+ */
7122
7235
  addNote(voiceId, note, noteLength, options) {
7123
7236
  assertArg(isVoiceId(voiceId), "voiceId", voiceId);
7124
- assertArg(note instanceof import_theory13.Note || import_ts_utils_lib11.Utils.Is.isString(note), "note", note);
7125
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength), "noteLength", noteLength);
7237
+ assertArg(note instanceof import_theory13.Note || import_ts_utils_lib13.Utils.Is.isNonEmptyString(note), "note", note);
7238
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
7126
7239
  if (options !== void 0) {
7127
7240
  assertNoteOptions(options);
7128
7241
  }
7129
7242
  this.getMeasure().addNoteGroup(voiceId, [note], noteLength, options);
7130
7243
  return this;
7131
7244
  }
7245
+ /**
7246
+ * @param voiceId - Voice id to add chord to.
7247
+ * @param notes - Array of notes, each instance of Note or string (e.g. "D4").
7248
+ * @param noteLength - Note length (e.g. "4n").
7249
+ * @param options - Note options.
7250
+ * @returns - This document builder instance.
7251
+ */
7132
7252
  addChord(voiceId, notes, noteLength, options) {
7133
7253
  assertArg(isVoiceId(voiceId), "voiceId", voiceId);
7134
- assertArg(import_ts_utils_lib11.Utils.Is.isArray(notes) && notes.length >= 1 && notes.every((note) => note instanceof import_theory13.Note || import_ts_utils_lib11.Utils.Is.isString(note)), "notes", notes);
7135
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength), "noteLength", noteLength);
7254
+ assertArg(import_ts_utils_lib13.Utils.Is.isNonEmptyArray(notes) && notes.every((note) => note instanceof import_theory13.Note || import_ts_utils_lib13.Utils.Is.isNonEmptyString(note)), "notes", notes);
7255
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
7136
7256
  if (options !== void 0) {
7137
7257
  assertNoteOptions(options);
7138
7258
  }
7139
7259
  this.getMeasure().addNoteGroup(voiceId, notes, noteLength, options);
7140
7260
  return this;
7141
7261
  }
7262
+ /**
7263
+ *
7264
+ * @param voiceId - Voice id to add rest to.
7265
+ * @param restLength - Rest length (e.g. "4n").
7266
+ * @param options - Rest options.
7267
+ * @returns - This document builder instance.
7268
+ */
7142
7269
  addRest(voiceId, restLength, options) {
7143
7270
  assertArg(isVoiceId(voiceId), "voiceId", voiceId);
7144
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(restLength, import_theory13.NoteLength), "restLength", restLength);
7271
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(restLength, import_theory13.NoteLength) || isNoteLength(restLength), "restLength", restLength);
7145
7272
  if (options !== void 0) {
7146
7273
  assertRestOptions(options);
7147
7274
  }
7148
7275
  this.getMeasure().addRest(voiceId, restLength, options);
7149
7276
  return this;
7150
7277
  }
7278
+ /**
7279
+ * Usage:
7280
+ * <pre>
7281
+ * addTuplet(0, Theory.Tuplet.Triplet, notes => {
7282
+ * notes.addNote("G3", Theory.NoteLength.Eighth);
7283
+ * notes.addNote("B3", Theory.NoteLength.Eighth);
7284
+ * notes.addNote("D4", Theory.NoteLength.Eighth);
7285
+ * });
7286
+ * </pre>
7287
+ *
7288
+ * @param voiceId - Voice id to add tuplet to.
7289
+ * @param tupletRatio - You can also use Theory.Tuplet presets (e.g. Theory.Tuplet.Triplet).
7290
+ * @param tupletBuilder - Tuplet builder function to build tuplet.
7291
+ * @returns - This document builder instance.
7292
+ */
7293
+ addTuplet(voiceId, tupletRatio, tupletBuilder) {
7294
+ assertArg(isVoiceId(voiceId), "voiceId", voiceId);
7295
+ assertArg(import_ts_utils_lib13.Utils.Is.isFunction(tupletBuilder), "tupletBuilder", tupletBuilder);
7296
+ assertArg(isTupletRatio(tupletRatio) && import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(tupletRatio.showRatio), "tupletRatio", tupletRatio);
7297
+ let tupletSymbols = [];
7298
+ const helper = {
7299
+ addNote: (note, noteLength, options) => {
7300
+ assertArg(note instanceof import_theory13.Note || import_ts_utils_lib13.Utils.Is.isNonEmptyString(note), "note", note);
7301
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
7302
+ if (options !== void 0) {
7303
+ delete options.triplet;
7304
+ assertNoteOptions(options);
7305
+ }
7306
+ let s = this.getMeasure().addNoteGroup(voiceId, [note], noteLength, options, tupletRatio);
7307
+ tupletSymbols.push(s);
7308
+ return helper;
7309
+ },
7310
+ addChord: (notes, noteLength, options) => {
7311
+ assertArg(import_ts_utils_lib13.Utils.Is.isNonEmptyArray(notes) && notes.every((note) => note instanceof import_theory13.Note || import_ts_utils_lib13.Utils.Is.isNonEmptyString(note)), "notes", notes);
7312
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
7313
+ if (options !== void 0) {
7314
+ delete options.triplet;
7315
+ assertNoteOptions(options);
7316
+ }
7317
+ let s = this.getMeasure().addNoteGroup(voiceId, notes, noteLength, options, tupletRatio);
7318
+ tupletSymbols.push(s);
7319
+ return helper;
7320
+ },
7321
+ addRest: (restLength, options) => {
7322
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(restLength, import_theory13.NoteLength) || isNoteLength(restLength), "restLength", restLength);
7323
+ if (options !== void 0) {
7324
+ delete options.triplet;
7325
+ assertRestOptions(options);
7326
+ }
7327
+ let s = this.getMeasure().addRest(voiceId, restLength, options, tupletRatio);
7328
+ tupletSymbols.push(s);
7329
+ return helper;
7330
+ }
7331
+ };
7332
+ tupletBuilder(helper);
7333
+ ObjBeamGroup.createTuplet(tupletSymbols, tupletRatio);
7334
+ return this;
7335
+ }
7151
7336
  addFermataInternal(staffTabOrGroups, fermata) {
7152
7337
  assertStaffTabOrGRoups(staffTabOrGroups);
7153
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(fermata, Fermata), "fermata", fermata);
7338
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(fermata, Fermata), "fermata", fermata);
7154
7339
  this.getMeasure().addFermata(staffTabOrGroups, fermata);
7155
7340
  return this;
7156
7341
  }
7157
- addFermata(fermata = 0 /* AtNote */) {
7342
+ /**
7343
+ * Add fermata to current measure.
7344
+ * @param fermata - Fermata type (e.g. "atNote" or Fermata.AtrNote).
7345
+ * @returns - This document builder instance.
7346
+ */
7347
+ addFermata(fermata = "atNote" /* AtNote */) {
7158
7348
  return this.addFermataInternal(void 0, fermata);
7159
7349
  }
7160
- /** @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name. */
7161
- addFermataTo(staffTabOrGroups, fermata = 0 /* AtNote */) {
7350
+ /**
7351
+ * Add Fermata to current measure to given staff/tab/group.
7352
+ * @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name.
7353
+ * @param fermata - Fermata type (e.g. "atNote" or Fermata.AtrNote).
7354
+ * @returns - This document builder instance.
7355
+ */
7356
+ addFermataTo(staffTabOrGroups, fermata = "atNote" /* AtNote */) {
7162
7357
  return this.addFermataInternal(staffTabOrGroups, fermata);
7163
7358
  }
7164
7359
  addNavigationInternal(staffTabOrGroups, navigation, ...args) {
7165
7360
  assertStaffTabOrGRoups(staffTabOrGroups);
7166
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(navigation, Navigation), "navigation", navigation);
7167
- if (navigation === 9 /* EndRepeat */ && args.length > 0) {
7168
- assertArg(import_ts_utils_lib11.Utils.Is.isIntegerGte(args[0], 1), "playCount", args[0]);
7169
- } else if (navigation === 10 /* Ending */ && args.length > 0) {
7170
- assertArg(args.every((passage) => import_ts_utils_lib11.Utils.Is.isIntegerGte(passage, 1)), "passages", args);
7361
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(navigation, Navigation), "navigation", navigation);
7362
+ if (navigation === "endRepeat" /* EndRepeat */ && args.length > 0) {
7363
+ assertArg(import_ts_utils_lib13.Utils.Is.isIntegerGte(args[0], 1), "playCount", args[0]);
7364
+ } else if (navigation === "ending" /* Ending */ && args.length > 0) {
7365
+ assertArg(args.every((passage) => import_ts_utils_lib13.Utils.Is.isIntegerGte(passage, 1)), "passages", args);
7171
7366
  }
7172
7367
  this.getMeasure().addNavigation(staffTabOrGroups, navigation, ...args);
7173
7368
  return this;
@@ -7178,100 +7373,186 @@ var DocumentBuilder = class {
7178
7373
  addNavigationTo(staffTabOrGroups, navigation, ...args) {
7179
7374
  return this.addNavigationInternal(staffTabOrGroups, navigation, ...args);
7180
7375
  }
7376
+ addAnnotationInternal(staffTabOrGroups, annotation, text) {
7377
+ annotation != null ? annotation : annotation = getAnnotation(text);
7378
+ if (annotation === void 0) {
7379
+ throw new import_core17.MusicError(import_core17.MusicErrorType.Score, `Annotation text "${text}" is not known annotation.`);
7380
+ }
7381
+ assertStaffTabOrGRoups(staffTabOrGroups);
7382
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(annotation, Annotation), "annotation", annotation);
7383
+ assertArg(import_ts_utils_lib13.Utils.Is.isNonEmptyString(text), "text", text);
7384
+ this.getMeasure().addAnnotation(staffTabOrGroups, annotation, text);
7385
+ return this;
7386
+ }
7387
+ addAnnotation(...args) {
7388
+ if (args.length === 1) {
7389
+ return this.addAnnotationInternal(void 0, void 0, args[0]);
7390
+ } else {
7391
+ return this.addAnnotationInternal(void 0, args[0], args[1]);
7392
+ }
7393
+ }
7394
+ addAnnotationTo(staffTabOrGroups, ...args) {
7395
+ if (args.length === 1) {
7396
+ return this.addAnnotationInternal(staffTabOrGroups, void 0, args[0]);
7397
+ } else {
7398
+ return this.addAnnotationInternal(staffTabOrGroups, args[0], args[1]);
7399
+ }
7400
+ }
7181
7401
  addLabelInternal(staffTabOrGroups, label, text) {
7182
7402
  assertStaffTabOrGRoups(staffTabOrGroups);
7183
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(label, Label), "label", label);
7184
- assertArg(import_ts_utils_lib11.Utils.Is.isString(text), "text", text);
7403
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(label, Label), "label", label);
7404
+ assertArg(import_ts_utils_lib13.Utils.Is.isNonEmptyString(text), "text", text);
7185
7405
  this.getMeasure().addLabel(staffTabOrGroups, label, text);
7186
7406
  return this;
7187
7407
  }
7408
+ /**
7409
+ * Add label text to column of last added note/chord/rest in current measure.
7410
+ * @param label - Label type (e.g. "chord" or Label.Chord).
7411
+ * @param text - label text (e.g. "Am").
7412
+ * @returns - This document builder instance.
7413
+ */
7188
7414
  addLabel(label, text) {
7189
7415
  return this.addLabelInternal(void 0, label, text);
7190
7416
  }
7191
- /** @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name. */
7417
+ /**
7418
+ * Add label text to column of last added note/chord/rest in current measure to given staff/tab/group.
7419
+ * @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name.
7420
+ * @param label - Label type (e.g. "chord" or Label.Chord).
7421
+ * @param text - label text (e.g. "Am").
7422
+ * @returns - This document builder instance.
7423
+ */
7192
7424
  addLabelTo(staffTabOrGroups, label, text) {
7193
7425
  return this.addLabelInternal(staffTabOrGroups, label, text);
7194
7426
  }
7195
- addAnnotationInternal(staffTabOrGroups, annotation, text) {
7196
- assertStaffTabOrGRoups(staffTabOrGroups);
7197
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(annotation, Annotation), "annotation", annotation);
7198
- assertArg(import_ts_utils_lib11.Utils.Is.isString(text), "text", text);
7199
- this.getMeasure().addAnnotation(staffTabOrGroups, annotation, text);
7200
- return this;
7201
- }
7202
- addAnnotation(annotation, text) {
7203
- return this.addAnnotationInternal(void 0, annotation, text);
7204
- }
7205
- /** @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name. */
7206
- addAnnotationTo(staffTabOrGroups, annotation, text) {
7207
- return this.addAnnotationInternal(staffTabOrGroups, annotation, text);
7208
- }
7209
7427
  addConnective(connective, ...args) {
7210
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(connective, Connective), "connective", connective);
7211
- if (connective === 0 /* Tie */) {
7212
- assertArg(import_ts_utils_lib11.Utils.Is.isUndefined(args[0]) || import_ts_utils_lib11.Utils.Is.isInteger(args[0]) || import_ts_utils_lib11.Utils.Is.isEnumValue(args[0], TieType), "tieSpan", args[0]);
7213
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValueOrUndefined(args[1], NoteAnchor), "noteAnchor", args[1]);
7428
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(connective, Connective), "connective", connective);
7429
+ if (connective === "tie" /* Tie */) {
7430
+ assertArg(import_ts_utils_lib13.Utils.Is.isIntegerOrUndefined(args[0]) || import_ts_utils_lib13.Utils.Is.isEnumValue(args[0], TieType), "tieSpan", args[0]);
7431
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValueOrUndefined(args[1], NoteAnchor), "noteAnchor", args[1]);
7214
7432
  let tieSpan = args[0];
7215
7433
  let noteAnchor = args[1];
7216
7434
  this.getMeasure().addConnective(connective, tieSpan, noteAnchor);
7217
- } else if (connective === 1 /* Slur */) {
7218
- assertArg(import_ts_utils_lib11.Utils.Is.isUndefined(args[0]) || import_ts_utils_lib11.Utils.Is.isInteger(args[0]), "slurSpan", args[0]);
7219
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValueOrUndefined(args[1], NoteAnchor), "noteAnchor", args[1]);
7435
+ } else if (connective === "slur" /* Slur */) {
7436
+ assertArg(import_ts_utils_lib13.Utils.Is.isIntegerOrUndefined(args[0]), "slurSpan", args[0]);
7437
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValueOrUndefined(args[1], NoteAnchor), "noteAnchor", args[1]);
7220
7438
  let slurSpan = args[0];
7221
7439
  let noteAnchor = args[1];
7222
7440
  this.getMeasure().addConnective(connective, slurSpan, noteAnchor);
7223
- } else if (connective === 2 /* Slide */) {
7224
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValueOrUndefined(args[0], NoteAnchor), "noteAnchor", args[0]);
7441
+ } else if (connective === "slide" /* Slide */) {
7442
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValueOrUndefined(args[0], NoteAnchor), "noteAnchor", args[0]);
7225
7443
  let noteAnchor = args[0];
7226
7444
  this.getMeasure().addConnective(connective, noteAnchor);
7227
7445
  }
7228
7446
  return this;
7229
7447
  }
7230
- addExtension(extensionLength, extensionVisible) {
7231
- assertArg(import_ts_utils_lib11.Utils.Is.isIntegerGte(extensionLength, 0) || extensionLength === Infinity || import_ts_utils_lib11.Utils.Is.isEnumValue(extensionLength, import_theory13.NoteLength), "extendionLength", extensionLength);
7232
- assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(extensionVisible), "extensionVisible", extensionVisible);
7233
- this.getMeasure().addExtension(extensionLength, extensionVisible != null ? extensionVisible : true);
7448
+ /**
7449
+ * Add extension line to previously added annotation or label element.
7450
+ * <pre>
7451
+ * // Example
7452
+ * addExtension(ext => ext.notes("1n", 2)) // length is 2 whole notes
7453
+ * addExtension(ext => ext.measures(3).hide()) // length is 3 measures, hidden
7454
+ * addExtension(ext => ext.measures(1).notes("8n")) // length is 1 measure + 1 eigth note
7455
+ * addExtension(ext => ext.infinity()) // length is as long as possible
7456
+ * </pre>
7457
+ * @param extensionBuilder - Extension builder function used to build exstension.
7458
+ * @returns - This document builder instance.
7459
+ */
7460
+ addExtension(extensionBuilder) {
7461
+ assertArg(import_ts_utils_lib13.Utils.Is.isFunctionOrUndefined(extensionBuilder), "addExtension() has new usage, for e.g. addExtension(ext => ext.measures(2)). Please refer to README or API Reference.", extensionBuilder);
7462
+ let ticks = 0;
7463
+ let visible = true;
7464
+ const helper = {
7465
+ notes: (noteLength, noteCount) => {
7466
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
7467
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(noteCount) || import_ts_utils_lib13.Utils.Is.isNumber(noteCount) && noteCount >= 0, "noteCount", noteCount);
7468
+ ticks += import_theory13.RhythmProps.get(noteLength).ticks * (noteCount != null ? noteCount : 1);
7469
+ return helper;
7470
+ },
7471
+ measures: (measureCount) => {
7472
+ assertArg(import_ts_utils_lib13.Utils.Is.isNumber(measureCount) && measureCount >= 1, "measureCount", measureCount);
7473
+ ticks += this.getMeasure().getMeasureTicks() * measureCount;
7474
+ return helper;
7475
+ },
7476
+ infinity: () => {
7477
+ ticks = Infinity;
7478
+ return helper;
7479
+ },
7480
+ hide: () => {
7481
+ visible = false;
7482
+ return helper;
7483
+ }
7484
+ };
7485
+ if (extensionBuilder) {
7486
+ extensionBuilder(helper);
7487
+ } else {
7488
+ ticks = Infinity;
7489
+ }
7490
+ this.getMeasure().addExtension(ticks, visible);
7234
7491
  return this;
7235
7492
  }
7236
7493
  /**
7237
- *
7494
+ * Add staff group.
7238
7495
  * @param groupName - Name of staff group.
7239
7496
  * @param staffsTabsAndGroups - staff/tab index (0=top), staff/tab name, or staff group name. Single value or array.
7240
7497
  * @param verticalPosition - Vertical position, are elements added above, below or both.
7241
- * @returns
7498
+ * @returns - This document builder instance.
7242
7499
  */
7243
- addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition = 3 /* Auto */) {
7244
- assertArg(import_ts_utils_lib11.Utils.Is.isString(groupName) && groupName.length > 0, "groupName", groupName);
7500
+ addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition = "auto" /* Auto */) {
7501
+ assertArg(import_ts_utils_lib13.Utils.Is.isNonEmptyString(groupName), "groupName", groupName);
7245
7502
  assertArg(
7246
- import_ts_utils_lib11.Utils.Is.isString(staffsTabsAndGroups) && staffsTabsAndGroups.length > 0 || import_ts_utils_lib11.Utils.Is.isIntegerGte(staffsTabsAndGroups, 0) || import_ts_utils_lib11.Utils.Is.isArray(staffsTabsAndGroups) && staffsTabsAndGroups.every((line) => import_ts_utils_lib11.Utils.Is.isString(line) && line.length > 0 || import_ts_utils_lib11.Utils.Is.isIntegerGte(line, 0)),
7503
+ import_ts_utils_lib13.Utils.Is.isNonEmptyString(staffsTabsAndGroups) || import_ts_utils_lib13.Utils.Is.isIntegerGte(staffsTabsAndGroups, 0) || import_ts_utils_lib13.Utils.Is.isNonEmptyArray(staffsTabsAndGroups) && staffsTabsAndGroups.every((line) => import_ts_utils_lib13.Utils.Is.isNonEmptyString(line) || import_ts_utils_lib13.Utils.Is.isIntegerGte(line, 0)),
7247
7504
  "staffsTabsAndGroups",
7248
7505
  staffsTabsAndGroups
7249
7506
  );
7250
- assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(verticalPosition, VerticalPosition), "verticalPosition", verticalPosition);
7507
+ assertArg(import_ts_utils_lib13.Utils.Is.isEnumValue(verticalPosition, VerticalPosition), "verticalPosition", verticalPosition);
7251
7508
  this.doc.addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition);
7252
7509
  return this;
7253
7510
  }
7511
+ /**
7512
+ * Add song end. Adds certain bar line at the end of measure.
7513
+ * @returns - This document builder instance.
7514
+ */
7254
7515
  endSong() {
7255
7516
  this.getMeasure().endSong();
7256
7517
  return this;
7257
7518
  }
7519
+ /**
7520
+ * Add section end. Adds certain bar line at the end of measure.
7521
+ * @returns - This document builder instance.
7522
+ */
7258
7523
  endSection() {
7259
7524
  this.getMeasure().endSection();
7260
7525
  return this;
7261
7526
  }
7527
+ /**
7528
+ * End current score row. Next measure will start new row.
7529
+ * @returns - This document builder instance.
7530
+ */
7262
7531
  endRow() {
7263
7532
  var _a;
7264
7533
  (_a = this.doc.getLastMeasure()) == null ? void 0 : _a.endRow();
7265
7534
  return this;
7266
7535
  }
7536
+ /**
7537
+ * Add rests to fill current measure.
7538
+ * @param voiceId - Voice id to add rests to. Single value, array or all if omitted.
7539
+ * @returns - This document builder instance.
7540
+ */
7267
7541
  completeRests(voiceId) {
7268
- assertArg(import_ts_utils_lib11.Utils.Is.isUndefined(voiceId) || isVoiceId(voiceId), "voiceId", voiceId);
7542
+ assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(voiceId) || isVoiceId(voiceId) || import_ts_utils_lib13.Utils.Is.isArray(voiceId) && voiceId.every((id) => isVoiceId(id)), "voiceId", voiceId);
7269
7543
  this.getMeasure().completeRests(voiceId);
7270
7544
  return this;
7271
7545
  }
7546
+ /**
7547
+ * Add notes of given scale in ascending order.
7548
+ * @param scale - Scale.
7549
+ * @param bottomNote - Scale starts from note >= bottom note.
7550
+ * @param numOctaves - Number of octaves to add.
7551
+ * @returns - This document builder instance.
7552
+ */
7272
7553
  addScaleArpeggio(scale, bottomNote, numOctaves) {
7273
- assertArg(import_ts_utils_lib11.Utils.Is.isString(bottomNote), "bottomNote", bottomNote);
7274
- assertArg(import_ts_utils_lib11.Utils.Is.isIntegerGte(numOctaves, 1), "numOctaves", numOctaves);
7554
+ assertArg(import_ts_utils_lib13.Utils.Is.isNonEmptyString(bottomNote), "bottomNote", bottomNote);
7555
+ assertArg(import_ts_utils_lib13.Utils.Is.isIntegerGte(numOctaves, 1), "numOctaves", numOctaves);
7275
7556
  let ts = this.getMeasure().getTimeSignature();
7276
7557
  let notes = scale.getScaleNotes(bottomNote, numOctaves);
7277
7558
  for (let i = 0; i < notes.length; i++) {
@@ -7280,7 +7561,7 @@ var DocumentBuilder = class {
7280
7561
  }
7281
7562
  let note = notes[i];
7282
7563
  this.addNote(0, note, ts.beatLength);
7283
- this.addLabel(0 /* Note */, note.formatOmitOctave(import_theory13.SymbolSet.Unicode));
7564
+ this.addLabel("note" /* Note */, note.formatOmitOctave(import_theory13.SymbolSet.Unicode));
7284
7565
  }
7285
7566
  return this;
7286
7567
  }
@@ -7289,11 +7570,22 @@ var DocumentBuilder = class {
7289
7570
  // src/score/pub/event.ts
7290
7571
  var import_core18 = require("@tspro/web-music-score/core");
7291
7572
  var ScoreEvent = class {
7573
+ /**
7574
+ * Create new score event instance.
7575
+ * @param type - Score event type.
7576
+ */
7292
7577
  constructor(type) {
7293
7578
  this.type = type;
7294
7579
  }
7295
7580
  };
7296
7581
  var ScoreStaffPosEvent = class extends ScoreEvent {
7582
+ /**
7583
+ * Create new score staff position event.
7584
+ * @param type - Score event type.
7585
+ * @param renderer - Renderer.
7586
+ * @param scoreRow - Score row.
7587
+ * @param diatonicId - Diatonic id that was clicked/entered/left.
7588
+ */
7297
7589
  constructor(type, renderer, scoreRow, diatonicId) {
7298
7590
  super(type);
7299
7591
  this.renderer = renderer;
@@ -7302,6 +7594,12 @@ var ScoreStaffPosEvent = class extends ScoreEvent {
7302
7594
  }
7303
7595
  };
7304
7596
  var ScoreObjectEvent = class extends ScoreEvent {
7597
+ /**
7598
+ * Create new score object event.
7599
+ * @param type - Score event type.
7600
+ * @param renderer - Renderer.
7601
+ * @param objects - Array of objects, last object in this array is the top object that was clicked/entered/left, previous objects are it's parent objects.
7602
+ */
7305
7603
  constructor(type, renderer, objects) {
7306
7604
  super(type);
7307
7605
  this.renderer = renderer;
@@ -7310,32 +7608,34 @@ var ScoreObjectEvent = class extends ScoreEvent {
7310
7608
  throw new import_core18.MusicError(import_core18.MusicErrorType.Score, "Empty array in score object event!");
7311
7609
  }
7312
7610
  }
7611
+ /** Top object getter. */
7313
7612
  get topObject() {
7314
7613
  return this.objects[this.objects.length - 1];
7315
7614
  }
7615
+ /**
7616
+ * Find object.
7617
+ * @param fn - Compare function.
7618
+ * @returns - First object that matched compare function, or undefined if no match.
7619
+ */
7316
7620
  findObject(fn) {
7317
7621
  return this.objects.find((obj) => fn(obj));
7318
7622
  }
7319
7623
  };
7320
7624
 
7321
- // src/score/pub/interface.ts
7625
+ // src/score/pub/music-interface.ts
7322
7626
  var Audio2 = __toESM(require("@tspro/web-music-score/audio"));
7323
- var import_ts_utils_lib12 = require("@tspro/ts-utils-lib");
7627
+ var import_ts_utils_lib15 = require("@tspro/ts-utils-lib");
7628
+
7629
+ // src/score/pub/music-objects.ts
7630
+ var import_ts_utils_lib14 = require("@tspro/ts-utils-lib");
7324
7631
  var import_core19 = require("@tspro/web-music-score/core");
7325
7632
  function assertArg2(condition, argName, argValue) {
7326
7633
  if (!condition) {
7327
7634
  throw new import_core19.MusicError(import_core19.MusicErrorType.Score, `Invalid arg: ${argName} = ${argValue}`);
7328
7635
  }
7329
7636
  }
7330
- function require_t(t, message) {
7331
- if (t === void 0 || t === null) {
7332
- throw new TypeError(message);
7333
- } else {
7334
- return t;
7335
- }
7336
- }
7337
7637
  function isVoiceId2(value) {
7338
- return import_ts_utils_lib12.Utils.Is.isNumber(value) && getVoiceIds().indexOf(value) >= 0;
7638
+ return import_ts_utils_lib14.Utils.Is.isNumber(value) && getVoiceIds().indexOf(value) >= 0;
7339
7639
  }
7340
7640
  function getNotationLine(line) {
7341
7641
  if (line instanceof ObjStaff || line instanceof ObjTab) {
@@ -7345,9 +7645,17 @@ function getNotationLine(line) {
7345
7645
  }
7346
7646
  }
7347
7647
  var MusicInterface6 = class {
7648
+ /**
7649
+ * Create new music interface object.
7650
+ * @param name - OBject name.
7651
+ */
7348
7652
  constructor(name) {
7349
7653
  this.name = name;
7350
7654
  }
7655
+ /**
7656
+ * Get parent object.
7657
+ * @returns - Parent object or undefined.
7658
+ */
7351
7659
  getParent() {
7352
7660
  var _a;
7353
7661
  return (_a = this.getMusicObject().getParent()) == null ? void 0 : _a.getMusicInterface();
@@ -7363,10 +7671,15 @@ var _MAccidental = class _MAccidental extends MusicInterface6 {
7363
7671
  getMusicObject() {
7364
7672
  return this.obj;
7365
7673
  }
7674
+ /**
7675
+ * Get accidental.
7676
+ * @returns - Accidental (e.g. 1 = #).
7677
+ */
7366
7678
  getAccidental() {
7367
7679
  return this.obj.accidental;
7368
7680
  }
7369
7681
  };
7682
+ /** Object name. */
7370
7683
  __publicField(_MAccidental, "Name", "Accidental");
7371
7684
  var MAccidental = _MAccidental;
7372
7685
  var _MConnective = class _MConnective extends MusicInterface6 {
@@ -7380,6 +7693,7 @@ var _MConnective = class _MConnective extends MusicInterface6 {
7380
7693
  return this.obj;
7381
7694
  }
7382
7695
  };
7696
+ /** Object name. */
7383
7697
  __publicField(_MConnective, "Name", "Connective");
7384
7698
  var MConnective = _MConnective;
7385
7699
  var _MArpeggio = class _MArpeggio extends MusicInterface6 {
@@ -7392,13 +7706,22 @@ var _MArpeggio = class _MArpeggio extends MusicInterface6 {
7392
7706
  getMusicObject() {
7393
7707
  return this.obj;
7394
7708
  }
7709
+ /**
7710
+ * Get rhythm column this arpeggio is in.
7711
+ * @returns - Rhythm column.
7712
+ */
7395
7713
  getRhythmColumn() {
7396
7714
  return this.obj.col.getMusicInterface();
7397
7715
  }
7716
+ /**
7717
+ * Get notation line this arpeggio is in.
7718
+ * @returns - Staff or tab object.
7719
+ */
7398
7720
  getNotationLine() {
7399
7721
  return getNotationLine(this.obj.line);
7400
7722
  }
7401
7723
  };
7724
+ /** Object name. */
7402
7725
  __publicField(_MArpeggio, "Name", "Arpeggio");
7403
7726
  var MArpeggio = _MArpeggio;
7404
7727
  var _MBeamGroup = class _MBeamGroup extends MusicInterface6 {
@@ -7412,6 +7735,7 @@ var _MBeamGroup = class _MBeamGroup extends MusicInterface6 {
7412
7735
  return this.obj;
7413
7736
  }
7414
7737
  };
7738
+ /** OBject name. */
7415
7739
  __publicField(_MBeamGroup, "Name", "BeamGroup");
7416
7740
  var MBeamGroup = _MBeamGroup;
7417
7741
  var _MStaffBeamGroup = class _MStaffBeamGroup extends MusicInterface6 {
@@ -7424,10 +7748,15 @@ var _MStaffBeamGroup = class _MStaffBeamGroup extends MusicInterface6 {
7424
7748
  getMusicObject() {
7425
7749
  return this.obj;
7426
7750
  }
7751
+ /**
7752
+ * Get staff this beam group is in.
7753
+ * @returns - Staff object.
7754
+ */
7427
7755
  getStaff() {
7428
7756
  return this.obj.staff.getMusicInterface();
7429
7757
  }
7430
7758
  };
7759
+ /** Object name. */
7431
7760
  __publicField(_MStaffBeamGroup, "Name", "StaffBeamGroup");
7432
7761
  var MStaffBeamGroup = _MStaffBeamGroup;
7433
7762
  var _MDocument = class _MDocument extends MusicInterface6 {
@@ -7440,27 +7769,53 @@ var _MDocument = class _MDocument extends MusicInterface6 {
7440
7769
  getMusicObject() {
7441
7770
  return this.obj;
7442
7771
  }
7772
+ /**
7773
+ * Get title.
7774
+ * @returns - Title string or undefined.
7775
+ */
7443
7776
  getTitle() {
7444
7777
  return this.obj.getTitle();
7445
7778
  }
7779
+ /**
7780
+ * Get composer.
7781
+ * @returns - Composer string or undefined.
7782
+ */
7446
7783
  getComposer() {
7447
7784
  return this.obj.getComposer();
7448
7785
  3;
7449
7786
  }
7787
+ /**
7788
+ * Get arranger.
7789
+ * @returns - Arranger string or undefined.
7790
+ */
7450
7791
  getArranger() {
7451
7792
  return this.obj.getArranger();
7452
7793
  }
7794
+ /**
7795
+ * Get score rows.
7796
+ * @returns - Array or score rows.
7797
+ */
7453
7798
  getRows() {
7454
7799
  return this.obj.getRows().map((r) => r.getMusicInterface());
7455
7800
  }
7801
+ /**
7802
+ * Get measures.
7803
+ * @returns - Array of measures.
7804
+ */
7456
7805
  getMeasures() {
7457
7806
  return this.obj.getMeasures().map((m) => m.getMusicInterface());
7458
7807
  }
7459
- play(fn) {
7460
- assertArg2(import_ts_utils_lib12.Utils.Is.isFunctionOrUndefined(fn), "playStateChangeListener", fn);
7461
- return new MPlayer(this, fn).play();
7808
+ /**
7809
+ * Play this document.
7810
+ * @param playStateChangeListener - Play state change listener function or undefined.
7811
+ * @returns - Player instance.
7812
+ */
7813
+ play(playStateChangeListener) {
7814
+ assertArg2(import_ts_utils_lib14.Utils.Is.isFunctionOrUndefined(playStateChangeListener), "playStateChangeListener", playStateChangeListener);
7815
+ return new MPlayer(this, playStateChangeListener).play();
7462
7816
  }
7463
7817
  };
7818
+ /** Object name. */
7464
7819
  __publicField(_MDocument, "Name", "Document");
7465
7820
  var MDocument2 = _MDocument;
7466
7821
  var _MEnding = class _MEnding extends MusicInterface6 {
@@ -7473,14 +7828,24 @@ var _MEnding = class _MEnding extends MusicInterface6 {
7473
7828
  getMusicObject() {
7474
7829
  return this.obj;
7475
7830
  }
7831
+ /**
7832
+ * Get passages.
7833
+ * @returns - Array of passage numbers, e.g. passage number 1 means that this ending is played on first pass.
7834
+ */
7476
7835
  getPassages() {
7477
7836
  return this.obj.passages;
7478
7837
  }
7838
+ /**
7839
+ * Has passage number?
7840
+ * @param passage - Passage number to find out.
7841
+ * @returns - Boolean whether this ending has asked passage number.
7842
+ */
7479
7843
  hasPassage(passage) {
7480
- assertArg2(import_ts_utils_lib12.Utils.Is.isIntegerGte(passage, 1), "passage", passage);
7844
+ assertArg2(import_ts_utils_lib14.Utils.Is.isIntegerGte(passage, 1), "passage", passage);
7481
7845
  return this.obj.hasPassage(passage);
7482
7846
  }
7483
7847
  };
7848
+ /** Object name. */
7484
7849
  __publicField(_MEnding, "Name", "Ending");
7485
7850
  var MEnding = _MEnding;
7486
7851
  var _MFermata = class _MFermata extends MusicInterface6 {
@@ -7494,6 +7859,7 @@ var _MFermata = class _MFermata extends MusicInterface6 {
7494
7859
  return this.obj;
7495
7860
  }
7496
7861
  };
7862
+ /** OBject name. */
7497
7863
  __publicField(_MFermata, "Name", "Fermata");
7498
7864
  var MFermata = _MFermata;
7499
7865
  var _MHeader = class _MHeader extends MusicInterface6 {
@@ -7506,16 +7872,29 @@ var _MHeader = class _MHeader extends MusicInterface6 {
7506
7872
  getMusicObject() {
7507
7873
  return this.obj;
7508
7874
  }
7875
+ /**
7876
+ * Get title.
7877
+ * @returns - Title string or undefined.
7878
+ */
7509
7879
  getTitle() {
7510
7880
  return this.obj.title;
7511
7881
  }
7882
+ /**
7883
+ * Get composer.
7884
+ * @returns - Composer string or undefined.
7885
+ */
7512
7886
  getComposer() {
7513
7887
  return this.obj.composer;
7514
7888
  }
7889
+ /**
7890
+ * Get arranger.
7891
+ * @returns - Arranger string or undefined.
7892
+ */
7515
7893
  getArranger() {
7516
7894
  return this.obj.arranger;
7517
7895
  }
7518
7896
  };
7897
+ /** OBject name. */
7519
7898
  __publicField(_MHeader, "Name", "Header");
7520
7899
  var MHeader = _MHeader;
7521
7900
  var _MImage = class _MImage extends MusicInterface6 {
@@ -7529,6 +7908,7 @@ var _MImage = class _MImage extends MusicInterface6 {
7529
7908
  return this.obj;
7530
7909
  }
7531
7910
  };
7911
+ /** Object name. */
7532
7912
  __publicField(_MImage, "Name", "Image");
7533
7913
  var MImage = _MImage;
7534
7914
  var _MMeasure = class _MMeasure extends MusicInterface6 {
@@ -7541,16 +7921,29 @@ var _MMeasure = class _MMeasure extends MusicInterface6 {
7541
7921
  getMusicObject() {
7542
7922
  return this.obj;
7543
7923
  }
7924
+ /**
7925
+ * Get measure number.
7926
+ * @returns - Measure number starting from 1, or 0 if upbeat.
7927
+ */
7544
7928
  getMeasureNumber() {
7545
7929
  return this.obj.getMeasureNumber();
7546
7930
  }
7931
+ /**
7932
+ * Get rhythm columns.
7933
+ * @returns - Array of rhythm columns.
7934
+ */
7547
7935
  getRhythmColumns() {
7548
7936
  return this.obj.getColumns().map((col) => col.getMusicInterface());
7549
7937
  }
7938
+ /**
7939
+ * Get score row that this measure is in.
7940
+ * @returns - Score row.
7941
+ */
7550
7942
  getRow() {
7551
7943
  return this.obj.row.getMusicInterface();
7552
7944
  }
7553
7945
  };
7946
+ /** OBject name. */
7554
7947
  __publicField(_MMeasure, "Name", "Measure");
7555
7948
  var MMeasure = _MMeasure;
7556
7949
  var _MBarLineRight = class _MBarLineRight extends MusicInterface6 {
@@ -7564,6 +7957,7 @@ var _MBarLineRight = class _MBarLineRight extends MusicInterface6 {
7564
7957
  return this.obj;
7565
7958
  }
7566
7959
  };
7960
+ /** OBject name. */
7567
7961
  __publicField(_MBarLineRight, "Name", "BarLineRight");
7568
7962
  var MBarLineRight = _MBarLineRight;
7569
7963
  var _MBarLineLeft = class _MBarLineLeft extends MusicInterface6 {
@@ -7577,6 +7971,7 @@ var _MBarLineLeft = class _MBarLineLeft extends MusicInterface6 {
7577
7971
  return this.obj;
7578
7972
  }
7579
7973
  };
7974
+ /** Object name. */
7580
7975
  __publicField(_MBarLineLeft, "Name", "BarLineLeft");
7581
7976
  var MBarLineLeft = _MBarLineLeft;
7582
7977
  var _MStaffTabBarLine = class _MStaffTabBarLine extends MusicInterface6 {
@@ -7589,6 +7984,10 @@ var _MStaffTabBarLine = class _MStaffTabBarLine extends MusicInterface6 {
7589
7984
  getMusicObject() {
7590
7985
  return this.obj;
7591
7986
  }
7987
+ /**
7988
+ * Get parent bar line object.
7989
+ * @returns - Parent bar line object.
7990
+ */
7592
7991
  getBarLine() {
7593
7992
  let barLine = this.obj.barLine;
7594
7993
  if (barLine instanceof ObjBarLineLeft || barLine instanceof ObjBarLineRight) {
@@ -7597,10 +7996,15 @@ var _MStaffTabBarLine = class _MStaffTabBarLine extends MusicInterface6 {
7597
7996
  throw new import_core19.MusicError(import_core19.MusicErrorType.Score, `Bar line not let nor right.`);
7598
7997
  }
7599
7998
  }
7999
+ /**
8000
+ * Get staff or tab this bar lien object is in.
8001
+ * @returns - Staff or tab.
8002
+ */
7600
8003
  getNotationLine() {
7601
8004
  return getNotationLine(this.obj.line);
7602
8005
  }
7603
8006
  };
8007
+ /** Object name. */
7604
8008
  __publicField(_MStaffTabBarLine, "Name", "StaffTabBarLine");
7605
8009
  var MStaffTabBarLine = _MStaffTabBarLine;
7606
8010
  var _MNoteGroup = class _MNoteGroup extends MusicInterface6 {
@@ -7613,19 +8017,36 @@ var _MNoteGroup = class _MNoteGroup extends MusicInterface6 {
7613
8017
  getMusicObject() {
7614
8018
  return this.obj;
7615
8019
  }
8020
+ /**
8021
+ * Get notes of this note group.
8022
+ * @returns - Array of Note instances.
8023
+ */
7616
8024
  getNotes() {
7617
8025
  return this.obj.notes;
7618
8026
  }
8027
+ /**
8028
+ * Get rhythm props of this note group.
8029
+ * @returns - Rhythm props.
8030
+ */
7619
8031
  getRhythmProps() {
7620
8032
  return this.obj.rhythmProps;
7621
8033
  }
8034
+ /**
8035
+ * Get rhythm column this note group is in.
8036
+ * @returns - Rhythm column.
8037
+ */
7622
8038
  getRhythmColumn() {
7623
8039
  return this.obj.col.getMusicInterface();
7624
8040
  }
8041
+ /**
8042
+ * Get the measure this note group is in.
8043
+ * @returns - Measure.
8044
+ */
7625
8045
  getMeasure() {
7626
8046
  return this.obj.measure.getMusicInterface();
7627
8047
  }
7628
8048
  };
8049
+ /** Object name. */
7629
8050
  __publicField(_MNoteGroup, "Name", "NoteGroup");
7630
8051
  var MNoteGroup = _MNoteGroup;
7631
8052
  var _MStaffNoteGroup = class _MStaffNoteGroup extends MusicInterface6 {
@@ -7638,19 +8059,36 @@ var _MStaffNoteGroup = class _MStaffNoteGroup extends MusicInterface6 {
7638
8059
  getMusicObject() {
7639
8060
  return this.obj;
7640
8061
  }
8062
+ /**
8063
+ * Get parent note group.
8064
+ * @returns - Parent note group.
8065
+ */
7641
8066
  getNoteGroup() {
7642
8067
  return this.obj.noteGroup.getMusicInterface();
7643
8068
  }
8069
+ /**
8070
+ * Get rhythm column this note group is in.
8071
+ * @returns - Rhythm column.
8072
+ */
7644
8073
  getRhythmColumn() {
7645
8074
  return this.getNoteGroup().getRhythmColumn();
7646
8075
  }
8076
+ /**
8077
+ * Get the measure this note group is in.
8078
+ * @returns - Measure.
8079
+ */
7647
8080
  getMeasure() {
7648
8081
  return this.getNoteGroup().getMeasure();
7649
8082
  }
8083
+ /**
8084
+ * Get staff notation line this note group is in.
8085
+ * @returns - Staff object.
8086
+ */
7650
8087
  getStaff() {
7651
8088
  return this.obj.staff.getMusicInterface();
7652
8089
  }
7653
8090
  };
8091
+ /** Object name. */
7654
8092
  __publicField(_MStaffNoteGroup, "Name", "StaffNoteGroup");
7655
8093
  var MStaffNoteGroup = _MStaffNoteGroup;
7656
8094
  var _MTabNoteGroup = class _MTabNoteGroup extends MusicInterface6 {
@@ -7663,19 +8101,36 @@ var _MTabNoteGroup = class _MTabNoteGroup extends MusicInterface6 {
7663
8101
  getMusicObject() {
7664
8102
  return this.obj;
7665
8103
  }
8104
+ /**
8105
+ * Get parent note group.
8106
+ * @returns - Parent note group.
8107
+ */
7666
8108
  getNoteGroup() {
7667
8109
  return this.obj.noteGroup.getMusicInterface();
7668
8110
  }
8111
+ /**
8112
+ * Get rhythm column this note group is in.
8113
+ * @returns - Rhythm column.
8114
+ */
7669
8115
  getRhythmColumn() {
7670
8116
  return this.getNoteGroup().getRhythmColumn();
7671
8117
  }
8118
+ /**
8119
+ * Get the measure this note group is in.
8120
+ * @returns - Measure.
8121
+ */
7672
8122
  getMeasure() {
7673
8123
  return this.getNoteGroup().getMeasure();
7674
8124
  }
8125
+ /**
8126
+ * Get guitar tab this note group is in.
8127
+ * @returns - Tab object.
8128
+ */
7675
8129
  getTab() {
7676
8130
  return this.obj.tab.getMusicInterface();
7677
8131
  }
7678
8132
  };
8133
+ /** OBject name. */
7679
8134
  __publicField(_MTabNoteGroup, "Name", "TabNoteGroup");
7680
8135
  var MTabNoteGroup = _MTabNoteGroup;
7681
8136
  var _MRest = class _MRest extends MusicInterface6 {
@@ -7688,16 +8143,29 @@ var _MRest = class _MRest extends MusicInterface6 {
7688
8143
  getMusicObject() {
7689
8144
  return this.obj;
7690
8145
  }
8146
+ /**
8147
+ * Get rhythm props of this rest.
8148
+ * @returns - Rhythm props.
8149
+ */
7691
8150
  getRhythmProps() {
7692
8151
  return this.obj.rhythmProps;
7693
8152
  }
8153
+ /**
8154
+ * Get rhythm column this rest is in.
8155
+ * @returns - Rhythm column.
8156
+ */
7694
8157
  getRhythmColumn() {
7695
8158
  return this.obj.col.getMusicInterface();
7696
8159
  }
8160
+ /**
8161
+ * Get the measure this rest is in.
8162
+ * @returns - Measure.
8163
+ */
7697
8164
  getMeasure() {
7698
8165
  return this.obj.measure.getMusicInterface();
7699
8166
  }
7700
8167
  };
8168
+ /** OBject name. */
7701
8169
  __publicField(_MRest, "Name", "Rest");
7702
8170
  var MRest = _MRest;
7703
8171
  var _MStaffRest = class _MStaffRest extends MusicInterface6 {
@@ -7710,19 +8178,36 @@ var _MStaffRest = class _MStaffRest extends MusicInterface6 {
7710
8178
  getMusicObject() {
7711
8179
  return this.obj;
7712
8180
  }
8181
+ /**
8182
+ * Get parent rest object.
8183
+ * @returns - Parent rest object.
8184
+ */
7713
8185
  getRest() {
7714
8186
  return this.obj.rest.getMusicInterface();
7715
8187
  }
8188
+ /**
8189
+ * Get rhythm column this rest is in.
8190
+ * @returns - Rhythm column.
8191
+ */
7716
8192
  getRhythmColumn() {
7717
8193
  return this.getRest().getRhythmColumn();
7718
8194
  }
8195
+ /**
8196
+ * Get the measure this rest is in.
8197
+ * @returns - Measure.
8198
+ */
7719
8199
  getMeasure() {
7720
8200
  return this.getRest().getMeasure();
7721
8201
  }
8202
+ /**
8203
+ * Get staff notation line this rest is in.
8204
+ * @returns - Staff object.
8205
+ */
7722
8206
  getStaff() {
7723
8207
  return this.obj.staff.getMusicInterface();
7724
8208
  }
7725
8209
  };
8210
+ /** Object name. */
7726
8211
  __publicField(_MStaffRest, "Name", "StaffRest");
7727
8212
  var MStaffRest = _MStaffRest;
7728
8213
  var _MRhythmColumn = class _MRhythmColumn extends MusicInterface6 {
@@ -7735,19 +8220,36 @@ var _MRhythmColumn = class _MRhythmColumn extends MusicInterface6 {
7735
8220
  getMusicObject() {
7736
8221
  return this.obj;
7737
8222
  }
8223
+ /**
8224
+ * Get symbol (note group or rest) of this column for given voice id.
8225
+ * @param voiceId - Voice id.
8226
+ * @returns - Note group, rest or undefined.
8227
+ */
7738
8228
  getRhythmSymbol(voiceId) {
7739
8229
  var _a;
7740
8230
  assertArg2(isVoiceId2(voiceId), "voiceId", voiceId);
7741
8231
  return (_a = this.obj.getVoiceSymbol(voiceId)) == null ? void 0 : _a.getMusicInterface();
7742
8232
  }
8233
+ /**
8234
+ * Get symbol (note group or rest) of this column for given voice id.
8235
+ * @deprecated - Use getRhythmSymbol(voiceId) instead.
8236
+ * @param voiceId - Voice id.
8237
+ * @returns - Note group, rest or undefined.
8238
+ */
8239
+ getVoiceSymbol(voiceId) {
8240
+ var _a;
8241
+ assertArg2(isVoiceId2(voiceId), "voiceId", voiceId);
8242
+ return (_a = this.obj.getVoiceSymbol(voiceId)) == null ? void 0 : _a.getMusicInterface();
8243
+ }
8244
+ /**
8245
+ * Get the measure this rhythm column is in.
8246
+ * @returns - Measure.
8247
+ */
7743
8248
  getMeasure() {
7744
8249
  return this.obj.measure.getMusicInterface();
7745
8250
  }
7746
- getVoiceSymbol(voiceId) {
7747
- let s = this.obj.getVoiceSymbol(voiceId);
7748
- return s instanceof ObjNoteGroup || s instanceof ObjRest ? s.getMusicInterface() : void 0;
7749
- }
7750
8251
  };
8252
+ /** OBject name. */
7751
8253
  __publicField(_MRhythmColumn, "Name", "RhythmColumn");
7752
8254
  var MRhythmColumn = _MRhythmColumn;
7753
8255
  var _MScoreRow = class _MScoreRow extends MusicInterface6 {
@@ -7760,16 +8262,29 @@ var _MScoreRow = class _MScoreRow extends MusicInterface6 {
7760
8262
  getMusicObject() {
7761
8263
  return this.obj;
7762
8264
  }
8265
+ /**
8266
+ * Parent music document.
8267
+ * @returns - Parent music document.
8268
+ */
7763
8269
  getDocument() {
7764
8270
  return this.obj.doc.getMusicInterface();
7765
8271
  }
8272
+ /**
8273
+ * Get measures of this score row.
8274
+ * @returns - Array of measures.
8275
+ */
7766
8276
  getMeasures() {
7767
8277
  return this.obj.getMeasures().map((m) => m.getMusicInterface());
7768
8278
  }
8279
+ /**
8280
+ * Get notation lines (staves and tabs) of this score row.
8281
+ * @returns - Array of staves and tabs.
8282
+ */
7769
8283
  getNotationLines() {
7770
8284
  return this.obj.getNotationLines().map((line) => getNotationLine(line));
7771
8285
  }
7772
8286
  };
8287
+ /** Object name. */
7773
8288
  __publicField(_MScoreRow, "Name", "ScoreRow");
7774
8289
  var MScoreRow = _MScoreRow;
7775
8290
  var _MStaff = class _MStaff extends MusicInterface6 {
@@ -7782,16 +8297,29 @@ var _MStaff = class _MStaff extends MusicInterface6 {
7782
8297
  getMusicObject() {
7783
8298
  return this.obj;
7784
8299
  }
8300
+ /**
8301
+ * Get index of this staff in score row.
8302
+ * @returns - Index (0=top notation line).
8303
+ */
7785
8304
  getId() {
7786
8305
  return this.obj.id;
7787
8306
  }
8307
+ /**
8308
+ * Get name of this staff.
8309
+ * @returns - Staff name.
8310
+ */
7788
8311
  getName() {
7789
8312
  return this.obj.name.length > 0 ? this.obj.name : void 0;
7790
8313
  }
8314
+ /**
8315
+ * Get the score row this staff is in.
8316
+ * @returns - Score row.
8317
+ */
7791
8318
  getRow() {
7792
8319
  return this.obj.row.getMusicInterface();
7793
8320
  }
7794
8321
  };
8322
+ /** Object name. */
7795
8323
  __publicField(_MStaff, "Name", "Staff");
7796
8324
  var MStaff = _MStaff;
7797
8325
  var _MTab = class _MTab extends MusicInterface6 {
@@ -7804,16 +8332,29 @@ var _MTab = class _MTab extends MusicInterface6 {
7804
8332
  getMusicObject() {
7805
8333
  return this.obj;
7806
8334
  }
8335
+ /**
8336
+ * Get index of this guitar tab in score row.
8337
+ * @returns - Index (0=top notation line).
8338
+ */
7807
8339
  getId() {
7808
8340
  return this.obj.id;
7809
8341
  }
8342
+ /**
8343
+ * Get name of this guitar tab.
8344
+ * @returns - Staff name.
8345
+ */
7810
8346
  getName() {
7811
8347
  return this.obj.name.length > 0 ? this.obj.name : void 0;
7812
8348
  }
8349
+ /**
8350
+ * Get the score row this guitar tab is in.
8351
+ * @returns - Score row.
8352
+ */
7813
8353
  getRow() {
7814
8354
  return this.obj.row.getMusicInterface();
7815
8355
  }
7816
8356
  };
8357
+ /** Object name. */
7817
8358
  __publicField(_MTab, "Name", "Tab");
7818
8359
  var MTab = _MTab;
7819
8360
  var _MSignature = class _MSignature extends MusicInterface6 {
@@ -7826,10 +8367,15 @@ var _MSignature = class _MSignature extends MusicInterface6 {
7826
8367
  getMusicObject() {
7827
8368
  return this.obj;
7828
8369
  }
8370
+ /**
8371
+ * Get staff notation line this signature is in.
8372
+ * @returns - Staff object.
8373
+ */
7829
8374
  getStaff() {
7830
8375
  return this.obj.staff.getMusicInterface();
7831
8376
  }
7832
8377
  };
8378
+ /** Object name. */
7833
8379
  __publicField(_MSignature, "Name", "Signature");
7834
8380
  var MSignature = _MSignature;
7835
8381
  var _MSpecialText = class _MSpecialText extends MusicInterface6 {
@@ -7842,10 +8388,15 @@ var _MSpecialText = class _MSpecialText extends MusicInterface6 {
7842
8388
  getMusicObject() {
7843
8389
  return this.obj;
7844
8390
  }
8391
+ /**
8392
+ * Get text content.
8393
+ * @returns - Text content.
8394
+ */
7845
8395
  getText() {
7846
8396
  return this.obj.getText();
7847
8397
  }
7848
8398
  };
8399
+ /** Object name. */
7849
8400
  __publicField(_MSpecialText, "Name", "SpecialText");
7850
8401
  var MSpecialText = _MSpecialText;
7851
8402
  var _MText = class _MText extends MusicInterface6 {
@@ -7858,10 +8409,15 @@ var _MText = class _MText extends MusicInterface6 {
7858
8409
  getMusicObject() {
7859
8410
  return this.obj;
7860
8411
  }
8412
+ /**
8413
+ * Get text content.
8414
+ * @returns - Text content.
8415
+ */
7861
8416
  getText() {
7862
8417
  return this.obj.getText();
7863
8418
  }
7864
8419
  };
8420
+ /** Object name. */
7865
8421
  __publicField(_MText, "Name", "Text");
7866
8422
  var MText = _MText;
7867
8423
  var _MExtensionLine = class _MExtensionLine extends MusicInterface6 {
@@ -7875,33 +8431,69 @@ var _MExtensionLine = class _MExtensionLine extends MusicInterface6 {
7875
8431
  return this.obj;
7876
8432
  }
7877
8433
  };
8434
+ /** OBject name. */
7878
8435
  __publicField(_MExtensionLine, "Name", "ExtensionLine");
7879
8436
  var MExtensionLine = _MExtensionLine;
8437
+
8438
+ // src/score/pub/music-interface.ts
8439
+ var import_core20 = require("@tspro/web-music-score/core");
8440
+ function assertArg3(condition, argName, argValue) {
8441
+ if (!condition) {
8442
+ throw new import_core20.MusicError(import_core20.MusicErrorType.Score, `Invalid arg: ${argName} = ${argValue}`);
8443
+ }
8444
+ }
8445
+ function require_t(t, message) {
8446
+ if (t === void 0 || t === null) {
8447
+ throw new TypeError(message);
8448
+ } else {
8449
+ return t;
8450
+ }
8451
+ }
7880
8452
  var _MPlayer = class _MPlayer {
7881
- constructor(doc, fn) {
8453
+ /**
8454
+ * Create new music player.
8455
+ * @param doc - Music document to play.
8456
+ * @param playStateChangeListener - Play state change listener.
8457
+ */
8458
+ constructor(doc, playStateChangeListener) {
7882
8459
  __publicField(this, "player");
7883
- assertArg2(doc instanceof MDocument2, "doc", doc);
7884
- assertArg2(import_ts_utils_lib12.Utils.Is.isFunctionOrUndefined(fn), "playStateChangeListener", fn);
8460
+ assertArg3(doc instanceof MDocument2, "doc", doc);
8461
+ assertArg3(import_ts_utils_lib15.Utils.Is.isFunctionOrUndefined(playStateChangeListener), "playStateChangeListener", playStateChangeListener);
7885
8462
  this.player = new Player();
7886
8463
  this.player.setDocument(doc.getMusicObject());
7887
8464
  this.player.setCursorPositionChangeListener((cursorRect) => doc.getMusicObject().updateCursorRect(cursorRect));
7888
- if (fn) {
7889
- this.player.setPlayStateChnageListener(fn);
8465
+ if (playStateChangeListener) {
8466
+ this.player.setPlayStateChnageListener(playStateChangeListener);
7890
8467
  }
7891
8468
  }
8469
+ /**
8470
+ * Stop all playing.
8471
+ */
7892
8472
  static stopAll() {
7893
8473
  this.currentlyPlaying.forEach((p) => p.stop());
7894
8474
  Audio2.stop();
7895
8475
  }
8476
+ /**
8477
+ * Playe attached document.
8478
+ * @returns - This player instance.
8479
+ */
7896
8480
  play() {
7897
8481
  _MPlayer.currentlyPlaying.add(this);
7898
8482
  this.player.play();
7899
8483
  return this;
7900
8484
  }
8485
+ /**
8486
+ * Pause playback of attached document.
8487
+ * @returns - This player instance.
8488
+ */
7901
8489
  pause() {
7902
8490
  this.player.pause();
7903
8491
  return this;
7904
8492
  }
8493
+ /**
8494
+ * Stop playback of attached document.
8495
+ * @returns - This player instance.
8496
+ */
7905
8497
  stop() {
7906
8498
  this.player.stop();
7907
8499
  _MPlayer.currentlyPlaying.delete(this);
@@ -7911,33 +8503,61 @@ var _MPlayer = class _MPlayer {
7911
8503
  __publicField(_MPlayer, "currentlyPlaying", /* @__PURE__ */ new Set());
7912
8504
  var MPlayer = _MPlayer;
7913
8505
  var MRenderer2 = class {
8506
+ /**
8507
+ * Create new renderer instance.
8508
+ */
7914
8509
  constructor() {
7915
8510
  __publicField(this, "renderer");
7916
8511
  this.renderer = new Renderer(this);
7917
8512
  }
8513
+ /**
8514
+ * Attach music document to this renderer.
8515
+ * @param doc - Music document.
8516
+ * @returns - This renderer instance.
8517
+ */
7918
8518
  setDocument(doc) {
7919
- assertArg2(import_ts_utils_lib12.Utils.Is.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
8519
+ assertArg3(import_ts_utils_lib15.Utils.Is.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
7920
8520
  this.renderer.setDocument(doc);
7921
8521
  return this;
7922
8522
  }
8523
+ /**
8524
+ * Set target canvas html element for this renderer.
8525
+ * @param canvas - HTML canvas element or element id.
8526
+ * @returns - This renderer instance.
8527
+ */
7923
8528
  setCanvas(canvas) {
7924
- canvas = require_t(import_ts_utils_lib12.Utils.Dom.getCanvas(canvas), typeof canvas === "string" ? "Cannot set renderer canvas because invalid canvas id: " + canvas : "Cannot set renderer canvas because given canvas is undefined.");
8529
+ canvas = require_t(import_ts_utils_lib15.Utils.Dom.getCanvas(canvas), typeof canvas === "string" ? "Cannot set renderer canvas because invalid canvas id: " + canvas : "Cannot set renderer canvas because given canvas is undefined.");
7925
8530
  this.renderer.setCanvas(canvas);
7926
8531
  return this;
7927
8532
  }
7928
- setScoreEventListener(fn) {
7929
- assertArg2(import_ts_utils_lib12.Utils.Is.isFunctionOrUndefined(fn), "scoreEventListener", fn);
7930
- this.renderer.setScoreEventListener(fn);
8533
+ /**
8534
+ * Set score event listener.
8535
+ * @param scoreEventListener - Score event listener.
8536
+ */
8537
+ setScoreEventListener(scoreEventListener) {
8538
+ assertArg3(import_ts_utils_lib15.Utils.Is.isFunctionOrUndefined(scoreEventListener), "scoreEventListener", scoreEventListener);
8539
+ this.renderer.setScoreEventListener(scoreEventListener);
7931
8540
  }
8541
+ /**
8542
+ * Draw given music object hilighted.
8543
+ * @param obj - Music object or undefined to remove hilighting.
8544
+ */
7932
8545
  hilightObject(obj) {
7933
8546
  this.renderer.hilightObject(obj == null ? void 0 : obj.getMusicObject());
7934
8547
  }
8548
+ /**
8549
+ * Draw given staff position hilighted.
8550
+ * @param staffPos - Staff position (score row and diatonic id) or undefined to remove hilighting.
8551
+ */
7935
8552
  hilightStaffPos(staffPos) {
7936
8553
  this.renderer.hilightStaffPos(staffPos ? {
7937
8554
  scoreRow: staffPos.scoreRow.getMusicObject(),
7938
8555
  diatonicId: staffPos.diatonicId
7939
8556
  } : void 0);
7940
8557
  }
8558
+ /**
8559
+ * Draw contents of attached music document to attached canvas.
8560
+ */
7941
8561
  draw() {
7942
8562
  try {
7943
8563
  this.renderer.draw();
@@ -7948,6 +8568,9 @@ var MRenderer2 = class {
7948
8568
  }
7949
8569
  };
7950
8570
  var _MPlaybackButtons = class _MPlaybackButtons {
8571
+ /**
8572
+ * Create new playback buttons helper class instance.
8573
+ */
7951
8574
  constructor() {
7952
8575
  __publicField(this, "playButton");
7953
8576
  __publicField(this, "stopButton");
@@ -7980,8 +8603,13 @@ var _MPlaybackButtons = class _MPlaybackButtons {
7980
8603
  };
7981
8604
  this.updateButtons();
7982
8605
  }
8606
+ /**
8607
+ * Attach music document whose playcak will be controlled by this playback buttons helper class instance.
8608
+ * @param doc - Music document.
8609
+ * @returns
8610
+ */
7983
8611
  setDocument(doc) {
7984
- assertArg2(import_ts_utils_lib12.Utils.Is.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
8612
+ assertArg3(import_ts_utils_lib15.Utils.Is.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
7985
8613
  this.onStop();
7986
8614
  if (doc) {
7987
8615
  this.player = new MPlayer(doc, (playState) => {
@@ -7994,6 +8622,9 @@ var _MPlaybackButtons = class _MPlaybackButtons {
7994
8622
  this.updateButtons();
7995
8623
  return this;
7996
8624
  }
8625
+ /**
8626
+ * Detach attached music document.
8627
+ */
7997
8628
  detachDocument() {
7998
8629
  this.setDocument(void 0);
7999
8630
  }
@@ -8015,31 +8646,50 @@ var _MPlaybackButtons = class _MPlaybackButtons {
8015
8646
  this.pauseButton.innerText = this.pauseLabel;
8016
8647
  }
8017
8648
  }
8649
+ /**
8650
+ * Set play button.
8651
+ * @param btn - HTML button element or element id.
8652
+ * @param btnLabel - Custom button label (e.g. "Play").
8653
+ * @returns - This playback buttons class instance.
8654
+ */
8018
8655
  setPlayButton(btn, btnLabel) {
8019
- assertArg2(import_ts_utils_lib12.Utils.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
8656
+ assertArg3(import_ts_utils_lib15.Utils.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
8020
8657
  _MPlaybackButtons.removeOnClickListeners(this.playButton, this.onPlay);
8021
- this.playButton = require_t(import_ts_utils_lib12.Utils.Dom.getButton(btn), "Play button required!");
8658
+ this.playButton = require_t(import_ts_utils_lib15.Utils.Dom.getButton(btn), "Play button required!");
8022
8659
  this.playLabel = btnLabel != null ? btnLabel : "Play";
8023
8660
  _MPlaybackButtons.removeOnClickListeners(this.playButton, "all");
8024
8661
  _MPlaybackButtons.addOnClickListener(this.playButton, this.onPlay);
8025
8662
  this.updateButtons();
8026
8663
  return this;
8027
8664
  }
8665
+ /**
8666
+ * Set stop button.
8667
+ * @param btn - HTML button element or element id.
8668
+ * @param btnLabel - Custom button label (e.g. "Stop").
8669
+ * @returns - This playback buttons class instance.
8670
+ */
8028
8671
  setStopButton(btn, btnLabel) {
8029
- assertArg2(import_ts_utils_lib12.Utils.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
8672
+ assertArg3(import_ts_utils_lib15.Utils.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
8030
8673
  _MPlaybackButtons.removeOnClickListeners(this.stopButton, this.onStop);
8031
- this.stopButton = require_t(import_ts_utils_lib12.Utils.Dom.getButton(btn), "Stop button required!");
8674
+ this.stopButton = require_t(import_ts_utils_lib15.Utils.Dom.getButton(btn), "Stop button required!");
8032
8675
  this.stopLabel = btnLabel != null ? btnLabel : "Stop";
8033
8676
  _MPlaybackButtons.removeOnClickListeners(this.stopButton, "all");
8034
8677
  _MPlaybackButtons.addOnClickListener(this.stopButton, this.onStop);
8035
8678
  this.updateButtons();
8036
8679
  return this;
8037
8680
  }
8681
+ /**
8682
+ * Set play/stop button.
8683
+ * @param btn - HTML button element or element id.
8684
+ * @param playLabel - Custom button label for play action (e.g. "Play").
8685
+ * @param stopLabel - Custom button label for stop action (e.g. "Stop").
8686
+ * @returns - This playback buttons class instance.
8687
+ */
8038
8688
  setPlayStopButton(btn, playLabel, stopLabel) {
8039
- assertArg2(import_ts_utils_lib12.Utils.Is.isStringOrUndefined(playLabel), "playLabel", playLabel);
8040
- assertArg2(import_ts_utils_lib12.Utils.Is.isStringOrUndefined(stopLabel), "stopLabel", stopLabel);
8689
+ assertArg3(import_ts_utils_lib15.Utils.Is.isStringOrUndefined(playLabel), "playLabel", playLabel);
8690
+ assertArg3(import_ts_utils_lib15.Utils.Is.isStringOrUndefined(stopLabel), "stopLabel", stopLabel);
8041
8691
  _MPlaybackButtons.removeOnClickListeners(this.playStopButton, this.onPlayStop);
8042
- this.playStopButton = require_t(import_ts_utils_lib12.Utils.Dom.getButton(btn), "Play/stop button required!");
8692
+ this.playStopButton = require_t(import_ts_utils_lib15.Utils.Dom.getButton(btn), "Play/stop button required!");
8043
8693
  this.playLabel = playLabel != null ? playLabel : "Play";
8044
8694
  this.stopLabel = stopLabel != null ? stopLabel : "Stop";
8045
8695
  _MPlaybackButtons.removeOnClickListeners(this.playStopButton, "all");
@@ -8047,10 +8697,16 @@ var _MPlaybackButtons = class _MPlaybackButtons {
8047
8697
  this.updateButtons();
8048
8698
  return this;
8049
8699
  }
8700
+ /**
8701
+ * Set pause button.
8702
+ * @param btn - HTML button element or element id.
8703
+ * @param btnLabel - Custom button label (e.g. "Pause").
8704
+ * @returns - This playback buttons class instance.
8705
+ */
8050
8706
  setPauseButton(btn, btnLabel) {
8051
- assertArg2(import_ts_utils_lib12.Utils.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
8707
+ assertArg3(import_ts_utils_lib15.Utils.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
8052
8708
  _MPlaybackButtons.removeOnClickListeners(this.pauseButton, this.onPause);
8053
- this.pauseButton = require_t(import_ts_utils_lib12.Utils.Dom.getButton(btn), "Pause button required!");
8709
+ this.pauseButton = require_t(import_ts_utils_lib15.Utils.Dom.getButton(btn), "Pause button required!");
8054
8710
  this.pauseLabel = btnLabel != null ? btnLabel : "Pause";
8055
8711
  _MPlaybackButtons.removeOnClickListeners(this.pauseButton, "all");
8056
8712
  _MPlaybackButtons.addOnClickListener(this.pauseButton, this.onPause);
@@ -8072,7 +8728,7 @@ var _MPlaybackButtons = class _MPlaybackButtons {
8072
8728
  }
8073
8729
  }
8074
8730
  static addOnClickListener(btn, onClick) {
8075
- assertArg2(import_ts_utils_lib12.Utils.Is.isFunction(onClick), "onClick", onClick);
8731
+ assertArg3(import_ts_utils_lib15.Utils.Is.isFunction(onClick), "onClick", onClick);
8076
8732
  btn.addEventListener("click", onClick);
8077
8733
  let clickListeners = this.savedOnClickListeners.get(btn) || [];
8078
8734
  this.savedOnClickListeners.set(btn, [...clickListeners, onClick]);
@@ -8082,8 +8738,8 @@ __publicField(_MPlaybackButtons, "savedOnClickListeners", /* @__PURE__ */ new Ma
8082
8738
  var MPlaybackButtons = _MPlaybackButtons;
8083
8739
 
8084
8740
  // src/score/index.ts
8085
- var import_core20 = require("@tspro/web-music-score/core");
8086
- (0, import_core20.init)();
8741
+ var import_core21 = require("@tspro/web-music-score/core");
8742
+ (0, import_core21.init)();
8087
8743
  // Annotate the CommonJS export names for ESM import in node:
8088
8744
  0 && (module.exports = {
8089
8745
  Annotation,
@@ -8092,6 +8748,7 @@ var import_core20 = require("@tspro/web-music-score/core");
8092
8748
  Connective,
8093
8749
  DivRect,
8094
8750
  DocumentBuilder,
8751
+ DynamicsAnnotation,
8095
8752
  Fermata,
8096
8753
  Label,
8097
8754
  MAccidental,
@@ -8133,6 +8790,7 @@ var import_core20 = require("@tspro/web-music-score/core");
8133
8790
  ScoreStaffPosEvent,
8134
8791
  StaffPreset,
8135
8792
  Stem,
8793
+ TempoAnnotation,
8136
8794
  TieType,
8137
8795
  VerticalPosition,
8138
8796
  getStringNumbers,