@tspro/web-music-score 3.0.1 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -1
- package/README.md +63 -20
- package/dist/audio/index.d.mts +1 -8
- package/dist/audio/index.d.ts +1 -8
- package/dist/audio/index.js +1 -1
- package/dist/audio/index.mjs +2 -2
- package/dist/audio-cg/index.d.mts +0 -1
- package/dist/audio-cg/index.d.ts +0 -1
- package/dist/audio-cg/index.js +1 -1
- package/dist/audio-cg/index.mjs +2 -2
- package/dist/{chunk-4AS76G4O.mjs → chunk-PU4J7K4Z.mjs} +2 -2
- package/dist/core/index.d.mts +0 -3
- package/dist/core/index.d.ts +0 -3
- package/dist/core/index.js +2 -2
- package/dist/core/index.mjs +3 -3
- package/dist/{guitar-BIFwFT31.d.ts → guitar-C2Cp71NZ.d.ts} +1 -8
- package/dist/{guitar-zASF7B1g.d.mts → guitar-DggbM2UL.d.mts} +1 -8
- package/dist/iife/index.global.js +11 -11
- package/dist/{interface-DkUnsAjj.d.mts → interface-Bz_525zj.d.mts} +94 -104
- package/dist/{interface-1TQHxSpb.d.ts → interface-Fn8ufBQx.d.ts} +94 -104
- package/dist/{note-B5ZtlHc8.d.mts → note-BFa43I86.d.mts} +0 -14
- package/dist/{note-B5ZtlHc8.d.ts → note-BFa43I86.d.ts} +0 -14
- package/dist/pieces/index.d.mts +3 -6
- package/dist/pieces/index.d.ts +3 -6
- package/dist/pieces/index.js +1 -1
- package/dist/pieces/index.mjs +2 -2
- package/dist/react-ui/index.d.mts +5 -23
- package/dist/react-ui/index.d.ts +5 -23
- package/dist/react-ui/index.js +1 -1
- package/dist/react-ui/index.mjs +2 -2
- package/dist/{scale-B_2MZaT9.d.ts → scale-DRR-t4Kr.d.mts} +2 -15
- package/dist/{scale-C-YS5iVG.d.mts → scale-ebJm37q1.d.ts} +2 -15
- package/dist/score/index.d.mts +32 -8
- package/dist/score/index.d.ts +32 -8
- package/dist/score/index.js +919 -675
- package/dist/score/index.mjs +893 -650
- package/dist/{tempo-TjQKn46X.d.mts → tempo-B4h5Ktob.d.mts} +1 -17
- package/dist/{tempo-DoJd-UYT.d.ts → tempo-DgqDEsn0.d.ts} +1 -17
- package/dist/theory/index.d.mts +6 -8
- package/dist/theory/index.d.ts +6 -8
- package/dist/theory/index.js +1 -1
- package/dist/theory/index.mjs +2 -2
- package/package.json +1 -1
package/dist/score/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* WebMusicScore v3.
|
|
1
|
+
/* WebMusicScore v3.1.1 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -81,6 +81,7 @@ __export(score_exports, {
|
|
|
81
81
|
StaffPreset: () => StaffPreset,
|
|
82
82
|
Stem: () => Stem,
|
|
83
83
|
TieType: () => TieType,
|
|
84
|
+
VerticalPosition: () => VerticalPosition,
|
|
84
85
|
getStringNumbers: () => getStringNumbers,
|
|
85
86
|
getVoiceIds: () => getVoiceIds
|
|
86
87
|
});
|
|
@@ -413,6 +414,13 @@ var Connective = /* @__PURE__ */ ((Connective3) => {
|
|
|
413
414
|
Connective3[Connective3["Slide"] = 2] = "Slide";
|
|
414
415
|
return Connective3;
|
|
415
416
|
})(Connective || {});
|
|
417
|
+
var VerticalPosition = /* @__PURE__ */ ((VerticalPosition4) => {
|
|
418
|
+
VerticalPosition4[VerticalPosition4["Above"] = 0] = "Above";
|
|
419
|
+
VerticalPosition4[VerticalPosition4["Below"] = 1] = "Below";
|
|
420
|
+
VerticalPosition4[VerticalPosition4["Both"] = 2] = "Both";
|
|
421
|
+
VerticalPosition4[VerticalPosition4["Auto"] = 3] = "Auto";
|
|
422
|
+
return VerticalPosition4;
|
|
423
|
+
})(VerticalPosition || {});
|
|
416
424
|
var PlayState = /* @__PURE__ */ ((PlayState2) => {
|
|
417
425
|
PlayState2[PlayState2["Playing"] = 0] = "Playing";
|
|
418
426
|
PlayState2[PlayState2["Paused"] = 1] = "Paused";
|
|
@@ -527,7 +535,7 @@ var MusicObject = class {
|
|
|
527
535
|
var import_theory12 = require("@tspro/web-music-score/theory");
|
|
528
536
|
|
|
529
537
|
// src/score/engine/obj-staff-and-tab.ts
|
|
530
|
-
var
|
|
538
|
+
var import_theory11 = require("@tspro/web-music-score/theory");
|
|
531
539
|
|
|
532
540
|
// src/score/engine/renderer.ts
|
|
533
541
|
var import_ts_utils_lib2 = require("@tspro/ts-utils-lib");
|
|
@@ -945,260 +953,16 @@ var Renderer = class {
|
|
|
945
953
|
};
|
|
946
954
|
|
|
947
955
|
// src/score/engine/obj-staff-and-tab.ts
|
|
948
|
-
var
|
|
949
|
-
var
|
|
950
|
-
var ObjStaff = class extends MusicObject {
|
|
951
|
-
constructor(row, staffConfig) {
|
|
952
|
-
super(row);
|
|
953
|
-
this.row = row;
|
|
954
|
-
this.staffConfig = staffConfig;
|
|
955
|
-
__publicField(this, "clefImageAsset");
|
|
956
|
-
__publicField(this, "clefLineDiatonicId");
|
|
957
|
-
__publicField(this, "topLineDiatonicId");
|
|
958
|
-
__publicField(this, "middleLineDiatonicId");
|
|
959
|
-
__publicField(this, "bottomLineDiatonicId");
|
|
960
|
-
__publicField(this, "minDiatonicId");
|
|
961
|
-
__publicField(this, "maxDiatonicId");
|
|
962
|
-
__publicField(this, "joinedGrandStaff");
|
|
963
|
-
__publicField(this, "topLineY", 0);
|
|
964
|
-
__publicField(this, "bottomLineY", 0);
|
|
965
|
-
__publicField(this, "objects", []);
|
|
966
|
-
__publicField(this, "mi");
|
|
967
|
-
const getDiatonicId = (noteName, isOctaveDown) => import_theory.Note.getNote(noteName).diatonicId - (isOctaveDown ? 7 : 0);
|
|
968
|
-
if (staffConfig.clef === "G" /* G */) {
|
|
969
|
-
this.clefImageAsset = 0 /* TrebleClefPng */;
|
|
970
|
-
this.clefLineDiatonicId = getDiatonicId("G4", staffConfig.isOctaveDown === true);
|
|
971
|
-
this.middleLineDiatonicId = this.clefLineDiatonicId + 2;
|
|
972
|
-
} else {
|
|
973
|
-
this.clefImageAsset = 1 /* BassClefPng */;
|
|
974
|
-
this.clefLineDiatonicId = getDiatonicId("F3", staffConfig.isOctaveDown === true);
|
|
975
|
-
this.middleLineDiatonicId = this.clefLineDiatonicId - 2;
|
|
976
|
-
}
|
|
977
|
-
this.topLineDiatonicId = this.middleLineDiatonicId + 4;
|
|
978
|
-
this.bottomLineDiatonicId = this.middleLineDiatonicId - 4;
|
|
979
|
-
this.minDiatonicId = staffConfig.minNote !== void 0 ? Math.min(getDiatonicId(staffConfig.minNote, false), this.bottomLineDiatonicId) : void 0;
|
|
980
|
-
this.maxDiatonicId = staffConfig.maxNote !== void 0 ? Math.max(getDiatonicId(staffConfig.maxNote, false), this.topLineDiatonicId) : void 0;
|
|
981
|
-
this.mi = new MStaff(this);
|
|
982
|
-
}
|
|
983
|
-
getMusicInterface() {
|
|
984
|
-
return this.mi;
|
|
985
|
-
}
|
|
986
|
-
get isOctaveDown() {
|
|
987
|
-
return this.staffConfig.isOctaveDown === true;
|
|
988
|
-
}
|
|
989
|
-
getTopLineY() {
|
|
990
|
-
return this.topLineY;
|
|
991
|
-
}
|
|
992
|
-
getMiddleLineY() {
|
|
993
|
-
return (this.topLineY + this.bottomLineY) / 2;
|
|
994
|
-
}
|
|
995
|
-
getBottomLineY() {
|
|
996
|
-
return this.bottomLineY;
|
|
997
|
-
}
|
|
998
|
-
joinGrandStaff(staff) {
|
|
999
|
-
if (staff !== this) {
|
|
1000
|
-
this.joinedGrandStaff = staff;
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
getLineSpacing() {
|
|
1004
|
-
return (this.bottomLineY - this.topLineY) / 4;
|
|
1005
|
-
}
|
|
1006
|
-
getDiatonicSpacing() {
|
|
1007
|
-
return this.getLineSpacing() / 2;
|
|
1008
|
-
}
|
|
1009
|
-
containsDiatonicId(diatonicId) {
|
|
1010
|
-
import_theory.Note.validateDiatonicId(diatonicId);
|
|
1011
|
-
return (this.minDiatonicId === void 0 || diatonicId >= this.minDiatonicId) && (this.maxDiatonicId === void 0 || diatonicId <= this.maxDiatonicId);
|
|
1012
|
-
}
|
|
1013
|
-
getDiatonicIdY(diatonicId) {
|
|
1014
|
-
if (this.containsDiatonicId(diatonicId)) {
|
|
1015
|
-
return this.bottomLineY + (this.bottomLineDiatonicId - diatonicId) * this.getDiatonicSpacing();
|
|
1016
|
-
} else if (this.joinedGrandStaff && this.joinedGrandStaff.containsDiatonicId(diatonicId)) {
|
|
1017
|
-
return this.joinedGrandStaff.getDiatonicIdY(diatonicId);
|
|
1018
|
-
} else {
|
|
1019
|
-
throw new import_core3.MusicError(import_core3.MusicErrorType.Score, "Staff does not contain diatonicId " + diatonicId);
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
getActualStaff(diatonicId) {
|
|
1023
|
-
if (this.containsDiatonicId(diatonicId)) {
|
|
1024
|
-
return this;
|
|
1025
|
-
} else if (this.joinedGrandStaff && this.joinedGrandStaff.containsDiatonicId(diatonicId)) {
|
|
1026
|
-
return this.joinedGrandStaff;
|
|
1027
|
-
} else {
|
|
1028
|
-
throw new import_core3.MusicError(import_core3.MusicErrorType.Score, "Staff does not contain diatonicId " + diatonicId);
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
getDiatonicIdAt(y) {
|
|
1032
|
-
let diatonicId = Math.round(this.bottomLineDiatonicId - (y - this.bottomLineY) / this.getDiatonicSpacing());
|
|
1033
|
-
return this.containsDiatonicId(diatonicId) ? diatonicId : void 0;
|
|
1034
|
-
}
|
|
1035
|
-
isLine(diatonicId) {
|
|
1036
|
-
return diatonicId % 2 === this.middleLineDiatonicId % 2;
|
|
1037
|
-
}
|
|
1038
|
-
isSpace(diatonicId) {
|
|
1039
|
-
return diatonicId % 2 !== this.middleLineDiatonicId % 2;
|
|
1040
|
-
}
|
|
1041
|
-
containsVoiceId(voiceId) {
|
|
1042
|
-
return !this.staffConfig.voiceIds || this.staffConfig.voiceIds.includes(voiceId);
|
|
1043
|
-
}
|
|
1044
|
-
isGrand() {
|
|
1045
|
-
return this.staffConfig.isGrand === true;
|
|
1046
|
-
}
|
|
1047
|
-
calcTop() {
|
|
1048
|
-
let top = this.topLineY;
|
|
1049
|
-
this.objects.forEach((o) => top = Math.min(top, o.getRect().top));
|
|
1050
|
-
if (this.maxDiatonicId !== void 0) {
|
|
1051
|
-
let y = this.getDiatonicIdY(this.maxDiatonicId);
|
|
1052
|
-
let y2 = this.getDiatonicIdY(this.maxDiatonicId - 1);
|
|
1053
|
-
top = Math.min(top, y - Math.abs(y2 - y) + 1);
|
|
1054
|
-
}
|
|
1055
|
-
return top;
|
|
1056
|
-
}
|
|
1057
|
-
calcBottom() {
|
|
1058
|
-
let bottom = this.bottomLineY;
|
|
1059
|
-
this.objects.forEach((o) => bottom = Math.max(bottom, o.getRect().bottom));
|
|
1060
|
-
if (this.minDiatonicId !== void 0) {
|
|
1061
|
-
let y = this.getDiatonicIdY(this.minDiatonicId);
|
|
1062
|
-
let y2 = this.getDiatonicIdY(this.minDiatonicId + 1);
|
|
1063
|
-
bottom = Math.max(bottom, y + Math.abs(y2 - y) - 1);
|
|
1064
|
-
}
|
|
1065
|
-
return bottom;
|
|
1066
|
-
}
|
|
1067
|
-
addObject(o) {
|
|
1068
|
-
this.objects.push(o);
|
|
1069
|
-
}
|
|
1070
|
-
removeObjects() {
|
|
1071
|
-
this.objects.length = 0;
|
|
1072
|
-
}
|
|
1073
|
-
pick(x, y) {
|
|
1074
|
-
return [this];
|
|
1075
|
-
}
|
|
1076
|
-
layoutHeight(renderer) {
|
|
1077
|
-
let { unitSize } = renderer;
|
|
1078
|
-
let h = unitSize * DocumentSettings.StaffHeight;
|
|
1079
|
-
this.topLineY = -h / 2;
|
|
1080
|
-
this.bottomLineY = h / 2;
|
|
1081
|
-
this.rect = new DivRect(0, 0, this.topLineY, this.bottomLineY);
|
|
1082
|
-
}
|
|
1083
|
-
layoutWidth(renderer) {
|
|
1084
|
-
this.rect.left = this.row.getRect().left;
|
|
1085
|
-
this.rect.right = this.row.getRect().right;
|
|
1086
|
-
}
|
|
1087
|
-
offset(dx, dy) {
|
|
1088
|
-
this.topLineY += dy;
|
|
1089
|
-
this.bottomLineY += dy;
|
|
1090
|
-
this.objects.forEach((o) => {
|
|
1091
|
-
if (o.offsetInPlace) {
|
|
1092
|
-
o.offsetInPlace(0, dy);
|
|
1093
|
-
} else if (o.offset) {
|
|
1094
|
-
o.offset(0, dy);
|
|
1095
|
-
}
|
|
1096
|
-
});
|
|
1097
|
-
this.rect.offsetInPlace(dx, dy);
|
|
1098
|
-
}
|
|
1099
|
-
draw(renderer) {
|
|
1100
|
-
}
|
|
1101
|
-
};
|
|
1102
|
-
var ObjTab = class extends MusicObject {
|
|
1103
|
-
constructor(row, tabConfig) {
|
|
1104
|
-
super(row);
|
|
1105
|
-
this.row = row;
|
|
1106
|
-
this.tabConfig = tabConfig;
|
|
1107
|
-
__publicField(this, "top", 0);
|
|
1108
|
-
__publicField(this, "bottom", 0);
|
|
1109
|
-
__publicField(this, "objects", []);
|
|
1110
|
-
__publicField(this, "tuningName");
|
|
1111
|
-
__publicField(this, "tuningStrings");
|
|
1112
|
-
__publicField(this, "mi");
|
|
1113
|
-
if (import_ts_utils_lib3.Utils.Is.isArray(tabConfig.tuning)) {
|
|
1114
|
-
this.tuningName = void 0;
|
|
1115
|
-
this.tuningStrings = tabConfig.tuning.map((noteName) => import_theory.Note.getNote(noteName)).reverse();
|
|
1116
|
-
} else if (typeof tabConfig.tuning === "string") {
|
|
1117
|
-
this.tuningName = (0, import_theory.validateTuningName)(tabConfig.tuning);
|
|
1118
|
-
this.tuningStrings = (0, import_theory.getTuningStrings)(this.tuningName);
|
|
1119
|
-
} else {
|
|
1120
|
-
this.tuningName = "Standard";
|
|
1121
|
-
this.tuningStrings = (0, import_theory.getTuningStrings)(this.tuningName);
|
|
1122
|
-
}
|
|
1123
|
-
this.mi = new MTab(this);
|
|
1124
|
-
}
|
|
1125
|
-
getMusicInterface() {
|
|
1126
|
-
return this.mi;
|
|
1127
|
-
}
|
|
1128
|
-
getTuningName() {
|
|
1129
|
-
return this.tuningName;
|
|
1130
|
-
}
|
|
1131
|
-
getTuningStrings() {
|
|
1132
|
-
return this.tuningStrings;
|
|
1133
|
-
}
|
|
1134
|
-
/** Return Y coordinate of string. */
|
|
1135
|
-
getStringY(stringId) {
|
|
1136
|
-
return this.top + (this.bottom - this.top) / 6 * (stringId + 0.5);
|
|
1137
|
-
}
|
|
1138
|
-
getTopStringY() {
|
|
1139
|
-
return this.getStringY(0);
|
|
1140
|
-
}
|
|
1141
|
-
getBottomStringY() {
|
|
1142
|
-
return this.getStringY(5);
|
|
1143
|
-
}
|
|
1144
|
-
getTop() {
|
|
1145
|
-
return this.top;
|
|
1146
|
-
}
|
|
1147
|
-
getBottom() {
|
|
1148
|
-
return this.bottom;
|
|
1149
|
-
}
|
|
1150
|
-
containsVoiceId(voiceId) {
|
|
1151
|
-
return !this.tabConfig.voiceIds || this.tabConfig.voiceIds.includes(voiceId);
|
|
1152
|
-
}
|
|
1153
|
-
calcTop() {
|
|
1154
|
-
return this.top;
|
|
1155
|
-
}
|
|
1156
|
-
calcBottom() {
|
|
1157
|
-
return this.bottom;
|
|
1158
|
-
}
|
|
1159
|
-
addObject(o) {
|
|
1160
|
-
this.objects.push(o);
|
|
1161
|
-
}
|
|
1162
|
-
removeObjects() {
|
|
1163
|
-
this.objects.length = 0;
|
|
1164
|
-
}
|
|
1165
|
-
pick(x, y) {
|
|
1166
|
-
return [this];
|
|
1167
|
-
}
|
|
1168
|
-
layoutHeight(renderer) {
|
|
1169
|
-
let { unitSize } = renderer;
|
|
1170
|
-
let h = unitSize * DocumentSettings.TabHeight;
|
|
1171
|
-
this.top = -h / 2;
|
|
1172
|
-
this.bottom = h / 2;
|
|
1173
|
-
this.rect = new DivRect(0, 0, this.top, this.bottom);
|
|
1174
|
-
}
|
|
1175
|
-
layoutWidth(renderer) {
|
|
1176
|
-
this.rect.left = this.row.getRect().left;
|
|
1177
|
-
this.rect.right = this.row.getRect().right;
|
|
1178
|
-
}
|
|
1179
|
-
offset(dx, dy) {
|
|
1180
|
-
this.top += dy;
|
|
1181
|
-
this.bottom += dy;
|
|
1182
|
-
this.objects.forEach((o) => {
|
|
1183
|
-
if (o.offsetInPlace) {
|
|
1184
|
-
o.offsetInPlace(0, dy);
|
|
1185
|
-
} else if (o.offset) {
|
|
1186
|
-
o.offset(0, dy);
|
|
1187
|
-
}
|
|
1188
|
-
});
|
|
1189
|
-
this.rect.offsetInPlace(dx, dy);
|
|
1190
|
-
}
|
|
1191
|
-
draw(renderer) {
|
|
1192
|
-
}
|
|
1193
|
-
};
|
|
956
|
+
var import_core15 = require("@tspro/web-music-score/core");
|
|
957
|
+
var import_ts_utils_lib9 = require("@tspro/ts-utils-lib");
|
|
1194
958
|
|
|
1195
959
|
// src/score/engine/obj-measure.ts
|
|
1196
|
-
var
|
|
960
|
+
var import_ts_utils_lib8 = require("@tspro/ts-utils-lib");
|
|
961
|
+
var import_theory9 = require("@tspro/web-music-score/theory");
|
|
1197
962
|
var import_theory10 = require("@tspro/web-music-score/theory");
|
|
1198
|
-
var import_theory11 = require("@tspro/web-music-score/theory");
|
|
1199
963
|
|
|
1200
964
|
// src/score/engine/acc-state.ts
|
|
1201
|
-
var
|
|
965
|
+
var import_theory = require("@tspro/web-music-score/theory");
|
|
1202
966
|
var AccidentalState = class {
|
|
1203
967
|
constructor(measure) {
|
|
1204
968
|
this.measure = measure;
|
|
@@ -1206,7 +970,7 @@ var AccidentalState = class {
|
|
|
1206
970
|
}
|
|
1207
971
|
getAccidentalFromKeySignature(diatonicId) {
|
|
1208
972
|
let ks = this.measure.getKeySignature();
|
|
1209
|
-
let accNote = ks.getOrderedAccidentalNotes().find((accNote2) => accNote2.diatonicClass ===
|
|
973
|
+
let accNote = ks.getOrderedAccidentalNotes().find((accNote2) => accNote2.diatonicClass === import_theory.Note.getDiatonicClass(diatonicId));
|
|
1210
974
|
return accNote ? accNote.accidental : void 0;
|
|
1211
975
|
}
|
|
1212
976
|
setAccidental(note) {
|
|
@@ -1220,7 +984,7 @@ var AccidentalState = class {
|
|
|
1220
984
|
};
|
|
1221
985
|
|
|
1222
986
|
// src/score/engine/obj-signature.ts
|
|
1223
|
-
var
|
|
987
|
+
var import_theory2 = require("@tspro/web-music-score/theory");
|
|
1224
988
|
|
|
1225
989
|
// src/score/engine/obj-image.ts
|
|
1226
990
|
var ObjImage = class extends MusicObject {
|
|
@@ -1268,7 +1032,7 @@ var ObjImage = class extends MusicObject {
|
|
|
1268
1032
|
};
|
|
1269
1033
|
|
|
1270
1034
|
// src/score/engine/obj-accidental.ts
|
|
1271
|
-
var
|
|
1035
|
+
var import_core3 = require("@tspro/web-music-score/core");
|
|
1272
1036
|
var ObjAccidental = class extends MusicObject {
|
|
1273
1037
|
constructor(parent, diatonicId, accidental, color = "black") {
|
|
1274
1038
|
super(parent);
|
|
@@ -1303,7 +1067,7 @@ var ObjAccidental = class extends MusicObject {
|
|
|
1303
1067
|
this.rect = DivRect.createSections(unitSize * 1, unitSize * 1, unitSize * 1, unitSize * 1);
|
|
1304
1068
|
break;
|
|
1305
1069
|
default:
|
|
1306
|
-
throw new
|
|
1070
|
+
throw new import_core3.MusicError(import_core3.MusicErrorType.Score, "Invalid accidental value: " + this.accidental);
|
|
1307
1071
|
}
|
|
1308
1072
|
}
|
|
1309
1073
|
offset(dx, dy) {
|
|
@@ -1516,7 +1280,7 @@ var ObjText = class extends MusicObject {
|
|
|
1516
1280
|
};
|
|
1517
1281
|
|
|
1518
1282
|
// src/score/engine/obj-signature.ts
|
|
1519
|
-
var
|
|
1283
|
+
var import_core4 = require("@tspro/web-music-score/core");
|
|
1520
1284
|
var ObjSignature = class extends MusicObject {
|
|
1521
1285
|
constructor(measure, staff) {
|
|
1522
1286
|
super(measure);
|
|
@@ -1561,7 +1325,7 @@ var ObjSignature = class extends MusicObject {
|
|
|
1561
1325
|
let newKeySignature = measure.getKeySignature();
|
|
1562
1326
|
this.ksNeutralizeAccidentals = [];
|
|
1563
1327
|
this.ksNewAccidentals = [];
|
|
1564
|
-
if (prevKeySignature && !
|
|
1328
|
+
if (prevKeySignature && !import_theory2.KeySignature.equals(newKeySignature, prevKeySignature)) {
|
|
1565
1329
|
prevKeySignature.getOrderedAccidentalNotes().forEach((accNote) => {
|
|
1566
1330
|
this.ksNeutralizeAccidentals.push(new ObjAccidental(this, this.getAccidentalDiatonicId(accNote), 0));
|
|
1567
1331
|
});
|
|
@@ -1587,7 +1351,7 @@ var ObjSignature = class extends MusicObject {
|
|
|
1587
1351
|
}
|
|
1588
1352
|
updateTempo(showTempo) {
|
|
1589
1353
|
if (showTempo) {
|
|
1590
|
-
let tempoStr = (0,
|
|
1354
|
+
let tempoStr = (0, import_theory2.getTempoString)(this.measure.getTempo());
|
|
1591
1355
|
this.tempoText = new ObjText(this, tempoStr, 0.5, 1);
|
|
1592
1356
|
} else {
|
|
1593
1357
|
this.tempoText = void 0;
|
|
@@ -1610,9 +1374,9 @@ var ObjSignature = class extends MusicObject {
|
|
|
1610
1374
|
}
|
|
1611
1375
|
}
|
|
1612
1376
|
if (bottomAccidentalDiatonicId !== void 0) {
|
|
1613
|
-
return
|
|
1377
|
+
return import_theory2.Note.findNextDiatonicIdAbove(accNote.diatonicId, bottomAccidentalDiatonicId, false);
|
|
1614
1378
|
} else {
|
|
1615
|
-
throw new
|
|
1379
|
+
throw new import_core4.MusicError(import_core4.MusicErrorType.Score, "Cannot get accidental diatonicId because note has no accidental.");
|
|
1616
1380
|
}
|
|
1617
1381
|
}
|
|
1618
1382
|
pick(x, y) {
|
|
@@ -1782,12 +1546,12 @@ var ObjSignature = class extends MusicObject {
|
|
|
1782
1546
|
};
|
|
1783
1547
|
|
|
1784
1548
|
// src/score/engine/player.ts
|
|
1785
|
-
var
|
|
1786
|
-
var
|
|
1549
|
+
var import_ts_utils_lib5 = require("@tspro/ts-utils-lib");
|
|
1550
|
+
var import_theory7 = require("@tspro/web-music-score/theory");
|
|
1787
1551
|
var Audio = __toESM(require("@tspro/web-music-score/audio"));
|
|
1788
1552
|
|
|
1789
1553
|
// src/score/engine/obj-rhythm-column.ts
|
|
1790
|
-
var
|
|
1554
|
+
var import_theory6 = require("@tspro/web-music-score/theory");
|
|
1791
1555
|
|
|
1792
1556
|
// src/score/engine/obj-arpeggio.ts
|
|
1793
1557
|
var ObjArpeggio = class extends MusicObject {
|
|
@@ -1814,8 +1578,8 @@ var ObjArpeggio = class extends MusicObject {
|
|
|
1814
1578
|
let { unitSize } = renderer;
|
|
1815
1579
|
this.topArrowHeight = this.arpeggioDir === 0 /* Up */ ? unitSize : 0;
|
|
1816
1580
|
this.bottomArrowHeight = this.arpeggioDir === 1 /* Down */ ? unitSize : 0;
|
|
1817
|
-
let top = this.line
|
|
1818
|
-
let bottom = this.line
|
|
1581
|
+
let top = this.line.getTopLineY();
|
|
1582
|
+
let bottom = this.line.getBottomLineY();
|
|
1819
1583
|
this.cycleHeight = unitSize * 2;
|
|
1820
1584
|
this.numCycles = Math.ceil((bottom - top) / this.cycleHeight) + 2;
|
|
1821
1585
|
let width = unitSize * 2;
|
|
@@ -1860,14 +1624,14 @@ var ObjArpeggio = class extends MusicObject {
|
|
|
1860
1624
|
};
|
|
1861
1625
|
|
|
1862
1626
|
// src/score/engine/obj-rest.ts
|
|
1863
|
-
var
|
|
1864
|
-
var
|
|
1627
|
+
var import_theory3 = require("@tspro/web-music-score/theory");
|
|
1628
|
+
var import_core5 = require("@tspro/web-music-score/core");
|
|
1865
1629
|
function getDiatonicIdFromStaffPos(staffPos) {
|
|
1866
1630
|
if (typeof staffPos === "number") {
|
|
1867
|
-
return
|
|
1631
|
+
return import_theory3.Note.getChromaticNote(staffPos).diatonicId;
|
|
1868
1632
|
} else if (typeof staffPos === "string") {
|
|
1869
|
-
return
|
|
1870
|
-
} else if (staffPos instanceof
|
|
1633
|
+
return import_theory3.Note.getNote(staffPos).diatonicId;
|
|
1634
|
+
} else if (staffPos instanceof import_theory3.Note) {
|
|
1871
1635
|
return staffPos.diatonicId;
|
|
1872
1636
|
} else {
|
|
1873
1637
|
return void 0;
|
|
@@ -1923,7 +1687,7 @@ var ObjRest = class extends MusicObject {
|
|
|
1923
1687
|
let hasStaff = this.row.hasStaff;
|
|
1924
1688
|
let staff2 = this.row.getStaff(diatonicId);
|
|
1925
1689
|
if (hasStaff && !staff2) {
|
|
1926
|
-
throw new
|
|
1690
|
+
throw new import_core5.MusicError(import_core5.MusicErrorType.Score, "Rest staffPos is out of staff boundaries!");
|
|
1927
1691
|
}
|
|
1928
1692
|
}
|
|
1929
1693
|
this.ownDiatonicId = this.measure.updateOwnDiatonicId(voiceId, diatonicId);
|
|
@@ -1937,7 +1701,7 @@ var ObjRest = class extends MusicObject {
|
|
|
1937
1701
|
}
|
|
1938
1702
|
this.color = (_a = options == null ? void 0 : options.color) != null ? _a : "black";
|
|
1939
1703
|
this.hide = (_b = options == null ? void 0 : options.hide) != null ? _b : false;
|
|
1940
|
-
this.rhythmProps = new
|
|
1704
|
+
this.rhythmProps = new import_theory3.RhythmProps(noteLength, options == null ? void 0 : options.dotted, options == null ? void 0 : options.triplet);
|
|
1941
1705
|
this.mi = new MRest(this);
|
|
1942
1706
|
}
|
|
1943
1707
|
getMusicInterface() {
|
|
@@ -1964,6 +1728,15 @@ var ObjRest = class extends MusicObject {
|
|
|
1964
1728
|
get triplet() {
|
|
1965
1729
|
return this.rhythmProps.triplet;
|
|
1966
1730
|
}
|
|
1731
|
+
getStaticObjects(line) {
|
|
1732
|
+
let staticObjects = [];
|
|
1733
|
+
this.staffObjects.forEach((obj) => {
|
|
1734
|
+
if (obj.staff === line) {
|
|
1735
|
+
staticObjects.push(obj);
|
|
1736
|
+
}
|
|
1737
|
+
});
|
|
1738
|
+
return staticObjects;
|
|
1739
|
+
}
|
|
1967
1740
|
pick(x, y) {
|
|
1968
1741
|
if (!this.getRect().contains(x, y)) {
|
|
1969
1742
|
return [];
|
|
@@ -2002,22 +1775,22 @@ var ObjRest = class extends MusicObject {
|
|
|
2002
1775
|
}
|
|
2003
1776
|
getRestDotVerticalDisplacement(noteLength) {
|
|
2004
1777
|
switch (noteLength) {
|
|
2005
|
-
case
|
|
1778
|
+
case import_theory3.NoteLength.Whole:
|
|
2006
1779
|
return 1;
|
|
2007
|
-
case
|
|
1780
|
+
case import_theory3.NoteLength.Half:
|
|
2008
1781
|
return -1;
|
|
2009
|
-
case
|
|
1782
|
+
case import_theory3.NoteLength.Quarter:
|
|
2010
1783
|
return -1;
|
|
2011
|
-
case
|
|
1784
|
+
case import_theory3.NoteLength.Eighth:
|
|
2012
1785
|
return -1;
|
|
2013
|
-
case
|
|
1786
|
+
case import_theory3.NoteLength.Sixteenth:
|
|
2014
1787
|
return -1;
|
|
2015
|
-
case
|
|
1788
|
+
case import_theory3.NoteLength.ThirtySecond:
|
|
2016
1789
|
return -3;
|
|
2017
|
-
case
|
|
1790
|
+
case import_theory3.NoteLength.SixtyFourth:
|
|
2018
1791
|
return -3;
|
|
2019
1792
|
default:
|
|
2020
|
-
throw new
|
|
1793
|
+
throw new import_core5.MusicError(import_core5.MusicErrorType.Score, "Cannot get rest dot vertical displacement because note length is invalid.");
|
|
2021
1794
|
}
|
|
2022
1795
|
}
|
|
2023
1796
|
updateAccidentalState(accState) {
|
|
@@ -2035,17 +1808,17 @@ var ObjRest = class extends MusicObject {
|
|
|
2035
1808
|
let rightw = 0;
|
|
2036
1809
|
let toph = 0;
|
|
2037
1810
|
let bottomh = 0;
|
|
2038
|
-
if (noteLength ===
|
|
1811
|
+
if (noteLength === import_theory3.NoteLength.Whole) {
|
|
2039
1812
|
leftw = unitSize;
|
|
2040
1813
|
rightw = unitSize;
|
|
2041
1814
|
toph = 0;
|
|
2042
1815
|
bottomh = unitSize;
|
|
2043
|
-
} else if (noteLength ===
|
|
1816
|
+
} else if (noteLength === import_theory3.NoteLength.Half) {
|
|
2044
1817
|
leftw = unitSize;
|
|
2045
1818
|
rightw = unitSize;
|
|
2046
1819
|
toph = unitSize;
|
|
2047
1820
|
bottomh = 0;
|
|
2048
|
-
} else if (noteLength ===
|
|
1821
|
+
} else if (noteLength === import_theory3.NoteLength.Quarter) {
|
|
2049
1822
|
leftw = unitSize * 1;
|
|
2050
1823
|
rightw = unitSize * 1;
|
|
2051
1824
|
toph = unitSize * 3.2;
|
|
@@ -2104,11 +1877,11 @@ var ObjRest = class extends MusicObject {
|
|
|
2104
1877
|
let { dotRect, restRect } = obj;
|
|
2105
1878
|
let x = restRect.centerX;
|
|
2106
1879
|
let y = restRect.centerY;
|
|
2107
|
-
if (noteLength ===
|
|
1880
|
+
if (noteLength === import_theory3.NoteLength.Whole) {
|
|
2108
1881
|
ctx.fillRect(x - unitSize, y, unitSize * 2, unitSize);
|
|
2109
|
-
} else if (noteLength ===
|
|
1882
|
+
} else if (noteLength === import_theory3.NoteLength.Half) {
|
|
2110
1883
|
ctx.fillRect(x - unitSize, y - unitSize, unitSize * 2, unitSize);
|
|
2111
|
-
} else if (noteLength ===
|
|
1884
|
+
} else if (noteLength === import_theory3.NoteLength.Quarter) {
|
|
2112
1885
|
ctx.beginPath();
|
|
2113
1886
|
ctx.moveTo(x - unitSize * 0.6, y - unitSize * 3.2);
|
|
2114
1887
|
ctx.lineTo(x + unitSize * 0.7, y - unitSize * 1.5);
|
|
@@ -2174,13 +1947,13 @@ var ObjRest = class extends MusicObject {
|
|
|
2174
1947
|
};
|
|
2175
1948
|
|
|
2176
1949
|
// src/score/engine/obj-note-group.ts
|
|
2177
|
-
var import_ts_utils_lib5 = require("@tspro/ts-utils-lib");
|
|
2178
|
-
var import_theory6 = require("@tspro/web-music-score/theory");
|
|
2179
|
-
|
|
2180
|
-
// src/score/engine/obj-beam-group.ts
|
|
2181
1950
|
var import_ts_utils_lib4 = require("@tspro/ts-utils-lib");
|
|
2182
1951
|
var import_theory5 = require("@tspro/web-music-score/theory");
|
|
2183
|
-
|
|
1952
|
+
|
|
1953
|
+
// src/score/engine/obj-beam-group.ts
|
|
1954
|
+
var import_ts_utils_lib3 = require("@tspro/ts-utils-lib");
|
|
1955
|
+
var import_theory4 = require("@tspro/web-music-score/theory");
|
|
1956
|
+
var import_core6 = require("@tspro/web-music-score/core");
|
|
2184
1957
|
var adjustBeamAngle = (dx, dy) => {
|
|
2185
1958
|
let T = DocumentSettings.BeamAngleFactor;
|
|
2186
1959
|
if (!Number.isFinite(T) || T === 0) {
|
|
@@ -2257,19 +2030,19 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
|
|
|
2257
2030
|
__publicField(this, "staffObjects", []);
|
|
2258
2031
|
this.mi = new MBeamGroup(this);
|
|
2259
2032
|
if (!symbols.every((s) => s.measure === symbols[0].measure)) {
|
|
2260
|
-
throw new
|
|
2033
|
+
throw new import_core6.MusicError(import_core6.MusicErrorType.Score, "All beam group symbols are not in same measure.");
|
|
2261
2034
|
} else if (symbols.length < 2) {
|
|
2262
|
-
throw new
|
|
2035
|
+
throw new import_core6.MusicError(import_core6.MusicErrorType.Score, "Beam group need minimum 2 symbols, but " + symbols.length + " given.");
|
|
2263
2036
|
}
|
|
2264
2037
|
if (triplet) {
|
|
2265
2038
|
if (!symbols.every((s) => s.triplet)) {
|
|
2266
|
-
throw new
|
|
2039
|
+
throw new import_core6.MusicError(import_core6.MusicErrorType.Score, "Not every symbol's triplet property is true.");
|
|
2267
2040
|
}
|
|
2268
2041
|
let isGroup = symbols.length < 3 || symbols.some((s) => !(s instanceof ObjNoteGroup)) || symbols.some((s) => s.rhythmProps.flagCount !== symbols[0].rhythmProps.flagCount);
|
|
2269
2042
|
if (symbols.length === 3 && symbols[0] instanceof ObjNoteGroup && symbols[symbols.length - 1] instanceof ObjNoteGroup && symbols[0].rhythmProps.flagCount === symbols[symbols.length - 1].rhythmProps.flagCount) {
|
|
2270
2043
|
isGroup = false;
|
|
2271
2044
|
}
|
|
2272
|
-
if (symbols.some((s) => s.rhythmProps.noteLength >=
|
|
2045
|
+
if (symbols.some((s) => s.rhythmProps.noteLength >= import_theory4.NoteLength.Quarter)) {
|
|
2273
2046
|
isGroup = true;
|
|
2274
2047
|
}
|
|
2275
2048
|
this.type = isGroup ? 2 /* TripletGroup */ : 1 /* TripletBeam */;
|
|
@@ -2281,7 +2054,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
|
|
|
2281
2054
|
symbols.forEach((s) => s.setBeamGroup(this));
|
|
2282
2055
|
symbols[0].measure.addBeamGroup(this);
|
|
2283
2056
|
} else {
|
|
2284
|
-
throw new
|
|
2057
|
+
throw new import_core6.MusicError(import_core6.MusicErrorType.Score, "Cannot add beam group because some symbol already has one.");
|
|
2285
2058
|
}
|
|
2286
2059
|
}
|
|
2287
2060
|
static createBeam(noteGroups) {
|
|
@@ -2293,10 +2066,10 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
|
|
|
2293
2066
|
if (!symbols.every((s) => s.triplet)) {
|
|
2294
2067
|
return false;
|
|
2295
2068
|
}
|
|
2296
|
-
let MaxTripletNoteLenght =
|
|
2069
|
+
let MaxTripletNoteLenght = import_theory4.NoteLength.Half;
|
|
2297
2070
|
let len = symbols.map((s) => s.rhythmProps.noteLength);
|
|
2298
2071
|
if (symbols.length == 2) {
|
|
2299
|
-
if (len[0] <= MaxTripletNoteLenght && len[1] === len[0] / 2 && len[0] / 2 >=
|
|
2072
|
+
if (len[0] <= MaxTripletNoteLenght && len[1] === len[0] / 2 && len[0] / 2 >= import_theory4.MinNoteLength || len[1] <= MaxTripletNoteLenght && len[0] === len[1] / 2 && len[1] / 2 >= import_theory4.MinNoteLength) {
|
|
2300
2073
|
new _ObjBeamGroup(symbols, true);
|
|
2301
2074
|
return true;
|
|
2302
2075
|
}
|
|
@@ -2420,7 +2193,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
|
|
|
2420
2193
|
symbolY.forEach((symY, i) => {
|
|
2421
2194
|
let symX = symbolX[i];
|
|
2422
2195
|
if (symX !== void 0 && symY !== void 0) {
|
|
2423
|
-
let beamY =
|
|
2196
|
+
let beamY = import_ts_utils_lib3.Utils.Math.interpolateY(leftX, leftY, rightX, rightY, symX);
|
|
2424
2197
|
let raiseY = symY - beamY;
|
|
2425
2198
|
if (stemDir === 1 /* Up */ && raiseY < 0) {
|
|
2426
2199
|
raiseBeamY = Math.min(raiseBeamY, raiseY);
|
|
@@ -2435,8 +2208,8 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
|
|
|
2435
2208
|
let obj = new ObjStaffBeamGroup(mainStaff, this);
|
|
2436
2209
|
if (this.type === 2 /* TripletGroup */) {
|
|
2437
2210
|
let ef = unitSize / (rightX - leftX);
|
|
2438
|
-
let l =
|
|
2439
|
-
let r =
|
|
2211
|
+
let l = import_ts_utils_lib3.Utils.Math.interpolateCoord(leftX, leftY + groupLineDy, rightX, rightY + groupLineDy, -ef);
|
|
2212
|
+
let r = import_ts_utils_lib3.Utils.Math.interpolateCoord(leftX, leftY + groupLineDy, rightX, rightY + groupLineDy, 1 + ef);
|
|
2440
2213
|
obj.points.push(new BeamPoint(leftStaff, this, leftSymbol, l.x, l.y));
|
|
2441
2214
|
obj.points.push(new BeamPoint(rightStaff, this, rightSymbol, r.x, r.y));
|
|
2442
2215
|
obj.tripletNumberOffsetY = 0;
|
|
@@ -2494,7 +2267,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
|
|
|
2494
2267
|
obj.points.forEach((pt) => {
|
|
2495
2268
|
if (pt.symbol instanceof ObjNoteGroup) {
|
|
2496
2269
|
if (pt !== left && pt !== right) {
|
|
2497
|
-
pt.y =
|
|
2270
|
+
pt.y = import_ts_utils_lib3.Utils.Math.interpolateY(left.x, left.y, right.x, right.y, pt.x);
|
|
2498
2271
|
}
|
|
2499
2272
|
pt.symbol.setStemTipY(pt.staff, pt.y);
|
|
2500
2273
|
}
|
|
@@ -2519,8 +2292,8 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
|
|
|
2519
2292
|
let r = obj.points[obj.points.length - 1];
|
|
2520
2293
|
if (l && r) {
|
|
2521
2294
|
let tf = obj.tripletNumber ? obj.tripletNumber.getRect().width / (r.x - l.x) * 1.2 : 0;
|
|
2522
|
-
let lc =
|
|
2523
|
-
let rc =
|
|
2295
|
+
let lc = import_ts_utils_lib3.Utils.Math.interpolateCoord(l.x, l.y, r.x, r.y, 0.5 - tf / 2);
|
|
2296
|
+
let rc = import_ts_utils_lib3.Utils.Math.interpolateCoord(l.x, l.y, r.x, r.y, 0.5 + tf / 2);
|
|
2524
2297
|
let tipH = this.stemDir === 1 /* Up */ ? unitSize : -unitSize;
|
|
2525
2298
|
renderer.drawLine(l.x, l.y, lc.x, lc.y, color, lineWidth);
|
|
2526
2299
|
renderer.drawLine(rc.x, rc.y, r.x, r.y, color, lineWidth);
|
|
@@ -2563,13 +2336,13 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
|
|
|
2563
2336
|
};
|
|
2564
2337
|
|
|
2565
2338
|
// src/score/engine/obj-note-group.ts
|
|
2566
|
-
var
|
|
2339
|
+
var import_core7 = require("@tspro/web-music-score/core");
|
|
2567
2340
|
function sortNoteStringData(notes, strings) {
|
|
2568
|
-
let stringArr =
|
|
2341
|
+
let stringArr = import_ts_utils_lib4.Utils.Arr.isArray(strings) ? strings : strings !== void 0 ? [strings] : [];
|
|
2569
2342
|
let noteStringData = notes.map((note, i) => {
|
|
2570
2343
|
return { note, string: stringArr[i] };
|
|
2571
2344
|
});
|
|
2572
|
-
noteStringData =
|
|
2345
|
+
noteStringData = import_ts_utils_lib4.Utils.Arr.removeDuplicatesCmp(noteStringData, (a, b) => import_theory5.Note.equals(a.note, b.note)).sort((a, b) => import_theory5.Note.compareFunc(a.note, b.note));
|
|
2573
2346
|
return {
|
|
2574
2347
|
notes: noteStringData.map((e) => e.note),
|
|
2575
2348
|
strings: noteStringData.every((e) => e.string === void 0) ? void 0 : noteStringData.map((e) => e.string)
|
|
@@ -2683,8 +2456,8 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2683
2456
|
__publicField(this, "staffObjects", []);
|
|
2684
2457
|
__publicField(this, "tabObjects", []);
|
|
2685
2458
|
__publicField(this, "mi");
|
|
2686
|
-
if (!
|
|
2687
|
-
throw new
|
|
2459
|
+
if (!import_ts_utils_lib4.Utils.Is.isIntegerGte(notes.length, 1)) {
|
|
2460
|
+
throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Cannot create note group object because notes array is empty.");
|
|
2688
2461
|
}
|
|
2689
2462
|
let noteStringData = sortNoteStringData(notes, options == null ? void 0 : options.string);
|
|
2690
2463
|
this.notes = noteStringData.notes;
|
|
@@ -2697,7 +2470,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2697
2470
|
this.staccato = (_b = options == null ? void 0 : options.staccato) != null ? _b : false;
|
|
2698
2471
|
this.diamond = (_c = options == null ? void 0 : options.diamond) != null ? _c : false;
|
|
2699
2472
|
this.arpeggio = solveArpeggio(options == null ? void 0 : options.arpeggio);
|
|
2700
|
-
this.rhythmProps = new
|
|
2473
|
+
this.rhythmProps = new import_theory5.RhythmProps(noteLength, options == null ? void 0 : options.dotted, options == null ? void 0 : options.triplet);
|
|
2701
2474
|
this.mi = new MNoteGroup(this);
|
|
2702
2475
|
}
|
|
2703
2476
|
getMusicInterface() {
|
|
@@ -2723,13 +2496,27 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2723
2496
|
}
|
|
2724
2497
|
startConnective(connectiveProps) {
|
|
2725
2498
|
if (!this.row.hasStaff && connectiveProps.connective === 0 /* Tie */) {
|
|
2726
|
-
throw new
|
|
2499
|
+
throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Ties not implemented for guitar tabs alone, staff is required!");
|
|
2727
2500
|
} else if (!this.row.hasStaff && connectiveProps.connective === 1 /* Slur */) {
|
|
2728
|
-
throw new
|
|
2501
|
+
throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Slurs not implemented for guitar tabs alone, staff is required!");
|
|
2729
2502
|
}
|
|
2730
2503
|
this.startConnnectives.push(connectiveProps);
|
|
2731
2504
|
this.doc.addConnectiveProps(connectiveProps);
|
|
2732
2505
|
}
|
|
2506
|
+
getStaticObjects(line) {
|
|
2507
|
+
let staticObjects = [];
|
|
2508
|
+
this.staffObjects.forEach((obj) => {
|
|
2509
|
+
if (obj.staff === line) {
|
|
2510
|
+
staticObjects.push(obj);
|
|
2511
|
+
}
|
|
2512
|
+
});
|
|
2513
|
+
this.tabObjects.forEach((obj) => {
|
|
2514
|
+
if (obj.tab === line) {
|
|
2515
|
+
staticObjects.push(obj);
|
|
2516
|
+
}
|
|
2517
|
+
});
|
|
2518
|
+
return staticObjects;
|
|
2519
|
+
}
|
|
2733
2520
|
pick(x, y) {
|
|
2734
2521
|
if (!this.getRect().contains(x, y)) {
|
|
2735
2522
|
return [];
|
|
@@ -2758,7 +2545,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2758
2545
|
if (line instanceof ObjStaff) {
|
|
2759
2546
|
let staff = line;
|
|
2760
2547
|
if (noteIndex < 0 || noteIndex >= this.notes.length) {
|
|
2761
|
-
throw new
|
|
2548
|
+
throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Invalid noteIndex: " + noteIndex);
|
|
2762
2549
|
}
|
|
2763
2550
|
let obj = this.staffObjects.find((obj2) => obj2.staff === staff);
|
|
2764
2551
|
if (!obj || noteIndex < 0 || noteIndex >= obj.noteHeadRects.length) {
|
|
@@ -2806,7 +2593,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2806
2593
|
case 4 /* StemTip */:
|
|
2807
2594
|
return { x: centerX, y: stemTip.centerY + (stemDir === 1 /* Up */ ? -padding : padding) };
|
|
2808
2595
|
default:
|
|
2809
|
-
throw new
|
|
2596
|
+
throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Invalid noteAnchor: " + noteAnchor);
|
|
2810
2597
|
}
|
|
2811
2598
|
} else {
|
|
2812
2599
|
let tab = line;
|
|
@@ -2905,7 +2692,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2905
2692
|
getStemHeight(renderer) {
|
|
2906
2693
|
let { unitSize } = renderer;
|
|
2907
2694
|
let { noteLength, flagCount } = this.rhythmProps;
|
|
2908
|
-
if (noteLength >=
|
|
2695
|
+
if (noteLength >= import_theory5.NoteLength.Whole) {
|
|
2909
2696
|
return 0;
|
|
2910
2697
|
} else {
|
|
2911
2698
|
let addY = this.hasBeamCount() ? DocumentSettings.BeamSeparation : DocumentSettings.FlagSeparation;
|
|
@@ -2938,15 +2725,15 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2938
2725
|
return Math.max(this.rhythmProps.ticks, this.measure.getMeasureTicks() - this.col.positionTicks);
|
|
2939
2726
|
}
|
|
2940
2727
|
let prev = tieNoteGroups[j - 1];
|
|
2941
|
-
if (prev && prev.notes.some((n) =>
|
|
2728
|
+
if (prev && prev.notes.some((n) => import_theory5.Note.equals(n, note))) {
|
|
2942
2729
|
return 0;
|
|
2943
2730
|
}
|
|
2944
2731
|
tieNoteGroups = tieNoteGroups.slice(j);
|
|
2945
|
-
j = tieNoteGroups.findIndex((ng) => ng.notes.every((n) => !
|
|
2732
|
+
j = tieNoteGroups.findIndex((ng) => ng.notes.every((n) => !import_theory5.Note.equals(n, note)));
|
|
2946
2733
|
if (j >= 0) {
|
|
2947
2734
|
tieNoteGroups = tieNoteGroups.slice(0, j);
|
|
2948
2735
|
}
|
|
2949
|
-
return
|
|
2736
|
+
return import_ts_utils_lib4.Utils.Math.sum(tieNoteGroups.map((ng) => ng.rhythmProps.ticks));
|
|
2950
2737
|
});
|
|
2951
2738
|
return tiedTicks.length === 0 ? this.rhythmProps.ticks : Math.max(...tiedTicks);
|
|
2952
2739
|
}
|
|
@@ -3107,7 +2894,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
3107
2894
|
ctx.strokeStyle = ctx.fillStyle = color;
|
|
3108
2895
|
ctx.lineWidth = lineWidth;
|
|
3109
2896
|
obj.noteHeadRects.forEach((r) => {
|
|
3110
|
-
let outlinedNoteHead = noteLength >=
|
|
2897
|
+
let outlinedNoteHead = noteLength >= import_theory5.NoteLength.Half;
|
|
3111
2898
|
if (this.diamond) {
|
|
3112
2899
|
if (outlinedNoteHead) {
|
|
3113
2900
|
ctx.beginPath();
|
|
@@ -3238,7 +3025,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
3238
3025
|
}
|
|
3239
3026
|
});
|
|
3240
3027
|
} else {
|
|
3241
|
-
throw new
|
|
3028
|
+
throw new import_core7.MusicError(import_core7.MusicErrorType.Score, "Cannot set triplet beam count because triplet beam group type is invalid.");
|
|
3242
3029
|
}
|
|
3243
3030
|
}
|
|
3244
3031
|
getDotVerticalDisplacement(staff, diatonicId, stemDir) {
|
|
@@ -3264,9 +3051,9 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
3264
3051
|
};
|
|
3265
3052
|
|
|
3266
3053
|
// src/score/engine/obj-rhythm-column.ts
|
|
3267
|
-
var
|
|
3054
|
+
var import_core8 = require("@tspro/web-music-score/core");
|
|
3268
3055
|
var noteHeadDataCompareFunc = (a, b) => {
|
|
3269
|
-
let cmp =
|
|
3056
|
+
let cmp = import_theory6.Note.compareFunc(a.note, b.note);
|
|
3270
3057
|
if (cmp === 0) {
|
|
3271
3058
|
cmp = a.noteGroup.stemDir === b.noteGroup.stemDir ? 0 : a.noteGroup.stemDir === 1 /* Up */ ? 1 : -1;
|
|
3272
3059
|
}
|
|
@@ -3307,7 +3094,7 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3307
3094
|
if (colId >= 0 && colId < this.measure.getColumnCount()) {
|
|
3308
3095
|
return this.measure.getColumn(colId + 1);
|
|
3309
3096
|
} else {
|
|
3310
|
-
throw new
|
|
3097
|
+
throw new import_core8.MusicError(import_core8.MusicErrorType.Score, "Cannot get next column in measure because current column's id in mesure is invalid.");
|
|
3311
3098
|
}
|
|
3312
3099
|
}
|
|
3313
3100
|
/**
|
|
@@ -3334,6 +3121,22 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3334
3121
|
this.getRect();
|
|
3335
3122
|
return this.shapeRects;
|
|
3336
3123
|
}
|
|
3124
|
+
getStaticObjects(line) {
|
|
3125
|
+
let staticObjects = [];
|
|
3126
|
+
this.voiceSymbol.forEach((symbol) => {
|
|
3127
|
+
if (symbol) {
|
|
3128
|
+
symbol.getRect();
|
|
3129
|
+
symbol.getStaticObjects(line).forEach((obj) => staticObjects.push(obj));
|
|
3130
|
+
}
|
|
3131
|
+
});
|
|
3132
|
+
this.arpeggios.forEach((arpeggio) => {
|
|
3133
|
+
if (arpeggio.line === line) {
|
|
3134
|
+
arpeggio.getRect();
|
|
3135
|
+
staticObjects.push(arpeggio);
|
|
3136
|
+
}
|
|
3137
|
+
});
|
|
3138
|
+
return staticObjects;
|
|
3139
|
+
}
|
|
3337
3140
|
get doc() {
|
|
3338
3141
|
return this.measure.doc;
|
|
3339
3142
|
}
|
|
@@ -3371,7 +3174,7 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3371
3174
|
validateVoiceId(voiceId);
|
|
3372
3175
|
this.voiceSymbol[voiceId] = symbol;
|
|
3373
3176
|
if (symbol instanceof ObjRest) {
|
|
3374
|
-
if (!symbol.hide && symbol.noteLength >=
|
|
3177
|
+
if (!symbol.hide && symbol.noteLength >= import_theory6.NoteLength.Half) {
|
|
3375
3178
|
this.minDiatonicId = this.minDiatonicId === void 0 ? symbol.ownDiatonicId : Math.min(this.minDiatonicId, symbol.ownDiatonicId);
|
|
3376
3179
|
this.maxDiatonicId = this.maxDiatonicId === void 0 ? symbol.ownDiatonicId : Math.max(this.maxDiatonicId, symbol.ownDiatonicId);
|
|
3377
3180
|
}
|
|
@@ -3384,6 +3187,7 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3384
3187
|
this.setupNoteHeadDisplacements();
|
|
3385
3188
|
}
|
|
3386
3189
|
this.requestLayout();
|
|
3190
|
+
this.requestRectUpdate();
|
|
3387
3191
|
}
|
|
3388
3192
|
getVoiceSymbol(voiceId) {
|
|
3389
3193
|
return this.voiceSymbol[voiceId];
|
|
@@ -3392,11 +3196,11 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3392
3196
|
let maxNoteLength = Math.max(...this.voiceSymbol.map((s) => s.rhythmProps.noteLength));
|
|
3393
3197
|
let w = DocumentSettings.NoteHeadWidth;
|
|
3394
3198
|
switch (maxNoteLength) {
|
|
3395
|
-
case
|
|
3199
|
+
case import_theory6.NoteLength.Whole:
|
|
3396
3200
|
return w * 5;
|
|
3397
|
-
case
|
|
3201
|
+
case import_theory6.NoteLength.Half:
|
|
3398
3202
|
return w * 3;
|
|
3399
|
-
case
|
|
3203
|
+
case import_theory6.NoteLength.Quarter:
|
|
3400
3204
|
return w * 2;
|
|
3401
3205
|
default:
|
|
3402
3206
|
return w;
|
|
@@ -3438,7 +3242,7 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3438
3242
|
}
|
|
3439
3243
|
}
|
|
3440
3244
|
getNoteHeadDisplacement(noteGroup, note) {
|
|
3441
|
-
let data = this.noteHeadDisplacements.find((d) => d.noteGroup === noteGroup &&
|
|
3245
|
+
let data = this.noteHeadDisplacements.find((d) => d.noteGroup === noteGroup && import_theory6.Note.equals(d.note, note));
|
|
3442
3246
|
if ((data == null ? void 0 : data.displacement) !== void 0) {
|
|
3443
3247
|
return data.displacement;
|
|
3444
3248
|
} else {
|
|
@@ -3482,7 +3286,7 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3482
3286
|
});
|
|
3483
3287
|
}
|
|
3484
3288
|
});
|
|
3485
|
-
playerNotes.sort((a, b) =>
|
|
3289
|
+
playerNotes.sort((a, b) => import_theory6.Note.compareFunc(a.note, b.note));
|
|
3486
3290
|
if (this.hasArpeggio() && this.getArpeggioDir() === 1 /* Down */) {
|
|
3487
3291
|
playerNotes.reverse();
|
|
3488
3292
|
}
|
|
@@ -3498,6 +3302,7 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3498
3302
|
if (!this.needLayout) {
|
|
3499
3303
|
return;
|
|
3500
3304
|
}
|
|
3305
|
+
this.requestRectUpdate();
|
|
3501
3306
|
this.rect = new DivRect();
|
|
3502
3307
|
let { row } = this;
|
|
3503
3308
|
let { unitSize } = renderer;
|
|
@@ -3535,7 +3340,6 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3535
3340
|
this.rect.left = -leftw;
|
|
3536
3341
|
this.rect.centerX = 0;
|
|
3537
3342
|
this.rect.right = rightw;
|
|
3538
|
-
this.requestRectUpdate();
|
|
3539
3343
|
this.row.getStaves().forEach((staff) => {
|
|
3540
3344
|
let minDiatonicId = void 0;
|
|
3541
3345
|
let maxDiatonicId = void 0;
|
|
@@ -3730,7 +3534,7 @@ function isTempoText(text) {
|
|
|
3730
3534
|
}
|
|
3731
3535
|
|
|
3732
3536
|
// src/score/engine/extension.ts
|
|
3733
|
-
var
|
|
3537
|
+
var import_core9 = require("@tspro/web-music-score/core");
|
|
3734
3538
|
function getTextAnchorY(linePos) {
|
|
3735
3539
|
switch (linePos) {
|
|
3736
3540
|
case "bottom":
|
|
@@ -3766,7 +3570,7 @@ var Extension = class extends MusicObjectLink {
|
|
|
3766
3570
|
if (head instanceof ObjText) {
|
|
3767
3571
|
head.updateAnchorY(getTextAnchorY(linePos));
|
|
3768
3572
|
} else {
|
|
3769
|
-
throw new
|
|
3573
|
+
throw new import_core9.MusicError(import_core9.MusicErrorType.Score, "Update anchor's y-coordinate is only implemented for text objects.");
|
|
3770
3574
|
}
|
|
3771
3575
|
}
|
|
3772
3576
|
isVisible() {
|
|
@@ -3846,7 +3650,7 @@ var RitardandoSpeedDiv = 2;
|
|
|
3846
3650
|
var CrescendoVolumeAdd = 0.5;
|
|
3847
3651
|
var DiminuendoVolumeSub = 0.5;
|
|
3848
3652
|
function calcTicksDuration(ticks, tempo) {
|
|
3849
|
-
let beatTicks = new
|
|
3653
|
+
let beatTicks = new import_theory7.RhythmProps(tempo.options.beatLength, tempo.options.dotted).ticks;
|
|
3850
3654
|
let ticksPerMinute = tempo.beatsPerMinute * beatTicks;
|
|
3851
3655
|
return 60 * ticks / ticksPerMinute;
|
|
3852
3656
|
}
|
|
@@ -3902,8 +3706,8 @@ var PlayerColumnProps = class {
|
|
|
3902
3706
|
return this.speed;
|
|
3903
3707
|
}
|
|
3904
3708
|
getTempo() {
|
|
3905
|
-
let speed =
|
|
3906
|
-
return (0,
|
|
3709
|
+
let speed = import_ts_utils_lib5.Utils.Math.clamp(this.getSpeed(), 0.1, 10);
|
|
3710
|
+
return (0, import_theory7.alterTempoSpeed)(this.measure.getTempo(), speed);
|
|
3907
3711
|
}
|
|
3908
3712
|
setVolume(volume) {
|
|
3909
3713
|
this.volume = volume;
|
|
@@ -3927,7 +3731,7 @@ var PlayerColumnProps = class {
|
|
|
3927
3731
|
if (symbolsTicks.length === 0) {
|
|
3928
3732
|
return 0;
|
|
3929
3733
|
} else {
|
|
3930
|
-
return
|
|
3734
|
+
return import_ts_utils_lib5.Utils.Math.sum(symbolsTicks) / symbolsTicks.length;
|
|
3931
3735
|
}
|
|
3932
3736
|
}
|
|
3933
3737
|
}
|
|
@@ -4075,7 +3879,7 @@ var Player = class _Player {
|
|
|
4075
3879
|
} else if (layoutObj.musicObj.getLink() instanceof Extension) {
|
|
4076
3880
|
let extension = layoutObj.musicObj.getLink();
|
|
4077
3881
|
let { columnRange, extensionBreakText } = extension.getExtensionRangeInfo();
|
|
4078
|
-
let totalTicks =
|
|
3882
|
+
let totalTicks = import_ts_utils_lib5.Utils.Math.sum(columnRange.map((c) => c.getTicksToNextColumn()));
|
|
4079
3883
|
switch (text) {
|
|
4080
3884
|
case "accel." /* accel */: {
|
|
4081
3885
|
let startSpeed = curSpeed;
|
|
@@ -4129,11 +3933,11 @@ var Player = class _Player {
|
|
|
4129
3933
|
});
|
|
4130
3934
|
let speedArr = (_a = speedMap.get(col)) != null ? _a : [];
|
|
4131
3935
|
if (speedArr.length > 0) {
|
|
4132
|
-
curSpeed =
|
|
3936
|
+
curSpeed = import_ts_utils_lib5.Utils.Math.sum(speedArr) / speedArr.length;
|
|
4133
3937
|
}
|
|
4134
3938
|
let volumeArr = (_b = volumeMap.get(col)) != null ? _b : [];
|
|
4135
3939
|
if (volumeArr.length > 0) {
|
|
4136
|
-
curVolume =
|
|
3940
|
+
curVolume = import_ts_utils_lib5.Utils.Math.sum(volumeArr) / volumeArr.length;
|
|
4137
3941
|
}
|
|
4138
3942
|
col.getPlayerProps().setSpeed(curSpeed);
|
|
4139
3943
|
col.getPlayerProps().setVolume(curVolume);
|
|
@@ -4171,11 +3975,11 @@ var Player = class _Player {
|
|
|
4171
3975
|
} else {
|
|
4172
3976
|
let playerNotes = col.getPlayerNotes();
|
|
4173
3977
|
playerNotes.forEach((note, i) => {
|
|
4174
|
-
let arpeggioDelayTicks = col.hasArpeggio() ?
|
|
3978
|
+
let arpeggioDelayTicks = col.hasArpeggio() ? import_theory7.NoteLength.ThirtySecond * i : 0;
|
|
4175
3979
|
let noteSeconds = getDuration(note.ticks + fermataHoldTicks - arpeggioDelayTicks, tempo);
|
|
4176
3980
|
if (noteSeconds > 0) {
|
|
4177
3981
|
if (note.staccato) {
|
|
4178
|
-
noteSeconds = Math.min(getDuration(
|
|
3982
|
+
noteSeconds = Math.min(getDuration(import_theory7.NoteLength.Eighth, tempo) / 2, noteSeconds / 2);
|
|
4179
3983
|
}
|
|
4180
3984
|
let volume = adjustVolume(col.getPlayerProps().getVolume());
|
|
4181
3985
|
if (note.slur === "slurred") {
|
|
@@ -4325,14 +4129,12 @@ var ObjBarLine = class extends MusicObject {
|
|
|
4325
4129
|
if (line instanceof ObjStaff) {
|
|
4326
4130
|
lineCenterY = line.getMiddleLineY();
|
|
4327
4131
|
lineDotOff = line.getDiatonicSpacing();
|
|
4328
|
-
top = line.getTopLineY();
|
|
4329
|
-
bottom = line.getBottomLineY();
|
|
4330
4132
|
} else {
|
|
4331
|
-
lineCenterY = (line.
|
|
4332
|
-
lineDotOff = (line.
|
|
4333
|
-
top = line.getTopStringY();
|
|
4334
|
-
bottom = line.getBottomStringY();
|
|
4133
|
+
lineCenterY = (line.getBottomLineY() + line.getTopLineY()) / 2;
|
|
4134
|
+
lineDotOff = (line.getBottomLineY() - line.getTopLineY()) / 6;
|
|
4335
4135
|
}
|
|
4136
|
+
top = line.getTopLineY();
|
|
4137
|
+
bottom = line.getBottomLineY();
|
|
4336
4138
|
switch (barLineType) {
|
|
4337
4139
|
case 0 /* None */:
|
|
4338
4140
|
obj.setRect(new DivRect(0, 0, 0, top, 0, bottom));
|
|
@@ -4464,8 +4266,8 @@ var ObjBarLineRight = class extends ObjBarLine {
|
|
|
4464
4266
|
};
|
|
4465
4267
|
|
|
4466
4268
|
// src/score/engine/obj-ending.ts
|
|
4467
|
-
var
|
|
4468
|
-
var
|
|
4269
|
+
var import_ts_utils_lib6 = require("@tspro/ts-utils-lib");
|
|
4270
|
+
var import_core10 = require("@tspro/web-music-score/core");
|
|
4469
4271
|
var ObjEnding = class extends MusicObject {
|
|
4470
4272
|
constructor(measure, passages) {
|
|
4471
4273
|
super(measure);
|
|
@@ -4475,10 +4277,10 @@ var ObjEnding = class extends MusicObject {
|
|
|
4475
4277
|
__publicField(this, "shapeRects", []);
|
|
4476
4278
|
__publicField(this, "mi");
|
|
4477
4279
|
this.mi = new MEnding(this);
|
|
4478
|
-
if (!
|
|
4479
|
-
throw new
|
|
4480
|
-
} else if (!this.passages.every((p) =>
|
|
4481
|
-
throw new
|
|
4280
|
+
if (!import_ts_utils_lib6.Utils.Is.isIntegerGte(passages.length, 1)) {
|
|
4281
|
+
throw new import_core10.MusicError(import_core10.MusicErrorType.Score, "Passages is empty.");
|
|
4282
|
+
} else if (!this.passages.every((p) => import_ts_utils_lib6.Utils.Is.isIntegerGte(p, 1))) {
|
|
4283
|
+
throw new import_core10.MusicError(import_core10.MusicErrorType.Score, "Invalid passages: " + this.passages);
|
|
4482
4284
|
}
|
|
4483
4285
|
this.passages.sort((a, b) => a - b);
|
|
4484
4286
|
let text = this.passages.map((p) => p + ".").join("");
|
|
@@ -4567,9 +4369,9 @@ var ObjFermata = class extends MusicObject {
|
|
|
4567
4369
|
let { measure } = anchor;
|
|
4568
4370
|
let { row } = measure;
|
|
4569
4371
|
if (row.getTopStaff() !== row.getBottomStaff()) {
|
|
4570
|
-
return [0 /*
|
|
4372
|
+
return [0 /* Above */, 1 /* Below */];
|
|
4571
4373
|
} else {
|
|
4572
|
-
return [0 /*
|
|
4374
|
+
return [0 /* Above */];
|
|
4573
4375
|
}
|
|
4574
4376
|
}
|
|
4575
4377
|
pick(x, y) {
|
|
@@ -4590,7 +4392,7 @@ var ObjFermata = class extends MusicObject {
|
|
|
4590
4392
|
return;
|
|
4591
4393
|
}
|
|
4592
4394
|
let { lineWidth, unitSize } = renderer;
|
|
4593
|
-
let upsideDown = this.pos === 1 /*
|
|
4395
|
+
let upsideDown = this.pos === 1 /* Below */;
|
|
4594
4396
|
let dy = (upsideDown ? unitSize : -unitSize) * 0.7;
|
|
4595
4397
|
let left = this.rect.left;
|
|
4596
4398
|
let right = this.rect.right;
|
|
@@ -4685,14 +4487,14 @@ var ObjExtensionLine = class extends MusicObject {
|
|
|
4685
4487
|
};
|
|
4686
4488
|
|
|
4687
4489
|
// src/score/engine/obj-measure.ts
|
|
4688
|
-
var
|
|
4490
|
+
var import_core13 = require("@tspro/web-music-score/core");
|
|
4689
4491
|
|
|
4690
4492
|
// src/score/engine/connective-props.ts
|
|
4691
|
-
var
|
|
4493
|
+
var import_theory8 = require("@tspro/web-music-score/theory");
|
|
4692
4494
|
|
|
4693
4495
|
// src/score/engine/obj-connective.ts
|
|
4694
|
-
var
|
|
4695
|
-
var
|
|
4496
|
+
var import_ts_utils_lib7 = require("@tspro/ts-utils-lib");
|
|
4497
|
+
var import_core11 = require("@tspro/web-music-score/core");
|
|
4696
4498
|
var ObjConnective = class extends MusicObject {
|
|
4697
4499
|
constructor(connectiveProps, line, measure, leftNoteGroup, leftNoteId, ...args) {
|
|
4698
4500
|
super(measure);
|
|
@@ -4720,7 +4522,7 @@ var ObjConnective = class extends MusicObject {
|
|
|
4720
4522
|
this.rightNoteGroup = args[0];
|
|
4721
4523
|
this.rightNoteId = args[1];
|
|
4722
4524
|
this.tieType = void 0;
|
|
4723
|
-
} else if (
|
|
4525
|
+
} else if (import_ts_utils_lib7.Utils.Is.isEnumValue(args[0], TieType)) {
|
|
4724
4526
|
this.rightNoteGroup = void 0;
|
|
4725
4527
|
this.rightNoteId = void 0;
|
|
4726
4528
|
this.tieType = args[0];
|
|
@@ -4781,7 +4583,7 @@ var ObjConnective = class extends MusicObject {
|
|
|
4781
4583
|
rx = contentRect.right;
|
|
4782
4584
|
ry = leftPos.y + (rightPos.y - leftPos.y) * tLeft / (tLeft + tRight);
|
|
4783
4585
|
} else {
|
|
4784
|
-
throw new
|
|
4586
|
+
throw new import_core11.MusicError(import_core11.MusicErrorType.Score, "Cannot layout connective object because no valid left and right note groups.");
|
|
4785
4587
|
}
|
|
4786
4588
|
let spanDy = arcDir === "up" ? -1 : 1;
|
|
4787
4589
|
let arcHeight = spanDy * unitSize * Math.log2(rx - lx) / 3;
|
|
@@ -4790,7 +4592,7 @@ var ObjConnective = class extends MusicObject {
|
|
|
4790
4592
|
this.rx = rx;
|
|
4791
4593
|
this.ry = ry;
|
|
4792
4594
|
this.arcHeight = this.connectiveProps.connective === 2 /* Slide */ ? 0 : arcHeight;
|
|
4793
|
-
let { nx, ny } =
|
|
4595
|
+
let { nx, ny } = import_ts_utils_lib7.Utils.Math.calcNormal(lx, ly, rx, ry);
|
|
4794
4596
|
this.cp1x = lx * 0.7 + rx * 0.3 + nx * this.arcHeight;
|
|
4795
4597
|
this.cp1y = ly * 0.7 + ry * 0.3 + ny * this.arcHeight;
|
|
4796
4598
|
this.cp2x = lx * 0.3 + rx * 0.7 + nx * this.arcHeight;
|
|
@@ -4850,7 +4652,7 @@ var ObjConnective = class extends MusicObject {
|
|
|
4850
4652
|
};
|
|
4851
4653
|
|
|
4852
4654
|
// src/score/engine/connective-props.ts
|
|
4853
|
-
var
|
|
4655
|
+
var import_core12 = require("@tspro/web-music-score/core");
|
|
4854
4656
|
var ConnectiveProps = class {
|
|
4855
4657
|
constructor(connective, span, noteAnchor, startNoteGroup) {
|
|
4856
4658
|
this.connective = connective;
|
|
@@ -4930,7 +4732,7 @@ var ConnectiveProps = class {
|
|
|
4930
4732
|
let leftNoteGroup = this.noteGroups[i];
|
|
4931
4733
|
let rightNoteGroup = this.noteGroups[i + 1];
|
|
4932
4734
|
leftNoteGroup.notes.forEach((leftNote, leftNoteId) => {
|
|
4933
|
-
let rightNoteId = rightNoteGroup.notes.findIndex((rightNote) =>
|
|
4735
|
+
let rightNoteId = rightNoteGroup.notes.findIndex((rightNote) => import_theory8.Note.equals(rightNote, leftNote));
|
|
4934
4736
|
if (rightNoteId >= 0) {
|
|
4935
4737
|
this.createObjConnective(leftNoteGroup, leftNoteId, rightNoteGroup, rightNoteId);
|
|
4936
4738
|
}
|
|
@@ -4985,7 +4787,7 @@ var ConnectiveProps = class {
|
|
|
4985
4787
|
addConnective(leftNoteGroup.measure, leftNoteGroup, leftNoteId, rightNoteGroup, rightNoteId);
|
|
4986
4788
|
addConnective(rightNoteGroup.measure, leftNoteGroup, leftNoteId, rightNoteGroup, rightNoteId);
|
|
4987
4789
|
} else {
|
|
4988
|
-
throw new
|
|
4790
|
+
throw new import_core12.MusicError(import_core12.MusicErrorType.Score, "Cannot create connective because it is jumping measures.");
|
|
4989
4791
|
}
|
|
4990
4792
|
}
|
|
4991
4793
|
};
|
|
@@ -4993,7 +4795,7 @@ var ConnectiveProps = class {
|
|
|
4993
4795
|
// src/score/engine/obj-measure.ts
|
|
4994
4796
|
function validateVoiceId(voiceId) {
|
|
4995
4797
|
if (getVoiceIds().indexOf(voiceId) < 0) {
|
|
4996
|
-
throw new
|
|
4798
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Invalid voiceId: " + voiceId);
|
|
4997
4799
|
} else {
|
|
4998
4800
|
return voiceId;
|
|
4999
4801
|
}
|
|
@@ -5004,9 +4806,9 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5004
4806
|
this.row = row;
|
|
5005
4807
|
__publicField(this, "prevMeasure");
|
|
5006
4808
|
__publicField(this, "nextMeasure");
|
|
5007
|
-
__publicField(this, "keySignature", (0,
|
|
5008
|
-
__publicField(this, "timeSignature", (0,
|
|
5009
|
-
__publicField(this, "tempo", (0,
|
|
4809
|
+
__publicField(this, "keySignature", (0, import_theory9.getDefaultKeySignature)());
|
|
4810
|
+
__publicField(this, "timeSignature", (0, import_theory10.getDefaultTimeSignature)());
|
|
4811
|
+
__publicField(this, "tempo", (0, import_theory10.getDefaultTempo)());
|
|
5010
4812
|
__publicField(this, "alterKeySignature");
|
|
5011
4813
|
__publicField(this, "alterTimeSignature");
|
|
5012
4814
|
__publicField(this, "alterTempo");
|
|
@@ -5029,7 +4831,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5029
4831
|
__publicField(this, "voiceSymbols", []);
|
|
5030
4832
|
__publicField(this, "lastAddedRhythmColumn");
|
|
5031
4833
|
__publicField(this, "lastAddedRhythmSymbol");
|
|
5032
|
-
__publicField(this, "
|
|
4834
|
+
__publicField(this, "addExtensionToMusicObjects", []);
|
|
5033
4835
|
__publicField(this, "layoutObjects", []);
|
|
5034
4836
|
__publicField(this, "postMeasureBreakWidth", 0);
|
|
5035
4837
|
__publicField(this, "passCount", 0);
|
|
@@ -5041,6 +4843,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5041
4843
|
__publicField(this, "endRepeatPlayCount", 2);
|
|
5042
4844
|
// play twice.
|
|
5043
4845
|
__publicField(this, "endRepeatPlayCountText");
|
|
4846
|
+
__publicField(this, "staticObjectsCache", /* @__PURE__ */ new Map());
|
|
5044
4847
|
__publicField(this, "mi");
|
|
5045
4848
|
this.mi = new MMeasure(this);
|
|
5046
4849
|
this.prevMeasure = row.doc.getLastMeasure();
|
|
@@ -5089,10 +4892,10 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5089
4892
|
if (this.row.hasStaff) {
|
|
5090
4893
|
diatonicId = this.row.getTopStaff().middleLineDiatonicId;
|
|
5091
4894
|
} else {
|
|
5092
|
-
diatonicId =
|
|
4895
|
+
diatonicId = import_theory9.Note.getNote("C4").diatonicId;
|
|
5093
4896
|
}
|
|
5094
4897
|
}
|
|
5095
|
-
return this.useDiatonicId[voiceId] =
|
|
4898
|
+
return this.useDiatonicId[voiceId] = import_theory9.Note.validateDiatonicId(diatonicId);
|
|
5096
4899
|
}
|
|
5097
4900
|
updateOwnStemDir(symbol, setStemDir) {
|
|
5098
4901
|
var _a, _b;
|
|
@@ -5219,23 +5022,23 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5219
5022
|
setKeySignature(...args) {
|
|
5220
5023
|
var _a;
|
|
5221
5024
|
(_a = this.getPrevMeasure()) == null ? void 0 : _a.endSection();
|
|
5222
|
-
if (args[0] instanceof
|
|
5025
|
+
if (args[0] instanceof import_theory9.KeySignature) {
|
|
5223
5026
|
this.alterKeySignature = args[0];
|
|
5224
|
-
} else if (args[0] instanceof
|
|
5027
|
+
} else if (args[0] instanceof import_theory9.Scale) {
|
|
5225
5028
|
this.alterKeySignature = args[0];
|
|
5226
5029
|
} else {
|
|
5227
5030
|
try {
|
|
5228
5031
|
let tonic = "" + args[0];
|
|
5229
|
-
let scaleType = (0,
|
|
5230
|
-
this.alterKeySignature = (0,
|
|
5032
|
+
let scaleType = (0, import_theory9.validateScaleType)("" + args[1]);
|
|
5033
|
+
this.alterKeySignature = (0, import_theory9.getScale)(tonic, scaleType);
|
|
5231
5034
|
} catch (e) {
|
|
5232
|
-
throw new
|
|
5035
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot set key signature because invalid args: " + args);
|
|
5233
5036
|
}
|
|
5234
5037
|
}
|
|
5235
5038
|
this.updateKeySignature();
|
|
5236
5039
|
}
|
|
5237
5040
|
updateKeySignature() {
|
|
5238
|
-
this.keySignature = this.prevMeasure ? this.prevMeasure.keySignature : (0,
|
|
5041
|
+
this.keySignature = this.prevMeasure ? this.prevMeasure.keySignature : (0, import_theory9.getDefaultKeySignature)();
|
|
5239
5042
|
if (this.alterKeySignature) {
|
|
5240
5043
|
this.keySignature = this.alterKeySignature;
|
|
5241
5044
|
}
|
|
@@ -5250,11 +5053,11 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5250
5053
|
setTimeSignature(timeSignature) {
|
|
5251
5054
|
var _a;
|
|
5252
5055
|
(_a = this.getPrevMeasure()) == null ? void 0 : _a.endSection();
|
|
5253
|
-
this.alterTimeSignature = timeSignature instanceof
|
|
5056
|
+
this.alterTimeSignature = timeSignature instanceof import_theory10.TimeSignature ? timeSignature : new import_theory10.TimeSignature(timeSignature);
|
|
5254
5057
|
this.updateTimeSignature();
|
|
5255
5058
|
}
|
|
5256
5059
|
updateTimeSignature() {
|
|
5257
|
-
this.timeSignature = this.prevMeasure ? this.prevMeasure.timeSignature : (0,
|
|
5060
|
+
this.timeSignature = this.prevMeasure ? this.prevMeasure.timeSignature : (0, import_theory10.getDefaultTimeSignature)();
|
|
5258
5061
|
if (this.alterTimeSignature) {
|
|
5259
5062
|
this.timeSignature = this.alterTimeSignature;
|
|
5260
5063
|
}
|
|
@@ -5275,7 +5078,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5275
5078
|
}
|
|
5276
5079
|
updateTempo() {
|
|
5277
5080
|
var _a;
|
|
5278
|
-
this.tempo = this.prevMeasure ? this.prevMeasure.tempo : (0,
|
|
5081
|
+
this.tempo = this.prevMeasure ? this.prevMeasure.tempo : (0, import_theory10.getDefaultTempo)();
|
|
5279
5082
|
if (this.alterTempo) {
|
|
5280
5083
|
let beatsPerMinute = this.alterTempo.beatsPerMinute;
|
|
5281
5084
|
let beatLength;
|
|
@@ -5303,25 +5106,65 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5303
5106
|
getPostMeasureBreakWidth() {
|
|
5304
5107
|
return this.postMeasureBreakWidth;
|
|
5305
5108
|
}
|
|
5306
|
-
addLayoutObject(musicObj, layoutGroupId, verticalPos) {
|
|
5307
|
-
|
|
5308
|
-
this.layoutObjects.push(w);
|
|
5109
|
+
addLayoutObject(musicObj, line, layoutGroupId, verticalPos) {
|
|
5110
|
+
this.layoutObjects.push(new LayoutObjectWrapper(musicObj, line, layoutGroupId, verticalPos));
|
|
5309
5111
|
this.requestLayout();
|
|
5112
|
+
this.requestRectUpdate();
|
|
5113
|
+
}
|
|
5114
|
+
forEachStaffGroup(staffTabOrGroups, defaultVerticalPos, addFn) {
|
|
5115
|
+
const lines = this.row.getNotationLines();
|
|
5116
|
+
const addToStaffTabOrGroup = (staffTabOrGroup, vpos, prevGroups = []) => {
|
|
5117
|
+
if (typeof staffTabOrGroup === "number") {
|
|
5118
|
+
if (lines[staffTabOrGroup]) {
|
|
5119
|
+
addFn(lines[staffTabOrGroup], vpos);
|
|
5120
|
+
}
|
|
5121
|
+
} else if (typeof staffTabOrGroup === "string" && staffTabOrGroup.length > 0) {
|
|
5122
|
+
let stavesAndTabs = lines.filter((l) => l.name === staffTabOrGroup);
|
|
5123
|
+
stavesAndTabs.forEach((line) => addFn(line, vpos));
|
|
5124
|
+
if (stavesAndTabs.length === 0) {
|
|
5125
|
+
let grp = this.doc.getStaffGroup(staffTabOrGroup);
|
|
5126
|
+
if (grp && !prevGroups.includes(staffTabOrGroup)) {
|
|
5127
|
+
let curGroups = [...prevGroups, staffTabOrGroup];
|
|
5128
|
+
(import_ts_utils_lib8.Utils.Is.isArray(grp.staffsTabsAndGroups) ? grp.staffsTabsAndGroups : [grp.staffsTabsAndGroups]).forEach((staffTabOrGroup2) => {
|
|
5129
|
+
switch (grp.verticalPosition) {
|
|
5130
|
+
case 0 /* Above */:
|
|
5131
|
+
addToStaffTabOrGroup(staffTabOrGroup2, 0 /* Above */, curGroups);
|
|
5132
|
+
break;
|
|
5133
|
+
case 1 /* Below */:
|
|
5134
|
+
addToStaffTabOrGroup(staffTabOrGroup2, 1 /* Below */, curGroups);
|
|
5135
|
+
break;
|
|
5136
|
+
case 2 /* Both */:
|
|
5137
|
+
addToStaffTabOrGroup(staffTabOrGroup2, 0 /* Above */, curGroups);
|
|
5138
|
+
addToStaffTabOrGroup(staffTabOrGroup2, 1 /* Below */, curGroups);
|
|
5139
|
+
break;
|
|
5140
|
+
case 3 /* Auto */:
|
|
5141
|
+
addToStaffTabOrGroup(staffTabOrGroup2, defaultVerticalPos, curGroups);
|
|
5142
|
+
break;
|
|
5143
|
+
}
|
|
5144
|
+
});
|
|
5145
|
+
}
|
|
5146
|
+
}
|
|
5147
|
+
}
|
|
5148
|
+
};
|
|
5149
|
+
if (staffTabOrGroups === void 0) {
|
|
5150
|
+
if (lines.length >= 2 && lines[0] instanceof ObjStaff && lines[0].staffConfig.clef === "G" /* G */ && lines[0].isGrand() && lines[1] instanceof ObjStaff && lines[1].staffConfig.clef === "F" /* F */ && lines[1].isGrand()) {
|
|
5151
|
+
addToStaffTabOrGroup(defaultVerticalPos === 1 /* Below */ ? 1 : 0, defaultVerticalPos);
|
|
5152
|
+
} else {
|
|
5153
|
+
addToStaffTabOrGroup(0, defaultVerticalPos);
|
|
5154
|
+
}
|
|
5155
|
+
} else if (import_ts_utils_lib8.Utils.Is.isArray(staffTabOrGroups)) {
|
|
5156
|
+
staffTabOrGroups.forEach((staffTabOrGroup) => addToStaffTabOrGroup(staffTabOrGroup, defaultVerticalPos));
|
|
5157
|
+
} else {
|
|
5158
|
+
addToStaffTabOrGroup(staffTabOrGroups, defaultVerticalPos);
|
|
5159
|
+
}
|
|
5310
5160
|
}
|
|
5311
|
-
addFermata(fermata) {
|
|
5161
|
+
addFermata(staffTabOrGroups, fermata) {
|
|
5312
5162
|
let anchor = fermata === 1 /* AtMeasureEnd */ ? this.barLineRight : this.lastAddedRhythmColumn;
|
|
5313
5163
|
if (!anchor) {
|
|
5314
|
-
throw new
|
|
5164
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add Fermata because anchor is undefined.");
|
|
5315
5165
|
}
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
let hasBelow = fermataObjArr.some((obj) => obj.pos === 1 /* BelowStaff */);
|
|
5319
|
-
ObjFermata.getFermataPositions(anchor).forEach((fermataPos) => {
|
|
5320
|
-
if (fermataPos === 0 /* AboveStaff */ && !hasAbove) {
|
|
5321
|
-
this.addLayoutObject(new ObjFermata(anchor, fermataPos), 0 /* Fermata */, fermataPos);
|
|
5322
|
-
} else if (fermataPos === 1 /* BelowStaff */ && !hasBelow) {
|
|
5323
|
-
this.addLayoutObject(new ObjFermata(anchor, fermataPos), 0 /* Fermata */, fermataPos);
|
|
5324
|
-
}
|
|
5166
|
+
this.forEachStaffGroup(staffTabOrGroups, 0 /* Above */, (line, vpos) => {
|
|
5167
|
+
this.addLayoutObject(new ObjFermata(anchor, vpos), line, 0 /* Fermata */, vpos);
|
|
5325
5168
|
});
|
|
5326
5169
|
this.disableExtension();
|
|
5327
5170
|
this.requestLayout();
|
|
@@ -5329,15 +5172,20 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5329
5172
|
hasFermata(anchor) {
|
|
5330
5173
|
return this.layoutObjects.some((layoutObj) => layoutObj.musicObj instanceof ObjFermata && layoutObj.anchor === anchor);
|
|
5331
5174
|
}
|
|
5332
|
-
addNavigation(navigation, ...args) {
|
|
5175
|
+
addNavigation(staffTabOrGroups, navigation, ...args) {
|
|
5176
|
+
let addLayoutObjectProps = void 0;
|
|
5333
5177
|
switch (navigation) {
|
|
5334
5178
|
case 10 /* Ending */:
|
|
5335
5179
|
if (this.navigationSet.has(navigation)) {
|
|
5336
|
-
throw new
|
|
5180
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add ending beasure measure already has one.");
|
|
5337
5181
|
}
|
|
5338
5182
|
let anchor = this;
|
|
5339
5183
|
let passages = args;
|
|
5340
|
-
|
|
5184
|
+
addLayoutObjectProps = {
|
|
5185
|
+
createObj: () => new ObjEnding(anchor, passages),
|
|
5186
|
+
layoutGroupId: 3 /* Ending */,
|
|
5187
|
+
defaultVerticalPos: 0 /* Above */
|
|
5188
|
+
};
|
|
5341
5189
|
break;
|
|
5342
5190
|
case 1 /* DC_al_Coda */:
|
|
5343
5191
|
case 0 /* DC_al_Fine */:
|
|
@@ -5345,37 +5193,53 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5345
5193
|
case 2 /* DS_al_Fine */: {
|
|
5346
5194
|
let anchor2 = this.barLineRight;
|
|
5347
5195
|
let text = getNavigationString(navigation);
|
|
5348
|
-
|
|
5349
|
-
|
|
5196
|
+
addLayoutObjectProps = {
|
|
5197
|
+
createObj: () => new ObjText(anchor2, text, 1, 1),
|
|
5198
|
+
layoutGroupId: 2 /* Navigation */,
|
|
5199
|
+
defaultVerticalPos: 0 /* Above */
|
|
5200
|
+
};
|
|
5201
|
+
this.addNavigation(staffTabOrGroups, 9 /* EndRepeat */);
|
|
5350
5202
|
this.endSong();
|
|
5351
5203
|
break;
|
|
5352
5204
|
}
|
|
5353
5205
|
case 7 /* Fine */: {
|
|
5354
5206
|
let anchor2 = this.barLineRight;
|
|
5355
5207
|
let text = getNavigationString(navigation);
|
|
5356
|
-
|
|
5208
|
+
addLayoutObjectProps = {
|
|
5209
|
+
createObj: () => new ObjText(anchor2, text, 1, 1),
|
|
5210
|
+
layoutGroupId: 2 /* Navigation */,
|
|
5211
|
+
defaultVerticalPos: 0 /* Above */
|
|
5212
|
+
};
|
|
5357
5213
|
break;
|
|
5358
5214
|
}
|
|
5359
5215
|
case 6 /* Segno */:
|
|
5360
5216
|
case 4 /* Coda */: {
|
|
5361
5217
|
let anchor2 = this.barLineLeft;
|
|
5362
5218
|
let text = getNavigationString(navigation);
|
|
5363
|
-
|
|
5219
|
+
addLayoutObjectProps = {
|
|
5220
|
+
createObj: () => new ObjSpecialText(anchor2, text),
|
|
5221
|
+
layoutGroupId: 2 /* Navigation */,
|
|
5222
|
+
defaultVerticalPos: 0 /* Above */
|
|
5223
|
+
};
|
|
5364
5224
|
break;
|
|
5365
5225
|
}
|
|
5366
5226
|
case 5 /* toCoda */: {
|
|
5367
5227
|
let anchor2 = this.barLineRight;
|
|
5368
5228
|
let text = getNavigationString(navigation);
|
|
5369
|
-
|
|
5229
|
+
addLayoutObjectProps = {
|
|
5230
|
+
createObj: () => new ObjSpecialText(anchor2, text),
|
|
5231
|
+
layoutGroupId: 2 /* Navigation */,
|
|
5232
|
+
defaultVerticalPos: 0 /* Above */
|
|
5233
|
+
};
|
|
5370
5234
|
break;
|
|
5371
5235
|
}
|
|
5372
5236
|
case 9 /* EndRepeat */:
|
|
5373
5237
|
if (args.length === 0) {
|
|
5374
5238
|
this.endRepeatPlayCount = 2;
|
|
5375
|
-
} else if (
|
|
5239
|
+
} else if (import_ts_utils_lib8.Utils.Is.isIntegerGte(args[0], 2)) {
|
|
5376
5240
|
this.endRepeatPlayCount = args[0];
|
|
5377
5241
|
} else {
|
|
5378
|
-
throw new
|
|
5242
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Invalid end repeat play count (should be 2 or greater integer): " + args[0]);
|
|
5379
5243
|
}
|
|
5380
5244
|
if (this.endRepeatPlayCount !== 2) {
|
|
5381
5245
|
let textProps = {
|
|
@@ -5386,85 +5250,118 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5386
5250
|
}
|
|
5387
5251
|
break;
|
|
5388
5252
|
}
|
|
5253
|
+
if (addLayoutObjectProps) {
|
|
5254
|
+
this.forEachStaffGroup(staffTabOrGroups, addLayoutObjectProps.defaultVerticalPos, (line, vpos) => {
|
|
5255
|
+
this.addLayoutObject(addLayoutObjectProps.createObj(), line, addLayoutObjectProps.layoutGroupId, vpos);
|
|
5256
|
+
});
|
|
5257
|
+
}
|
|
5389
5258
|
this.navigationSet.add(navigation);
|
|
5390
5259
|
this.disableExtension();
|
|
5391
5260
|
}
|
|
5392
5261
|
hasNavigation(n) {
|
|
5393
5262
|
return this.navigationSet.has(n);
|
|
5394
5263
|
}
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
addConnective(connective, ...args) {
|
|
5402
|
-
let anchor = this.lastAddedRhythmSymbol;
|
|
5403
|
-
if (!(anchor instanceof ObjNoteGroup)) {
|
|
5404
|
-
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Connective can be added to note group only.");
|
|
5264
|
+
addAnnotation(staffTabOrGroups, annotation, text) {
|
|
5265
|
+
let anchor = this.lastAddedRhythmColumn;
|
|
5266
|
+
if (!anchor) {
|
|
5267
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add annotation because anchor is undefined.");
|
|
5268
|
+
} else if (text.length === 0) {
|
|
5269
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add annotation because annotation text is empty.");
|
|
5405
5270
|
}
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5271
|
+
let textProps = { text };
|
|
5272
|
+
let layoutGroupId;
|
|
5273
|
+
let defaultVerticalPos;
|
|
5274
|
+
switch (annotation) {
|
|
5275
|
+
case 0 /* Dynamics */:
|
|
5276
|
+
layoutGroupId = 5 /* DynamicsAnnotation */;
|
|
5277
|
+
defaultVerticalPos = 0 /* Above */;
|
|
5278
|
+
textProps.italic = true;
|
|
5279
|
+
break;
|
|
5280
|
+
case 1 /* Tempo */:
|
|
5281
|
+
layoutGroupId = 4 /* TempoAnnotation */;
|
|
5282
|
+
defaultVerticalPos = 0 /* Above */;
|
|
5283
|
+
textProps.italic = true;
|
|
5284
|
+
break;
|
|
5417
5285
|
}
|
|
5286
|
+
this.forEachStaffGroup(staffTabOrGroups, defaultVerticalPos, (line, vpos) => {
|
|
5287
|
+
let textObj = new ObjText(anchor, textProps, 0.5, 1);
|
|
5288
|
+
this.addLayoutObject(textObj, line, layoutGroupId, vpos);
|
|
5289
|
+
this.enableExtension(textObj);
|
|
5290
|
+
});
|
|
5418
5291
|
}
|
|
5419
|
-
addLabel(label, text) {
|
|
5292
|
+
addLabel(staffTabOrGroups, label, text) {
|
|
5420
5293
|
let anchor = this.lastAddedRhythmColumn;
|
|
5421
5294
|
if (!anchor) {
|
|
5422
|
-
throw new
|
|
5295
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add label because anchor is undefined.");
|
|
5423
5296
|
} else if (text.length === 0) {
|
|
5424
|
-
throw new
|
|
5297
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add label because label text is empty.");
|
|
5425
5298
|
}
|
|
5426
5299
|
let textProps = { text };
|
|
5427
5300
|
let layoutGroupId;
|
|
5428
|
-
let
|
|
5301
|
+
let defaultVerticalPos;
|
|
5429
5302
|
switch (label) {
|
|
5430
5303
|
case 0 /* Note */:
|
|
5431
5304
|
layoutGroupId = 1 /* NoteLabel */;
|
|
5432
|
-
|
|
5305
|
+
defaultVerticalPos = 1 /* Below */;
|
|
5433
5306
|
break;
|
|
5434
5307
|
case 1 /* Chord */:
|
|
5435
5308
|
layoutGroupId = 6 /* ChordLabel */;
|
|
5436
|
-
|
|
5309
|
+
defaultVerticalPos = 0 /* Above */;
|
|
5437
5310
|
break;
|
|
5438
5311
|
}
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
|
|
5312
|
+
this.forEachStaffGroup(staffTabOrGroups, defaultVerticalPos, (line, vpos) => {
|
|
5313
|
+
let textObj = new ObjText(anchor, textProps, 0.5, 1);
|
|
5314
|
+
this.addLayoutObject(textObj, line, layoutGroupId, vpos);
|
|
5315
|
+
this.enableExtension(textObj);
|
|
5316
|
+
});
|
|
5442
5317
|
}
|
|
5443
|
-
|
|
5444
|
-
let anchor = this.
|
|
5445
|
-
if (!anchor) {
|
|
5446
|
-
throw new
|
|
5447
|
-
} else if (text.length === 0) {
|
|
5448
|
-
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot add annotation because annotation text is empty.");
|
|
5318
|
+
addConnective(connective, ...args) {
|
|
5319
|
+
let anchor = this.lastAddedRhythmSymbol;
|
|
5320
|
+
if (!(anchor instanceof ObjNoteGroup)) {
|
|
5321
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Connective can be added to note group only.");
|
|
5449
5322
|
}
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5323
|
+
if (connective === 0 /* Tie */) {
|
|
5324
|
+
let tieSpan = import_ts_utils_lib8.Utils.Is.isInteger(args[0]) || import_ts_utils_lib8.Utils.Is.isEnumValue(args[0], TieType) ? args[0] : 2;
|
|
5325
|
+
let noteAnchor = import_ts_utils_lib8.Utils.Is.isEnumValue(args[1], NoteAnchor) ? args[1] : 0 /* Auto */;
|
|
5326
|
+
anchor.startConnective(new ConnectiveProps(0 /* Tie */, tieSpan, noteAnchor, anchor));
|
|
5327
|
+
} else if (connective === 1 /* Slur */) {
|
|
5328
|
+
let slurSpan = import_ts_utils_lib8.Utils.Is.isInteger(args[0]) ? args[0] : 2;
|
|
5329
|
+
let noteAnchor = import_ts_utils_lib8.Utils.Is.isEnumValue(args[1], NoteAnchor) ? args[1] : 0 /* Auto */;
|
|
5330
|
+
anchor.startConnective(new ConnectiveProps(1 /* Slur */, slurSpan, noteAnchor, anchor));
|
|
5331
|
+
} else if (connective === 2 /* Slide */) {
|
|
5332
|
+
let noteAnchor = import_ts_utils_lib8.Utils.Is.isEnumValue(args[0], NoteAnchor) ? args[0] : 0 /* Auto */;
|
|
5333
|
+
anchor.startConnective(new ConnectiveProps(2 /* Slide */, 2, noteAnchor, anchor));
|
|
5334
|
+
}
|
|
5335
|
+
}
|
|
5336
|
+
addExtension(extensionLength, extensionVisible) {
|
|
5337
|
+
this.addExtensionToMusicObjects.forEach((musicObj) => {
|
|
5338
|
+
let anchor = musicObj.getParent();
|
|
5339
|
+
if (musicObj instanceof ObjText && anchor instanceof ObjRhythmColumn) {
|
|
5340
|
+
let lineStyle = "dashed";
|
|
5341
|
+
let linePos = "bottom";
|
|
5342
|
+
let extension = new Extension(musicObj, anchor, extensionLength, extensionVisible, lineStyle, linePos);
|
|
5343
|
+
musicObj.setLink(extension);
|
|
5344
|
+
} else {
|
|
5345
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add extension becaue no compatible music object to attach it to.");
|
|
5346
|
+
}
|
|
5347
|
+
});
|
|
5348
|
+
if (this.addExtensionToMusicObjects.length === 0) {
|
|
5349
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add extension because music object to attach it to is undefined.");
|
|
5464
5350
|
}
|
|
5465
|
-
|
|
5466
|
-
this.
|
|
5467
|
-
|
|
5351
|
+
this.disableExtension();
|
|
5352
|
+
this.requestLayout();
|
|
5353
|
+
}
|
|
5354
|
+
enableExtension(musicObject) {
|
|
5355
|
+
this.addExtensionToMusicObjects.push(musicObject);
|
|
5356
|
+
}
|
|
5357
|
+
disableExtension() {
|
|
5358
|
+
this.addExtensionToMusicObjects = [];
|
|
5359
|
+
}
|
|
5360
|
+
getEnding() {
|
|
5361
|
+
return this.layoutObjects.map((layoutObj) => layoutObj.musicObj).find((musicObj) => musicObj instanceof ObjEnding);
|
|
5362
|
+
}
|
|
5363
|
+
getEndRepeatPlayCount() {
|
|
5364
|
+
return this.endRepeatPlayCount;
|
|
5468
5365
|
}
|
|
5469
5366
|
endSong() {
|
|
5470
5367
|
this.isEndSong = true;
|
|
@@ -5486,28 +5383,6 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5486
5383
|
this.doc.requestNewRow();
|
|
5487
5384
|
this.disableExtension();
|
|
5488
5385
|
}
|
|
5489
|
-
enableExtension(musicObj) {
|
|
5490
|
-
this.addExtensionToMusicObject = musicObj;
|
|
5491
|
-
}
|
|
5492
|
-
disableExtension() {
|
|
5493
|
-
this.addExtensionToMusicObject = void 0;
|
|
5494
|
-
}
|
|
5495
|
-
addExtension(extensionLength, extensionVisible) {
|
|
5496
|
-
let musicObj = this.addExtensionToMusicObject;
|
|
5497
|
-
let anchor = musicObj == null ? void 0 : musicObj.getParent();
|
|
5498
|
-
if (musicObj instanceof ObjText && anchor instanceof ObjRhythmColumn) {
|
|
5499
|
-
let lineStyle = "dashed";
|
|
5500
|
-
let linePos = "bottom";
|
|
5501
|
-
let extension = new Extension(musicObj, anchor, extensionLength, extensionVisible, lineStyle, linePos);
|
|
5502
|
-
musicObj.setLink(extension);
|
|
5503
|
-
this.disableExtension();
|
|
5504
|
-
this.requestLayout();
|
|
5505
|
-
} else if (musicObj === void 0) {
|
|
5506
|
-
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot add extension because music object to attach it to is undefined.");
|
|
5507
|
-
} else {
|
|
5508
|
-
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot add extension becaue no compatible music object to attach it to.");
|
|
5509
|
-
}
|
|
5510
|
-
}
|
|
5511
5386
|
addRhythmSymbol(voiceId, symbol) {
|
|
5512
5387
|
let { col } = symbol;
|
|
5513
5388
|
col.setVoiceSymbol(voiceId, symbol);
|
|
@@ -5518,7 +5393,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5518
5393
|
this.lastAddedRhythmSymbol = symbol;
|
|
5519
5394
|
}
|
|
5520
5395
|
addNoteGroup(voiceId, notes, noteLength, options) {
|
|
5521
|
-
let notes2 = notes.map((note) => typeof note === "string" ?
|
|
5396
|
+
let notes2 = notes.map((note) => typeof note === "string" ? import_theory9.Note.getNote(note) : note);
|
|
5522
5397
|
let col = this.getRhythmColumn(voiceId);
|
|
5523
5398
|
this.addRhythmSymbol(voiceId, new ObjNoteGroup(col, voiceId, notes2, noteLength, options));
|
|
5524
5399
|
}
|
|
@@ -5550,7 +5425,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5550
5425
|
return col2;
|
|
5551
5426
|
}
|
|
5552
5427
|
}
|
|
5553
|
-
throw new
|
|
5428
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Error in rhythm column. Should never get here.");
|
|
5554
5429
|
}
|
|
5555
5430
|
getMeasureTicks() {
|
|
5556
5431
|
return this.getTimeSignature().measureTicks;
|
|
@@ -5602,11 +5477,15 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5602
5477
|
getStaffLineRight() {
|
|
5603
5478
|
return this.barLineRight.getRect().centerX;
|
|
5604
5479
|
}
|
|
5605
|
-
getStaticObjects() {
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5480
|
+
getStaticObjects(line) {
|
|
5481
|
+
let staticObjects = this.staticObjectsCache.get(line);
|
|
5482
|
+
if (!staticObjects) {
|
|
5483
|
+
staticObjects = [];
|
|
5484
|
+
this.getColumns().forEach((col) => col.getStaticObjects(line).forEach((obj) => staticObjects == null ? void 0 : staticObjects.push(obj)));
|
|
5485
|
+
this.staticObjectsCache.set(line, staticObjects);
|
|
5486
|
+
}
|
|
5487
|
+
let layoutObjects = this.layoutObjects.filter((layoutObj) => layoutObj.line === line && layoutObj.isPositionResolved()).map((layoutObj) => layoutObj.musicObj);
|
|
5488
|
+
return layoutObjects.length > 0 ? [...staticObjects, ...layoutObjects] : staticObjects;
|
|
5610
5489
|
}
|
|
5611
5490
|
removeLayoutObjects(musicObj) {
|
|
5612
5491
|
this.layoutObjects = this.layoutObjects.filter((layoutObj) => {
|
|
@@ -5634,16 +5513,22 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5634
5513
|
}
|
|
5635
5514
|
createExtensions() {
|
|
5636
5515
|
this.layoutObjects.forEach((layoutObj) => {
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5516
|
+
var _a;
|
|
5517
|
+
let { musicObj, measure, layoutGroupId, verticalPos, line } = layoutObj;
|
|
5518
|
+
if (musicObj.getLink() instanceof Extension) {
|
|
5519
|
+
let extension = musicObj.getLink();
|
|
5520
|
+
if (extension.getHead() === musicObj) {
|
|
5521
|
+
extension.getTails().forEach((musicObj2) => measure.removeLayoutObjects(musicObj2));
|
|
5641
5522
|
let { startColumn, endColumn } = extension.getExtensionRangeInfo();
|
|
5642
5523
|
if (extension.isVisible() && startColumn !== endColumn) {
|
|
5643
5524
|
for (let m = startColumn.measure; m !== void 0; m = m === endColumn.measure ? void 0 : m.getNextMeasure()) {
|
|
5644
5525
|
let leftObj = m === startColumn.measure ? extension.getHead() : m.getBarLineLeft();
|
|
5645
5526
|
let rightObj = m === endColumn.measure ? endColumn : m.getBarLineRight();
|
|
5646
|
-
|
|
5527
|
+
const lines = m.row.getNotationLines();
|
|
5528
|
+
let line2 = (_a = lines.find((l) => l.name !== "" && l.name === line.name)) != null ? _a : lines[line.id];
|
|
5529
|
+
if (line2) {
|
|
5530
|
+
m.addLayoutObject(new ObjExtensionLine(m, extension, leftObj, rightObj), line2, layoutGroupId, verticalPos);
|
|
5531
|
+
}
|
|
5647
5532
|
}
|
|
5648
5533
|
}
|
|
5649
5534
|
}
|
|
@@ -5750,12 +5635,12 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5750
5635
|
let consumedTicks = this.getConsumedTicks(voiceId);
|
|
5751
5636
|
let remainingTicks = measureTicks - consumedTicks;
|
|
5752
5637
|
let rests = [];
|
|
5753
|
-
let noteLengthValues =
|
|
5638
|
+
let noteLengthValues = import_ts_utils_lib8.Utils.Enum.getEnumValues(import_theory9.NoteLength);
|
|
5754
5639
|
while (remainingTicks > 0) {
|
|
5755
5640
|
noteLengthValues.forEach((restLength) => {
|
|
5756
|
-
let restValue = new
|
|
5641
|
+
let restValue = new import_theory9.RhythmProps(restLength, false);
|
|
5757
5642
|
if (restValue.canDot()) {
|
|
5758
|
-
let dottedRestValue = new
|
|
5643
|
+
let dottedRestValue = new import_theory9.RhythmProps(restLength, true);
|
|
5759
5644
|
while (dottedRestValue.ticks <= remainingTicks) {
|
|
5760
5645
|
rests.push(dottedRestValue);
|
|
5761
5646
|
remainingTicks -= dottedRestValue.ticks;
|
|
@@ -5780,6 +5665,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5780
5665
|
if (!this.needLayout) {
|
|
5781
5666
|
return;
|
|
5782
5667
|
}
|
|
5668
|
+
this.staticObjectsCache.clear();
|
|
5783
5669
|
this.requestRectUpdate();
|
|
5784
5670
|
let { unitSize } = renderer;
|
|
5785
5671
|
this.postMeasureBreakWidth = this.hasPostMeasureBreak() ? DocumentSettings.PostMeasureBreakWidth * unitSize : 0;
|
|
@@ -5811,7 +5697,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5811
5697
|
if (this === this.row.getFirstMeasure()) {
|
|
5812
5698
|
this.row.getTabs().forEach((tab) => {
|
|
5813
5699
|
for (let stringId = 0; stringId < 6; stringId++) {
|
|
5814
|
-
let note = tab.getTuningStrings()[stringId].format(
|
|
5700
|
+
let note = tab.getTuningStrings()[stringId].format(import_theory9.PitchNotation.Helmholtz, import_theory9.SymbolSet.Unicode);
|
|
5815
5701
|
let obj = new ObjText(this, { text: note, scale: 0.8 }, 1, 0.5);
|
|
5816
5702
|
obj.layout(renderer);
|
|
5817
5703
|
obj.offset(this.tabStringNotesWidth * 0.8, tab.getStringY(stringId));
|
|
@@ -5827,6 +5713,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5827
5713
|
if (this.endRepeatPlayCountText) {
|
|
5828
5714
|
this.endRepeatPlayCountText.layout(renderer);
|
|
5829
5715
|
}
|
|
5716
|
+
this.layoutObjects.forEach((layoutObj) => layoutObj.layout(renderer));
|
|
5830
5717
|
let padding = renderer.unitSize;
|
|
5831
5718
|
this.leftSolidAreaWidth = this.tabStringNotesWidth + Math.max(0, ...this.signatures.map((signature) => signature.getRect().width)) + this.barLineLeft.getRect().width + padding;
|
|
5832
5719
|
this.rightSolidAreaWidth = padding + this.barLineRight.getRect().width;
|
|
@@ -5858,7 +5745,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5858
5745
|
let columnsAreaLeft = this.rect.left + this.leftSolidAreaWidth;
|
|
5859
5746
|
let columnsAreaRight = this.rect.right - this.rightSolidAreaWidth;
|
|
5860
5747
|
let columnsAreaWidth = columnsAreaRight - columnsAreaLeft;
|
|
5861
|
-
let columnsWidth =
|
|
5748
|
+
let columnsWidth = import_ts_utils_lib8.Utils.Math.sum(this.columns.map((col) => col.getRect().width));
|
|
5862
5749
|
let columnScale = columnsAreaWidth / columnsWidth;
|
|
5863
5750
|
let columnLeft = columnsAreaLeft;
|
|
5864
5751
|
this.columns.forEach((col) => {
|
|
@@ -5903,7 +5790,8 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5903
5790
|
...this.columns.filter((col) => !col.isEmpty()).map((col) => col.getRect().top),
|
|
5904
5791
|
this.barLineRight.getRect().top,
|
|
5905
5792
|
...this.connectives.map((c) => c.getRect().top),
|
|
5906
|
-
...this.beamGroups.filter((b) => !b.isEmpty()).map((b) => b.getRect().top)
|
|
5793
|
+
...this.beamGroups.filter((b) => !b.isEmpty()).map((b) => b.getRect().top),
|
|
5794
|
+
...this.layoutObjects.filter((o) => o.isPositionResolved()).map((o) => o.musicObj.getRect().top)
|
|
5907
5795
|
);
|
|
5908
5796
|
this.rect.bottom = Math.max(
|
|
5909
5797
|
...this.signatures.map((s) => s.getRect().bottom),
|
|
@@ -5912,12 +5800,20 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5912
5800
|
...this.columns.filter((col) => !col.isEmpty()).map((col) => col.getRect().bottom),
|
|
5913
5801
|
this.barLineRight.getRect().bottom,
|
|
5914
5802
|
...this.connectives.map((c) => c.getRect().bottom),
|
|
5915
|
-
...this.beamGroups.filter((b) => !b.isEmpty()).map((b) => b.getRect().bottom)
|
|
5803
|
+
...this.beamGroups.filter((b) => !b.isEmpty()).map((b) => b.getRect().bottom),
|
|
5804
|
+
...this.layoutObjects.filter((o) => o.isPositionResolved()).map((o) => o.musicObj.getRect().bottom)
|
|
5916
5805
|
);
|
|
5806
|
+
if (this === this.row.getLastMeasure()) {
|
|
5807
|
+
this.rect.right = Math.max(
|
|
5808
|
+
this.rect.right,
|
|
5809
|
+
...this.layoutObjects.filter((o) => o.isPositionResolved() && o.musicObj instanceof ObjFermata).map((o) => o.musicObj.getRect().right)
|
|
5810
|
+
);
|
|
5811
|
+
}
|
|
5917
5812
|
this.row.getNotationLines().forEach((line) => {
|
|
5918
5813
|
this.rect.top = Math.min(this.rect.top, line.calcTop());
|
|
5919
5814
|
this.rect.bottom = Math.max(this.rect.bottom, line.calcBottom());
|
|
5920
5815
|
});
|
|
5816
|
+
this.row.requestRectUpdate();
|
|
5921
5817
|
}
|
|
5922
5818
|
offset(dx, dy) {
|
|
5923
5819
|
this.signatures.forEach((signature) => signature.offset(dx, 0));
|
|
@@ -5930,7 +5826,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5930
5826
|
}
|
|
5931
5827
|
this.connectives.forEach((connective) => connective.offset(dx, 0));
|
|
5932
5828
|
this.beamGroups.forEach((beam) => beam.offset(dx, dy));
|
|
5933
|
-
this.layoutObjects.forEach((layoutObj) => layoutObj.
|
|
5829
|
+
this.layoutObjects.forEach((layoutObj) => layoutObj.offset(dx, 0));
|
|
5934
5830
|
this.rect.offsetInPlace(dx, dy);
|
|
5935
5831
|
this.requestRectUpdate();
|
|
5936
5832
|
}
|
|
@@ -5945,7 +5841,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5945
5841
|
for (let p = line.bottomLineDiatonicId; p <= line.topLineDiatonicId; p += 2) {
|
|
5946
5842
|
drawLine(line.getDiatonicIdY(p));
|
|
5947
5843
|
}
|
|
5948
|
-
} else {
|
|
5844
|
+
} else if (line instanceof ObjTab) {
|
|
5949
5845
|
for (let stringId = 0; stringId < 6; stringId++) {
|
|
5950
5846
|
drawLine(line.getStringY(stringId));
|
|
5951
5847
|
}
|
|
@@ -5968,7 +5864,7 @@ __publicField(_ObjMeasure, "MinFlexContentWidth", 10);
|
|
|
5968
5864
|
var ObjMeasure2 = _ObjMeasure;
|
|
5969
5865
|
|
|
5970
5866
|
// src/score/engine/layout-object.ts
|
|
5971
|
-
var
|
|
5867
|
+
var import_core14 = require("@tspro/web-music-score/core");
|
|
5972
5868
|
var WidenColumnList = [1 /* NoteLabel */, 6 /* ChordLabel */];
|
|
5973
5869
|
var RowAlignList = [2 /* Navigation */, 3 /* Ending */, 4 /* TempoAnnotation */, 5 /* DynamicsAnnotation */, 6 /* ChordLabel */];
|
|
5974
5870
|
function requireParentMeasure(p) {
|
|
@@ -5978,11 +5874,19 @@ function requireParentMeasure(p) {
|
|
|
5978
5874
|
}
|
|
5979
5875
|
p = p.getParent();
|
|
5980
5876
|
}
|
|
5981
|
-
throw new
|
|
5877
|
+
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Parent measure is required but not found!");
|
|
5982
5878
|
}
|
|
5879
|
+
var StaffGroup = class {
|
|
5880
|
+
constructor(groupName, staffsTabsAndGroups, verticalPosition) {
|
|
5881
|
+
this.groupName = groupName;
|
|
5882
|
+
this.staffsTabsAndGroups = staffsTabsAndGroups;
|
|
5883
|
+
this.verticalPosition = verticalPosition;
|
|
5884
|
+
}
|
|
5885
|
+
};
|
|
5983
5886
|
var LayoutObjectWrapper = class {
|
|
5984
|
-
constructor(musicObj, layoutGroupId, verticalPos) {
|
|
5887
|
+
constructor(musicObj, line, layoutGroupId, verticalPos) {
|
|
5985
5888
|
this.musicObj = musicObj;
|
|
5889
|
+
this.line = line;
|
|
5986
5890
|
this.layoutGroupId = layoutGroupId;
|
|
5987
5891
|
this.verticalPos = verticalPos;
|
|
5988
5892
|
__publicField(this, "anchor");
|
|
@@ -5990,15 +5894,15 @@ var LayoutObjectWrapper = class {
|
|
|
5990
5894
|
__publicField(this, "row");
|
|
5991
5895
|
__publicField(this, "layoutGroup");
|
|
5992
5896
|
__publicField(this, "positionResolved", true);
|
|
5993
|
-
this.measure = requireParentMeasure(musicObj);
|
|
5897
|
+
this.measure = requireParentMeasure(this.musicObj);
|
|
5994
5898
|
this.row = this.measure.row;
|
|
5995
5899
|
let anchor = this.musicObj.getParent();
|
|
5996
5900
|
if (!anchor) {
|
|
5997
|
-
throw new
|
|
5901
|
+
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Parent music object is required as an anchor.");
|
|
5998
5902
|
}
|
|
5999
5903
|
this.anchor = anchor;
|
|
6000
5904
|
this.anchor.addAnchoredLayoutObject(this);
|
|
6001
|
-
this.layoutGroup = this.
|
|
5905
|
+
this.layoutGroup = this.line.getLayoutGroup(layoutGroupId);
|
|
6002
5906
|
this.layoutGroup.add(this);
|
|
6003
5907
|
}
|
|
6004
5908
|
clearPositionResolved() {
|
|
@@ -6011,20 +5915,19 @@ var LayoutObjectWrapper = class {
|
|
|
6011
5915
|
return this.positionResolved;
|
|
6012
5916
|
}
|
|
6013
5917
|
resolveClosestToStaffY(renderer) {
|
|
6014
|
-
let { musicObj, measure, verticalPos } = this;
|
|
6015
|
-
let
|
|
6016
|
-
let
|
|
6017
|
-
let
|
|
6018
|
-
let
|
|
6019
|
-
let
|
|
6020
|
-
let staticObjects = measure.getStaticObjects();
|
|
5918
|
+
let { musicObj, measure, verticalPos, line } = this;
|
|
5919
|
+
let lineTop = line.getTopLineY();
|
|
5920
|
+
let lineBottom = line.getBottomLineY();
|
|
5921
|
+
let linePadding = renderer.unitSize * 2;
|
|
5922
|
+
let y = verticalPos === 1 /* Below */ ? lineBottom + linePadding + musicObj.getRect().toph : lineTop - linePadding - musicObj.getRect().bottomh;
|
|
5923
|
+
let staticObjects = measure.getStaticObjects(line);
|
|
6021
5924
|
let objShapeRects = musicObj.getShapeRects();
|
|
6022
5925
|
staticObjects.forEach((staticObj) => {
|
|
6023
5926
|
let staticShapeRects = staticObj.getShapeRects();
|
|
6024
5927
|
objShapeRects.forEach((objR) => {
|
|
6025
5928
|
staticShapeRects.forEach((staticR) => {
|
|
6026
5929
|
if (DivRect.overlapX(objR, staticR)) {
|
|
6027
|
-
y = verticalPos === 1 /*
|
|
5930
|
+
y = verticalPos === 1 /* Below */ ? Math.max(y, staticR.bottom + objR.toph + objR.centerY) : Math.min(y, staticR.top - objR.bottomh - objR.centerY);
|
|
6028
5931
|
}
|
|
6029
5932
|
});
|
|
6030
5933
|
});
|
|
@@ -6038,6 +5941,15 @@ var LayoutObjectWrapper = class {
|
|
|
6038
5941
|
return void 0;
|
|
6039
5942
|
}
|
|
6040
5943
|
}
|
|
5944
|
+
layout(renderer) {
|
|
5945
|
+
this.line.addObject(this);
|
|
5946
|
+
}
|
|
5947
|
+
offset(dx, dy) {
|
|
5948
|
+
this.musicObj.offset(dx, dy);
|
|
5949
|
+
}
|
|
5950
|
+
getRect() {
|
|
5951
|
+
return this.musicObj.getRect();
|
|
5952
|
+
}
|
|
6041
5953
|
};
|
|
6042
5954
|
var LayoutGroup = class {
|
|
6043
5955
|
constructor(layoutGroupId) {
|
|
@@ -6045,8 +5957,8 @@ var LayoutGroup = class {
|
|
|
6045
5957
|
__publicField(this, "layoutObjectTable", []);
|
|
6046
5958
|
__publicField(this, "rowAlign");
|
|
6047
5959
|
__publicField(this, "widensColumn");
|
|
6048
|
-
this.layoutObjectTable[0 /*
|
|
6049
|
-
this.layoutObjectTable[1 /*
|
|
5960
|
+
this.layoutObjectTable[0 /* Above */] = [];
|
|
5961
|
+
this.layoutObjectTable[1 /* Below */] = [];
|
|
6050
5962
|
this.rowAlign = RowAlignList.indexOf(layoutGroupId) >= 0;
|
|
6051
5963
|
this.widensColumn = WidenColumnList.indexOf(layoutGroupId) >= 0;
|
|
6052
5964
|
}
|
|
@@ -6074,73 +5986,400 @@ var LayoutGroup = class {
|
|
|
6074
5986
|
}
|
|
6075
5987
|
};
|
|
6076
5988
|
|
|
6077
|
-
// src/score/engine/obj-
|
|
6078
|
-
var
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
this
|
|
6083
|
-
this.prevRow = prevRow;
|
|
6084
|
-
this.scoreConfig = scoreConfig;
|
|
6085
|
-
__publicField(this, "nextRow");
|
|
6086
|
-
__publicField(this, "minWidth", 0);
|
|
6087
|
-
__publicField(this, "notationLines");
|
|
6088
|
-
__publicField(this, "staves");
|
|
6089
|
-
__publicField(this, "tabs");
|
|
6090
|
-
__publicField(this, "measures", []);
|
|
6091
|
-
__publicField(this, "needLayout", true);
|
|
6092
|
-
__publicField(this, "mi");
|
|
6093
|
-
this.notationLines = this.createNotationLines();
|
|
6094
|
-
this.staves = this.notationLines.filter((line) => line instanceof ObjStaff);
|
|
6095
|
-
this.tabs = this.notationLines.filter((line) => line instanceof ObjTab);
|
|
6096
|
-
if (this.prevRow) {
|
|
6097
|
-
this.prevRow.nextRow = this;
|
|
6098
|
-
}
|
|
6099
|
-
this.mi = new MScoreRow(this);
|
|
6100
|
-
}
|
|
6101
|
-
getMusicInterface() {
|
|
6102
|
-
return this.mi;
|
|
6103
|
-
}
|
|
6104
|
-
createNotationLines() {
|
|
6105
|
-
let notationLines = this.scoreConfig.map((cfg) => cfg.type === "staff" ? new ObjStaff(this, cfg) : new ObjTab(this, cfg));
|
|
6106
|
-
for (let i = 0; i < notationLines.length - 1; i++) {
|
|
6107
|
-
let treble = notationLines[i];
|
|
6108
|
-
let bass = notationLines[i + 1];
|
|
6109
|
-
if (treble instanceof ObjStaff && treble.isGrand() && treble.staffConfig.clef === "G" /* G */ && bass instanceof ObjStaff && bass.isGrand() && bass.staffConfig.clef === "F" /* F */) {
|
|
6110
|
-
treble.joinGrandStaff(bass);
|
|
6111
|
-
bass.joinGrandStaff(treble);
|
|
6112
|
-
}
|
|
6113
|
-
}
|
|
6114
|
-
return notationLines;
|
|
5989
|
+
// src/score/engine/obj-staff-and-tab.ts
|
|
5990
|
+
var ObjNotationLine4 = class extends MusicObject {
|
|
5991
|
+
constructor(parent) {
|
|
5992
|
+
super(parent);
|
|
5993
|
+
__publicField(this, "objects", []);
|
|
5994
|
+
__publicField(this, "layoutGroups", []);
|
|
6115
5995
|
}
|
|
6116
|
-
|
|
6117
|
-
|
|
5996
|
+
addObject(o) {
|
|
5997
|
+
this.objects.push(o);
|
|
6118
5998
|
}
|
|
6119
|
-
|
|
6120
|
-
|
|
5999
|
+
removeObjects() {
|
|
6000
|
+
this.objects.length = 0;
|
|
6121
6001
|
}
|
|
6122
|
-
|
|
6123
|
-
|
|
6002
|
+
getLayoutGroup(lauoutGroupId) {
|
|
6003
|
+
let layoutGroup = this.layoutGroups[lauoutGroupId];
|
|
6004
|
+
if (!layoutGroup) {
|
|
6005
|
+
layoutGroup = this.layoutGroups[lauoutGroupId] = new LayoutGroup(lauoutGroupId);
|
|
6006
|
+
}
|
|
6007
|
+
return layoutGroup;
|
|
6124
6008
|
}
|
|
6125
|
-
|
|
6126
|
-
|
|
6009
|
+
resetLayoutGroups(renderer) {
|
|
6010
|
+
this.layoutGroups.forEach((layoutGroup) => {
|
|
6011
|
+
if (layoutGroup) {
|
|
6012
|
+
layoutGroup.clearPositionAndLayout(renderer);
|
|
6013
|
+
}
|
|
6014
|
+
});
|
|
6127
6015
|
}
|
|
6128
|
-
|
|
6129
|
-
|
|
6016
|
+
layoutLayoutGroups(renderer) {
|
|
6017
|
+
this.layoutGroups.forEach((layoutGroup) => {
|
|
6018
|
+
if (layoutGroup) {
|
|
6019
|
+
this.layoutLayoutGroup(renderer, layoutGroup, 0 /* Above */);
|
|
6020
|
+
this.layoutLayoutGroup(renderer, layoutGroup, 1 /* Below */);
|
|
6021
|
+
}
|
|
6022
|
+
});
|
|
6130
6023
|
}
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
return topStaff;
|
|
6135
|
-
} else {
|
|
6136
|
-
throw new import_core16.MusicError(import_core16.MusicErrorType.Score, "Top staff is required!");
|
|
6024
|
+
setObjectY(layoutObj, y) {
|
|
6025
|
+
if (y === void 0) {
|
|
6026
|
+
return;
|
|
6137
6027
|
}
|
|
6028
|
+
layoutObj.offset(0, y - layoutObj.getRect().centerY);
|
|
6029
|
+
layoutObj.setPositionResolved();
|
|
6138
6030
|
}
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6031
|
+
alignObjectsY(renderer, layoutObjArr) {
|
|
6032
|
+
layoutObjArr = layoutObjArr.filter((layoutObj) => !layoutObj.isPositionResolved());
|
|
6033
|
+
let rowY;
|
|
6034
|
+
layoutObjArr.forEach((layoutObj) => {
|
|
6035
|
+
let y = layoutObj.resolveClosestToStaffY(renderer);
|
|
6036
|
+
rowY = layoutObj.verticalPos === 1 /* Below */ ? Math.max(y, rowY != null ? rowY : y) : Math.min(y, rowY != null ? rowY : y);
|
|
6037
|
+
});
|
|
6038
|
+
layoutObjArr.forEach((layoutObj) => this.setObjectY(layoutObj, rowY));
|
|
6039
|
+
}
|
|
6040
|
+
layoutLayoutGroup(renderer, layoutGroup, verticalPos) {
|
|
6041
|
+
let rowLayoutObjs = layoutGroup.getLayoutObjects(verticalPos).filter((layoutObj) => !layoutObj.isPositionResolved());
|
|
6042
|
+
rowLayoutObjs.forEach((layoutObj) => {
|
|
6043
|
+
let { musicObj, anchor } = layoutObj;
|
|
6044
|
+
if (musicObj instanceof ObjEnding || musicObj instanceof ObjExtensionLine) {
|
|
6045
|
+
musicObj.layoutFitToMeasure(renderer);
|
|
6046
|
+
} else {
|
|
6047
|
+
musicObj.offset(anchor.getRect().centerX - musicObj.getRect().centerX, 0);
|
|
6048
|
+
}
|
|
6049
|
+
});
|
|
6050
|
+
if (layoutGroup.rowAlign) {
|
|
6051
|
+
this.alignObjectsY(renderer, rowLayoutObjs);
|
|
6052
|
+
} else {
|
|
6053
|
+
rowLayoutObjs.forEach((layoutObj) => {
|
|
6054
|
+
let link = layoutObj.musicObj.getLink();
|
|
6055
|
+
if (link && link.getHead() === layoutObj.musicObj) {
|
|
6056
|
+
let objectParts = [link.getHead(), ...link.getTails()];
|
|
6057
|
+
let layoutObjs = rowLayoutObjs.filter((layoutObj2) => objectParts.some((o) => o === layoutObj2.musicObj));
|
|
6058
|
+
this.alignObjectsY(renderer, layoutObjs);
|
|
6059
|
+
} else {
|
|
6060
|
+
this.alignObjectsY(renderer, [layoutObj]);
|
|
6061
|
+
}
|
|
6062
|
+
});
|
|
6063
|
+
}
|
|
6064
|
+
}
|
|
6065
|
+
};
|
|
6066
|
+
var ObjStaff = class extends ObjNotationLine4 {
|
|
6067
|
+
constructor(row, staffConfig, id) {
|
|
6068
|
+
super(row);
|
|
6069
|
+
this.row = row;
|
|
6070
|
+
this.staffConfig = staffConfig;
|
|
6071
|
+
this.id = id;
|
|
6072
|
+
__publicField(this, "clefImageAsset");
|
|
6073
|
+
__publicField(this, "clefLineDiatonicId");
|
|
6074
|
+
__publicField(this, "topLineDiatonicId");
|
|
6075
|
+
__publicField(this, "middleLineDiatonicId");
|
|
6076
|
+
__publicField(this, "bottomLineDiatonicId");
|
|
6077
|
+
__publicField(this, "minDiatonicId");
|
|
6078
|
+
__publicField(this, "maxDiatonicId");
|
|
6079
|
+
__publicField(this, "joinedGrandStaff");
|
|
6080
|
+
__publicField(this, "topLineY", 0);
|
|
6081
|
+
__publicField(this, "bottomLineY", 0);
|
|
6082
|
+
__publicField(this, "mi");
|
|
6083
|
+
const getDiatonicId = (noteName, isOctaveDown) => import_theory11.Note.getNote(noteName).diatonicId - (isOctaveDown ? 7 : 0);
|
|
6084
|
+
if (staffConfig.clef === "G" /* G */) {
|
|
6085
|
+
this.clefImageAsset = 0 /* TrebleClefPng */;
|
|
6086
|
+
this.clefLineDiatonicId = getDiatonicId("G4", staffConfig.isOctaveDown === true);
|
|
6087
|
+
this.middleLineDiatonicId = this.clefLineDiatonicId + 2;
|
|
6088
|
+
} else {
|
|
6089
|
+
this.clefImageAsset = 1 /* BassClefPng */;
|
|
6090
|
+
this.clefLineDiatonicId = getDiatonicId("F3", staffConfig.isOctaveDown === true);
|
|
6091
|
+
this.middleLineDiatonicId = this.clefLineDiatonicId - 2;
|
|
6092
|
+
}
|
|
6093
|
+
this.topLineDiatonicId = this.middleLineDiatonicId + 4;
|
|
6094
|
+
this.bottomLineDiatonicId = this.middleLineDiatonicId - 4;
|
|
6095
|
+
this.minDiatonicId = staffConfig.minNote !== void 0 ? Math.min(getDiatonicId(staffConfig.minNote, false), this.bottomLineDiatonicId) : void 0;
|
|
6096
|
+
this.maxDiatonicId = staffConfig.maxNote !== void 0 ? Math.max(getDiatonicId(staffConfig.maxNote, false), this.topLineDiatonicId) : void 0;
|
|
6097
|
+
this.mi = new MStaff(this);
|
|
6098
|
+
}
|
|
6099
|
+
getMusicInterface() {
|
|
6100
|
+
return this.mi;
|
|
6101
|
+
}
|
|
6102
|
+
get isOctaveDown() {
|
|
6103
|
+
return this.staffConfig.isOctaveDown === true;
|
|
6104
|
+
}
|
|
6105
|
+
get name() {
|
|
6106
|
+
var _a;
|
|
6107
|
+
return (_a = this.staffConfig.name) != null ? _a : "";
|
|
6108
|
+
}
|
|
6109
|
+
getTopLineY() {
|
|
6110
|
+
return this.topLineY;
|
|
6111
|
+
}
|
|
6112
|
+
getMiddleLineY() {
|
|
6113
|
+
return (this.topLineY + this.bottomLineY) / 2;
|
|
6114
|
+
}
|
|
6115
|
+
getBottomLineY() {
|
|
6116
|
+
return this.bottomLineY;
|
|
6117
|
+
}
|
|
6118
|
+
joinGrandStaff(staff) {
|
|
6119
|
+
if (staff !== this) {
|
|
6120
|
+
this.joinedGrandStaff = staff;
|
|
6121
|
+
}
|
|
6122
|
+
}
|
|
6123
|
+
getLineSpacing() {
|
|
6124
|
+
return (this.bottomLineY - this.topLineY) / 4;
|
|
6125
|
+
}
|
|
6126
|
+
getDiatonicSpacing() {
|
|
6127
|
+
return this.getLineSpacing() / 2;
|
|
6128
|
+
}
|
|
6129
|
+
containsDiatonicId(diatonicId) {
|
|
6130
|
+
import_theory11.Note.validateDiatonicId(diatonicId);
|
|
6131
|
+
return (this.minDiatonicId === void 0 || diatonicId >= this.minDiatonicId) && (this.maxDiatonicId === void 0 || diatonicId <= this.maxDiatonicId);
|
|
6132
|
+
}
|
|
6133
|
+
getDiatonicIdY(diatonicId) {
|
|
6134
|
+
if (this.containsDiatonicId(diatonicId)) {
|
|
6135
|
+
return this.bottomLineY + (this.bottomLineDiatonicId - diatonicId) * this.getDiatonicSpacing();
|
|
6136
|
+
} else if (this.joinedGrandStaff && this.joinedGrandStaff.containsDiatonicId(diatonicId)) {
|
|
6137
|
+
return this.joinedGrandStaff.getDiatonicIdY(diatonicId);
|
|
6138
|
+
} else {
|
|
6139
|
+
throw new import_core15.MusicError(import_core15.MusicErrorType.Score, "Staff does not contain diatonicId " + diatonicId);
|
|
6140
|
+
}
|
|
6141
|
+
}
|
|
6142
|
+
getActualStaff(diatonicId) {
|
|
6143
|
+
if (this.containsDiatonicId(diatonicId)) {
|
|
6144
|
+
return this;
|
|
6145
|
+
} else if (this.joinedGrandStaff && this.joinedGrandStaff.containsDiatonicId(diatonicId)) {
|
|
6146
|
+
return this.joinedGrandStaff;
|
|
6147
|
+
} else {
|
|
6148
|
+
throw new import_core15.MusicError(import_core15.MusicErrorType.Score, "Staff does not contain diatonicId " + diatonicId);
|
|
6149
|
+
}
|
|
6150
|
+
}
|
|
6151
|
+
getDiatonicIdAt(y) {
|
|
6152
|
+
let diatonicId = Math.round(this.bottomLineDiatonicId - (y - this.bottomLineY) / this.getDiatonicSpacing());
|
|
6153
|
+
return this.containsDiatonicId(diatonicId) ? diatonicId : void 0;
|
|
6154
|
+
}
|
|
6155
|
+
isLine(diatonicId) {
|
|
6156
|
+
return diatonicId % 2 === this.middleLineDiatonicId % 2;
|
|
6157
|
+
}
|
|
6158
|
+
isSpace(diatonicId) {
|
|
6159
|
+
return diatonicId % 2 !== this.middleLineDiatonicId % 2;
|
|
6160
|
+
}
|
|
6161
|
+
containsVoiceId(voiceId) {
|
|
6162
|
+
return !this.staffConfig.voiceIds || this.staffConfig.voiceIds.includes(voiceId);
|
|
6163
|
+
}
|
|
6164
|
+
isGrand() {
|
|
6165
|
+
return this.staffConfig.isGrand === true;
|
|
6166
|
+
}
|
|
6167
|
+
calcTop() {
|
|
6168
|
+
let top = this.topLineY;
|
|
6169
|
+
this.objects.forEach((o) => top = Math.min(top, o.getRect().top));
|
|
6170
|
+
if (this.maxDiatonicId !== void 0) {
|
|
6171
|
+
let y = this.getDiatonicIdY(this.maxDiatonicId);
|
|
6172
|
+
let y2 = this.getDiatonicIdY(this.maxDiatonicId - 1);
|
|
6173
|
+
top = Math.min(top, y - Math.abs(y2 - y) + 1);
|
|
6174
|
+
}
|
|
6175
|
+
return top;
|
|
6176
|
+
}
|
|
6177
|
+
calcBottom() {
|
|
6178
|
+
let bottom = this.bottomLineY;
|
|
6179
|
+
this.objects.forEach((o) => bottom = Math.max(bottom, o.getRect().bottom));
|
|
6180
|
+
if (this.minDiatonicId !== void 0) {
|
|
6181
|
+
let y = this.getDiatonicIdY(this.minDiatonicId);
|
|
6182
|
+
let y2 = this.getDiatonicIdY(this.minDiatonicId + 1);
|
|
6183
|
+
bottom = Math.max(bottom, y + Math.abs(y2 - y) - 1);
|
|
6184
|
+
}
|
|
6185
|
+
return bottom;
|
|
6186
|
+
}
|
|
6187
|
+
pick(x, y) {
|
|
6188
|
+
return [this];
|
|
6189
|
+
}
|
|
6190
|
+
layoutHeight(renderer) {
|
|
6191
|
+
let { unitSize } = renderer;
|
|
6192
|
+
let h = unitSize * DocumentSettings.StaffHeight;
|
|
6193
|
+
this.topLineY = -h / 2;
|
|
6194
|
+
this.bottomLineY = h / 2;
|
|
6195
|
+
this.rect = new DivRect(0, 0, this.topLineY, this.bottomLineY);
|
|
6196
|
+
}
|
|
6197
|
+
layoutWidth(renderer) {
|
|
6198
|
+
this.rect.left = this.row.getRect().left;
|
|
6199
|
+
this.rect.right = this.row.getRect().right;
|
|
6200
|
+
}
|
|
6201
|
+
offset(dx, dy) {
|
|
6202
|
+
this.topLineY += dy;
|
|
6203
|
+
this.bottomLineY += dy;
|
|
6204
|
+
this.objects.forEach((o) => {
|
|
6205
|
+
if (o.offsetInPlace) {
|
|
6206
|
+
o.offsetInPlace(0, dy);
|
|
6207
|
+
} else if (o.offset) {
|
|
6208
|
+
o.offset(0, dy);
|
|
6209
|
+
}
|
|
6210
|
+
});
|
|
6211
|
+
this.rect.offsetInPlace(dx, dy);
|
|
6212
|
+
}
|
|
6213
|
+
draw(renderer) {
|
|
6214
|
+
}
|
|
6215
|
+
};
|
|
6216
|
+
var ObjTab = class extends ObjNotationLine4 {
|
|
6217
|
+
constructor(row, tabConfig, id) {
|
|
6218
|
+
super(row);
|
|
6219
|
+
this.row = row;
|
|
6220
|
+
this.tabConfig = tabConfig;
|
|
6221
|
+
this.id = id;
|
|
6222
|
+
__publicField(this, "top", 0);
|
|
6223
|
+
__publicField(this, "bottom", 0);
|
|
6224
|
+
__publicField(this, "tuningName");
|
|
6225
|
+
__publicField(this, "tuningStrings");
|
|
6226
|
+
__publicField(this, "mi");
|
|
6227
|
+
if (import_ts_utils_lib9.Utils.Is.isArray(tabConfig.tuning)) {
|
|
6228
|
+
this.tuningName = void 0;
|
|
6229
|
+
this.tuningStrings = tabConfig.tuning.map((noteName) => import_theory11.Note.getNote(noteName)).reverse();
|
|
6230
|
+
} else if (typeof tabConfig.tuning === "string") {
|
|
6231
|
+
this.tuningName = (0, import_theory11.validateTuningName)(tabConfig.tuning);
|
|
6232
|
+
this.tuningStrings = (0, import_theory11.getTuningStrings)(this.tuningName);
|
|
6233
|
+
} else {
|
|
6234
|
+
this.tuningName = "Standard";
|
|
6235
|
+
this.tuningStrings = (0, import_theory11.getTuningStrings)(this.tuningName);
|
|
6236
|
+
}
|
|
6237
|
+
this.mi = new MTab(this);
|
|
6238
|
+
}
|
|
6239
|
+
getMusicInterface() {
|
|
6240
|
+
return this.mi;
|
|
6241
|
+
}
|
|
6242
|
+
get name() {
|
|
6243
|
+
var _a;
|
|
6244
|
+
return (_a = this.tabConfig.name) != null ? _a : "";
|
|
6245
|
+
}
|
|
6246
|
+
getTuningName() {
|
|
6247
|
+
return this.tuningName;
|
|
6248
|
+
}
|
|
6249
|
+
getTuningStrings() {
|
|
6250
|
+
return this.tuningStrings;
|
|
6251
|
+
}
|
|
6252
|
+
/** Return Y coordinate of string. */
|
|
6253
|
+
getStringY(stringId) {
|
|
6254
|
+
return this.top + (this.bottom - this.top) / 6 * (stringId + 0.5);
|
|
6255
|
+
}
|
|
6256
|
+
getTopStringY() {
|
|
6257
|
+
return this.getStringY(0);
|
|
6258
|
+
}
|
|
6259
|
+
getBottomStringY() {
|
|
6260
|
+
return this.getStringY(5);
|
|
6261
|
+
}
|
|
6262
|
+
getTopLineY() {
|
|
6263
|
+
return this.getTopStringY();
|
|
6264
|
+
}
|
|
6265
|
+
getBottomLineY() {
|
|
6266
|
+
return this.getBottomStringY();
|
|
6267
|
+
}
|
|
6268
|
+
getTop() {
|
|
6269
|
+
return this.top;
|
|
6270
|
+
}
|
|
6271
|
+
getBottom() {
|
|
6272
|
+
return this.bottom;
|
|
6273
|
+
}
|
|
6274
|
+
containsVoiceId(voiceId) {
|
|
6275
|
+
return !this.tabConfig.voiceIds || this.tabConfig.voiceIds.includes(voiceId);
|
|
6276
|
+
}
|
|
6277
|
+
containsDiatonicId(diatonicId) {
|
|
6278
|
+
return true;
|
|
6279
|
+
}
|
|
6280
|
+
calcTop() {
|
|
6281
|
+
return this.top;
|
|
6282
|
+
}
|
|
6283
|
+
calcBottom() {
|
|
6284
|
+
return this.bottom;
|
|
6285
|
+
}
|
|
6286
|
+
pick(x, y) {
|
|
6287
|
+
return [this];
|
|
6288
|
+
}
|
|
6289
|
+
layoutHeight(renderer) {
|
|
6290
|
+
let { unitSize } = renderer;
|
|
6291
|
+
let h = unitSize * DocumentSettings.TabHeight;
|
|
6292
|
+
this.top = -h / 2;
|
|
6293
|
+
this.bottom = h / 2;
|
|
6294
|
+
this.rect = new DivRect(0, 0, this.top, this.bottom);
|
|
6295
|
+
}
|
|
6296
|
+
layoutWidth(renderer) {
|
|
6297
|
+
this.rect.left = this.row.getRect().left;
|
|
6298
|
+
this.rect.right = this.row.getRect().right;
|
|
6299
|
+
}
|
|
6300
|
+
offset(dx, dy) {
|
|
6301
|
+
this.top += dy;
|
|
6302
|
+
this.bottom += dy;
|
|
6303
|
+
this.objects.forEach((o) => {
|
|
6304
|
+
if (o.offsetInPlace) {
|
|
6305
|
+
o.offsetInPlace(0, dy);
|
|
6306
|
+
} else if (o.offset) {
|
|
6307
|
+
o.offset(0, dy);
|
|
6308
|
+
}
|
|
6309
|
+
});
|
|
6310
|
+
this.rect.offsetInPlace(dx, dy);
|
|
6311
|
+
}
|
|
6312
|
+
draw(renderer) {
|
|
6313
|
+
}
|
|
6314
|
+
};
|
|
6315
|
+
|
|
6316
|
+
// src/score/engine/obj-score-row.ts
|
|
6317
|
+
var import_core16 = require("@tspro/web-music-score/core");
|
|
6318
|
+
var ObjScoreRow = class extends MusicObject {
|
|
6319
|
+
constructor(doc, prevRow, scoreConfig) {
|
|
6320
|
+
super(doc);
|
|
6321
|
+
this.doc = doc;
|
|
6322
|
+
this.prevRow = prevRow;
|
|
6323
|
+
this.scoreConfig = scoreConfig;
|
|
6324
|
+
__publicField(this, "nextRow");
|
|
6325
|
+
__publicField(this, "minWidth", 0);
|
|
6326
|
+
__publicField(this, "notationLines");
|
|
6327
|
+
__publicField(this, "staves");
|
|
6328
|
+
__publicField(this, "tabs");
|
|
6329
|
+
__publicField(this, "measures", []);
|
|
6330
|
+
__publicField(this, "needLayout", true);
|
|
6331
|
+
__publicField(this, "mi");
|
|
6332
|
+
this.notationLines = this.createNotationLines();
|
|
6333
|
+
this.staves = this.notationLines.filter((line) => line instanceof ObjStaff);
|
|
6334
|
+
this.tabs = this.notationLines.filter((line) => line instanceof ObjTab);
|
|
6335
|
+
if (this.prevRow) {
|
|
6336
|
+
this.prevRow.nextRow = this;
|
|
6337
|
+
}
|
|
6338
|
+
this.mi = new MScoreRow(this);
|
|
6339
|
+
}
|
|
6340
|
+
getMusicInterface() {
|
|
6341
|
+
return this.mi;
|
|
6342
|
+
}
|
|
6343
|
+
createNotationLines() {
|
|
6344
|
+
let notationLines = this.scoreConfig.map((cfg, index) => cfg.type === "staff" ? new ObjStaff(this, cfg, index) : new ObjTab(this, cfg, index));
|
|
6345
|
+
for (let i = 0; i < notationLines.length - 1; i++) {
|
|
6346
|
+
let treble = notationLines[i];
|
|
6347
|
+
let bass = notationLines[i + 1];
|
|
6348
|
+
if (treble instanceof ObjStaff && treble.isGrand() && treble.staffConfig.clef === "G" /* G */ && bass instanceof ObjStaff && bass.isGrand() && bass.staffConfig.clef === "F" /* F */) {
|
|
6349
|
+
treble.joinGrandStaff(bass);
|
|
6350
|
+
bass.joinGrandStaff(treble);
|
|
6351
|
+
}
|
|
6352
|
+
}
|
|
6353
|
+
return notationLines;
|
|
6354
|
+
}
|
|
6355
|
+
getNotationLines() {
|
|
6356
|
+
return this.notationLines;
|
|
6357
|
+
}
|
|
6358
|
+
getStaves() {
|
|
6359
|
+
return this.staves;
|
|
6360
|
+
}
|
|
6361
|
+
getTabs() {
|
|
6362
|
+
return this.tabs;
|
|
6363
|
+
}
|
|
6364
|
+
get hasStaff() {
|
|
6365
|
+
return this.staves.length > 0;
|
|
6366
|
+
}
|
|
6367
|
+
get hasTab() {
|
|
6368
|
+
return this.tabs.length > 0;
|
|
6369
|
+
}
|
|
6370
|
+
getTopStaff() {
|
|
6371
|
+
let topStaff = this.staves[0];
|
|
6372
|
+
if (topStaff) {
|
|
6373
|
+
return topStaff;
|
|
6374
|
+
} else {
|
|
6375
|
+
throw new import_core16.MusicError(import_core16.MusicErrorType.Score, "Top staff is required!");
|
|
6376
|
+
}
|
|
6377
|
+
}
|
|
6378
|
+
getBottomStaff() {
|
|
6379
|
+
let bottomStaff = this.staves[this.staves.length - 1];
|
|
6380
|
+
if (bottomStaff) {
|
|
6381
|
+
return bottomStaff;
|
|
6382
|
+
} else {
|
|
6144
6383
|
throw new import_core16.MusicError(import_core16.MusicErrorType.Score, "Bottom staff is required!");
|
|
6145
6384
|
}
|
|
6146
6385
|
}
|
|
@@ -6154,6 +6393,12 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
6154
6393
|
}
|
|
6155
6394
|
return void 0;
|
|
6156
6395
|
}
|
|
6396
|
+
resetLayoutGroups(renderer) {
|
|
6397
|
+
this.notationLines.forEach((line) => line.resetLayoutGroups(renderer));
|
|
6398
|
+
}
|
|
6399
|
+
layoutLayoutGroups(renderer) {
|
|
6400
|
+
this.notationLines.forEach((line) => line.layoutLayoutGroups(renderer));
|
|
6401
|
+
}
|
|
6157
6402
|
pick(x, y) {
|
|
6158
6403
|
if (!this.getRect().contains(x, y)) {
|
|
6159
6404
|
return [];
|
|
@@ -6234,7 +6479,6 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
6234
6479
|
this.minWidth = 0;
|
|
6235
6480
|
this.measures.forEach((m) => {
|
|
6236
6481
|
m.layout(renderer);
|
|
6237
|
-
this.rect.expandInPlace(new DivRect(0, 0, m.getRect().top, m.getRect().bottom));
|
|
6238
6482
|
this.minWidth += m.getMinWidth();
|
|
6239
6483
|
this.minWidth += m.getPostMeasureBreakWidth();
|
|
6240
6484
|
});
|
|
@@ -6268,6 +6512,13 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
6268
6512
|
m.layoutBeams(renderer);
|
|
6269
6513
|
});
|
|
6270
6514
|
}
|
|
6515
|
+
updateRect() {
|
|
6516
|
+
let left = this.measures.length > 0 ? this.measures[0].getRect().left : 0;
|
|
6517
|
+
let right = this.measures.length > 0 ? this.measures[this.measures.length - 1].getRect().right : 0;
|
|
6518
|
+
let top = Math.min(0, ...this.measures.map((m) => m.getRect().top));
|
|
6519
|
+
let bottom = Math.max(0, ...this.measures.map((m) => m.getRect().bottom));
|
|
6520
|
+
this.rect = new DivRect(left, right, top, bottom);
|
|
6521
|
+
}
|
|
6271
6522
|
alignStemsToBeams() {
|
|
6272
6523
|
this.measures.forEach((m) => m.alignStemsToBeams());
|
|
6273
6524
|
}
|
|
@@ -6284,7 +6535,6 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
6284
6535
|
cur.offset(0, prev.calcBottom() - cur.calcTop() + sep);
|
|
6285
6536
|
}
|
|
6286
6537
|
}
|
|
6287
|
-
this.requestRectUpdate();
|
|
6288
6538
|
this.measures.forEach((m) => {
|
|
6289
6539
|
m.requestRectUpdate();
|
|
6290
6540
|
m.getBarLineLeft().requestRectUpdate();
|
|
@@ -6297,59 +6547,12 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
6297
6547
|
});
|
|
6298
6548
|
});
|
|
6299
6549
|
});
|
|
6300
|
-
let lines = this.getNotationLines();
|
|
6301
|
-
this.rect.top = lines[0].calcTop();
|
|
6302
|
-
this.rect.bottom = lines[lines.length - 1].calcBottom();
|
|
6303
6550
|
this.alignStemsToBeams();
|
|
6304
|
-
|
|
6305
|
-
updateRect() {
|
|
6306
|
-
}
|
|
6307
|
-
setObjectY(layoutObj, y) {
|
|
6308
|
-
if (y === void 0) {
|
|
6309
|
-
return;
|
|
6310
|
-
}
|
|
6311
|
-
let { measure, musicObj } = layoutObj;
|
|
6312
|
-
musicObj.offset(0, y - musicObj.getRect().centerY);
|
|
6313
|
-
layoutObj.setPositionResolved();
|
|
6314
|
-
measure.getRect().expandInPlace(musicObj.getRect());
|
|
6315
|
-
this.rect.expandInPlace(measure.getRect());
|
|
6316
|
-
}
|
|
6317
|
-
alignObjectsY(renderer, layoutObjArr) {
|
|
6318
|
-
layoutObjArr = layoutObjArr.filter((layoutObj) => !layoutObj.isPositionResolved());
|
|
6319
|
-
let rowY;
|
|
6320
|
-
layoutObjArr.forEach((layoutObj) => {
|
|
6321
|
-
let y = layoutObj.resolveClosestToStaffY(renderer);
|
|
6322
|
-
rowY = layoutObj.verticalPos === 1 /* BelowStaff */ ? Math.max(y, rowY != null ? rowY : y) : Math.min(y, rowY != null ? rowY : y);
|
|
6323
|
-
});
|
|
6324
|
-
layoutObjArr.forEach((layoutObj) => this.setObjectY(layoutObj, rowY));
|
|
6325
|
-
}
|
|
6326
|
-
layoutLayoutGroup(renderer, layoutGroup, verticalPos) {
|
|
6327
|
-
let rowLayoutObjs = layoutGroup.getLayoutObjects(verticalPos).filter((layoutObj) => layoutObj.row === this && !layoutObj.isPositionResolved());
|
|
6328
|
-
rowLayoutObjs.forEach((layoutObj) => {
|
|
6329
|
-
let { musicObj, anchor } = layoutObj;
|
|
6330
|
-
if (musicObj instanceof ObjEnding || musicObj instanceof ObjExtensionLine) {
|
|
6331
|
-
musicObj.layoutFitToMeasure(renderer);
|
|
6332
|
-
} else {
|
|
6333
|
-
musicObj.offset(anchor.getRect().centerX - musicObj.getRect().centerX, 0);
|
|
6334
|
-
}
|
|
6335
|
-
});
|
|
6336
|
-
if (layoutGroup.rowAlign) {
|
|
6337
|
-
this.alignObjectsY(renderer, rowLayoutObjs);
|
|
6338
|
-
} else {
|
|
6339
|
-
rowLayoutObjs.forEach((layoutObj) => {
|
|
6340
|
-
let link = layoutObj.musicObj.getLink();
|
|
6341
|
-
if (link && link.getHead() === layoutObj.musicObj) {
|
|
6342
|
-
let objectParts = [link.getHead(), ...link.getTails()];
|
|
6343
|
-
let layoutObjs = rowLayoutObjs.filter((layoutObj2) => objectParts.some((o) => o === layoutObj2.musicObj));
|
|
6344
|
-
this.alignObjectsY(renderer, layoutObjs);
|
|
6345
|
-
} else {
|
|
6346
|
-
this.alignObjectsY(renderer, [layoutObj]);
|
|
6347
|
-
}
|
|
6348
|
-
});
|
|
6349
|
-
}
|
|
6551
|
+
this.requestRectUpdate();
|
|
6350
6552
|
}
|
|
6351
6553
|
layoutPadding(renderer) {
|
|
6352
6554
|
let p = renderer.unitSize / 2;
|
|
6555
|
+
this.getRect();
|
|
6353
6556
|
this.rect.left -= p;
|
|
6354
6557
|
this.rect.right += p;
|
|
6355
6558
|
this.rect.top -= p;
|
|
@@ -6373,21 +6576,10 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
6373
6576
|
ctx.save();
|
|
6374
6577
|
ctx.rect(this.getRect().left, this.getRect().top, this.getRect().width, this.getRect().height);
|
|
6375
6578
|
ctx.clip();
|
|
6376
|
-
if (this.getFirstMeasure() && this.notationLines.length > 1 || this.notationLines
|
|
6579
|
+
if (this.getFirstMeasure() && (this.notationLines.length > 1 || this.notationLines[0] instanceof ObjTab)) {
|
|
6377
6580
|
let left = this.getFirstMeasure().getStaffLineLeft();
|
|
6378
|
-
let
|
|
6379
|
-
let
|
|
6380
|
-
this.notationLines.forEach((line) => {
|
|
6381
|
-
if (line instanceof ObjStaff) {
|
|
6382
|
-
tops.push(line.getTopLineY());
|
|
6383
|
-
bottoms.push(line.getBottomLineY());
|
|
6384
|
-
} else {
|
|
6385
|
-
tops.push(line.getTopStringY());
|
|
6386
|
-
bottoms.push(line.getBottomStringY());
|
|
6387
|
-
}
|
|
6388
|
-
});
|
|
6389
|
-
let top = Math.min(...tops);
|
|
6390
|
-
let bottom = Math.max(...bottoms);
|
|
6581
|
+
let top = Math.min(...this.notationLines.map((line) => line.getTopLineY()));
|
|
6582
|
+
let bottom = Math.max(...this.notationLines.map((line) => line.getBottomLineY()));
|
|
6391
6583
|
renderer.drawLine(left, top, left, bottom);
|
|
6392
6584
|
}
|
|
6393
6585
|
this.measures.forEach((m) => m.draw(renderer));
|
|
@@ -6498,9 +6690,9 @@ var ObjDocument = class extends MusicObject {
|
|
|
6498
6690
|
__publicField(this, "measuresPerRow", Infinity);
|
|
6499
6691
|
__publicField(this, "curScoreConfig", [{ type: "staff", clef: "G" /* G */ }]);
|
|
6500
6692
|
__publicField(this, "header");
|
|
6501
|
-
__publicField(this, "layoutGroups", []);
|
|
6502
6693
|
__publicField(this, "newRowRequested", false);
|
|
6503
6694
|
__publicField(this, "allConnectiveProps", []);
|
|
6695
|
+
__publicField(this, "staffGroups", /* @__PURE__ */ new Map());
|
|
6504
6696
|
__publicField(this, "mi");
|
|
6505
6697
|
this.mi = new MDocument2(this);
|
|
6506
6698
|
}
|
|
@@ -6566,13 +6758,6 @@ var ObjDocument = class extends MusicObject {
|
|
|
6566
6758
|
addConnectiveProps(connectiveProps) {
|
|
6567
6759
|
this.allConnectiveProps.push(connectiveProps);
|
|
6568
6760
|
}
|
|
6569
|
-
getLayoutGroup(lauoutGroupId) {
|
|
6570
|
-
let layoutGroup = this.layoutGroups[lauoutGroupId];
|
|
6571
|
-
if (!layoutGroup) {
|
|
6572
|
-
layoutGroup = this.layoutGroups[lauoutGroupId] = new LayoutGroup(lauoutGroupId);
|
|
6573
|
-
}
|
|
6574
|
-
return layoutGroup;
|
|
6575
|
-
}
|
|
6576
6761
|
setRenderer(renderer) {
|
|
6577
6762
|
if (this.renderer === renderer) {
|
|
6578
6763
|
return;
|
|
@@ -6638,6 +6823,12 @@ var ObjDocument = class extends MusicObject {
|
|
|
6638
6823
|
this.requestLayout();
|
|
6639
6824
|
return measure;
|
|
6640
6825
|
}
|
|
6826
|
+
addStaffGroup(groupName, layoutElements, verticalPosition) {
|
|
6827
|
+
this.staffGroups.set(groupName, new StaffGroup(groupName, layoutElements, verticalPosition));
|
|
6828
|
+
}
|
|
6829
|
+
getStaffGroup(groupName) {
|
|
6830
|
+
return this.staffGroups.get(groupName);
|
|
6831
|
+
}
|
|
6641
6832
|
getVoiceSymbols(voiceId) {
|
|
6642
6833
|
let voiceSymbols = [];
|
|
6643
6834
|
this.forEachMeasure((m) => voiceSymbols = voiceSymbols.concat(m.getVoiceSymbols(voiceId)));
|
|
@@ -6685,21 +6876,15 @@ var ObjDocument = class extends MusicObject {
|
|
|
6685
6876
|
this.forEachMeasure((m) => m.createExtensions());
|
|
6686
6877
|
this.allConnectiveProps.forEach((props) => props.removeConnectives());
|
|
6687
6878
|
this.allConnectiveProps.forEach((props) => props.createConnectives());
|
|
6688
|
-
|
|
6689
|
-
layoutGroups.forEach((layoutGroup) => layoutGroup.clearPositionAndLayout(renderer));
|
|
6879
|
+
this.rows.forEach((row) => row.resetLayoutGroups(renderer));
|
|
6690
6880
|
this.rows.forEach((row) => row.layout(renderer));
|
|
6691
6881
|
let rowWidth = Math.max(
|
|
6692
6882
|
DocumentSettings.DocumentMinWidth * unitSize,
|
|
6693
6883
|
...this.rows.map((row) => 1.4 * row.getMinWidth())
|
|
6694
6884
|
);
|
|
6695
6885
|
this.rows.forEach((row) => row.layoutWidth(renderer, rowWidth));
|
|
6886
|
+
this.rows.forEach((row) => row.layoutLayoutGroups(renderer));
|
|
6696
6887
|
this.rows.forEach((row) => row.layoutPositionLines(renderer));
|
|
6697
|
-
layoutGroups.forEach((layoutGroup) => {
|
|
6698
|
-
this.rows.forEach((row) => {
|
|
6699
|
-
row.layoutLayoutGroup(renderer, layoutGroup, 0 /* AboveStaff */);
|
|
6700
|
-
row.layoutLayoutGroup(renderer, layoutGroup, 1 /* BelowStaff */);
|
|
6701
|
-
});
|
|
6702
|
-
});
|
|
6703
6888
|
this.rows.forEach((row) => row.layoutPadding(renderer));
|
|
6704
6889
|
this.rect = new DivRect();
|
|
6705
6890
|
if (this.header) {
|
|
@@ -6823,6 +7008,15 @@ function assertRestOptions(options) {
|
|
|
6823
7008
|
assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(options.hide), "restOptions.hide", options.hide);
|
|
6824
7009
|
assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(options.triplet), "restOptions.triplet", options.triplet);
|
|
6825
7010
|
}
|
|
7011
|
+
function assertStaffTabOrGRoups(staffTabOrGroups) {
|
|
7012
|
+
assertArg(
|
|
7013
|
+
import_ts_utils_lib11.Utils.Is.isStringOrUndefined(staffTabOrGroups) || import_ts_utils_lib11.Utils.Is.isIntegerGte(staffTabOrGroups, 0) || import_ts_utils_lib11.Utils.Is.isArray(staffTabOrGroups) && staffTabOrGroups.every(
|
|
7014
|
+
(staffTabOrGroup) => import_ts_utils_lib11.Utils.Is.isString(staffTabOrGroup) || import_ts_utils_lib11.Utils.Is.isIntegerGte(staffTabOrGroup, 0)
|
|
7015
|
+
),
|
|
7016
|
+
"staffTabOrGroup",
|
|
7017
|
+
staffTabOrGroups
|
|
7018
|
+
);
|
|
7019
|
+
}
|
|
6826
7020
|
var DocumentBuilder = class {
|
|
6827
7021
|
constructor() {
|
|
6828
7022
|
__publicField(this, "doc");
|
|
@@ -6924,21 +7118,64 @@ var DocumentBuilder = class {
|
|
|
6924
7118
|
this.getMeasure().addRest(voiceId, restLength, options);
|
|
6925
7119
|
return this;
|
|
6926
7120
|
}
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
7121
|
+
addFermataInternal(staffTabOrGroups, fermata) {
|
|
7122
|
+
assertStaffTabOrGRoups(staffTabOrGroups);
|
|
7123
|
+
assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(fermata, Fermata), "fermata", fermata);
|
|
7124
|
+
this.getMeasure().addFermata(staffTabOrGroups, fermata);
|
|
6930
7125
|
return this;
|
|
6931
7126
|
}
|
|
6932
|
-
|
|
7127
|
+
addFermata(fermata = 0 /* AtNote */) {
|
|
7128
|
+
return this.addFermataInternal(void 0, fermata);
|
|
7129
|
+
}
|
|
7130
|
+
/** @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name. */
|
|
7131
|
+
addFermataTo(staffTabOrGroups, fermata = 0 /* AtNote */) {
|
|
7132
|
+
return this.addFermataInternal(staffTabOrGroups, fermata);
|
|
7133
|
+
}
|
|
7134
|
+
addNavigationInternal(staffTabOrGroups, navigation, ...args) {
|
|
7135
|
+
assertStaffTabOrGRoups(staffTabOrGroups);
|
|
6933
7136
|
assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(navigation, Navigation), "navigation", navigation);
|
|
6934
7137
|
if (navigation === 9 /* EndRepeat */ && args.length > 0) {
|
|
6935
7138
|
assertArg(import_ts_utils_lib11.Utils.Is.isIntegerGte(args[0], 1), "playCount", args[0]);
|
|
6936
7139
|
} else if (navigation === 10 /* Ending */ && args.length > 0) {
|
|
6937
7140
|
assertArg(args.every((passage) => import_ts_utils_lib11.Utils.Is.isIntegerGte(passage, 1)), "passages", args);
|
|
6938
7141
|
}
|
|
6939
|
-
this.getMeasure().addNavigation(navigation, ...args);
|
|
7142
|
+
this.getMeasure().addNavigation(staffTabOrGroups, navigation, ...args);
|
|
6940
7143
|
return this;
|
|
6941
7144
|
}
|
|
7145
|
+
addNavigation(navigation, ...args) {
|
|
7146
|
+
return this.addNavigationInternal(void 0, navigation, ...args);
|
|
7147
|
+
}
|
|
7148
|
+
addNavigationTo(staffTabOrGroups, navigation, ...args) {
|
|
7149
|
+
return this.addNavigationInternal(staffTabOrGroups, navigation, ...args);
|
|
7150
|
+
}
|
|
7151
|
+
addLabelInternal(staffTabOrGroups, label, text) {
|
|
7152
|
+
assertStaffTabOrGRoups(staffTabOrGroups);
|
|
7153
|
+
assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(label, Label), "label", label);
|
|
7154
|
+
assertArg(import_ts_utils_lib11.Utils.Is.isString(text), "text", text);
|
|
7155
|
+
this.getMeasure().addLabel(staffTabOrGroups, label, text);
|
|
7156
|
+
return this;
|
|
7157
|
+
}
|
|
7158
|
+
addLabel(label, text) {
|
|
7159
|
+
return this.addLabelInternal(void 0, label, text);
|
|
7160
|
+
}
|
|
7161
|
+
/** @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name. */
|
|
7162
|
+
addLabelTo(staffTabOrGroups, label, text) {
|
|
7163
|
+
return this.addLabelInternal(staffTabOrGroups, label, text);
|
|
7164
|
+
}
|
|
7165
|
+
addAnnotationInternal(staffTabOrGroups, annotation, text) {
|
|
7166
|
+
assertStaffTabOrGRoups(staffTabOrGroups);
|
|
7167
|
+
assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(annotation, Annotation), "annotation", annotation);
|
|
7168
|
+
assertArg(import_ts_utils_lib11.Utils.Is.isString(text), "text", text);
|
|
7169
|
+
this.getMeasure().addAnnotation(staffTabOrGroups, annotation, text);
|
|
7170
|
+
return this;
|
|
7171
|
+
}
|
|
7172
|
+
addAnnotation(annotation, text) {
|
|
7173
|
+
return this.addAnnotationInternal(void 0, annotation, text);
|
|
7174
|
+
}
|
|
7175
|
+
/** @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name. */
|
|
7176
|
+
addAnnotationTo(staffTabOrGroups, annotation, text) {
|
|
7177
|
+
return this.addAnnotationInternal(staffTabOrGroups, annotation, text);
|
|
7178
|
+
}
|
|
6942
7179
|
addConnective(connective, ...args) {
|
|
6943
7180
|
assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(connective, Connective), "connective", connective);
|
|
6944
7181
|
if (connective === 0 /* Tie */) {
|
|
@@ -6960,24 +7197,30 @@ var DocumentBuilder = class {
|
|
|
6960
7197
|
}
|
|
6961
7198
|
return this;
|
|
6962
7199
|
}
|
|
6963
|
-
addLabel(label, text) {
|
|
6964
|
-
assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(label, Label), "label", label);
|
|
6965
|
-
assertArg(import_ts_utils_lib11.Utils.Is.isString(text), "text", text);
|
|
6966
|
-
this.getMeasure().addLabel(label, text);
|
|
6967
|
-
return this;
|
|
6968
|
-
}
|
|
6969
|
-
addAnnotation(annotation, text) {
|
|
6970
|
-
assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(annotation, Annotation), "annotation", annotation);
|
|
6971
|
-
assertArg(import_ts_utils_lib11.Utils.Is.isString(text), "text", text);
|
|
6972
|
-
this.getMeasure().addAnnotation(annotation, text);
|
|
6973
|
-
return this;
|
|
6974
|
-
}
|
|
6975
7200
|
addExtension(extensionLength, extensionVisible) {
|
|
6976
7201
|
assertArg(import_ts_utils_lib11.Utils.Is.isIntegerGte(extensionLength, 0) || extensionLength === Infinity || import_ts_utils_lib11.Utils.Is.isEnumValue(extensionLength, import_theory13.NoteLength), "extendionLength", extensionLength);
|
|
6977
7202
|
assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(extensionVisible), "extensionVisible", extensionVisible);
|
|
6978
7203
|
this.getMeasure().addExtension(extensionLength, extensionVisible != null ? extensionVisible : true);
|
|
6979
7204
|
return this;
|
|
6980
7205
|
}
|
|
7206
|
+
/**
|
|
7207
|
+
*
|
|
7208
|
+
* @param groupName - Name of staff group.
|
|
7209
|
+
* @param staffsTabsAndGroups - staff/tab index (0=top), staff/tab name, or staff group name. Single value or array.
|
|
7210
|
+
* @param verticalPosition - Vertical position, are elements added above, below or both.
|
|
7211
|
+
* @returns
|
|
7212
|
+
*/
|
|
7213
|
+
addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition = 3 /* Auto */) {
|
|
7214
|
+
assertArg(import_ts_utils_lib11.Utils.Is.isString(groupName) && groupName.length > 0, "groupName", groupName);
|
|
7215
|
+
assertArg(
|
|
7216
|
+
import_ts_utils_lib11.Utils.Is.isString(staffsTabsAndGroups) && staffsTabsAndGroups.length > 0 || import_ts_utils_lib11.Utils.Is.isIntegerGte(staffsTabsAndGroups, 0) || import_ts_utils_lib11.Utils.Is.isArray(staffsTabsAndGroups) && staffsTabsAndGroups.every((line) => import_ts_utils_lib11.Utils.Is.isString(line) && line.length > 0 || import_ts_utils_lib11.Utils.Is.isIntegerGte(line, 0)),
|
|
7217
|
+
"staffsTabsAndGroups",
|
|
7218
|
+
staffsTabsAndGroups
|
|
7219
|
+
);
|
|
7220
|
+
assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(verticalPosition, VerticalPosition), "verticalPosition", verticalPosition);
|
|
7221
|
+
this.doc.addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition);
|
|
7222
|
+
return this;
|
|
7223
|
+
}
|
|
6981
7224
|
endSong() {
|
|
6982
7225
|
this.getMeasure().endSong();
|
|
6983
7226
|
return this;
|
|
@@ -7749,6 +7992,7 @@ var import_core20 = require("@tspro/web-music-score/core");
|
|
|
7749
7992
|
StaffPreset,
|
|
7750
7993
|
Stem,
|
|
7751
7994
|
TieType,
|
|
7995
|
+
VerticalPosition,
|
|
7752
7996
|
getStringNumbers,
|
|
7753
7997
|
getVoiceIds
|
|
7754
7998
|
});
|