@tspro/web-music-score 5.4.1 → 5.4.2
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.
- package/CHANGELOG.md +3 -0
- package/README.md +4 -4
- package/dist/audio/index.d.mts +1 -1
- package/dist/audio/index.js +1 -1
- package/dist/audio/index.mjs +3 -3
- package/dist/audio-cg/index.js +1 -1
- package/dist/audio-cg/index.mjs +3 -3
- package/dist/audio-synth/index.js +1 -1
- package/dist/audio-synth/index.mjs +3 -3
- package/dist/{chunk-A5SMODAT.mjs → chunk-42IBAVOC.mjs} +3 -3
- package/dist/{chunk-5I5KENEC.mjs → chunk-CVYTUTL6.mjs} +2 -2
- package/dist/{chunk-6P4ECBUH.mjs → chunk-MMWSQGVR.mjs} +3 -3
- package/dist/{chunk-U2ACCEHX.mjs → chunk-ROBXPR34.mjs} +2 -2
- package/dist/core/index.js +2 -2
- package/dist/core/index.mjs +4 -4
- package/dist/{guitar-DXlB-9vK.d.mts → guitar-DK18GZ6h.d.mts} +1 -1
- package/dist/iife/audio-cg.global.js +1 -1
- package/dist/iife/index.global.js +11 -11
- package/dist/{music-objects-DYMqx839.d.mts → music-objects-DqoO-Sfv.d.mts} +93 -39
- package/dist/{music-objects-DumXKWJp.d.ts → music-objects-T8u8bnNP.d.ts} +91 -37
- package/dist/{note-RVXvpfyV.d.mts → note-CJuq5aBy.d.mts} +1 -1
- package/dist/pieces/index.d.mts +3 -3
- package/dist/pieces/index.d.ts +1 -1
- package/dist/pieces/index.js +1 -1
- package/dist/pieces/index.mjs +2 -2
- package/dist/react-ui/index.d.mts +5 -5
- package/dist/react-ui/index.d.ts +1 -1
- package/dist/react-ui/index.js +1 -1
- package/dist/react-ui/index.mjs +2 -2
- package/dist/{scale-C8gHC448.d.mts → scale-DWM4RQco.d.mts} +2 -2
- package/dist/score/index.d.mts +5 -5
- package/dist/score/index.d.ts +2 -2
- package/dist/score/index.js +623 -441
- package/dist/score/index.mjs +516 -335
- package/dist/{tempo-BlCGZuYg.d.mts → tempo-Cxu8vusu.d.mts} +1 -1
- package/dist/theory/index.d.mts +6 -6
- package/dist/theory/index.js +1 -1
- package/dist/theory/index.mjs +3 -3
- package/package.json +2 -1
package/dist/score/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* WebMusicScore v5.4.
|
|
1
|
+
/* WebMusicScore v5.4.2 | (c) 2023-2025 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -66,13 +66,14 @@ __export(score_exports, {
|
|
|
66
66
|
MRest: () => MRest,
|
|
67
67
|
MRhythmColumn: () => MRhythmColumn,
|
|
68
68
|
MScoreRow: () => MScoreRow,
|
|
69
|
+
MScoreRowGroup: () => MScoreRowGroup,
|
|
69
70
|
MSpecialText: () => MSpecialText,
|
|
70
71
|
MStaff: () => MStaff,
|
|
72
|
+
MStaffBarLine: () => MStaffBarLine,
|
|
71
73
|
MStaffBeamGroup: () => MStaffBeamGroup,
|
|
72
74
|
MStaffNoteGroup: () => MStaffNoteGroup,
|
|
73
75
|
MStaffRest: () => MStaffRest,
|
|
74
76
|
MStaffSignature: () => MStaffSignature,
|
|
75
|
-
MStaffTabBarLine: () => MStaffTabBarLine,
|
|
76
77
|
MTab: () => MTab,
|
|
77
78
|
MTabNoteGroup: () => MTabNoteGroup,
|
|
78
79
|
MTabRhythm: () => MTabRhythm,
|
|
@@ -425,7 +426,7 @@ var DivRect = class _DivRect {
|
|
|
425
426
|
};
|
|
426
427
|
|
|
427
428
|
// src/score/pub/document-builder.ts
|
|
428
|
-
var
|
|
429
|
+
var import_ts_utils_lib33 = require("@tspro/ts-utils-lib");
|
|
429
430
|
|
|
430
431
|
// src/score/pub/types.ts
|
|
431
432
|
var import_ts_utils_lib2 = require("@tspro/ts-utils-lib");
|
|
@@ -657,13 +658,52 @@ var MusicObject = class {
|
|
|
657
658
|
}
|
|
658
659
|
updateRect() {
|
|
659
660
|
}
|
|
661
|
+
forceRectUpdate() {
|
|
662
|
+
this.needRectUpdate = true;
|
|
663
|
+
this.updateRect();
|
|
664
|
+
this.needRectUpdate = false;
|
|
665
|
+
}
|
|
660
666
|
getRect() {
|
|
661
|
-
if (this.needRectUpdate)
|
|
662
|
-
this.
|
|
663
|
-
this.needRectUpdate = false;
|
|
664
|
-
}
|
|
667
|
+
if (this.needRectUpdate)
|
|
668
|
+
this.forceRectUpdate();
|
|
665
669
|
return this.rect;
|
|
666
670
|
}
|
|
671
|
+
offsetX(dx) {
|
|
672
|
+
this.offset(dx, 0);
|
|
673
|
+
}
|
|
674
|
+
offsetY(dy) {
|
|
675
|
+
this.offset(0, dy);
|
|
676
|
+
}
|
|
677
|
+
setLeft(x) {
|
|
678
|
+
this.offset(x - this.getRect().left, 0);
|
|
679
|
+
}
|
|
680
|
+
setRight(x) {
|
|
681
|
+
this.offset(x - this.getRect().right, 0);
|
|
682
|
+
}
|
|
683
|
+
setTop(y) {
|
|
684
|
+
this.offset(0, y - this.getRect().top);
|
|
685
|
+
}
|
|
686
|
+
setBottom(y) {
|
|
687
|
+
this.offset(0, y - this.getRect().bottom);
|
|
688
|
+
}
|
|
689
|
+
setAnchor(x, y) {
|
|
690
|
+
this.offset(x - this.getRect().anchorX, y - this.getRect().anchorY);
|
|
691
|
+
}
|
|
692
|
+
setAnchorX(x) {
|
|
693
|
+
this.offset(x - this.getRect().anchorX, 0);
|
|
694
|
+
}
|
|
695
|
+
setAnchorY(y) {
|
|
696
|
+
this.offset(0, y - this.getRect().anchorY);
|
|
697
|
+
}
|
|
698
|
+
setCenter(x, y) {
|
|
699
|
+
this.offset(x - this.getRect().centerX, y - this.getRect().centerY);
|
|
700
|
+
}
|
|
701
|
+
setCenterX(x) {
|
|
702
|
+
this.offset(x - this.getRect().centerX, 0);
|
|
703
|
+
}
|
|
704
|
+
setCenterY(y) {
|
|
705
|
+
this.offset(0, y - this.getRect().centerY);
|
|
706
|
+
}
|
|
667
707
|
/**
|
|
668
708
|
* Most objects are simple rects in shape.
|
|
669
709
|
* Some objects might be more complex consisting of multiple rects.
|
|
@@ -707,7 +747,7 @@ var DebugSettings = {
|
|
|
707
747
|
};
|
|
708
748
|
var DocumentSettings = {
|
|
709
749
|
DocumentScale: 1,
|
|
710
|
-
|
|
750
|
+
MinStaffWidth: 75,
|
|
711
751
|
MinColumnsWidth: 10,
|
|
712
752
|
ColumnWidthScale: 1.7,
|
|
713
753
|
PostMeasureBreakWidth: 10,
|
|
@@ -1516,63 +1556,103 @@ var RenderContext = class {
|
|
|
1516
1556
|
}
|
|
1517
1557
|
}
|
|
1518
1558
|
arc(x, y, radius, startRadians, endRadians) {
|
|
1519
|
-
|
|
1520
|
-
|
|
1559
|
+
if (this.ctx) this.ctx.arc(x, y, radius, startRadians, endRadians);
|
|
1560
|
+
return this;
|
|
1521
1561
|
}
|
|
1522
1562
|
fillCircle(x, y, radius) {
|
|
1523
|
-
if (this.ctx)
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1563
|
+
if (!this.ctx) return this;
|
|
1564
|
+
this.ctx.beginPath();
|
|
1565
|
+
this.ctx.arc(x, y, radius, 0, 2 * Math.PI);
|
|
1566
|
+
this.ctx.fill();
|
|
1567
|
+
return this;
|
|
1528
1568
|
}
|
|
1529
1569
|
strokeLine(startX, startY, endX, endY) {
|
|
1530
|
-
if (this.ctx)
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1570
|
+
if (!this.ctx) return this;
|
|
1571
|
+
this.ctx.beginPath();
|
|
1572
|
+
this.ctx.moveTo(startX, startY);
|
|
1573
|
+
this.ctx.lineTo(endX, endY);
|
|
1574
|
+
this.ctx.stroke();
|
|
1575
|
+
return this;
|
|
1536
1576
|
}
|
|
1537
1577
|
strokePartialLine(startX, startY, endX, endY, startT, endT) {
|
|
1578
|
+
if (!this.ctx) return this;
|
|
1538
1579
|
let x1 = startX + (endX - startX) * startT;
|
|
1539
1580
|
let y1 = startY + (endY - startY) * startT;
|
|
1540
1581
|
let x2 = startX + (endX - startX) * endT;
|
|
1541
1582
|
let y2 = startY + (endY - startY) * endT;
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
}
|
|
1583
|
+
this.ctx.beginPath();
|
|
1584
|
+
this.ctx.moveTo(x1, y1);
|
|
1585
|
+
this.ctx.lineTo(x2, y2);
|
|
1586
|
+
this.ctx.stroke();
|
|
1587
|
+
return this;
|
|
1548
1588
|
}
|
|
1589
|
+
/** @deprecated - Use {@link drawBracket} instead. */
|
|
1549
1590
|
drawBrace(rect, side) {
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1591
|
+
return this.drawBracket(rect, side === "left" ? "{" : "}");
|
|
1592
|
+
}
|
|
1593
|
+
drawBracket(rect, bracket) {
|
|
1594
|
+
if (!this.ctx) return this;
|
|
1595
|
+
let { left, right, width, top, bottom, height, anchorY } = rect;
|
|
1596
|
+
if ([")", "]", "}", ">"].includes(bracket)) {
|
|
1597
|
+
[left, right, width] = [right, left, -width];
|
|
1598
|
+
}
|
|
1599
|
+
switch (bracket) {
|
|
1600
|
+
case "(":
|
|
1601
|
+
case ")":
|
|
1602
|
+
this.ctx.beginPath();
|
|
1603
|
+
this.ctx.moveTo(right, top);
|
|
1604
|
+
this.ctx.bezierCurveTo(
|
|
1605
|
+
left - width * 0.2,
|
|
1606
|
+
top + height * 0.3,
|
|
1607
|
+
left - width * 0.2,
|
|
1608
|
+
top + height * 0.7,
|
|
1609
|
+
right,
|
|
1610
|
+
bottom
|
|
1611
|
+
);
|
|
1612
|
+
this.ctx.stroke();
|
|
1613
|
+
break;
|
|
1614
|
+
case "{":
|
|
1615
|
+
case "}":
|
|
1616
|
+
this.ctx.beginPath();
|
|
1617
|
+
this.ctx.moveTo(right, top);
|
|
1618
|
+
this.ctx.bezierCurveTo(
|
|
1619
|
+
left + width * 0.1,
|
|
1620
|
+
top,
|
|
1621
|
+
left + width * 0.8,
|
|
1622
|
+
anchorY,
|
|
1623
|
+
left,
|
|
1624
|
+
anchorY
|
|
1625
|
+
);
|
|
1626
|
+
this.ctx.moveTo(right, bottom);
|
|
1627
|
+
this.ctx.bezierCurveTo(
|
|
1628
|
+
left + width * 0.1,
|
|
1629
|
+
bottom,
|
|
1630
|
+
left + width * 0.8,
|
|
1631
|
+
anchorY,
|
|
1632
|
+
left,
|
|
1633
|
+
anchorY
|
|
1634
|
+
);
|
|
1635
|
+
this.ctx.stroke();
|
|
1636
|
+
break;
|
|
1637
|
+
case "[":
|
|
1638
|
+
case "]":
|
|
1639
|
+
this.ctx.beginPath();
|
|
1640
|
+
this.ctx.moveTo(right, top);
|
|
1641
|
+
this.ctx.lineTo(left, top);
|
|
1642
|
+
this.ctx.lineTo(left, bottom);
|
|
1643
|
+
this.ctx.lineTo(right, bottom);
|
|
1644
|
+
this.ctx.stroke();
|
|
1645
|
+
break;
|
|
1646
|
+
case "<":
|
|
1647
|
+
case ">":
|
|
1648
|
+
this.ctx.beginPath();
|
|
1649
|
+
this.ctx.moveTo(right, top);
|
|
1650
|
+
this.ctx.lineTo(left, anchorY);
|
|
1651
|
+
this.ctx.lineTo(right, bottom);
|
|
1652
|
+
this.ctx.stroke();
|
|
1653
|
+
break;
|
|
1575
1654
|
}
|
|
1655
|
+
return this;
|
|
1576
1656
|
}
|
|
1577
1657
|
};
|
|
1578
1658
|
|
|
@@ -2009,20 +2089,21 @@ var ObjStaffSignature = class extends MusicObject {
|
|
|
2009
2089
|
if (this.clefImage) {
|
|
2010
2090
|
x += paddingX;
|
|
2011
2091
|
this.clefImage.layout(ctx);
|
|
2012
|
-
this.clefImage.
|
|
2092
|
+
this.clefImage.setAnchor(x, staff.getDiatonicIdY(staff.clefLineDiatonicId));
|
|
2013
2093
|
this.rect.expandInPlace(this.clefImage.getRect());
|
|
2014
2094
|
x = this.rect.right;
|
|
2015
2095
|
if (this.eightBelowClef) {
|
|
2016
2096
|
let r = this.clefImage.getRect();
|
|
2017
2097
|
this.eightBelowClef.layout(ctx);
|
|
2018
|
-
this.eightBelowClef.
|
|
2098
|
+
this.eightBelowClef.setCenterX(r.centerX);
|
|
2099
|
+
this.eightBelowClef.setTop(Math.max(r.anchorY + r.height * 0.3, staff.getBottomLineY()));
|
|
2019
2100
|
this.rect.expandInPlace(this.eightBelowClef.getRect());
|
|
2020
2101
|
}
|
|
2021
2102
|
}
|
|
2022
2103
|
if (this.measureNumber) {
|
|
2023
2104
|
this.measureNumber.layout(ctx);
|
|
2024
|
-
|
|
2025
|
-
this.measureNumber.
|
|
2105
|
+
this.measureNumber.setLeft(0);
|
|
2106
|
+
this.measureNumber.setBottom(Math.min(staff.getTopLineY(), this.clefImage ? this.clefImage.getRect().top : staff.getTopLineY()));
|
|
2026
2107
|
this.rect.expandInPlace(this.measureNumber.getRect());
|
|
2027
2108
|
x = Math.max(x, this.rect.right);
|
|
2028
2109
|
}
|
|
@@ -2030,7 +2111,8 @@ var ObjStaffSignature = class extends MusicObject {
|
|
|
2030
2111
|
x += paddingX;
|
|
2031
2112
|
this.ksNeutralizeAccidentals.forEach((objAcc) => {
|
|
2032
2113
|
objAcc.layout(ctx);
|
|
2033
|
-
objAcc.
|
|
2114
|
+
objAcc.setLeft(x);
|
|
2115
|
+
objAcc.setAnchorY(staff.getDiatonicIdY(objAcc.diatonicId));
|
|
2034
2116
|
this.rect.expandInPlace(objAcc.getRect());
|
|
2035
2117
|
x = this.rect.right;
|
|
2036
2118
|
});
|
|
@@ -2039,7 +2121,8 @@ var ObjStaffSignature = class extends MusicObject {
|
|
|
2039
2121
|
x += paddingX;
|
|
2040
2122
|
this.ksNewAccidentals.forEach((objAcc) => {
|
|
2041
2123
|
objAcc.layout(ctx);
|
|
2042
|
-
objAcc.
|
|
2124
|
+
objAcc.setLeft(x);
|
|
2125
|
+
objAcc.setAnchorY(staff.getDiatonicIdY(objAcc.diatonicId));
|
|
2043
2126
|
this.rect.expandInPlace(objAcc.getRect());
|
|
2044
2127
|
x = this.rect.right;
|
|
2045
2128
|
});
|
|
@@ -2049,24 +2132,34 @@ var ObjStaffSignature = class extends MusicObject {
|
|
|
2049
2132
|
(_b = this.beatSizeText) == null ? void 0 : _b.layout(ctx);
|
|
2050
2133
|
let tsWidth = Math.max((_d = (_c = this.beatCountText) == null ? void 0 : _c.getRect().width) != null ? _d : 0, (_f = (_e = this.beatSizeText) == null ? void 0 : _e.getRect().width) != null ? _f : 0);
|
|
2051
2134
|
if (this.beatCountText) {
|
|
2052
|
-
this.beatCountText.
|
|
2135
|
+
this.beatCountText.setCenter(
|
|
2136
|
+
x + tsWidth / 2 + paddingX,
|
|
2137
|
+
staff.getDiatonicIdY(staff.middleLineDiatonicId + 2)
|
|
2138
|
+
);
|
|
2053
2139
|
this.rect.expandInPlace(this.beatCountText.getRect());
|
|
2054
2140
|
right = Math.max(right, this.rect.right);
|
|
2055
2141
|
}
|
|
2056
2142
|
if (this.beatSizeText) {
|
|
2057
|
-
this.beatSizeText.
|
|
2143
|
+
this.beatSizeText.setCenter(
|
|
2144
|
+
x + tsWidth / 2 + paddingX,
|
|
2145
|
+
staff.getDiatonicIdY(staff.bottomLineDiatonicId + 2)
|
|
2146
|
+
);
|
|
2058
2147
|
this.rect.expandInPlace(this.beatSizeText.getRect());
|
|
2059
2148
|
right = Math.max(right, this.rect.right);
|
|
2060
2149
|
}
|
|
2061
2150
|
x = right;
|
|
2062
2151
|
if (this.tempoText) {
|
|
2063
|
-
let tempoBottom = Math.min(
|
|
2064
|
-
this.clefImage ? this.clefImage.getRect().top : staff.getTopLineY(),
|
|
2065
|
-
...this.ksNeutralizeAccidentals.map((o) => o.getRect().top),
|
|
2066
|
-
...this.ksNewAccidentals.map((o) => o.getRect().top)
|
|
2067
|
-
);
|
|
2068
2152
|
this.tempoText.layout(ctx);
|
|
2069
|
-
this.tempoText.
|
|
2153
|
+
this.tempoText.setCenterX(x);
|
|
2154
|
+
this.tempoText.setBottom(staff.getTopLineY());
|
|
2155
|
+
if (this.clefImage && import_ts_utils_lib9.AnchoredRect.overlap(this.clefImage.getRect(), this.tempoText.getRect())) {
|
|
2156
|
+
this.tempoText.setBottom(this.clefImage.getRect().top);
|
|
2157
|
+
}
|
|
2158
|
+
[...this.ksNeutralizeAccidentals, ...this.ksNewAccidentals].forEach((acc) => {
|
|
2159
|
+
if (this.tempoText && import_ts_utils_lib9.AnchoredRect.overlap(acc.getRect(), this.tempoText.getRect())) {
|
|
2160
|
+
this.tempoText.setBottom(acc.getRect().top);
|
|
2161
|
+
}
|
|
2162
|
+
});
|
|
2070
2163
|
this.rect.expandInPlace(this.tempoText.getRect());
|
|
2071
2164
|
}
|
|
2072
2165
|
this.rect.right += paddingX;
|
|
@@ -2177,7 +2270,8 @@ var ObjTabSignature = class extends MusicObject {
|
|
|
2177
2270
|
this.rect = new import_ts_utils_lib9.AnchoredRect();
|
|
2178
2271
|
if (this.measureNumber) {
|
|
2179
2272
|
this.measureNumber.layout(ctx);
|
|
2180
|
-
this.measureNumber.
|
|
2273
|
+
this.measureNumber.setLeft(0);
|
|
2274
|
+
this.measureNumber.setBottom(topLineY);
|
|
2181
2275
|
this.rect.expandInPlace(this.measureNumber.getRect());
|
|
2182
2276
|
x = Math.max(x, this.rect.right);
|
|
2183
2277
|
}
|
|
@@ -2185,16 +2279,23 @@ var ObjTabSignature = class extends MusicObject {
|
|
|
2185
2279
|
(_b = this.beatSizeText) == null ? void 0 : _b.layout(ctx);
|
|
2186
2280
|
let tsWidth = Math.max((_d = (_c = this.beatCountText) == null ? void 0 : _c.getRect().width) != null ? _d : 0, (_f = (_e = this.beatSizeText) == null ? void 0 : _e.getRect().width) != null ? _f : 0);
|
|
2187
2281
|
if (this.beatCountText) {
|
|
2188
|
-
this.beatCountText.
|
|
2282
|
+
this.beatCountText.setCenter(
|
|
2283
|
+
0 + tsWidth / 2 + paddingX,
|
|
2284
|
+
tab.getRect().anchorY - this.beatCountText.getRect().bottomh
|
|
2285
|
+
);
|
|
2189
2286
|
this.rect.expandInPlace(this.beatCountText.getRect());
|
|
2190
2287
|
}
|
|
2191
2288
|
if (this.beatSizeText) {
|
|
2192
|
-
this.beatSizeText.
|
|
2289
|
+
this.beatSizeText.setCenter(
|
|
2290
|
+
0 + tsWidth / 2 + paddingX,
|
|
2291
|
+
tab.getRect().anchorY + this.beatSizeText.getRect().toph
|
|
2292
|
+
);
|
|
2193
2293
|
this.rect.expandInPlace(this.beatSizeText.getRect());
|
|
2194
2294
|
}
|
|
2195
2295
|
if (this.tempoText) {
|
|
2196
2296
|
this.tempoText.layout(ctx);
|
|
2197
|
-
this.tempoText.
|
|
2297
|
+
this.tempoText.setLeft(x + unitSize * 2);
|
|
2298
|
+
this.tempoText.setBottom(topLineY);
|
|
2198
2299
|
this.rect.expandInPlace(this.tempoText.getRect());
|
|
2199
2300
|
}
|
|
2200
2301
|
this.rect.right += paddingX;
|
|
@@ -2493,7 +2594,7 @@ var _ObjRest = class _ObjRest extends MusicObject {
|
|
|
2493
2594
|
let dotY = this.getRestDotVerticalDisplacement(noteSize) * unitSize;
|
|
2494
2595
|
obj.dotRects.push(import_ts_utils_lib11.AnchoredRect.createCentered(dotX, dotY, dotWidth, dotWidth));
|
|
2495
2596
|
}
|
|
2496
|
-
obj.
|
|
2597
|
+
obj.setAnchor(0, staff.getDiatonicIdY(diatonicId));
|
|
2497
2598
|
this.staffObjects.push(obj);
|
|
2498
2599
|
this.measure.addStaticObject(staff, obj);
|
|
2499
2600
|
});
|
|
@@ -3001,7 +3102,10 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
3001
3102
|
let acc = obj.accidentals[noteIndex] = new ObjAccidental(this, note.diatonicId, note.accidental, this.color);
|
|
3002
3103
|
if (acc) {
|
|
3003
3104
|
acc.layout(ctx);
|
|
3004
|
-
acc.
|
|
3105
|
+
acc.setAnchor(
|
|
3106
|
+
-noteHeadRect.leftw - unitSize * DocumentSettings.NoteAccSpace - acc.getRect().rightw,
|
|
3107
|
+
noteY
|
|
3108
|
+
);
|
|
3005
3109
|
}
|
|
3006
3110
|
noteStaff.addObject(acc);
|
|
3007
3111
|
}
|
|
@@ -3065,9 +3169,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
3065
3169
|
let color = fretId < 0 ? "red" : "black";
|
|
3066
3170
|
let fretNumber = new ObjText(this, { text: String(fretId), color, bgcolor: "white" }, 0.5, 0.5);
|
|
3067
3171
|
fretNumber.layout(ctx);
|
|
3068
|
-
|
|
3069
|
-
let y = tab.getStringY(stringNumber - 1);
|
|
3070
|
-
fretNumber.offset(x, y);
|
|
3172
|
+
fretNumber.setAnchor(this.col.getRect().anchorX, tab.getStringY(stringNumber - 1));
|
|
3071
3173
|
obj.fretNumbers.push(fretNumber);
|
|
3072
3174
|
}
|
|
3073
3175
|
});
|
|
@@ -3242,7 +3344,7 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3242
3344
|
return Math.max(0, nextPositionTicks - curPositionTicks);
|
|
3243
3345
|
}
|
|
3244
3346
|
getShapeRects() {
|
|
3245
|
-
this.
|
|
3347
|
+
this.forceRectUpdate();
|
|
3246
3348
|
return this.shapeRects;
|
|
3247
3349
|
}
|
|
3248
3350
|
get doc() {
|
|
@@ -3408,6 +3510,8 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3408
3510
|
return;
|
|
3409
3511
|
}
|
|
3410
3512
|
let { row } = this;
|
|
3513
|
+
this.rect = new import_ts_utils_lib13.AnchoredRect();
|
|
3514
|
+
this.requestRectUpdate();
|
|
3411
3515
|
let leftw = 0;
|
|
3412
3516
|
let rightw = 0;
|
|
3413
3517
|
this.voiceSymbol.forEach((symbol) => {
|
|
@@ -3421,7 +3525,7 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3421
3525
|
this.arpeggios.forEach((a) => a.layout(ctx));
|
|
3422
3526
|
const arpeggioWidth = this.arpeggios.map((a) => a.getRect().width).reduce((accState2, cur) => Math.max(accState2, cur)) + ctx.unitSize;
|
|
3423
3527
|
this.arpeggios.forEach((a) => {
|
|
3424
|
-
a.
|
|
3528
|
+
a.setAnchor(-leftw - arpeggioWidth / 2, a.line.getRect().anchorY);
|
|
3425
3529
|
a.line.addObject(a);
|
|
3426
3530
|
this.measure.addStaticObject(a.line, a);
|
|
3427
3531
|
});
|
|
@@ -3436,7 +3540,9 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3436
3540
|
rightw = Math.max(rightw, MinColumnWidth / 2);
|
|
3437
3541
|
leftw *= DocumentSettings.ColumnWidthScale;
|
|
3438
3542
|
rightw *= DocumentSettings.ColumnWidthScale;
|
|
3439
|
-
this.rect =
|
|
3543
|
+
this.rect.left = -leftw;
|
|
3544
|
+
this.rect.anchorX = 0;
|
|
3545
|
+
this.rect.right = rightw;
|
|
3440
3546
|
this.requestRectUpdate();
|
|
3441
3547
|
this.voiceSymbol.forEach((symbol) => symbol.updateAccidentalState(accState));
|
|
3442
3548
|
this.row.getStaves().forEach((staff) => {
|
|
@@ -3588,8 +3694,8 @@ var _ObjSpecialText = class _ObjSpecialText extends MusicObject {
|
|
|
3588
3694
|
let codaText = this.components[1];
|
|
3589
3695
|
codaSym.layout(ctx);
|
|
3590
3696
|
codaText.layout(ctx);
|
|
3591
|
-
codaSym.
|
|
3592
|
-
codaText.
|
|
3697
|
+
codaSym.setAnchorY(codaText.getRect().centerY);
|
|
3698
|
+
codaText.setLeft(codaSym.getRect().right);
|
|
3593
3699
|
this.rect = new import_ts_utils_lib14.AnchoredRect(
|
|
3594
3700
|
codaSym.getRect().left,
|
|
3595
3701
|
codaSym.getRect().anchorX,
|
|
@@ -3605,8 +3711,8 @@ var _ObjSpecialText = class _ObjSpecialText extends MusicObject {
|
|
|
3605
3711
|
let codaSym = this.components[1];
|
|
3606
3712
|
toCodaText.layout(ctx);
|
|
3607
3713
|
codaSym.layout(ctx);
|
|
3608
|
-
codaSym.
|
|
3609
|
-
toCodaText.
|
|
3714
|
+
codaSym.setAnchorY(toCodaText.getRect().centerY);
|
|
3715
|
+
toCodaText.setRight(codaSym.getRect().left);
|
|
3610
3716
|
this.rect = new import_ts_utils_lib14.AnchoredRect(
|
|
3611
3717
|
toCodaText.getRect().left,
|
|
3612
3718
|
codaSym.getRect().anchorX,
|
|
@@ -4186,16 +4292,16 @@ var Player = class _Player {
|
|
|
4186
4292
|
|
|
4187
4293
|
// src/score/engine/obj-bar-line.ts
|
|
4188
4294
|
var import_ts_utils_lib17 = require("@tspro/ts-utils-lib");
|
|
4189
|
-
var
|
|
4295
|
+
var ObjStaffBarLine = class extends MusicObject {
|
|
4190
4296
|
constructor(barLine, line) {
|
|
4191
4297
|
super(line);
|
|
4192
4298
|
this.barLine = barLine;
|
|
4193
4299
|
this.line = line;
|
|
4194
|
-
__publicField(this, "
|
|
4300
|
+
__publicField(this, "vlines", []);
|
|
4195
4301
|
__publicField(this, "dots", []);
|
|
4196
4302
|
__publicField(this, "mi");
|
|
4197
4303
|
line.addObject(this);
|
|
4198
|
-
this.mi = new
|
|
4304
|
+
this.mi = new MStaffBarLine(this);
|
|
4199
4305
|
}
|
|
4200
4306
|
getMusicInterface() {
|
|
4201
4307
|
return this.mi;
|
|
@@ -4203,11 +4309,17 @@ var ObjStaffTabBarLine = class extends MusicObject {
|
|
|
4203
4309
|
pick(x, y) {
|
|
4204
4310
|
return this.getRect().contains(x, y) ? [this] : [];
|
|
4205
4311
|
}
|
|
4206
|
-
|
|
4207
|
-
this.rect =
|
|
4312
|
+
updateRect() {
|
|
4313
|
+
this.rect = new import_ts_utils_lib17.AnchoredRect(0, 0, this.line.getTopLineY(), this.line.getBottomLineY());
|
|
4314
|
+
this.vlines.forEach(
|
|
4315
|
+
(l) => this.rect.expandInPlace(new import_ts_utils_lib17.AnchoredRect(l.left, l.left + l.width, this.rect.top, this.rect.bottom))
|
|
4316
|
+
);
|
|
4317
|
+
this.dots.forEach(
|
|
4318
|
+
(d) => this.rect.expandInPlace(new import_ts_utils_lib17.AnchoredRect(d.x - d.r, d.x + d.r, d.y - d.r, d.y + d.r))
|
|
4319
|
+
);
|
|
4208
4320
|
}
|
|
4209
4321
|
offset(dx, dy) {
|
|
4210
|
-
this.
|
|
4322
|
+
this.vlines.forEach((l) => l.left += dx);
|
|
4211
4323
|
this.dots.forEach((d) => {
|
|
4212
4324
|
d.x += dx;
|
|
4213
4325
|
d.y += dy;
|
|
@@ -4219,16 +4331,16 @@ var ObjBarLine = class extends MusicObject {
|
|
|
4219
4331
|
constructor(measure) {
|
|
4220
4332
|
super(measure);
|
|
4221
4333
|
this.measure = measure;
|
|
4222
|
-
__publicField(this, "
|
|
4223
|
-
__publicField(this, "
|
|
4334
|
+
__publicField(this, "notationLineObjects", []);
|
|
4335
|
+
__publicField(this, "notationLineObjectsByGrp", new import_ts_utils_lib17.UniMap());
|
|
4224
4336
|
__publicField(this, "barLineType", 0 /* None */);
|
|
4225
4337
|
}
|
|
4226
4338
|
pick(x, y) {
|
|
4227
4339
|
if (!this.getRect().contains(x, y)) {
|
|
4228
4340
|
return [];
|
|
4229
4341
|
}
|
|
4230
|
-
for (let i = 0; i < this.
|
|
4231
|
-
let arr = this.
|
|
4342
|
+
for (let i = 0; i < this.notationLineObjects.length; i++) {
|
|
4343
|
+
let arr = this.notationLineObjects[i].pick(x, y);
|
|
4232
4344
|
if (arr.length > 0) {
|
|
4233
4345
|
return [this, ...arr];
|
|
4234
4346
|
}
|
|
@@ -4237,7 +4349,6 @@ var ObjBarLine = class extends MusicObject {
|
|
|
4237
4349
|
}
|
|
4238
4350
|
layout(ctx) {
|
|
4239
4351
|
this.requestRectUpdate();
|
|
4240
|
-
this.staffTabObjects.length = 0;
|
|
4241
4352
|
this.barLineType = this.solveBarLineType();
|
|
4242
4353
|
let { unitSize, _lineWidth } = ctx;
|
|
4243
4354
|
let { measure, barLineType } = this;
|
|
@@ -4247,102 +4358,95 @@ var ObjBarLine = class extends MusicObject {
|
|
|
4247
4358
|
let spaceW = 0.7 * unitSize;
|
|
4248
4359
|
let dotW = DocumentSettings.DotSize * unitSize;
|
|
4249
4360
|
let dotRadius = dotW / 2;
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4361
|
+
this.notationLineObjects = [];
|
|
4362
|
+
this.notationLineObjectsByGrp.clear();
|
|
4363
|
+
row.getRowGroups().forEach((grp) => {
|
|
4364
|
+
grp.lines.forEach((line) => {
|
|
4365
|
+
let obj = new ObjStaffBarLine(this, line);
|
|
4366
|
+
this.notationLineObjects.push(obj);
|
|
4367
|
+
this.notationLineObjectsByGrp.getOrCreate(grp, []).push(obj);
|
|
4368
|
+
let lineCenterY;
|
|
4369
|
+
let lineDotOff;
|
|
4370
|
+
const addVerticalLine = (left, width) => {
|
|
4371
|
+
obj.vlines.push({ left, width });
|
|
4372
|
+
};
|
|
4373
|
+
const addDotPair = (cx) => {
|
|
4374
|
+
for (let i = -1; i <= 1; i += 2) {
|
|
4375
|
+
let y = lineCenterY + i * lineDotOff;
|
|
4376
|
+
obj.dots.push({ x: cx, y, r: dotRadius });
|
|
4377
|
+
}
|
|
4378
|
+
};
|
|
4379
|
+
if (line instanceof ObjStaff) {
|
|
4380
|
+
lineCenterY = line.getMiddleLineY();
|
|
4381
|
+
lineDotOff = line.getDiatonicSpacing();
|
|
4382
|
+
} else {
|
|
4383
|
+
lineCenterY = (line.getBottomLineY() + line.getTopLineY()) / 2;
|
|
4384
|
+
lineDotOff = (line.getBottomLineY() - line.getTopLineY()) / 6;
|
|
4262
4385
|
}
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
case 5 /* EndRepeat */:
|
|
4298
|
-
obj.setRect(new import_ts_utils_lib17.AnchoredRect(-thicW - spaceW - thinW - spaceW - dotW, 0, 0, top, 0, bottom));
|
|
4299
|
-
addVerticalLine(-thinW - spaceW - thicW, thinW);
|
|
4300
|
-
addVerticalLine(-thicW, thicW);
|
|
4301
|
-
addDotPair(-thinW - spaceW - thicW - spaceW - dotRadius);
|
|
4302
|
-
break;
|
|
4303
|
-
case 6 /* EndStartRepeat */:
|
|
4304
|
-
obj.setRect(new import_ts_utils_lib17.AnchoredRect(-dotW - spaceW - thinW - spaceW - thicW / 2, 0, thicW / 2 + spaceW + thinW + spaceW + dotW, top, 0, bottom));
|
|
4305
|
-
addVerticalLine(-thicW / 2, thicW);
|
|
4306
|
-
addVerticalLine(-thicW / 2 - spaceW - thinW, thinW);
|
|
4307
|
-
addVerticalLine(thicW / 2 + spaceW, thinW);
|
|
4308
|
-
addDotPair(-thicW / 2 - spaceW - thinW - spaceW - dotRadius);
|
|
4309
|
-
addDotPair(thicW / 2 + spaceW + thinW + spaceW + dotRadius);
|
|
4310
|
-
break;
|
|
4311
|
-
}
|
|
4312
|
-
this.staffTabObjects.push(obj);
|
|
4386
|
+
switch (barLineType) {
|
|
4387
|
+
case 0 /* None */:
|
|
4388
|
+
break;
|
|
4389
|
+
case 1 /* Single */:
|
|
4390
|
+
addVerticalLine(-thinW, thinW);
|
|
4391
|
+
break;
|
|
4392
|
+
case 2 /* Double */:
|
|
4393
|
+
addVerticalLine(-thinW - spaceW - thinW, thinW);
|
|
4394
|
+
addVerticalLine(-thinW, thinW);
|
|
4395
|
+
break;
|
|
4396
|
+
case 3 /* EndSong */:
|
|
4397
|
+
addVerticalLine(-thinW - spaceW - thicW, thinW);
|
|
4398
|
+
addVerticalLine(-thicW, thicW);
|
|
4399
|
+
break;
|
|
4400
|
+
case 4 /* StartRepeat */:
|
|
4401
|
+
addVerticalLine(0, thicW);
|
|
4402
|
+
addVerticalLine(thicW + spaceW, thinW);
|
|
4403
|
+
addDotPair(thicW + spaceW + thinW + spaceW + dotRadius);
|
|
4404
|
+
break;
|
|
4405
|
+
case 5 /* EndRepeat */:
|
|
4406
|
+
addVerticalLine(-thinW - spaceW - thicW, thinW);
|
|
4407
|
+
addVerticalLine(-thicW, thicW);
|
|
4408
|
+
addDotPair(-thinW - spaceW - thicW - spaceW - dotRadius);
|
|
4409
|
+
break;
|
|
4410
|
+
case 6 /* EndStartRepeat */:
|
|
4411
|
+
addVerticalLine(-thicW / 2, thicW);
|
|
4412
|
+
addVerticalLine(-thicW / 2 - spaceW - thinW, thinW);
|
|
4413
|
+
addVerticalLine(thicW / 2 + spaceW, thinW);
|
|
4414
|
+
addDotPair(-thicW / 2 - spaceW - thinW - spaceW - dotRadius);
|
|
4415
|
+
addDotPair(thicW / 2 + spaceW + thinW + spaceW + dotRadius);
|
|
4416
|
+
break;
|
|
4417
|
+
}
|
|
4418
|
+
obj.forceRectUpdate();
|
|
4419
|
+
});
|
|
4313
4420
|
});
|
|
4314
|
-
this.staffTabObjectGroups = row.getInstrumentLineGroups().map(
|
|
4315
|
-
(lines) => lines.map((line) => this.staffTabObjects.find((obj) => obj.line === line)).filter((obj) => obj !== void 0)
|
|
4316
|
-
);
|
|
4317
4421
|
}
|
|
4318
4422
|
updateRect() {
|
|
4319
|
-
if (this.
|
|
4320
|
-
this.rect = this.
|
|
4321
|
-
for (let i = 1; i < this.
|
|
4322
|
-
this.rect.expandInPlace(this.
|
|
4423
|
+
if (this.notationLineObjects.length > 0) {
|
|
4424
|
+
this.rect = this.notationLineObjects[0].getRect().clone();
|
|
4425
|
+
for (let i = 1; i < this.notationLineObjects.length; i++) {
|
|
4426
|
+
this.rect.expandInPlace(this.notationLineObjects[i].getRect());
|
|
4323
4427
|
}
|
|
4324
4428
|
} else {
|
|
4325
4429
|
this.rect = new import_ts_utils_lib17.AnchoredRect();
|
|
4326
4430
|
}
|
|
4327
4431
|
}
|
|
4328
4432
|
offset(dx, dy) {
|
|
4329
|
-
this.
|
|
4433
|
+
this.notationLineObjects.forEach((obj) => obj.offset(dx, 0));
|
|
4330
4434
|
this.requestRectUpdate();
|
|
4331
4435
|
}
|
|
4332
4436
|
draw(ctx) {
|
|
4333
|
-
if (this.barLineType === 0 /* None */)
|
|
4437
|
+
if (this.barLineType === 0 /* None */)
|
|
4334
4438
|
return;
|
|
4335
|
-
}
|
|
4336
4439
|
ctx.drawDebugRect(this.getRect());
|
|
4337
4440
|
ctx.color("black");
|
|
4338
|
-
this.
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4441
|
+
for (const [grp, objects] of this.notationLineObjectsByGrp) {
|
|
4442
|
+
objects.forEach((obj, i) => {
|
|
4443
|
+
obj.dots.forEach((d) => ctx.fillCircle(d.x, d.y, d.r));
|
|
4444
|
+
if (i === 0) {
|
|
4445
|
+
let { top, height } = obj.barLine.getRect();
|
|
4446
|
+
obj.vlines.forEach((l) => ctx.fillRect(l.left, top, l.width, height));
|
|
4447
|
+
}
|
|
4448
|
+
});
|
|
4449
|
+
}
|
|
4346
4450
|
}
|
|
4347
4451
|
};
|
|
4348
4452
|
var ObjBarLineLeft = class extends ObjBarLine {
|
|
@@ -4459,7 +4563,8 @@ var ObjEnding = class extends MusicObject {
|
|
|
4459
4563
|
let measureContent = measure.getColumnsContentRect();
|
|
4460
4564
|
let endingHeight = textRect.height;
|
|
4461
4565
|
this.rect = new import_ts_utils_lib18.AnchoredRect(measureContent.left + unitSize, measureContent.right - unitSize, -endingHeight, 0);
|
|
4462
|
-
this.endingText.
|
|
4566
|
+
this.endingText.setLeft(this.rect.left + unitSize / 2);
|
|
4567
|
+
this.endingText.setBottom(this.rect.bottom);
|
|
4463
4568
|
this.shapeRects = [
|
|
4464
4569
|
new import_ts_utils_lib18.AnchoredRect(this.rect.left, this.rect.left + 1, this.rect.top, this.rect.bottom),
|
|
4465
4570
|
new import_ts_utils_lib18.AnchoredRect(this.rect.left, this.rect.right, this.rect.top, this.rect.top + 1),
|
|
@@ -4886,8 +4991,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
|
|
|
4886
4991
|
});
|
|
4887
4992
|
}
|
|
4888
4993
|
if (obj.tupletNumber) {
|
|
4889
|
-
|
|
4890
|
-
obj.tupletNumber.offset(0, -obj.tupletNumber.getRect().anchorY + y);
|
|
4994
|
+
obj.tupletNumber.setAnchorY((left.y + right.y) / 2 + obj.tupletNumberOffsetY);
|
|
4891
4995
|
}
|
|
4892
4996
|
});
|
|
4893
4997
|
}
|
|
@@ -5647,8 +5751,7 @@ var ObjTabRhythm = class extends MusicObject {
|
|
|
5647
5751
|
this.tupletPartsTextObjMap.set(text, textObj = new ObjText(this, { text, scale: 0.75 }, 0.5, 0.5));
|
|
5648
5752
|
textObj.layout(ctx);
|
|
5649
5753
|
}
|
|
5650
|
-
textObj.
|
|
5651
|
-
textObj.offset(cx, stemTop - fontSize / 2);
|
|
5754
|
+
textObj.setCenter(cx, stemTop - fontSize / 2);
|
|
5652
5755
|
textObj.draw(ctx);
|
|
5653
5756
|
}
|
|
5654
5757
|
if (symbols.length > 1) {
|
|
@@ -6690,7 +6793,8 @@ var ObjMeasure = class extends MusicObject {
|
|
|
6690
6793
|
let note = tab.getTuningStrings()[stringId].format(import_theory9.PitchNotation.Helmholtz, import_theory9.SymbolSet.Unicode);
|
|
6691
6794
|
let obj = new ObjText(this, { text: note, scale: 0.8 }, 1, 0.5);
|
|
6692
6795
|
obj.layout(ctx);
|
|
6693
|
-
obj.
|
|
6796
|
+
obj.setRight(this.regions.tabTuning_0 * 0.8);
|
|
6797
|
+
obj.setCenterY(tab.getStringY(stringId));
|
|
6694
6798
|
this.tabStringNotes.push(obj);
|
|
6695
6799
|
tab.addObject(obj);
|
|
6696
6800
|
}
|
|
@@ -6716,7 +6820,6 @@ var ObjMeasure = class extends MusicObject {
|
|
|
6716
6820
|
this.regions.rightBarLine_6 = this.barLineRight.getRect().width;
|
|
6717
6821
|
}
|
|
6718
6822
|
layoutWidth(ctx, width) {
|
|
6719
|
-
var _a;
|
|
6720
6823
|
if (!this.needLayout) {
|
|
6721
6824
|
return;
|
|
6722
6825
|
}
|
|
@@ -6724,17 +6827,19 @@ var ObjMeasure = class extends MusicObject {
|
|
|
6724
6827
|
this.rect = new import_ts_utils_lib26.AnchoredRect();
|
|
6725
6828
|
this.rect.anchorX = this.rect.left + width / 2;
|
|
6726
6829
|
this.rect.right = this.rect.left + width;
|
|
6727
|
-
let rect;
|
|
6728
6830
|
this.signatures.forEach((signature) => {
|
|
6729
|
-
rect
|
|
6730
|
-
signature.
|
|
6831
|
+
signature.setLeft(this.rect.left + this.regions.tabTuning_0);
|
|
6832
|
+
signature.setAnchorY(this.rect.anchorY);
|
|
6731
6833
|
});
|
|
6732
6834
|
let signaturesWidth = Math.max(0, ...this.signatures.map((signature) => signature.getRect().width));
|
|
6733
|
-
rect
|
|
6734
|
-
this.barLineLeft.
|
|
6735
|
-
|
|
6736
|
-
this.barLineRight.
|
|
6737
|
-
(
|
|
6835
|
+
this.barLineLeft.setLeft(this.rect.left + this.regions.tabTuning_0 + signaturesWidth);
|
|
6836
|
+
this.barLineLeft.setAnchorY(this.rect.anchorY);
|
|
6837
|
+
this.barLineRight.setRight(this.rect.right);
|
|
6838
|
+
this.barLineRight.setAnchorY(this.rect.anchorY);
|
|
6839
|
+
if (this.endRepeatPlayCountText) {
|
|
6840
|
+
this.endRepeatPlayCountText.setCenterX(this.barLineRight.getRect().left);
|
|
6841
|
+
this.endRepeatPlayCountText.setBottom(this.barLineRight.getRect().top);
|
|
6842
|
+
}
|
|
6738
6843
|
let columnsLeft = this.rect.left + this.regions.leftSolid;
|
|
6739
6844
|
let columnsRight = this.rect.right - this.regions.rightSolid;
|
|
6740
6845
|
let columnsWidth = columnsRight - columnsLeft;
|
|
@@ -6742,9 +6847,9 @@ var ObjMeasure = class extends MusicObject {
|
|
|
6742
6847
|
let columnScale = columnsWidth / columnsMinWidth;
|
|
6743
6848
|
let curColumnLeft = columnsLeft;
|
|
6744
6849
|
this.columns.forEach((col) => {
|
|
6745
|
-
rect = col.getRect();
|
|
6850
|
+
let rect = col.getRect();
|
|
6746
6851
|
let columnAnchorX = curColumnLeft + rect.leftw * columnScale;
|
|
6747
|
-
col.
|
|
6852
|
+
col.setAnchor(columnAnchorX, this.rect.anchorY);
|
|
6748
6853
|
curColumnLeft += rect.width * columnScale;
|
|
6749
6854
|
});
|
|
6750
6855
|
getVoiceIds().forEach((voiceId) => {
|
|
@@ -6753,8 +6858,7 @@ var ObjMeasure = class extends MusicObject {
|
|
|
6753
6858
|
if (!onlyRest) return;
|
|
6754
6859
|
const isOnlySymbolInCol = getVoiceIds().map((voiceId2) => onlyRest.col.getVoiceSymbol(voiceId2)).filter((sym) => sym !== void 0 && sym !== onlyRest).length === 0;
|
|
6755
6860
|
if (isOnlySymbolInCol) return;
|
|
6756
|
-
|
|
6757
|
-
onlyRest.offset(r.centerX - onlyRest.getRect().anchorX, 0);
|
|
6861
|
+
onlyRest.setAnchorX(this.getColumnsContentRect().centerX);
|
|
6758
6862
|
});
|
|
6759
6863
|
}
|
|
6760
6864
|
layoutConnectives(ctx) {
|
|
@@ -6823,9 +6927,8 @@ var ObjMeasure = class extends MusicObject {
|
|
|
6823
6927
|
this.barLineLeft.offset(dx, dy);
|
|
6824
6928
|
this.columns.forEach((col) => col.offset(dx, dy));
|
|
6825
6929
|
this.barLineRight.offset(dx, dy);
|
|
6826
|
-
if (this.endRepeatPlayCountText)
|
|
6930
|
+
if (this.endRepeatPlayCountText)
|
|
6827
6931
|
this.endRepeatPlayCountText.offset(dx, dy);
|
|
6828
|
-
}
|
|
6829
6932
|
this.connectives.forEach((connective) => connective.offset(dx, 0));
|
|
6830
6933
|
this.beamGroups.forEach((beam) => beam.offset(dx, dy));
|
|
6831
6934
|
this.layoutObjects.forEach((layoutObj) => layoutObj.offset(dx, 0));
|
|
@@ -6973,6 +7076,9 @@ var LayoutObjectWrapper = class {
|
|
|
6973
7076
|
offset(dx, dy) {
|
|
6974
7077
|
this.musicObj.offset(dx, dy);
|
|
6975
7078
|
}
|
|
7079
|
+
setAnchorY(y) {
|
|
7080
|
+
this.musicObj.setAnchorY(y);
|
|
7081
|
+
}
|
|
6976
7082
|
getRect() {
|
|
6977
7083
|
return this.musicObj.getRect();
|
|
6978
7084
|
}
|
|
@@ -7043,7 +7149,7 @@ var ObjNotationLine5 = class extends MusicObject {
|
|
|
7043
7149
|
if (y === void 0) {
|
|
7044
7150
|
return;
|
|
7045
7151
|
}
|
|
7046
|
-
layoutObj.
|
|
7152
|
+
layoutObj.setAnchorY(y - layoutObj.getRect().anchorY);
|
|
7047
7153
|
layoutObj.setPositionResolved();
|
|
7048
7154
|
}
|
|
7049
7155
|
alignObjectsY(ctx, layoutObjects, verticalPos) {
|
|
@@ -7064,7 +7170,7 @@ var ObjNotationLine5 = class extends MusicObject {
|
|
|
7064
7170
|
if (musicObj instanceof ObjEnding || musicObj instanceof ObjExtensionLine || musicObj instanceof ObjTabRhythm) {
|
|
7065
7171
|
musicObj.layoutFitToMeasure(ctx);
|
|
7066
7172
|
} else {
|
|
7067
|
-
musicObj.
|
|
7173
|
+
musicObj.setAnchorX(anchor.getRect().anchorX);
|
|
7068
7174
|
}
|
|
7069
7175
|
});
|
|
7070
7176
|
if (layoutGroup.rowAlign) {
|
|
@@ -7344,7 +7450,112 @@ var ObjTab = class extends ObjNotationLine5 {
|
|
|
7344
7450
|
|
|
7345
7451
|
// src/score/engine/obj-score-row.ts
|
|
7346
7452
|
var import_core16 = require("@tspro/web-music-score/core");
|
|
7453
|
+
var import_ts_utils_lib30 = require("@tspro/ts-utils-lib");
|
|
7454
|
+
|
|
7455
|
+
// src/score/engine/obj-score-row-group.ts
|
|
7347
7456
|
var import_ts_utils_lib29 = require("@tspro/ts-utils-lib");
|
|
7457
|
+
var ObjScoreRowGroup = class extends MusicObject {
|
|
7458
|
+
constructor(lines) {
|
|
7459
|
+
var _a;
|
|
7460
|
+
super(lines[0].row);
|
|
7461
|
+
this.lines = lines;
|
|
7462
|
+
__publicField(this, "space", 0);
|
|
7463
|
+
__publicField(this, "instrument");
|
|
7464
|
+
__publicField(this, "instrText");
|
|
7465
|
+
__publicField(this, "braceRect", new import_ts_utils_lib29.AnchoredRect());
|
|
7466
|
+
__publicField(this, "mi");
|
|
7467
|
+
this.instrument = (_a = lines[0].getConfig().instrument) != null ? _a : "";
|
|
7468
|
+
this.instrText = new ObjText(this, { text: this.instrument, color: "black", scale: 1 }, 1, 0.5);
|
|
7469
|
+
this.mi = new MScoreRowGroup(this);
|
|
7470
|
+
}
|
|
7471
|
+
getMusicInterface() {
|
|
7472
|
+
return this.mi;
|
|
7473
|
+
}
|
|
7474
|
+
get row() {
|
|
7475
|
+
return this.lines[0].row;
|
|
7476
|
+
}
|
|
7477
|
+
get hasBrace() {
|
|
7478
|
+
return this.hasInstrument && this.lines.length > 1;
|
|
7479
|
+
}
|
|
7480
|
+
get hasInstrument() {
|
|
7481
|
+
return this.instrument.length > 0;
|
|
7482
|
+
}
|
|
7483
|
+
pick(x, y) {
|
|
7484
|
+
if (!this.getRect().contains(x, y))
|
|
7485
|
+
return [];
|
|
7486
|
+
let arr = this.instrText.pick(x, y);
|
|
7487
|
+
if (arr.length > 0) {
|
|
7488
|
+
return [this, ...arr];
|
|
7489
|
+
}
|
|
7490
|
+
return [this];
|
|
7491
|
+
}
|
|
7492
|
+
updateRect() {
|
|
7493
|
+
this.instrText.setRight(this.braceRect.left - this.space);
|
|
7494
|
+
this.instrText.setCenterY(this.braceRect.anchorY);
|
|
7495
|
+
this.rect = this.instrText.getRect().clone().expandInPlace(this.braceRect);
|
|
7496
|
+
}
|
|
7497
|
+
layout(ctx) {
|
|
7498
|
+
this.space = ctx.unitSize;
|
|
7499
|
+
this.instrText.layout(ctx);
|
|
7500
|
+
this.braceRect = new import_ts_utils_lib29.AnchoredRect(-(this.hasBrace ? ctx.unitSize * 5 : 0), 0, 0, 0);
|
|
7501
|
+
this.forceRectUpdate();
|
|
7502
|
+
}
|
|
7503
|
+
layoutToNotationLines() {
|
|
7504
|
+
this.braceRect.top = this.lines[0].getTopLineY();
|
|
7505
|
+
this.braceRect.bottom = this.lines[this.lines.length - 1].getBottomLineY();
|
|
7506
|
+
this.braceRect.anchorY = this.braceRect.centerY;
|
|
7507
|
+
this.forceRectUpdate();
|
|
7508
|
+
}
|
|
7509
|
+
offset(dx, dy) {
|
|
7510
|
+
this.instrText.offset(dx, dy);
|
|
7511
|
+
this.braceRect.offsetInPlace(dx, dy);
|
|
7512
|
+
this.rect.offsetInPlace(dx, dy);
|
|
7513
|
+
}
|
|
7514
|
+
draw(ctx) {
|
|
7515
|
+
this.instrText.draw(ctx);
|
|
7516
|
+
if (this.hasBrace) {
|
|
7517
|
+
ctx.color("brack").lineWidth(1).drawBracket(this.braceRect, "{");
|
|
7518
|
+
}
|
|
7519
|
+
}
|
|
7520
|
+
};
|
|
7521
|
+
|
|
7522
|
+
// src/score/engine/obj-score-row.ts
|
|
7523
|
+
var ScoreRowRegions = class {
|
|
7524
|
+
constructor() {
|
|
7525
|
+
__publicField(this, "instrWidth", 0);
|
|
7526
|
+
__publicField(this, "staffWidth", 0);
|
|
7527
|
+
}
|
|
7528
|
+
resetWidths() {
|
|
7529
|
+
this.instrWidth = this.staffWidth = 0;
|
|
7530
|
+
}
|
|
7531
|
+
addRowInstrWidth(w) {
|
|
7532
|
+
this.instrWidth = Math.max(this.instrWidth, w);
|
|
7533
|
+
}
|
|
7534
|
+
addRowstaffWidth(w) {
|
|
7535
|
+
this.staffWidth = Math.max(this.staffWidth, w);
|
|
7536
|
+
}
|
|
7537
|
+
get instrLeft() {
|
|
7538
|
+
return 0;
|
|
7539
|
+
}
|
|
7540
|
+
get instrRight() {
|
|
7541
|
+
return this.instrWidth;
|
|
7542
|
+
}
|
|
7543
|
+
get staffLeft() {
|
|
7544
|
+
return this.instrRight;
|
|
7545
|
+
}
|
|
7546
|
+
get staffRight() {
|
|
7547
|
+
return this.staffLeft + this.staffWidth;
|
|
7548
|
+
}
|
|
7549
|
+
get left() {
|
|
7550
|
+
return this.instrLeft;
|
|
7551
|
+
}
|
|
7552
|
+
get right() {
|
|
7553
|
+
return this.staffRight;
|
|
7554
|
+
}
|
|
7555
|
+
get width() {
|
|
7556
|
+
return this.instrWidth + this.staffWidth;
|
|
7557
|
+
}
|
|
7558
|
+
};
|
|
7348
7559
|
var ObjScoreRow = class extends MusicObject {
|
|
7349
7560
|
constructor(doc, prevRow, scoreConfig) {
|
|
7350
7561
|
super(doc);
|
|
@@ -7352,12 +7563,10 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7352
7563
|
this.prevRow = prevRow;
|
|
7353
7564
|
this.scoreConfig = scoreConfig;
|
|
7354
7565
|
__publicField(this, "nextRow");
|
|
7355
|
-
__publicField(this, "minWidth", 0);
|
|
7356
7566
|
__publicField(this, "notationLines");
|
|
7357
|
-
__publicField(this, "
|
|
7567
|
+
__publicField(this, "rowGroups");
|
|
7358
7568
|
__publicField(this, "staves");
|
|
7359
7569
|
__publicField(this, "tabs");
|
|
7360
|
-
__publicField(this, "instrumentNames");
|
|
7361
7570
|
__publicField(this, "measures", []);
|
|
7362
7571
|
__publicField(this, "needLayout", true);
|
|
7363
7572
|
__publicField(this, "mi");
|
|
@@ -7374,10 +7583,7 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7374
7583
|
prevGroup.push(line);
|
|
7375
7584
|
}
|
|
7376
7585
|
}
|
|
7377
|
-
this.
|
|
7378
|
-
this.instrumentNames = this.instrumentLineGroups.map((lines) => {
|
|
7379
|
-
return lines.length > 0 && import_ts_utils_lib29.Guard.isNonEmptyString(lines[0].getConfig().instrument) ? new ObjText(this, String(lines[0].getConfig().instrument), 0, 0.5) : void 0;
|
|
7380
|
-
});
|
|
7586
|
+
this.rowGroups = lineGroups.filter((lines) => lines.length > 0).map((lines) => new ObjScoreRowGroup(lines));
|
|
7381
7587
|
if (this.prevRow) {
|
|
7382
7588
|
this.prevRow.nextRow = this;
|
|
7383
7589
|
}
|
|
@@ -7401,14 +7607,17 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7401
7607
|
getNotationLines() {
|
|
7402
7608
|
return this.notationLines;
|
|
7403
7609
|
}
|
|
7404
|
-
|
|
7405
|
-
return this.
|
|
7610
|
+
getRowGroups() {
|
|
7611
|
+
return this.rowGroups;
|
|
7406
7612
|
}
|
|
7407
7613
|
findMatchingLine(line) {
|
|
7408
7614
|
return line.row === this ? line : this.notationLines.find(
|
|
7409
|
-
(curLine) =>
|
|
7615
|
+
(curLine) => import_ts_utils_lib30.Utils.Obj.deepEqual(line.row.scoreConfig, curLine.row.scoreConfig) && line.id === curLine.id || import_ts_utils_lib30.Guard.isNonEmptyString(line.getConfig().name) && line.getConfig().name === curLine.getConfig().name && line.getConfig().type === curLine.getConfig().type
|
|
7410
7616
|
);
|
|
7411
7617
|
}
|
|
7618
|
+
get regions() {
|
|
7619
|
+
return this.doc.regions;
|
|
7620
|
+
}
|
|
7412
7621
|
getStaves() {
|
|
7413
7622
|
return this.staves;
|
|
7414
7623
|
}
|
|
@@ -7454,7 +7663,6 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7454
7663
|
this.notationLines.forEach((line) => line.layoutLayoutGroups(ctx));
|
|
7455
7664
|
}
|
|
7456
7665
|
pick(x, y) {
|
|
7457
|
-
var _a, _b;
|
|
7458
7666
|
if (!this.getRect().contains(x, y)) {
|
|
7459
7667
|
return [];
|
|
7460
7668
|
}
|
|
@@ -7464,8 +7672,8 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7464
7672
|
return [this, ...arr];
|
|
7465
7673
|
}
|
|
7466
7674
|
}
|
|
7467
|
-
for (let i = 0; i < this.
|
|
7468
|
-
let arr =
|
|
7675
|
+
for (let i = 0; i < this.rowGroups.length; i++) {
|
|
7676
|
+
let arr = this.rowGroups[i].pick(x, y);
|
|
7469
7677
|
if (arr.length > 0) {
|
|
7470
7678
|
return [this, ...arr];
|
|
7471
7679
|
}
|
|
@@ -7482,7 +7690,7 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7482
7690
|
let r = this.getRect();
|
|
7483
7691
|
let firstMeasure = this.getFirstMeasure();
|
|
7484
7692
|
let left = firstMeasure ? firstMeasure.getColumnsContentRect().left : r.left;
|
|
7485
|
-
return new
|
|
7693
|
+
return new import_ts_utils_lib30.AnchoredRect(left, (left + r.right) / 2, r.right, r.top, r.anchorY, r.bottom);
|
|
7486
7694
|
}
|
|
7487
7695
|
getDiatonicIdAt(y) {
|
|
7488
7696
|
for (let i = 0; i < this.notationLines.length; i++) {
|
|
@@ -7518,9 +7726,6 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7518
7726
|
getLastMeasure() {
|
|
7519
7727
|
return this.measures.length > 0 ? this.measures[this.measures.length - 1] : void 0;
|
|
7520
7728
|
}
|
|
7521
|
-
getMinWidth() {
|
|
7522
|
-
return this.minWidth;
|
|
7523
|
-
}
|
|
7524
7729
|
solveAutoStemDir(symbols) {
|
|
7525
7730
|
if (symbols.length === 0) {
|
|
7526
7731
|
return "up" /* Up */;
|
|
@@ -7532,14 +7737,11 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7532
7737
|
return "up" /* Up */;
|
|
7533
7738
|
}
|
|
7534
7739
|
let diatonicIds = noteGroupDiatonicIds.length > 0 ? noteGroupDiatonicIds : restDiatonicIds;
|
|
7535
|
-
let avgDiatonicId = Math.floor(
|
|
7740
|
+
let avgDiatonicId = Math.floor(import_ts_utils_lib30.Utils.Math.avg(...diatonicIds));
|
|
7536
7741
|
let staves = this.getStaves().filter((staff) => staff.containsVoiceId(voiceId) && staff.containsDiatonicId(avgDiatonicId));
|
|
7537
7742
|
return staves.length > 0 ? avgDiatonicId >= staves[0].middleLineDiatonicId ? "down" /* Down */ : "up" /* Up */ : "up" /* Up */;
|
|
7538
7743
|
}
|
|
7539
7744
|
}
|
|
7540
|
-
getInstrumentNameWidth(ctx) {
|
|
7541
|
-
return Math.max(0, ...this.instrumentNames.map((obj) => obj ? obj.getRect().width : 0));
|
|
7542
|
-
}
|
|
7543
7745
|
requestLayout() {
|
|
7544
7746
|
if (!this.needLayout) {
|
|
7545
7747
|
this.needLayout = true;
|
|
@@ -7551,37 +7753,39 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7551
7753
|
return;
|
|
7552
7754
|
}
|
|
7553
7755
|
this.requestRectUpdate();
|
|
7554
|
-
this.instrumentNames.forEach((obj) => obj == null ? void 0 : obj.layout(ctx));
|
|
7555
7756
|
this.notationLines.forEach((line) => {
|
|
7556
7757
|
line.removeObjects();
|
|
7557
7758
|
line.layoutHeight(ctx);
|
|
7558
7759
|
});
|
|
7559
|
-
this.
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
this.minWidth += m.getMinWidth();
|
|
7563
|
-
this.minWidth += m.getPostMeasureBreakWidth();
|
|
7760
|
+
this.rowGroups.forEach((grp) => {
|
|
7761
|
+
grp.layout(ctx);
|
|
7762
|
+
this.regions.addRowInstrWidth(grp.getRect().width);
|
|
7564
7763
|
});
|
|
7764
|
+
this.measures.forEach((m) => m.layout(ctx));
|
|
7765
|
+
let packedWidth = this.measures.map((m) => m.getMinWidth() + m.getPostMeasureBreakWidth()).reduce((acc, cur) => acc + cur);
|
|
7766
|
+
this.regions.addRowstaffWidth(packedWidth);
|
|
7565
7767
|
}
|
|
7566
|
-
|
|
7768
|
+
layoutStretch(ctx) {
|
|
7567
7769
|
if (!this.needLayout) {
|
|
7568
7770
|
return;
|
|
7569
7771
|
}
|
|
7570
|
-
this.rect = new
|
|
7772
|
+
this.rect = new import_ts_utils_lib30.AnchoredRect(this.regions.left, this.regions.right, 0, 0);
|
|
7571
7773
|
this.notationLines.forEach((line) => line.layoutWidth(ctx));
|
|
7572
|
-
|
|
7774
|
+
this.rowGroups.forEach((grp) => grp.setRight(this.regions.instrRight));
|
|
7775
|
+
let targetColumnsAreaWidth = this.regions.staffWidth;
|
|
7573
7776
|
let minColumnsAreaWidth = 0;
|
|
7574
7777
|
this.measures.forEach((m) => {
|
|
7575
7778
|
targetColumnsAreaWidth -= m.getTotalSolidWidth() + m.getPostMeasureBreakWidth();
|
|
7576
7779
|
minColumnsAreaWidth += m.getMinColumnsWidth();
|
|
7577
7780
|
});
|
|
7578
7781
|
let columnsAreaScale = targetColumnsAreaWidth / minColumnsAreaWidth;
|
|
7579
|
-
let x = this.
|
|
7782
|
+
let x = this.regions.staffLeft;
|
|
7580
7783
|
this.measures.forEach((m) => {
|
|
7581
7784
|
let newMeasureWidth = m.getTotalSolidWidth() + m.getMinColumnsWidth() * columnsAreaScale;
|
|
7582
7785
|
m.layoutWidth(ctx, newMeasureWidth);
|
|
7583
7786
|
let r = m.getRect();
|
|
7584
|
-
m.
|
|
7787
|
+
m.setLeft(x);
|
|
7788
|
+
m.setAnchorY(0);
|
|
7585
7789
|
x += r.width;
|
|
7586
7790
|
x += m.getPostMeasureBreakWidth();
|
|
7587
7791
|
});
|
|
@@ -7591,11 +7795,20 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7591
7795
|
});
|
|
7592
7796
|
}
|
|
7593
7797
|
updateRect() {
|
|
7594
|
-
|
|
7595
|
-
let
|
|
7596
|
-
let
|
|
7597
|
-
let
|
|
7598
|
-
|
|
7798
|
+
var _a;
|
|
7799
|
+
let left = this.regions.left;
|
|
7800
|
+
let right = this.regions.right;
|
|
7801
|
+
let top = 0;
|
|
7802
|
+
let bottom = 0;
|
|
7803
|
+
const fermata = (_a = this.getLastMeasure()) == null ? void 0 : _a.getBarLineRight().getAnchoredLayoutObjects().map((o) => o.musicObj).find((o) => o instanceof ObjFermata);
|
|
7804
|
+
if (fermata) {
|
|
7805
|
+
right = Math.max(right, fermata.getRect().right);
|
|
7806
|
+
}
|
|
7807
|
+
if (this.measures.length > 0) {
|
|
7808
|
+
top = Math.min(...this.measures.map((m) => m.getRect().top));
|
|
7809
|
+
bottom = Math.max(...this.measures.map((m) => m.getRect().bottom));
|
|
7810
|
+
}
|
|
7811
|
+
this.rect = new import_ts_utils_lib30.AnchoredRect(left, right, top, bottom);
|
|
7599
7812
|
}
|
|
7600
7813
|
alignStemsToBeams() {
|
|
7601
7814
|
this.measures.forEach((m) => m.alignStemsToBeams());
|
|
@@ -7607,10 +7820,10 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7607
7820
|
let cur = this.notationLines[i];
|
|
7608
7821
|
if (prev instanceof ObjStaff && cur instanceof ObjStaff && prev.staffConfig.grandId !== void 0 && prev.staffConfig.grandId === cur.staffConfig.grandId) {
|
|
7609
7822
|
let dy = prev.getBottomLineY() - cur.getTopLineY() + unitSize * 6;
|
|
7610
|
-
cur.
|
|
7823
|
+
cur.offsetY(dy);
|
|
7611
7824
|
} else {
|
|
7612
7825
|
let dy = prev.calcBottom() - cur.calcTop() + unitSize * 3;
|
|
7613
|
-
cur.
|
|
7826
|
+
cur.offsetY(dy);
|
|
7614
7827
|
}
|
|
7615
7828
|
}
|
|
7616
7829
|
this.measures.forEach((m) => {
|
|
@@ -7625,26 +7838,10 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7625
7838
|
});
|
|
7626
7839
|
});
|
|
7627
7840
|
});
|
|
7628
|
-
this.
|
|
7629
|
-
let grp = this.instrumentLineGroups[i];
|
|
7630
|
-
if (obj && grp.length > 0) {
|
|
7631
|
-
obj.offset(
|
|
7632
|
-
-obj.getRect().left,
|
|
7633
|
-
-obj.getRect().anchorY + (grp[0].getRect().top + grp[grp.length - 1].getRect().bottom) / 2
|
|
7634
|
-
);
|
|
7635
|
-
}
|
|
7636
|
-
});
|
|
7841
|
+
this.rowGroups.forEach((grp) => grp.layoutToNotationLines());
|
|
7637
7842
|
this.alignStemsToBeams();
|
|
7638
7843
|
this.requestRectUpdate();
|
|
7639
7844
|
}
|
|
7640
|
-
layoutPadding(ctx) {
|
|
7641
|
-
let p = ctx.unitSize / 2;
|
|
7642
|
-
this.getRect();
|
|
7643
|
-
this.rect.left -= p;
|
|
7644
|
-
this.rect.right += p;
|
|
7645
|
-
this.rect.top -= p;
|
|
7646
|
-
this.rect.bottom += p;
|
|
7647
|
-
}
|
|
7648
7845
|
layoutDone() {
|
|
7649
7846
|
this.measures.forEach((m) => m.layoutDone());
|
|
7650
7847
|
this.needLayout = false;
|
|
@@ -7653,13 +7850,14 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7653
7850
|
this.measures.forEach((m) => m.offset(dx, dy));
|
|
7654
7851
|
this.rect.offsetInPlace(dx, dy);
|
|
7655
7852
|
this.notationLines.forEach((l) => l.offset(dx, dy));
|
|
7656
|
-
this.
|
|
7853
|
+
this.rowGroups.forEach((grp) => grp.offset(dx, dy));
|
|
7657
7854
|
}
|
|
7658
7855
|
draw(ctx) {
|
|
7659
7856
|
ctx.drawDebugRect(this.getRect());
|
|
7857
|
+
const { left, top, width, height } = this.getRect();
|
|
7858
|
+
const p = ctx._lineWidth;
|
|
7660
7859
|
ctx.save();
|
|
7661
|
-
|
|
7662
|
-
ctx.rect(left, top, width, height);
|
|
7860
|
+
ctx.rect(left - p, top, width + 2 * p, height);
|
|
7663
7861
|
ctx.clip();
|
|
7664
7862
|
if (this.getFirstMeasure() && (this.notationLines.length > 1 || this.notationLines[0] instanceof ObjTab)) {
|
|
7665
7863
|
let left2 = this.getFirstMeasure().getStaffLineLeft();
|
|
@@ -7669,31 +7867,17 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7669
7867
|
}
|
|
7670
7868
|
this.measures.forEach((m) => m.draw(ctx));
|
|
7671
7869
|
this.notationLines.forEach((m) => m.draw(ctx));
|
|
7672
|
-
|
|
7673
|
-
this.instrumentNames.forEach((obj, i) => {
|
|
7674
|
-
let grp = this.instrumentLineGroups[i];
|
|
7675
|
-
if (grp.length > 1) {
|
|
7676
|
-
let r = new import_ts_utils_lib29.AnchoredRect(
|
|
7677
|
-
grpSize.braceLeft,
|
|
7678
|
-
grpSize.braceRight,
|
|
7679
|
-
grp[0].getTopLineY(),
|
|
7680
|
-
grp[grp.length - 1].getBottomLineY()
|
|
7681
|
-
);
|
|
7682
|
-
ctx.color("brack").lineWidth(1).drawBrace(r, "left");
|
|
7683
|
-
}
|
|
7684
|
-
if (obj) {
|
|
7685
|
-
obj.draw(ctx);
|
|
7686
|
-
}
|
|
7687
|
-
});
|
|
7870
|
+
this.rowGroups.forEach((grp) => grp.draw(ctx));
|
|
7688
7871
|
ctx.restore();
|
|
7689
7872
|
}
|
|
7690
7873
|
};
|
|
7691
7874
|
|
|
7692
7875
|
// src/score/engine/obj-header.ts
|
|
7693
|
-
var
|
|
7876
|
+
var import_ts_utils_lib31 = require("@tspro/ts-utils-lib");
|
|
7694
7877
|
var ObjHeader = class extends MusicObject {
|
|
7695
7878
|
constructor(doc, title, composer, arranger) {
|
|
7696
7879
|
super(doc);
|
|
7880
|
+
this.doc = doc;
|
|
7697
7881
|
this.title = title;
|
|
7698
7882
|
this.composer = composer;
|
|
7699
7883
|
this.arranger = arranger;
|
|
@@ -7733,24 +7917,29 @@ var ObjHeader = class extends MusicObject {
|
|
|
7733
7917
|
}
|
|
7734
7918
|
return [this];
|
|
7735
7919
|
}
|
|
7736
|
-
|
|
7920
|
+
layout(ctx) {
|
|
7737
7921
|
let top = 0;
|
|
7738
|
-
|
|
7922
|
+
const left = this.doc.regions.staffLeft;
|
|
7923
|
+
const right = this.doc.regions.staffRight;
|
|
7924
|
+
this.rect = new import_ts_utils_lib31.AnchoredRect(left, right, 0, 0);
|
|
7739
7925
|
if (this.titleText) {
|
|
7740
7926
|
this.titleText.layout(ctx);
|
|
7741
|
-
this.titleText.
|
|
7927
|
+
this.titleText.setCenterX((left + right) / 2);
|
|
7928
|
+
this.titleText.setTop(top);
|
|
7742
7929
|
top += this.titleText.getRect().height;
|
|
7743
7930
|
this.rect.expandInPlace(this.titleText.getRect());
|
|
7744
7931
|
}
|
|
7745
7932
|
if (this.composerText) {
|
|
7746
7933
|
this.composerText.layout(ctx);
|
|
7747
|
-
this.composerText.
|
|
7934
|
+
this.composerText.setRight(right);
|
|
7935
|
+
this.composerText.setTop(top);
|
|
7748
7936
|
top += this.composerText.getRect().height;
|
|
7749
7937
|
this.rect.expandInPlace(this.composerText.getRect());
|
|
7750
7938
|
}
|
|
7751
7939
|
if (this.arrangerText) {
|
|
7752
7940
|
this.arrangerText.layout(ctx);
|
|
7753
|
-
this.arrangerText.
|
|
7941
|
+
this.arrangerText.setRight(right);
|
|
7942
|
+
this.arrangerText.setTop(top);
|
|
7754
7943
|
top += this.arrangerText.getRect().height;
|
|
7755
7944
|
this.rect.expandInPlace(this.arrangerText.getRect());
|
|
7756
7945
|
}
|
|
@@ -7781,30 +7970,14 @@ var ObjHeader = class extends MusicObject {
|
|
|
7781
7970
|
};
|
|
7782
7971
|
|
|
7783
7972
|
// src/score/engine/obj-document.ts
|
|
7784
|
-
var
|
|
7973
|
+
var import_ts_utils_lib32 = require("@tspro/ts-utils-lib");
|
|
7785
7974
|
var import_core17 = require("@tspro/web-music-score/core");
|
|
7786
|
-
var InstrumentGroupRegions = class {
|
|
7787
|
-
constructor() {
|
|
7788
|
-
__publicField(this, "nameLeft", 0);
|
|
7789
|
-
__publicField(this, "nameRight", 0);
|
|
7790
|
-
__publicField(this, "braceLeft", 0);
|
|
7791
|
-
__publicField(this, "braceRight", 0);
|
|
7792
|
-
}
|
|
7793
|
-
get left() {
|
|
7794
|
-
return this.nameLeft;
|
|
7795
|
-
}
|
|
7796
|
-
get right() {
|
|
7797
|
-
return this.braceRight;
|
|
7798
|
-
}
|
|
7799
|
-
get width() {
|
|
7800
|
-
return this.right - this.left;
|
|
7801
|
-
}
|
|
7802
|
-
};
|
|
7803
7975
|
var ObjDocument = class extends MusicObject {
|
|
7804
7976
|
constructor() {
|
|
7805
7977
|
super(void 0);
|
|
7806
7978
|
__publicField(this, "needLayout", true);
|
|
7807
7979
|
__publicField(this, "ctx");
|
|
7980
|
+
__publicField(this, "regions", new ScoreRowRegions());
|
|
7808
7981
|
__publicField(this, "rows", []);
|
|
7809
7982
|
__publicField(this, "measures", []);
|
|
7810
7983
|
__publicField(this, "measuresPerRow", Infinity);
|
|
@@ -7812,8 +7985,7 @@ var ObjDocument = class extends MusicObject {
|
|
|
7812
7985
|
__publicField(this, "header");
|
|
7813
7986
|
__publicField(this, "newRowRequested", false);
|
|
7814
7987
|
__publicField(this, "allConnectiveProps", []);
|
|
7815
|
-
__publicField(this, "staffGroups", new
|
|
7816
|
-
__publicField(this, "instrumentGroupRegions", new InstrumentGroupRegions());
|
|
7988
|
+
__publicField(this, "staffGroups", new import_ts_utils_lib32.UniMap());
|
|
7817
7989
|
__publicField(this, "mi");
|
|
7818
7990
|
this.mi = new MDocument2(this);
|
|
7819
7991
|
}
|
|
@@ -7821,7 +7993,7 @@ var ObjDocument = class extends MusicObject {
|
|
|
7821
7993
|
return this.mi;
|
|
7822
7994
|
}
|
|
7823
7995
|
setScoreConfiguration(config) {
|
|
7824
|
-
if (
|
|
7996
|
+
if (import_ts_utils_lib32.Guard.isEnumValue(config, StaffPreset)) {
|
|
7825
7997
|
switch (config) {
|
|
7826
7998
|
default:
|
|
7827
7999
|
case "treble" /* Treble */:
|
|
@@ -7849,7 +8021,7 @@ var ObjDocument = class extends MusicObject {
|
|
|
7849
8021
|
];
|
|
7850
8022
|
break;
|
|
7851
8023
|
}
|
|
7852
|
-
} else if (
|
|
8024
|
+
} else if (import_ts_utils_lib32.Guard.isArray(config)) {
|
|
7853
8025
|
this.curScoreConfig = config;
|
|
7854
8026
|
} else {
|
|
7855
8027
|
this.curScoreConfig = [config];
|
|
@@ -8010,17 +8182,6 @@ var ObjDocument = class extends MusicObject {
|
|
|
8010
8182
|
this.ctx.updateCursorRect(cursorRect);
|
|
8011
8183
|
}
|
|
8012
8184
|
}
|
|
8013
|
-
getInstrumentGroupRegions(ctx) {
|
|
8014
|
-
let nameWidth = Math.max(0, ...this.rows.map((row) => row.getInstrumentNameWidth(ctx)));
|
|
8015
|
-
let hasName = nameWidth > 0;
|
|
8016
|
-
let padding = hasName ? ctx.unitSize : 0;
|
|
8017
|
-
let braceWidth = hasName ? ctx.unitSize * 5 : 0;
|
|
8018
|
-
this.instrumentGroupRegions.nameLeft = 0;
|
|
8019
|
-
this.instrumentGroupRegions.nameRight = nameWidth;
|
|
8020
|
-
this.instrumentGroupRegions.braceLeft = nameWidth + padding;
|
|
8021
|
-
this.instrumentGroupRegions.braceRight = nameWidth + padding + braceWidth + padding;
|
|
8022
|
-
return this.instrumentGroupRegions;
|
|
8023
|
-
}
|
|
8024
8185
|
requestLayout() {
|
|
8025
8186
|
this.needLayout = true;
|
|
8026
8187
|
}
|
|
@@ -8048,28 +8209,27 @@ var ObjDocument = class extends MusicObject {
|
|
|
8048
8209
|
this.allConnectiveProps.forEach((props) => props.removeConnectives());
|
|
8049
8210
|
this.allConnectiveProps.forEach((props) => props.createConnectives());
|
|
8050
8211
|
this.rows.forEach((row) => row.resetLayoutGroups(ctx));
|
|
8212
|
+
this.regions.resetWidths();
|
|
8213
|
+
this.regions.addRowstaffWidth(DocumentSettings.MinStaffWidth * unitSize);
|
|
8051
8214
|
this.rows.forEach((row) => row.layout(ctx));
|
|
8052
|
-
|
|
8053
|
-
let rowRight = rowLeft + Math.max(
|
|
8054
|
-
DocumentSettings.DocumentMinWidth * unitSize,
|
|
8055
|
-
...this.rows.map((row) => row.getMinWidth())
|
|
8056
|
-
);
|
|
8057
|
-
this.rows.forEach((row) => row.layoutWidth(ctx, rowLeft, rowRight));
|
|
8215
|
+
this.rows.forEach((row) => row.layoutStretch(ctx));
|
|
8058
8216
|
this.rows.forEach((row) => row.layoutLayoutGroups(ctx));
|
|
8059
8217
|
this.rows.forEach((row) => row.layoutSetNotationLines(ctx));
|
|
8060
|
-
this.
|
|
8061
|
-
this.rect = new import_ts_utils_lib31.AnchoredRect();
|
|
8218
|
+
this.rect = new import_ts_utils_lib32.AnchoredRect();
|
|
8062
8219
|
if (this.header) {
|
|
8063
|
-
this.header.
|
|
8220
|
+
this.header.layout(ctx);
|
|
8064
8221
|
this.rect.expandInPlace(this.header.getRect());
|
|
8065
8222
|
}
|
|
8066
8223
|
this.rows.forEach((row) => {
|
|
8067
|
-
row.
|
|
8224
|
+
row.setLeft(0);
|
|
8225
|
+
row.setTop(this.rect.bottom + unitSize * 2);
|
|
8068
8226
|
this.rect.expandInPlace(row.getRect());
|
|
8069
8227
|
});
|
|
8070
8228
|
this.rows.forEach((row) => row.layoutDone());
|
|
8071
8229
|
this.needLayout = false;
|
|
8072
8230
|
}
|
|
8231
|
+
offset(dx, dy) {
|
|
8232
|
+
}
|
|
8073
8233
|
drawContent() {
|
|
8074
8234
|
const { ctx } = this;
|
|
8075
8235
|
if (!ctx) {
|
|
@@ -8138,86 +8298,86 @@ function assertArgMsg(condition, msg) {
|
|
|
8138
8298
|
function assertBaseConfig(baseConfig) {
|
|
8139
8299
|
var _a;
|
|
8140
8300
|
assertArg(
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
|
|
8301
|
+
import_ts_utils_lib33.Guard.isObject(baseConfig),
|
|
8302
|
+
import_ts_utils_lib33.Guard.isStringOrUndefined(baseConfig.name),
|
|
8303
|
+
import_ts_utils_lib33.Guard.isUndefined(baseConfig.voiceId) || isVoiceId(baseConfig.voiceId) || import_ts_utils_lib33.Guard.isArray(baseConfig.voiceId) && baseConfig.voiceId.every((voiceId) => isVoiceId(voiceId))
|
|
8144
8304
|
);
|
|
8145
|
-
if (!
|
|
8146
|
-
assertArg(isVoiceId(baseConfig.voiceIds) ||
|
|
8305
|
+
if (!import_ts_utils_lib33.Guard.isUndefined(baseConfig.voiceIds)) {
|
|
8306
|
+
assertArg(isVoiceId(baseConfig.voiceIds) || import_ts_utils_lib33.Guard.isArray(baseConfig.voiceIds) && baseConfig.voiceIds.every((voiceId) => isVoiceId(voiceId)));
|
|
8147
8307
|
console.warn(`Staff/tab config property 'voiceIds' is deprecated, use 'voiceId' instead.`);
|
|
8148
|
-
let arr =
|
|
8149
|
-
|
|
8308
|
+
let arr = import_ts_utils_lib33.Utils.Arr.toArray((_a = baseConfig.voiceId) != null ? _a : []);
|
|
8309
|
+
import_ts_utils_lib33.Utils.Arr.toArray(baseConfig.voiceIds).forEach((voiceId) => arr.push(voiceId));
|
|
8150
8310
|
baseConfig.voiceId = arr;
|
|
8151
8311
|
}
|
|
8152
|
-
if (
|
|
8153
|
-
baseConfig.voiceId =
|
|
8312
|
+
if (import_ts_utils_lib33.Guard.isArray(baseConfig.voiceId)) {
|
|
8313
|
+
baseConfig.voiceId = import_ts_utils_lib33.Utils.Arr.removeDuplicates(baseConfig.voiceId);
|
|
8154
8314
|
}
|
|
8155
|
-
assertArg(
|
|
8315
|
+
assertArg(import_ts_utils_lib33.Guard.isStringOrUndefined(baseConfig.instrument));
|
|
8156
8316
|
}
|
|
8157
8317
|
function assertStaffConfig(staffConfig) {
|
|
8158
8318
|
assertBaseConfig(staffConfig);
|
|
8159
8319
|
assertArg(
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
|
|
8320
|
+
import_ts_utils_lib33.Guard.isObject(staffConfig),
|
|
8321
|
+
import_ts_utils_lib33.Guard.isStrictEqual(staffConfig.type, "staff"),
|
|
8322
|
+
import_ts_utils_lib33.Guard.isEnumValue(staffConfig.clef, Clef),
|
|
8323
|
+
import_ts_utils_lib33.Guard.isBooleanOrUndefined(staffConfig.isOctaveDown),
|
|
8324
|
+
import_ts_utils_lib33.Guard.isUndefined(staffConfig.minNote) || import_theory13.Note.isNote(staffConfig.minNote),
|
|
8325
|
+
import_ts_utils_lib33.Guard.isUndefined(staffConfig.maxNote) || import_theory13.Note.isNote(staffConfig.maxNote),
|
|
8326
|
+
import_ts_utils_lib33.Guard.isStringOrUndefined(staffConfig.grandId),
|
|
8327
|
+
import_ts_utils_lib33.Guard.isBooleanOrUndefined(staffConfig.isGrand)
|
|
8168
8328
|
);
|
|
8169
|
-
if (!
|
|
8329
|
+
if (!import_ts_utils_lib33.Guard.isUndefined(staffConfig.isGrand))
|
|
8170
8330
|
console.warn(`Staff config property 'isGrand' is deprecated, use 'grandId' instead.`);
|
|
8171
8331
|
}
|
|
8172
8332
|
function assertTabConfig(tabConfig) {
|
|
8173
8333
|
assertBaseConfig(tabConfig);
|
|
8174
8334
|
assertArg(
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8335
|
+
import_ts_utils_lib33.Guard.isObject(tabConfig),
|
|
8336
|
+
import_ts_utils_lib33.Guard.isStrictEqual(tabConfig.type, "tab"),
|
|
8337
|
+
import_ts_utils_lib33.Guard.isUndefined(tabConfig.tuning) || import_ts_utils_lib33.Guard.isString(tabConfig.tuning) && import_ts_utils_lib33.Guard.isIncluded(tabConfig.tuning, import_theory13.TuningNameList) || import_ts_utils_lib33.Guard.isArray(tabConfig.tuning) && import_ts_utils_lib33.Guard.isStrictEqual(tabConfig.tuning.length, getStringNumbers().length && tabConfig.tuning.every((s) => import_theory13.Note.isNote(s)))
|
|
8178
8338
|
);
|
|
8179
8339
|
}
|
|
8180
8340
|
function assertNoteOptions(noteOptions) {
|
|
8181
8341
|
assertArg(
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
|
|
8190
|
-
|
|
8342
|
+
import_ts_utils_lib33.Guard.isObject(noteOptions),
|
|
8343
|
+
import_ts_utils_lib33.Guard.isBooleanOrUndefined(noteOptions.dotted) || import_ts_utils_lib33.Guard.isIntegerGte(noteOptions.dotted, 0),
|
|
8344
|
+
import_ts_utils_lib33.Guard.isEnumValueOrUndefined(noteOptions.stem, Stem),
|
|
8345
|
+
import_ts_utils_lib33.Guard.isStringOrUndefined(noteOptions.color),
|
|
8346
|
+
import_ts_utils_lib33.Guard.isBooleanOrUndefined(noteOptions.arpeggio) || import_ts_utils_lib33.Guard.isEnumValue(noteOptions.arpeggio, Arpeggio),
|
|
8347
|
+
import_ts_utils_lib33.Guard.isBooleanOrUndefined(noteOptions.staccato),
|
|
8348
|
+
import_ts_utils_lib33.Guard.isBooleanOrUndefined(noteOptions.diamond),
|
|
8349
|
+
import_ts_utils_lib33.Guard.isBooleanOrUndefined(noteOptions.triplet),
|
|
8350
|
+
import_ts_utils_lib33.Guard.isUndefined(noteOptions.string) || isStringNumber(noteOptions.string) || import_ts_utils_lib33.Guard.isEmptyArray(noteOptions.string) || import_ts_utils_lib33.Guard.isNonEmptyArray(noteOptions.string) && noteOptions.string.every((string) => isStringNumber(string))
|
|
8191
8351
|
);
|
|
8192
|
-
assertArgMsg(
|
|
8193
|
-
assertArgMsg(
|
|
8352
|
+
assertArgMsg(import_ts_utils_lib33.Guard.isUndefined(noteOptions.tieSpan), `NoteOptions.tieSpan was removed. Use addConnective("tie", tieSpan)`);
|
|
8353
|
+
assertArgMsg(import_ts_utils_lib33.Guard.isUndefined(noteOptions.slurSpan), `NoteOptions.slurSpan was removed. Use addConnective("slur", slurSpan)`);
|
|
8194
8354
|
}
|
|
8195
8355
|
function assertRestOptions(restOptions) {
|
|
8196
8356
|
assertArg(
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8357
|
+
import_ts_utils_lib33.Guard.isObject(restOptions),
|
|
8358
|
+
import_ts_utils_lib33.Guard.isBooleanOrUndefined(restOptions.dotted) || import_ts_utils_lib33.Guard.isIntegerGte(restOptions.dotted, 0),
|
|
8359
|
+
import_ts_utils_lib33.Guard.isStringOrUndefined(restOptions.staffPos) || import_ts_utils_lib33.Guard.isInteger(restOptions.staffPos) || restOptions.staffPos instanceof import_theory13.Note,
|
|
8360
|
+
import_ts_utils_lib33.Guard.isStringOrUndefined(restOptions.color),
|
|
8361
|
+
import_ts_utils_lib33.Guard.isBooleanOrUndefined(restOptions.hide),
|
|
8362
|
+
import_ts_utils_lib33.Guard.isBooleanOrUndefined(restOptions.triplet)
|
|
8203
8363
|
);
|
|
8204
8364
|
}
|
|
8205
8365
|
function assertLyricsOptions(lyricsOptions) {
|
|
8206
8366
|
assertArg(
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8367
|
+
import_ts_utils_lib33.Guard.isObject(lyricsOptions),
|
|
8368
|
+
import_ts_utils_lib33.Guard.isEnumValueOrUndefined(lyricsOptions.align, LyricsAlign),
|
|
8369
|
+
import_ts_utils_lib33.Guard.isEnumValueOrUndefined(lyricsOptions.hyphen, LyricsHyphen)
|
|
8210
8370
|
);
|
|
8211
8371
|
}
|
|
8212
8372
|
function assertMeasureOptions(measureOptions) {
|
|
8213
8373
|
assertArg(
|
|
8214
|
-
|
|
8215
|
-
|
|
8374
|
+
import_ts_utils_lib33.Guard.isObject(measureOptions),
|
|
8375
|
+
import_ts_utils_lib33.Guard.isBooleanOrUndefined(measureOptions.showNumber)
|
|
8216
8376
|
);
|
|
8217
8377
|
}
|
|
8218
8378
|
function assertStaffTabOrGRoups(staffTabOrGroups) {
|
|
8219
8379
|
assertArg(
|
|
8220
|
-
|
|
8380
|
+
import_ts_utils_lib33.Guard.isStringOrUndefined(staffTabOrGroups) || import_ts_utils_lib33.Guard.isIntegerGte(staffTabOrGroups, 0) || import_ts_utils_lib33.Guard.isNonEmptyArray(staffTabOrGroups) && staffTabOrGroups.every((staffTabOrGroup) => import_ts_utils_lib33.Guard.isString(staffTabOrGroup) || import_ts_utils_lib33.Guard.isIntegerGte(staffTabOrGroup, 0))
|
|
8221
8381
|
);
|
|
8222
8382
|
}
|
|
8223
8383
|
var _DocumentBuilder = class _DocumentBuilder {
|
|
@@ -8231,19 +8391,19 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8231
8391
|
}
|
|
8232
8392
|
setScoreConfiguration(config) {
|
|
8233
8393
|
setAssertFunction("setScoreConfiguration", config);
|
|
8234
|
-
if (
|
|
8394
|
+
if (import_ts_utils_lib33.Guard.isEnumValue(config, StaffPreset)) {
|
|
8235
8395
|
this.doc.setScoreConfiguration(config);
|
|
8236
|
-
} else if (
|
|
8396
|
+
} else if (import_ts_utils_lib33.Guard.isObject(config) && config.type === "staff") {
|
|
8237
8397
|
assertStaffConfig(config);
|
|
8238
8398
|
this.doc.setScoreConfiguration(config);
|
|
8239
|
-
} else if (
|
|
8399
|
+
} else if (import_ts_utils_lib33.Guard.isObject(config) && config.type === "tab") {
|
|
8240
8400
|
assertTabConfig(config);
|
|
8241
8401
|
this.doc.setScoreConfiguration(config);
|
|
8242
|
-
} else if (
|
|
8402
|
+
} else if (import_ts_utils_lib33.Guard.isNonEmptyArray(config)) {
|
|
8243
8403
|
config.forEach((c) => {
|
|
8244
|
-
if (
|
|
8404
|
+
if (import_ts_utils_lib33.Guard.isObject(c) && c.type === "staff") {
|
|
8245
8405
|
assertStaffConfig(c);
|
|
8246
|
-
} else if (
|
|
8406
|
+
} else if (import_ts_utils_lib33.Guard.isObject(c) && c.type === "tab") {
|
|
8247
8407
|
assertTabConfig(c);
|
|
8248
8408
|
} else {
|
|
8249
8409
|
assertArg(false);
|
|
@@ -8276,9 +8436,9 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8276
8436
|
setHeader(title, composer, arranger) {
|
|
8277
8437
|
setAssertFunction("setHeader", title, composer, arranger);
|
|
8278
8438
|
assertArg(
|
|
8279
|
-
|
|
8280
|
-
|
|
8281
|
-
|
|
8439
|
+
import_ts_utils_lib33.Guard.isStringOrUndefined(title),
|
|
8440
|
+
import_ts_utils_lib33.Guard.isStringOrUndefined(composer),
|
|
8441
|
+
import_ts_utils_lib33.Guard.isStringOrUndefined(arranger)
|
|
8282
8442
|
);
|
|
8283
8443
|
this.doc.setHeader(title, composer, arranger);
|
|
8284
8444
|
return this;
|
|
@@ -8290,7 +8450,7 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8290
8450
|
*/
|
|
8291
8451
|
setMeasuresPerRow(measuresPerRow) {
|
|
8292
8452
|
setAssertFunction("setMeasuresPerRow", measuresPerRow);
|
|
8293
|
-
assertArg(
|
|
8453
|
+
assertArg(import_ts_utils_lib33.Guard.isIntegerGte(measuresPerRow, 1) || import_ts_utils_lib33.Guard.isPosInfinity(measuresPerRow));
|
|
8294
8454
|
this.doc.setMeasuresPerRow(measuresPerRow);
|
|
8295
8455
|
return this;
|
|
8296
8456
|
}
|
|
@@ -8308,7 +8468,7 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8308
8468
|
}
|
|
8309
8469
|
setKeySignature(...args) {
|
|
8310
8470
|
setAssertFunction("setKeySignature", ...args);
|
|
8311
|
-
assertArg(args[0] instanceof import_theory13.Scale || args[0] instanceof import_theory13.KeySignature ||
|
|
8471
|
+
assertArg(args[0] instanceof import_theory13.Scale || args[0] instanceof import_theory13.KeySignature || import_ts_utils_lib33.Guard.isNonEmptyString(args[0]) && import_ts_utils_lib33.Guard.isEnumValueOrUndefined(args[1], import_theory13.ScaleType));
|
|
8312
8472
|
this.getMeasure().setKeySignature(...args);
|
|
8313
8473
|
return this;
|
|
8314
8474
|
}
|
|
@@ -8316,9 +8476,9 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8316
8476
|
setAssertFunction("setTimeSignature", ...args);
|
|
8317
8477
|
if (args[0] instanceof import_theory13.TimeSignature) {
|
|
8318
8478
|
this.getMeasure().setTimeSignature(args[0]);
|
|
8319
|
-
} else if (
|
|
8479
|
+
} else if (import_ts_utils_lib33.Guard.isEnumValue(args[0], import_theory13.TimeSignatures) && import_ts_utils_lib33.Guard.isEnumValueOrUndefined(args[1], import_theory13.BeamGrouping)) {
|
|
8320
8480
|
this.getMeasure().setTimeSignature(new import_theory13.TimeSignature(args[0], args[1]));
|
|
8321
|
-
} else if (
|
|
8481
|
+
} else if (import_ts_utils_lib33.Guard.isIntegerGte(args[0], 1) && import_ts_utils_lib33.Guard.isIntegerGte(args[1], 1) && import_ts_utils_lib33.Guard.isEnumValueOrUndefined(args[2], import_theory13.BeamGrouping)) {
|
|
8322
8482
|
this.getMeasure().setTimeSignature(new import_theory13.TimeSignature(args[0], args[1], args[2]));
|
|
8323
8483
|
} else {
|
|
8324
8484
|
assertArg(false);
|
|
@@ -8328,8 +8488,8 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8328
8488
|
setTempo(beatsPerMinute, beatLength, dotted) {
|
|
8329
8489
|
setAssertFunction("setTempo", beatsPerMinute, beatLength, dotted);
|
|
8330
8490
|
assertArg(
|
|
8331
|
-
|
|
8332
|
-
|
|
8491
|
+
import_ts_utils_lib33.Guard.isIntegerGte(beatsPerMinute, 1),
|
|
8492
|
+
import_ts_utils_lib33.Guard.isUndefined(beatLength) && import_ts_utils_lib33.Guard.isUndefined(dotted) || (0, import_theory13.isNoteLength)(beatLength) && (import_ts_utils_lib33.Guard.isBooleanOrUndefined(dotted) || import_ts_utils_lib33.Guard.isIntegerGte(dotted, 0))
|
|
8333
8493
|
);
|
|
8334
8494
|
this.getMeasure().setTempo(beatsPerMinute, beatLength, dotted);
|
|
8335
8495
|
return this;
|
|
@@ -8346,15 +8506,15 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8346
8506
|
setAssertFunction("addNote", voiceId, note, noteLength, noteOptions);
|
|
8347
8507
|
assertArg(
|
|
8348
8508
|
isVoiceId(voiceId),
|
|
8349
|
-
note instanceof import_theory13.Note ||
|
|
8509
|
+
note instanceof import_theory13.Note || import_ts_utils_lib33.Guard.isNonEmptyString(note) || import_ts_utils_lib33.Guard.isArray(note) && note.every((note2) => note2 instanceof import_theory13.Note || import_ts_utils_lib33.Guard.isNonEmptyString(note2)),
|
|
8350
8510
|
(0, import_theory13.isNoteLength)(noteLength)
|
|
8351
8511
|
);
|
|
8352
8512
|
noteOptions != null ? noteOptions : noteOptions = {};
|
|
8353
8513
|
assertNoteOptions(noteOptions);
|
|
8354
|
-
if (
|
|
8514
|
+
if (import_ts_utils_lib33.Guard.isArray(note)) {
|
|
8355
8515
|
let string = noteOptions.string;
|
|
8356
8516
|
note.forEach((note2, noteId) => {
|
|
8357
|
-
noteOptions.string =
|
|
8517
|
+
noteOptions.string = import_ts_utils_lib33.Guard.isArray(string) ? string[noteId] : string;
|
|
8358
8518
|
this.getMeasure().addNoteGroup(voiceId, [note2], noteLength, noteOptions);
|
|
8359
8519
|
});
|
|
8360
8520
|
} else {
|
|
@@ -8374,7 +8534,7 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8374
8534
|
setAssertFunction("addChord", voiceId, notes, noteLength, noteOptions);
|
|
8375
8535
|
assertArg(
|
|
8376
8536
|
isVoiceId(voiceId),
|
|
8377
|
-
|
|
8537
|
+
import_ts_utils_lib33.Guard.isNonEmptyArray(notes) && notes.every((note) => note instanceof import_theory13.Note || import_ts_utils_lib33.Guard.isNonEmptyString(note)),
|
|
8378
8538
|
(0, import_theory13.isNoteLength)(noteLength)
|
|
8379
8539
|
);
|
|
8380
8540
|
noteOptions != null ? noteOptions : noteOptions = {};
|
|
@@ -8419,24 +8579,24 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8419
8579
|
setAssertFunction("addTuplet", voiceId, tupletRatio);
|
|
8420
8580
|
assertArg(
|
|
8421
8581
|
isVoiceId(voiceId),
|
|
8422
|
-
|
|
8423
|
-
(0, import_theory13.isTupletRatio)(tupletRatio) &&
|
|
8582
|
+
import_ts_utils_lib33.Guard.isFunction(tupletBuilder),
|
|
8583
|
+
(0, import_theory13.isTupletRatio)(tupletRatio) && import_ts_utils_lib33.Guard.isBooleanOrUndefined(tupletRatio.showRatio)
|
|
8424
8584
|
);
|
|
8425
8585
|
let tupletSymbols = [];
|
|
8426
8586
|
const helper = {
|
|
8427
8587
|
addNote: (note, noteLength, noteOptions) => {
|
|
8428
8588
|
setAssertFunction("addTuplet => addNote", note, noteLength, noteOptions);
|
|
8429
8589
|
assertArg(
|
|
8430
|
-
note instanceof import_theory13.Note ||
|
|
8590
|
+
note instanceof import_theory13.Note || import_ts_utils_lib33.Guard.isNonEmptyString(note) || import_ts_utils_lib33.Guard.isArray(note) && note.every((note2) => note2 instanceof import_theory13.Note || import_ts_utils_lib33.Guard.isNonEmptyString(note2)),
|
|
8431
8591
|
(0, import_theory13.isNoteLength)(noteLength)
|
|
8432
8592
|
);
|
|
8433
8593
|
noteOptions != null ? noteOptions : noteOptions = {};
|
|
8434
8594
|
delete noteOptions.triplet;
|
|
8435
8595
|
assertNoteOptions(noteOptions);
|
|
8436
|
-
if (
|
|
8596
|
+
if (import_ts_utils_lib33.Guard.isArray(note)) {
|
|
8437
8597
|
let string = noteOptions.string;
|
|
8438
8598
|
note.forEach((note2, noteId) => {
|
|
8439
|
-
noteOptions.string =
|
|
8599
|
+
noteOptions.string = import_ts_utils_lib33.Guard.isArray(string) ? string[noteId] : string;
|
|
8440
8600
|
let s = this.getMeasure().addNoteGroup(voiceId, [note2], noteLength, noteOptions, tupletRatio);
|
|
8441
8601
|
tupletSymbols.push(s);
|
|
8442
8602
|
});
|
|
@@ -8449,7 +8609,7 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8449
8609
|
addChord: (notes, noteLength, noteOptions) => {
|
|
8450
8610
|
setAssertFunction("addTuplet => addChord", notes, noteLength, noteOptions);
|
|
8451
8611
|
assertArg(
|
|
8452
|
-
|
|
8612
|
+
import_ts_utils_lib33.Guard.isNonEmptyArray(notes) && notes.every((note) => note instanceof import_theory13.Note || import_ts_utils_lib33.Guard.isNonEmptyString(note)),
|
|
8453
8613
|
(0, import_theory13.isNoteLength)(noteLength)
|
|
8454
8614
|
);
|
|
8455
8615
|
noteOptions != null ? noteOptions : noteOptions = {};
|
|
@@ -8479,8 +8639,8 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8479
8639
|
assertStaffTabOrGRoups(staffTabOrGroups);
|
|
8480
8640
|
assertArg(
|
|
8481
8641
|
isVerseNumber(verse),
|
|
8482
|
-
|
|
8483
|
-
|
|
8642
|
+
import_ts_utils_lib33.Guard.isEnumValue(lyricsLength, import_theory13.NoteLength),
|
|
8643
|
+
import_ts_utils_lib33.Guard.isString(lyricsText) || import_ts_utils_lib33.Guard.isArray(lyricsText) && lyricsText.every((text) => import_ts_utils_lib33.Guard.isString(text))
|
|
8484
8644
|
);
|
|
8485
8645
|
lyricsOptions != null ? lyricsOptions : lyricsOptions = {};
|
|
8486
8646
|
assertLyricsOptions(lyricsOptions);
|
|
@@ -8489,7 +8649,7 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8489
8649
|
} else {
|
|
8490
8650
|
(_a = lyricsOptions.align) != null ? _a : lyricsOptions.align = this.currentLyricsAlign;
|
|
8491
8651
|
}
|
|
8492
|
-
if (
|
|
8652
|
+
if (import_ts_utils_lib33.Guard.isArray(lyricsText)) {
|
|
8493
8653
|
lyricsText.forEach((text) => this.getMeasure().addLyrics(staffTabOrGroups, verse, lyricsLength, text, lyricsOptions));
|
|
8494
8654
|
} else {
|
|
8495
8655
|
this.getMeasure().addLyrics(staffTabOrGroups, verse, lyricsLength, lyricsText, lyricsOptions);
|
|
@@ -8523,7 +8683,7 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8523
8683
|
}
|
|
8524
8684
|
addFermataInternal(staffTabOrGroups, fermata) {
|
|
8525
8685
|
assertStaffTabOrGRoups(staffTabOrGroups);
|
|
8526
|
-
assertArg(
|
|
8686
|
+
assertArg(import_ts_utils_lib33.Guard.isEnumValue(fermata, Fermata));
|
|
8527
8687
|
this.getMeasure().addFermata(staffTabOrGroups, fermata);
|
|
8528
8688
|
return this;
|
|
8529
8689
|
}
|
|
@@ -8549,7 +8709,7 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8549
8709
|
addNavigationInternal(staffTabOrGroups, navigation, ...args) {
|
|
8550
8710
|
assertStaffTabOrGRoups(staffTabOrGroups);
|
|
8551
8711
|
assertArg(
|
|
8552
|
-
|
|
8712
|
+
import_ts_utils_lib33.Guard.isStrictEqual(navigation, "endRepeat" /* EndRepeat */) && import_ts_utils_lib33.Guard.isStrictEqual(args.length, 1) || import_ts_utils_lib33.Guard.isStrictEqual(navigation, "ending" /* Ending */) && import_ts_utils_lib33.Guard.isIntegerGte(args.length, 1) && args.every((passage) => import_ts_utils_lib33.Guard.isIntegerGte(passage, 1)) || import_ts_utils_lib33.Guard.isEnumValue(navigation, Navigation) && import_ts_utils_lib33.Guard.isEmptyArray(args)
|
|
8553
8713
|
);
|
|
8554
8714
|
this.getMeasure().addNavigation(staffTabOrGroups, navigation, ...args);
|
|
8555
8715
|
return this;
|
|
@@ -8569,8 +8729,8 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8569
8729
|
}
|
|
8570
8730
|
assertStaffTabOrGRoups(staffTabOrGroups);
|
|
8571
8731
|
assertArg(
|
|
8572
|
-
|
|
8573
|
-
|
|
8732
|
+
import_ts_utils_lib33.Guard.isEnumValue(annotation, Annotation),
|
|
8733
|
+
import_ts_utils_lib33.Guard.isNonEmptyString(text)
|
|
8574
8734
|
);
|
|
8575
8735
|
this.getMeasure().addAnnotation(staffTabOrGroups, annotation, text);
|
|
8576
8736
|
return this;
|
|
@@ -8594,8 +8754,8 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8594
8754
|
addLabelInternal(staffTabOrGroups, label, text) {
|
|
8595
8755
|
assertStaffTabOrGRoups(staffTabOrGroups);
|
|
8596
8756
|
assertArg(
|
|
8597
|
-
|
|
8598
|
-
|
|
8757
|
+
import_ts_utils_lib33.Guard.isEnumValue(label, Label),
|
|
8758
|
+
import_ts_utils_lib33.Guard.isNonEmptyString(text)
|
|
8599
8759
|
);
|
|
8600
8760
|
this.getMeasure().addLabel(staffTabOrGroups, label, text);
|
|
8601
8761
|
return this;
|
|
@@ -8623,21 +8783,21 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8623
8783
|
}
|
|
8624
8784
|
addConnective(connective, ...args) {
|
|
8625
8785
|
setAssertFunction("addConnective", connective, ...args);
|
|
8626
|
-
assertArg(
|
|
8786
|
+
assertArg(import_ts_utils_lib33.Guard.isEnumValue(connective, Connective));
|
|
8627
8787
|
if (connective === "tie" /* Tie */) {
|
|
8628
|
-
assertArg(
|
|
8629
|
-
assertArg(
|
|
8788
|
+
assertArg(import_ts_utils_lib33.Guard.isIntegerOrUndefined(args[0]) || import_ts_utils_lib33.Guard.isEnumValue(args[0], TieType));
|
|
8789
|
+
assertArg(import_ts_utils_lib33.Guard.isEnumValueOrUndefined(args[1], NoteAnchor));
|
|
8630
8790
|
let tieSpan = args[0];
|
|
8631
8791
|
let noteAnchor = args[1];
|
|
8632
8792
|
this.getMeasure().addConnective(connective, tieSpan, noteAnchor);
|
|
8633
8793
|
} else if (connective === "slur" /* Slur */) {
|
|
8634
|
-
assertArg(
|
|
8635
|
-
assertArg(
|
|
8794
|
+
assertArg(import_ts_utils_lib33.Guard.isIntegerOrUndefined(args[0]));
|
|
8795
|
+
assertArg(import_ts_utils_lib33.Guard.isEnumValueOrUndefined(args[1], NoteAnchor));
|
|
8636
8796
|
let slurSpan = args[0];
|
|
8637
8797
|
let noteAnchor = args[1];
|
|
8638
8798
|
this.getMeasure().addConnective(connective, slurSpan, noteAnchor);
|
|
8639
8799
|
} else if (connective === "slide" /* Slide */) {
|
|
8640
|
-
assertArg(
|
|
8800
|
+
assertArg(import_ts_utils_lib33.Guard.isEnumValueOrUndefined(args[0], NoteAnchor));
|
|
8641
8801
|
let noteAnchor = args[0];
|
|
8642
8802
|
this.getMeasure().addConnective(connective, noteAnchor);
|
|
8643
8803
|
}
|
|
@@ -8657,20 +8817,20 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8657
8817
|
*/
|
|
8658
8818
|
addExtension(extensionBuilder) {
|
|
8659
8819
|
setAssertFunction("addExtension");
|
|
8660
|
-
assertArgMsg(
|
|
8820
|
+
assertArgMsg(import_ts_utils_lib33.Guard.isFunctionOrUndefined(extensionBuilder), "addExtension() has new usage, e.g. addExtension(ext => ext.measures(2)).");
|
|
8661
8821
|
let ticks = 0;
|
|
8662
8822
|
let visible = true;
|
|
8663
8823
|
const helper = {
|
|
8664
8824
|
notes: (noteLength, noteCount) => {
|
|
8665
8825
|
setAssertFunction("addExtension.notes", noteLength, noteCount);
|
|
8666
8826
|
assertArg((0, import_theory13.isNoteLength)(noteLength));
|
|
8667
|
-
assertArg(
|
|
8827
|
+
assertArg(import_ts_utils_lib33.Guard.isUndefined(noteCount) || import_ts_utils_lib33.Guard.isNumber(noteCount) && noteCount >= 0);
|
|
8668
8828
|
ticks += import_theory13.RhythmProps.get(noteLength).ticks * (noteCount != null ? noteCount : 1);
|
|
8669
8829
|
return helper;
|
|
8670
8830
|
},
|
|
8671
8831
|
measures: (measureCount) => {
|
|
8672
8832
|
setAssertFunction("addExtension.measures", measureCount);
|
|
8673
|
-
assertArg(
|
|
8833
|
+
assertArg(import_ts_utils_lib33.Guard.isNumber(measureCount) && measureCount >= 1);
|
|
8674
8834
|
ticks += this.getMeasure().getMeasureTicks() * measureCount;
|
|
8675
8835
|
return helper;
|
|
8676
8836
|
},
|
|
@@ -8703,9 +8863,9 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8703
8863
|
addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition = "auto" /* Auto */) {
|
|
8704
8864
|
setAssertFunction("addStaffGroup", groupName, staffsTabsAndGroups, verticalPosition);
|
|
8705
8865
|
assertArg(
|
|
8706
|
-
|
|
8707
|
-
|
|
8708
|
-
|
|
8866
|
+
import_ts_utils_lib33.Guard.isNonEmptyString(groupName),
|
|
8867
|
+
import_ts_utils_lib33.Guard.isNonEmptyString(staffsTabsAndGroups) || import_ts_utils_lib33.Guard.isIntegerGte(staffsTabsAndGroups, 0) || import_ts_utils_lib33.Guard.isNonEmptyArray(staffsTabsAndGroups) && staffsTabsAndGroups.every((line) => import_ts_utils_lib33.Guard.isNonEmptyString(line) || import_ts_utils_lib33.Guard.isIntegerGte(line, 0)),
|
|
8868
|
+
import_ts_utils_lib33.Guard.isEnumValue(verticalPosition, VerticalPosition)
|
|
8709
8869
|
);
|
|
8710
8870
|
this.doc.addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition);
|
|
8711
8871
|
return this;
|
|
@@ -8745,7 +8905,7 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8745
8905
|
*/
|
|
8746
8906
|
completeRests(voiceId) {
|
|
8747
8907
|
setAssertFunction("completeRests", voiceId);
|
|
8748
|
-
assertArg(
|
|
8908
|
+
assertArg(import_ts_utils_lib33.Guard.isUndefined(voiceId) || isVoiceId(voiceId) || import_ts_utils_lib33.Guard.isArray(voiceId) && voiceId.every((id) => isVoiceId(id)));
|
|
8749
8909
|
this.getMeasure().completeRests(voiceId);
|
|
8750
8910
|
return this;
|
|
8751
8911
|
}
|
|
@@ -8759,8 +8919,8 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8759
8919
|
addScaleArpeggio(scale, bottomNote, numOctaves) {
|
|
8760
8920
|
setAssertFunction("addScaleArpeggio", scale, bottomNote, numOctaves);
|
|
8761
8921
|
assertArg(
|
|
8762
|
-
|
|
8763
|
-
|
|
8922
|
+
import_ts_utils_lib33.Guard.isNonEmptyString(bottomNote),
|
|
8923
|
+
import_ts_utils_lib33.Guard.isIntegerGte(numOctaves, 1)
|
|
8764
8924
|
);
|
|
8765
8925
|
let ts = this.getMeasure().getTimeSignature();
|
|
8766
8926
|
let notes = scale.getScaleNotes(bottomNote, numOctaves);
|
|
@@ -8847,10 +9007,10 @@ var ScoreObjectEvent = class extends ScoreEvent {
|
|
|
8847
9007
|
|
|
8848
9008
|
// src/score/pub/music-interface.ts
|
|
8849
9009
|
var Audio2 = __toESM(require("@tspro/web-music-score/audio"));
|
|
8850
|
-
var
|
|
9010
|
+
var import_ts_utils_lib35 = require("@tspro/ts-utils-lib");
|
|
8851
9011
|
|
|
8852
9012
|
// src/score/pub/music-objects.ts
|
|
8853
|
-
var
|
|
9013
|
+
var import_ts_utils_lib34 = require("@tspro/ts-utils-lib");
|
|
8854
9014
|
var import_core20 = require("@tspro/web-music-score/core");
|
|
8855
9015
|
function assertArg2(condition, argName, argValue) {
|
|
8856
9016
|
if (!condition) {
|
|
@@ -9031,7 +9191,7 @@ var _MDocument = class _MDocument extends MusicInterface5 {
|
|
|
9031
9191
|
* @returns - Player instance.
|
|
9032
9192
|
*/
|
|
9033
9193
|
play(playStateChangeListener) {
|
|
9034
|
-
assertArg2(
|
|
9194
|
+
assertArg2(import_ts_utils_lib34.Guard.isFunctionOrUndefined(playStateChangeListener), "playStateChangeListener", playStateChangeListener);
|
|
9035
9195
|
return new MPlayer(this, playStateChangeListener).play();
|
|
9036
9196
|
}
|
|
9037
9197
|
};
|
|
@@ -9061,7 +9221,7 @@ var _MEnding = class _MEnding extends MusicInterface5 {
|
|
|
9061
9221
|
* @returns - Boolean whether this ending has asked passage number.
|
|
9062
9222
|
*/
|
|
9063
9223
|
hasPassage(passage) {
|
|
9064
|
-
assertArg2(
|
|
9224
|
+
assertArg2(import_ts_utils_lib34.Guard.isIntegerGte(passage, 1), "passage", passage);
|
|
9065
9225
|
return this.obj.hasPassage(passage);
|
|
9066
9226
|
}
|
|
9067
9227
|
};
|
|
@@ -9194,10 +9354,10 @@ var _MBarLineLeft = class _MBarLineLeft extends MusicInterface5 {
|
|
|
9194
9354
|
/** Object name. */
|
|
9195
9355
|
__publicField(_MBarLineLeft, "Name", "BarLineLeft");
|
|
9196
9356
|
var MBarLineLeft = _MBarLineLeft;
|
|
9197
|
-
var
|
|
9357
|
+
var _MStaffBarLine = class _MStaffBarLine extends MusicInterface5 {
|
|
9198
9358
|
/** @internal */
|
|
9199
9359
|
constructor(obj) {
|
|
9200
|
-
super(
|
|
9360
|
+
super(_MStaffBarLine.Name);
|
|
9201
9361
|
this.obj = obj;
|
|
9202
9362
|
}
|
|
9203
9363
|
/** @internal */
|
|
@@ -9213,7 +9373,7 @@ var _MStaffTabBarLine = class _MStaffTabBarLine extends MusicInterface5 {
|
|
|
9213
9373
|
if (barLine instanceof ObjBarLineLeft || barLine instanceof ObjBarLineRight) {
|
|
9214
9374
|
return barLine.getMusicInterface();
|
|
9215
9375
|
} else {
|
|
9216
|
-
throw new import_core20.MusicError(import_core20.MusicErrorType.Score, `Bar line not
|
|
9376
|
+
throw new import_core20.MusicError(import_core20.MusicErrorType.Score, `Bar line not left nor right.`);
|
|
9217
9377
|
}
|
|
9218
9378
|
}
|
|
9219
9379
|
/**
|
|
@@ -9225,8 +9385,8 @@ var _MStaffTabBarLine = class _MStaffTabBarLine extends MusicInterface5 {
|
|
|
9225
9385
|
}
|
|
9226
9386
|
};
|
|
9227
9387
|
/** Object name. */
|
|
9228
|
-
__publicField(
|
|
9229
|
-
var
|
|
9388
|
+
__publicField(_MStaffBarLine, "Name", "StaffBarLine");
|
|
9389
|
+
var MStaffBarLine = _MStaffBarLine;
|
|
9230
9390
|
var _MNoteGroup = class _MNoteGroup extends MusicInterface5 {
|
|
9231
9391
|
/** @internal */
|
|
9232
9392
|
constructor(obj) {
|
|
@@ -9507,6 +9667,27 @@ var _MScoreRow = class _MScoreRow extends MusicInterface5 {
|
|
|
9507
9667
|
/** Object name. */
|
|
9508
9668
|
__publicField(_MScoreRow, "Name", "ScoreRow");
|
|
9509
9669
|
var MScoreRow = _MScoreRow;
|
|
9670
|
+
var _MScoreRowGroup = class _MScoreRowGroup extends MusicInterface5 {
|
|
9671
|
+
/** @internal */
|
|
9672
|
+
constructor(obj) {
|
|
9673
|
+
super(_MScoreRowGroup.Name);
|
|
9674
|
+
this.obj = obj;
|
|
9675
|
+
}
|
|
9676
|
+
/** @internal */
|
|
9677
|
+
getMusicObject() {
|
|
9678
|
+
return this.obj;
|
|
9679
|
+
}
|
|
9680
|
+
/**
|
|
9681
|
+
* Get instrument name.
|
|
9682
|
+
* @returns - instrument name.
|
|
9683
|
+
*/
|
|
9684
|
+
getInstrument() {
|
|
9685
|
+
return this.obj.instrument;
|
|
9686
|
+
}
|
|
9687
|
+
};
|
|
9688
|
+
/** Object name. */
|
|
9689
|
+
__publicField(_MScoreRowGroup, "Name", "ScoreRowGroup");
|
|
9690
|
+
var MScoreRowGroup = _MScoreRowGroup;
|
|
9510
9691
|
var _MStaff = class _MStaff extends MusicInterface5 {
|
|
9511
9692
|
/** @internal */
|
|
9512
9693
|
constructor(obj) {
|
|
@@ -9748,7 +9929,7 @@ var _MPlayer = class _MPlayer {
|
|
|
9748
9929
|
constructor(doc, playStateChangeListener) {
|
|
9749
9930
|
__publicField(this, "player");
|
|
9750
9931
|
assertArg3(doc instanceof MDocument2, "doc", doc);
|
|
9751
|
-
assertArg3(
|
|
9932
|
+
assertArg3(import_ts_utils_lib35.Guard.isFunctionOrUndefined(playStateChangeListener), "playStateChangeListener", playStateChangeListener);
|
|
9752
9933
|
this.player = new Player();
|
|
9753
9934
|
this.player.setDocument(doc.getMusicObject());
|
|
9754
9935
|
this.player.setCursorPositionChangeListener((cursorRect) => {
|
|
@@ -9792,7 +9973,7 @@ var _MPlayer = class _MPlayer {
|
|
|
9792
9973
|
return this;
|
|
9793
9974
|
}
|
|
9794
9975
|
};
|
|
9795
|
-
__publicField(_MPlayer, "currentlyPlaying", new
|
|
9976
|
+
__publicField(_MPlayer, "currentlyPlaying", new import_ts_utils_lib35.ValueSet());
|
|
9796
9977
|
var MPlayer = _MPlayer;
|
|
9797
9978
|
var MRenderContext2 = class {
|
|
9798
9979
|
/**
|
|
@@ -9808,7 +9989,7 @@ var MRenderContext2 = class {
|
|
|
9808
9989
|
* @returns - This render context instance.
|
|
9809
9990
|
*/
|
|
9810
9991
|
setDocument(doc) {
|
|
9811
|
-
assertArg3(
|
|
9992
|
+
assertArg3(import_ts_utils_lib35.Guard.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
|
|
9812
9993
|
this.ctx.setDocument(doc);
|
|
9813
9994
|
return this;
|
|
9814
9995
|
}
|
|
@@ -9818,7 +9999,7 @@ var MRenderContext2 = class {
|
|
|
9818
9999
|
* @returns - This render context instance.
|
|
9819
10000
|
*/
|
|
9820
10001
|
setCanvas(canvas) {
|
|
9821
|
-
canvas = require_t(
|
|
10002
|
+
canvas = require_t(import_ts_utils_lib35.Utils.Dom.getCanvas(canvas), typeof canvas === "string" ? "Cannot set render canvas because invalid canvas id: " + canvas : "Cannot set render canvas because given canvas is undefined.");
|
|
9822
10003
|
this.ctx.setCanvas(canvas);
|
|
9823
10004
|
return this;
|
|
9824
10005
|
}
|
|
@@ -9827,7 +10008,7 @@ var MRenderContext2 = class {
|
|
|
9827
10008
|
* @param scoreEventListener - Score event listener.
|
|
9828
10009
|
*/
|
|
9829
10010
|
setScoreEventListener(scoreEventListener) {
|
|
9830
|
-
assertArg3(
|
|
10011
|
+
assertArg3(import_ts_utils_lib35.Guard.isFunctionOrUndefined(scoreEventListener), "scoreEventListener", scoreEventListener);
|
|
9831
10012
|
this.ctx.setScoreEventListener(scoreEventListener);
|
|
9832
10013
|
}
|
|
9833
10014
|
/**
|
|
@@ -9902,7 +10083,7 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
9902
10083
|
* @returns
|
|
9903
10084
|
*/
|
|
9904
10085
|
setDocument(doc) {
|
|
9905
|
-
assertArg3(
|
|
10086
|
+
assertArg3(import_ts_utils_lib35.Guard.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
|
|
9906
10087
|
this.onStop();
|
|
9907
10088
|
if (doc) {
|
|
9908
10089
|
this.player = new MPlayer(doc, (playState) => {
|
|
@@ -9946,9 +10127,9 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
9946
10127
|
* @returns - This playback buttons class instance.
|
|
9947
10128
|
*/
|
|
9948
10129
|
setPlayButton(btn, btnLabel) {
|
|
9949
|
-
assertArg3(
|
|
10130
|
+
assertArg3(import_ts_utils_lib35.Guard.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
|
|
9950
10131
|
_MPlaybackButtons.removeOnClickListeners(this.playButton, this.onPlay);
|
|
9951
|
-
this.playButton = require_t(
|
|
10132
|
+
this.playButton = require_t(import_ts_utils_lib35.Utils.Dom.getButton(btn), "Play button required!");
|
|
9952
10133
|
this.playLabel = btnLabel != null ? btnLabel : "Play";
|
|
9953
10134
|
_MPlaybackButtons.removeOnClickListeners(this.playButton, "all");
|
|
9954
10135
|
_MPlaybackButtons.addOnClickListener(this.playButton, this.onPlay);
|
|
@@ -9962,9 +10143,9 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
9962
10143
|
* @returns - This playback buttons class instance.
|
|
9963
10144
|
*/
|
|
9964
10145
|
setStopButton(btn, btnLabel) {
|
|
9965
|
-
assertArg3(
|
|
10146
|
+
assertArg3(import_ts_utils_lib35.Guard.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
|
|
9966
10147
|
_MPlaybackButtons.removeOnClickListeners(this.stopButton, this.onStop);
|
|
9967
|
-
this.stopButton = require_t(
|
|
10148
|
+
this.stopButton = require_t(import_ts_utils_lib35.Utils.Dom.getButton(btn), "Stop button required!");
|
|
9968
10149
|
this.stopLabel = btnLabel != null ? btnLabel : "Stop";
|
|
9969
10150
|
_MPlaybackButtons.removeOnClickListeners(this.stopButton, "all");
|
|
9970
10151
|
_MPlaybackButtons.addOnClickListener(this.stopButton, this.onStop);
|
|
@@ -9979,10 +10160,10 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
9979
10160
|
* @returns - This playback buttons class instance.
|
|
9980
10161
|
*/
|
|
9981
10162
|
setPlayStopButton(btn, playLabel, stopLabel) {
|
|
9982
|
-
assertArg3(
|
|
9983
|
-
assertArg3(
|
|
10163
|
+
assertArg3(import_ts_utils_lib35.Guard.isStringOrUndefined(playLabel), "playLabel", playLabel);
|
|
10164
|
+
assertArg3(import_ts_utils_lib35.Guard.isStringOrUndefined(stopLabel), "stopLabel", stopLabel);
|
|
9984
10165
|
_MPlaybackButtons.removeOnClickListeners(this.playStopButton, this.onPlayStop);
|
|
9985
|
-
this.playStopButton = require_t(
|
|
10166
|
+
this.playStopButton = require_t(import_ts_utils_lib35.Utils.Dom.getButton(btn), "Play/stop button required!");
|
|
9986
10167
|
this.playLabel = playLabel != null ? playLabel : "Play";
|
|
9987
10168
|
this.stopLabel = stopLabel != null ? stopLabel : "Stop";
|
|
9988
10169
|
_MPlaybackButtons.removeOnClickListeners(this.playStopButton, "all");
|
|
@@ -9997,9 +10178,9 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
9997
10178
|
* @returns - This playback buttons class instance.
|
|
9998
10179
|
*/
|
|
9999
10180
|
setPauseButton(btn, btnLabel) {
|
|
10000
|
-
assertArg3(
|
|
10181
|
+
assertArg3(import_ts_utils_lib35.Guard.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
|
|
10001
10182
|
_MPlaybackButtons.removeOnClickListeners(this.pauseButton, this.onPause);
|
|
10002
|
-
this.pauseButton = require_t(
|
|
10183
|
+
this.pauseButton = require_t(import_ts_utils_lib35.Utils.Dom.getButton(btn), "Pause button required!");
|
|
10003
10184
|
this.pauseLabel = btnLabel != null ? btnLabel : "Pause";
|
|
10004
10185
|
_MPlaybackButtons.removeOnClickListeners(this.pauseButton, "all");
|
|
10005
10186
|
_MPlaybackButtons.addOnClickListener(this.pauseButton, this.onPause);
|
|
@@ -10020,12 +10201,12 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
10020
10201
|
this.savedOnClickListeners.set(btn, curListeners);
|
|
10021
10202
|
}
|
|
10022
10203
|
static addOnClickListener(btn, onClickListener) {
|
|
10023
|
-
assertArg3(
|
|
10204
|
+
assertArg3(import_ts_utils_lib35.Guard.isFunction(onClickListener), "onClick", onClickListener);
|
|
10024
10205
|
btn.addEventListener("click", onClickListener);
|
|
10025
10206
|
this.savedOnClickListeners.getOrCreate(btn, []).push(onClickListener);
|
|
10026
10207
|
}
|
|
10027
10208
|
};
|
|
10028
|
-
__publicField(_MPlaybackButtons, "savedOnClickListeners", new
|
|
10209
|
+
__publicField(_MPlaybackButtons, "savedOnClickListeners", new import_ts_utils_lib35.UniMap());
|
|
10029
10210
|
var MPlaybackButtons = _MPlaybackButtons;
|
|
10030
10211
|
|
|
10031
10212
|
// src/score/index.ts
|
|
@@ -10066,13 +10247,14 @@ var import_core22 = require("@tspro/web-music-score/core");
|
|
|
10066
10247
|
MRest,
|
|
10067
10248
|
MRhythmColumn,
|
|
10068
10249
|
MScoreRow,
|
|
10250
|
+
MScoreRowGroup,
|
|
10069
10251
|
MSpecialText,
|
|
10070
10252
|
MStaff,
|
|
10253
|
+
MStaffBarLine,
|
|
10071
10254
|
MStaffBeamGroup,
|
|
10072
10255
|
MStaffNoteGroup,
|
|
10073
10256
|
MStaffRest,
|
|
10074
10257
|
MStaffSignature,
|
|
10075
|
-
MStaffTabBarLine,
|
|
10076
10258
|
MTab,
|
|
10077
10259
|
MTabNoteGroup,
|
|
10078
10260
|
MTabRhythm,
|