@tspro/web-music-score 3.0.1 → 3.1.0
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 +6 -1
- package/README.md +61 -20
- package/dist/audio/index.js +1 -1
- package/dist/audio/index.mjs +2 -2
- package/dist/audio-cg/index.js +1 -1
- package/dist/audio-cg/index.mjs +2 -2
- package/dist/{chunk-4AS76G4O.mjs → chunk-B4J3KED2.mjs} +2 -2
- package/dist/core/index.js +2 -2
- package/dist/core/index.mjs +3 -3
- package/dist/iife/index.global.js +11 -11
- package/dist/{interface-DkUnsAjj.d.mts → interface-BedxdQDE.d.mts} +86 -36
- package/dist/{interface-1TQHxSpb.d.ts → interface-DprVf__B.d.ts} +86 -36
- package/dist/pieces/index.d.mts +1 -1
- package/dist/pieces/index.d.ts +1 -1
- package/dist/pieces/index.js +1 -1
- package/dist/pieces/index.mjs +2 -2
- package/dist/react-ui/index.d.mts +1 -1
- package/dist/react-ui/index.d.ts +1 -1
- package/dist/react-ui/index.js +1 -1
- package/dist/react-ui/index.mjs +2 -2
- package/dist/score/index.d.mts +29 -5
- package/dist/score/index.d.ts +29 -5
- package/dist/score/index.js +821 -582
- package/dist/score/index.mjs +775 -537
- 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.0
|
|
1
|
+
/* WebMusicScore v3.1.0 | (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,18 @@ 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();
|
|
5310
5113
|
}
|
|
5311
|
-
addFermata(fermata) {
|
|
5114
|
+
addFermata(staffTabOrGroup, fermata) {
|
|
5312
5115
|
let anchor = fermata === 1 /* AtMeasureEnd */ ? this.barLineRight : this.lastAddedRhythmColumn;
|
|
5313
5116
|
if (!anchor) {
|
|
5314
|
-
throw new
|
|
5117
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add Fermata because anchor is undefined.");
|
|
5315
5118
|
}
|
|
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
|
-
}
|
|
5119
|
+
this.forEachStaffGroup(staffTabOrGroup, 0 /* Above */, (line, vpos) => {
|
|
5120
|
+
this.addLayoutObject(new ObjFermata(anchor, vpos), line, 0 /* Fermata */, vpos);
|
|
5325
5121
|
});
|
|
5326
5122
|
this.disableExtension();
|
|
5327
5123
|
this.requestLayout();
|
|
@@ -5329,15 +5125,20 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5329
5125
|
hasFermata(anchor) {
|
|
5330
5126
|
return this.layoutObjects.some((layoutObj) => layoutObj.musicObj instanceof ObjFermata && layoutObj.anchor === anchor);
|
|
5331
5127
|
}
|
|
5332
|
-
addNavigation(navigation, ...args) {
|
|
5128
|
+
addNavigation(staffTabOrGroup, navigation, ...args) {
|
|
5129
|
+
let addLayoutObjectProps = void 0;
|
|
5333
5130
|
switch (navigation) {
|
|
5334
5131
|
case 10 /* Ending */:
|
|
5335
5132
|
if (this.navigationSet.has(navigation)) {
|
|
5336
|
-
throw new
|
|
5133
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add ending beasure measure already has one.");
|
|
5337
5134
|
}
|
|
5338
5135
|
let anchor = this;
|
|
5339
5136
|
let passages = args;
|
|
5340
|
-
|
|
5137
|
+
addLayoutObjectProps = {
|
|
5138
|
+
createObj: () => new ObjEnding(anchor, passages),
|
|
5139
|
+
layoutGroupId: 3 /* Ending */,
|
|
5140
|
+
defaultVerticalPos: 0 /* Above */
|
|
5141
|
+
};
|
|
5341
5142
|
break;
|
|
5342
5143
|
case 1 /* DC_al_Coda */:
|
|
5343
5144
|
case 0 /* DC_al_Fine */:
|
|
@@ -5345,37 +5146,53 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5345
5146
|
case 2 /* DS_al_Fine */: {
|
|
5346
5147
|
let anchor2 = this.barLineRight;
|
|
5347
5148
|
let text = getNavigationString(navigation);
|
|
5348
|
-
|
|
5349
|
-
|
|
5149
|
+
addLayoutObjectProps = {
|
|
5150
|
+
createObj: () => new ObjText(anchor2, text, 1, 1),
|
|
5151
|
+
layoutGroupId: 2 /* Navigation */,
|
|
5152
|
+
defaultVerticalPos: 0 /* Above */
|
|
5153
|
+
};
|
|
5154
|
+
this.addNavigation(staffTabOrGroup, 9 /* EndRepeat */);
|
|
5350
5155
|
this.endSong();
|
|
5351
5156
|
break;
|
|
5352
5157
|
}
|
|
5353
5158
|
case 7 /* Fine */: {
|
|
5354
5159
|
let anchor2 = this.barLineRight;
|
|
5355
5160
|
let text = getNavigationString(navigation);
|
|
5356
|
-
|
|
5161
|
+
addLayoutObjectProps = {
|
|
5162
|
+
createObj: () => new ObjText(anchor2, text, 1, 1),
|
|
5163
|
+
layoutGroupId: 2 /* Navigation */,
|
|
5164
|
+
defaultVerticalPos: 0 /* Above */
|
|
5165
|
+
};
|
|
5357
5166
|
break;
|
|
5358
5167
|
}
|
|
5359
5168
|
case 6 /* Segno */:
|
|
5360
5169
|
case 4 /* Coda */: {
|
|
5361
5170
|
let anchor2 = this.barLineLeft;
|
|
5362
5171
|
let text = getNavigationString(navigation);
|
|
5363
|
-
|
|
5172
|
+
addLayoutObjectProps = {
|
|
5173
|
+
createObj: () => new ObjSpecialText(anchor2, text),
|
|
5174
|
+
layoutGroupId: 2 /* Navigation */,
|
|
5175
|
+
defaultVerticalPos: 0 /* Above */
|
|
5176
|
+
};
|
|
5364
5177
|
break;
|
|
5365
5178
|
}
|
|
5366
5179
|
case 5 /* toCoda */: {
|
|
5367
5180
|
let anchor2 = this.barLineRight;
|
|
5368
5181
|
let text = getNavigationString(navigation);
|
|
5369
|
-
|
|
5182
|
+
addLayoutObjectProps = {
|
|
5183
|
+
createObj: () => new ObjSpecialText(anchor2, text),
|
|
5184
|
+
layoutGroupId: 2 /* Navigation */,
|
|
5185
|
+
defaultVerticalPos: 0 /* Above */
|
|
5186
|
+
};
|
|
5370
5187
|
break;
|
|
5371
5188
|
}
|
|
5372
5189
|
case 9 /* EndRepeat */:
|
|
5373
5190
|
if (args.length === 0) {
|
|
5374
5191
|
this.endRepeatPlayCount = 2;
|
|
5375
|
-
} else if (
|
|
5192
|
+
} else if (import_ts_utils_lib8.Utils.Is.isIntegerGte(args[0], 2)) {
|
|
5376
5193
|
this.endRepeatPlayCount = args[0];
|
|
5377
5194
|
} else {
|
|
5378
|
-
throw new
|
|
5195
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Invalid end repeat play count (should be 2 or greater integer): " + args[0]);
|
|
5379
5196
|
}
|
|
5380
5197
|
if (this.endRepeatPlayCount !== 2) {
|
|
5381
5198
|
let textProps = {
|
|
@@ -5386,6 +5203,11 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5386
5203
|
}
|
|
5387
5204
|
break;
|
|
5388
5205
|
}
|
|
5206
|
+
if (addLayoutObjectProps) {
|
|
5207
|
+
this.forEachStaffGroup(staffTabOrGroup, addLayoutObjectProps.defaultVerticalPos, (line, vpos) => {
|
|
5208
|
+
this.addLayoutObject(addLayoutObjectProps.createObj(), line, addLayoutObjectProps.layoutGroupId, vpos);
|
|
5209
|
+
});
|
|
5210
|
+
}
|
|
5389
5211
|
this.navigationSet.add(navigation);
|
|
5390
5212
|
this.disableExtension();
|
|
5391
5213
|
}
|
|
@@ -5401,70 +5223,125 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5401
5223
|
addConnective(connective, ...args) {
|
|
5402
5224
|
let anchor = this.lastAddedRhythmSymbol;
|
|
5403
5225
|
if (!(anchor instanceof ObjNoteGroup)) {
|
|
5404
|
-
throw new
|
|
5226
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Connective can be added to note group only.");
|
|
5405
5227
|
}
|
|
5406
5228
|
if (connective === 0 /* Tie */) {
|
|
5407
|
-
let tieSpan =
|
|
5408
|
-
let noteAnchor =
|
|
5229
|
+
let tieSpan = import_ts_utils_lib8.Utils.Is.isInteger(args[0]) || import_ts_utils_lib8.Utils.Is.isEnumValue(args[0], TieType) ? args[0] : 2;
|
|
5230
|
+
let noteAnchor = import_ts_utils_lib8.Utils.Is.isEnumValue(args[1], NoteAnchor) ? args[1] : 0 /* Auto */;
|
|
5409
5231
|
anchor.startConnective(new ConnectiveProps(0 /* Tie */, tieSpan, noteAnchor, anchor));
|
|
5410
5232
|
} else if (connective === 1 /* Slur */) {
|
|
5411
|
-
let slurSpan =
|
|
5412
|
-
let noteAnchor =
|
|
5233
|
+
let slurSpan = import_ts_utils_lib8.Utils.Is.isInteger(args[0]) ? args[0] : 2;
|
|
5234
|
+
let noteAnchor = import_ts_utils_lib8.Utils.Is.isEnumValue(args[1], NoteAnchor) ? args[1] : 0 /* Auto */;
|
|
5413
5235
|
anchor.startConnective(new ConnectiveProps(1 /* Slur */, slurSpan, noteAnchor, anchor));
|
|
5414
5236
|
} else if (connective === 2 /* Slide */) {
|
|
5415
|
-
let noteAnchor =
|
|
5237
|
+
let noteAnchor = import_ts_utils_lib8.Utils.Is.isEnumValue(args[0], NoteAnchor) ? args[0] : 0 /* Auto */;
|
|
5416
5238
|
anchor.startConnective(new ConnectiveProps(2 /* Slide */, 2, noteAnchor, anchor));
|
|
5417
5239
|
}
|
|
5418
5240
|
}
|
|
5419
|
-
|
|
5241
|
+
forEachStaffGroup(staffTabOrGroup, defaultVerticalPos, add) {
|
|
5242
|
+
const lines = this.row.getNotationLines();
|
|
5243
|
+
const performAdd = (lineId, vpos, depth) => {
|
|
5244
|
+
if (depth >= 5) {
|
|
5245
|
+
return;
|
|
5246
|
+
}
|
|
5247
|
+
let success = false;
|
|
5248
|
+
if (typeof lineId === "number") {
|
|
5249
|
+
if (lines[lineId]) {
|
|
5250
|
+
add(lines[lineId], vpos);
|
|
5251
|
+
success = true;
|
|
5252
|
+
}
|
|
5253
|
+
} else if (typeof lineId === "string" && lineId.length > 0) {
|
|
5254
|
+
lines.filter((l) => l.name === lineId).forEach((line) => {
|
|
5255
|
+
add(line, vpos);
|
|
5256
|
+
success = true;
|
|
5257
|
+
});
|
|
5258
|
+
}
|
|
5259
|
+
if (typeof lineId === "string" && !success) {
|
|
5260
|
+
let grp = this.doc.getStaffGroup(lineId);
|
|
5261
|
+
if (grp) {
|
|
5262
|
+
(import_ts_utils_lib8.Utils.Is.isArray(grp.staffsTabsAndGroups) ? grp.staffsTabsAndGroups : [grp.staffsTabsAndGroups]).forEach((lineId2) => {
|
|
5263
|
+
switch (grp.verticalPosition) {
|
|
5264
|
+
case 0 /* Above */:
|
|
5265
|
+
performAdd(lineId2, 0 /* Above */, depth + 1);
|
|
5266
|
+
break;
|
|
5267
|
+
case 1 /* Below */:
|
|
5268
|
+
performAdd(lineId2, 1 /* Below */, depth + 1);
|
|
5269
|
+
break;
|
|
5270
|
+
case 2 /* Both */:
|
|
5271
|
+
performAdd(lineId2, 0 /* Above */, depth + 1);
|
|
5272
|
+
performAdd(lineId2, 1 /* Below */, depth + 1);
|
|
5273
|
+
break;
|
|
5274
|
+
case 3 /* Auto */:
|
|
5275
|
+
performAdd(lineId2, defaultVerticalPos, depth + 1);
|
|
5276
|
+
break;
|
|
5277
|
+
}
|
|
5278
|
+
});
|
|
5279
|
+
}
|
|
5280
|
+
}
|
|
5281
|
+
};
|
|
5282
|
+
if (staffTabOrGroup === void 0) {
|
|
5283
|
+
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()) {
|
|
5284
|
+
performAdd(defaultVerticalPos === 1 /* Below */ ? 1 : 0, defaultVerticalPos, 0);
|
|
5285
|
+
} else {
|
|
5286
|
+
performAdd(0, defaultVerticalPos, 0);
|
|
5287
|
+
}
|
|
5288
|
+
} else {
|
|
5289
|
+
performAdd(staffTabOrGroup, defaultVerticalPos, 0);
|
|
5290
|
+
}
|
|
5291
|
+
}
|
|
5292
|
+
addLabel(staffTabOrGroup, 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(staffTabOrGroup, 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
|
-
addAnnotation(annotation, text) {
|
|
5318
|
+
addAnnotation(staffTabOrGroup, annotation, text) {
|
|
5444
5319
|
let anchor = this.lastAddedRhythmColumn;
|
|
5445
5320
|
if (!anchor) {
|
|
5446
|
-
throw new
|
|
5321
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add annotation because anchor is undefined.");
|
|
5447
5322
|
} else if (text.length === 0) {
|
|
5448
|
-
throw new
|
|
5323
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add annotation because annotation text is empty.");
|
|
5449
5324
|
}
|
|
5450
5325
|
let textProps = { text };
|
|
5451
5326
|
let layoutGroupId;
|
|
5452
|
-
let
|
|
5327
|
+
let defaultVerticalPos;
|
|
5453
5328
|
switch (annotation) {
|
|
5454
5329
|
case 0 /* Dynamics */:
|
|
5455
5330
|
layoutGroupId = 5 /* DynamicsAnnotation */;
|
|
5456
|
-
|
|
5331
|
+
defaultVerticalPos = 0 /* Above */;
|
|
5457
5332
|
textProps.italic = true;
|
|
5458
5333
|
break;
|
|
5459
5334
|
case 1 /* Tempo */:
|
|
5460
5335
|
layoutGroupId = 4 /* TempoAnnotation */;
|
|
5461
|
-
|
|
5336
|
+
defaultVerticalPos = 0 /* Above */;
|
|
5462
5337
|
textProps.italic = true;
|
|
5463
5338
|
break;
|
|
5464
5339
|
}
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5340
|
+
this.forEachStaffGroup(staffTabOrGroup, defaultVerticalPos, (line, vpos) => {
|
|
5341
|
+
let textObj = new ObjText(anchor, textProps, 0.5, 1);
|
|
5342
|
+
this.addLayoutObject(textObj, line, layoutGroupId, vpos);
|
|
5343
|
+
this.enableExtension(textObj);
|
|
5344
|
+
});
|
|
5468
5345
|
}
|
|
5469
5346
|
endSong() {
|
|
5470
5347
|
this.isEndSong = true;
|
|
@@ -5486,27 +5363,29 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5486
5363
|
this.doc.requestNewRow();
|
|
5487
5364
|
this.disableExtension();
|
|
5488
5365
|
}
|
|
5489
|
-
enableExtension(
|
|
5490
|
-
this.
|
|
5366
|
+
enableExtension(musicObject) {
|
|
5367
|
+
this.addExtensionToMusicObjects.push(musicObject);
|
|
5491
5368
|
}
|
|
5492
5369
|
disableExtension() {
|
|
5493
|
-
this.
|
|
5370
|
+
this.addExtensionToMusicObjects = [];
|
|
5494
5371
|
}
|
|
5495
5372
|
addExtension(extensionLength, extensionVisible) {
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
throw new
|
|
5373
|
+
this.addExtensionToMusicObjects.forEach((musicObj) => {
|
|
5374
|
+
let anchor = musicObj.getParent();
|
|
5375
|
+
if (musicObj instanceof ObjText && anchor instanceof ObjRhythmColumn) {
|
|
5376
|
+
let lineStyle = "dashed";
|
|
5377
|
+
let linePos = "bottom";
|
|
5378
|
+
let extension = new Extension(musicObj, anchor, extensionLength, extensionVisible, lineStyle, linePos);
|
|
5379
|
+
musicObj.setLink(extension);
|
|
5380
|
+
} else {
|
|
5381
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add extension becaue no compatible music object to attach it to.");
|
|
5382
|
+
}
|
|
5383
|
+
});
|
|
5384
|
+
if (this.addExtensionToMusicObjects.length === 0) {
|
|
5385
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot add extension because music object to attach it to is undefined.");
|
|
5509
5386
|
}
|
|
5387
|
+
this.disableExtension();
|
|
5388
|
+
this.requestLayout();
|
|
5510
5389
|
}
|
|
5511
5390
|
addRhythmSymbol(voiceId, symbol) {
|
|
5512
5391
|
let { col } = symbol;
|
|
@@ -5518,7 +5397,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5518
5397
|
this.lastAddedRhythmSymbol = symbol;
|
|
5519
5398
|
}
|
|
5520
5399
|
addNoteGroup(voiceId, notes, noteLength, options) {
|
|
5521
|
-
let notes2 = notes.map((note) => typeof note === "string" ?
|
|
5400
|
+
let notes2 = notes.map((note) => typeof note === "string" ? import_theory9.Note.getNote(note) : note);
|
|
5522
5401
|
let col = this.getRhythmColumn(voiceId);
|
|
5523
5402
|
this.addRhythmSymbol(voiceId, new ObjNoteGroup(col, voiceId, notes2, noteLength, options));
|
|
5524
5403
|
}
|
|
@@ -5550,7 +5429,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5550
5429
|
return col2;
|
|
5551
5430
|
}
|
|
5552
5431
|
}
|
|
5553
|
-
throw new
|
|
5432
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Error in rhythm column. Should never get here.");
|
|
5554
5433
|
}
|
|
5555
5434
|
getMeasureTicks() {
|
|
5556
5435
|
return this.getTimeSignature().measureTicks;
|
|
@@ -5602,11 +5481,15 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5602
5481
|
getStaffLineRight() {
|
|
5603
5482
|
return this.barLineRight.getRect().centerX;
|
|
5604
5483
|
}
|
|
5605
|
-
getStaticObjects() {
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5484
|
+
getStaticObjects(line) {
|
|
5485
|
+
let staticObjects = this.staticObjectsCache.get(line);
|
|
5486
|
+
if (!staticObjects) {
|
|
5487
|
+
staticObjects = [];
|
|
5488
|
+
this.getColumns().forEach((col) => col.getStaticObjects(line).forEach((obj) => staticObjects == null ? void 0 : staticObjects.push(obj)));
|
|
5489
|
+
this.staticObjectsCache.set(line, staticObjects);
|
|
5490
|
+
}
|
|
5491
|
+
let layoutObjects = this.layoutObjects.filter((layoutObj) => layoutObj.line === line && layoutObj.isPositionResolved()).map((layoutObj) => layoutObj.musicObj);
|
|
5492
|
+
return layoutObjects.length > 0 ? [...staticObjects, ...layoutObjects] : staticObjects;
|
|
5610
5493
|
}
|
|
5611
5494
|
removeLayoutObjects(musicObj) {
|
|
5612
5495
|
this.layoutObjects = this.layoutObjects.filter((layoutObj) => {
|
|
@@ -5634,16 +5517,22 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5634
5517
|
}
|
|
5635
5518
|
createExtensions() {
|
|
5636
5519
|
this.layoutObjects.forEach((layoutObj) => {
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5520
|
+
var _a;
|
|
5521
|
+
let { musicObj, measure, layoutGroupId, verticalPos, line } = layoutObj;
|
|
5522
|
+
if (musicObj.getLink() instanceof Extension) {
|
|
5523
|
+
let extension = musicObj.getLink();
|
|
5524
|
+
if (extension.getHead() === musicObj) {
|
|
5525
|
+
extension.getTails().forEach((musicObj2) => measure.removeLayoutObjects(musicObj2));
|
|
5641
5526
|
let { startColumn, endColumn } = extension.getExtensionRangeInfo();
|
|
5642
5527
|
if (extension.isVisible() && startColumn !== endColumn) {
|
|
5643
5528
|
for (let m = startColumn.measure; m !== void 0; m = m === endColumn.measure ? void 0 : m.getNextMeasure()) {
|
|
5644
5529
|
let leftObj = m === startColumn.measure ? extension.getHead() : m.getBarLineLeft();
|
|
5645
5530
|
let rightObj = m === endColumn.measure ? endColumn : m.getBarLineRight();
|
|
5646
|
-
|
|
5531
|
+
const lines = m.row.getNotationLines();
|
|
5532
|
+
let line2 = (_a = lines.find((l) => l.name !== "" && l.name === line.name)) != null ? _a : lines[line.id];
|
|
5533
|
+
if (line2) {
|
|
5534
|
+
m.addLayoutObject(new ObjExtensionLine(m, extension, leftObj, rightObj), line2, layoutGroupId, verticalPos);
|
|
5535
|
+
}
|
|
5647
5536
|
}
|
|
5648
5537
|
}
|
|
5649
5538
|
}
|
|
@@ -5750,12 +5639,12 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5750
5639
|
let consumedTicks = this.getConsumedTicks(voiceId);
|
|
5751
5640
|
let remainingTicks = measureTicks - consumedTicks;
|
|
5752
5641
|
let rests = [];
|
|
5753
|
-
let noteLengthValues =
|
|
5642
|
+
let noteLengthValues = import_ts_utils_lib8.Utils.Enum.getEnumValues(import_theory9.NoteLength);
|
|
5754
5643
|
while (remainingTicks > 0) {
|
|
5755
5644
|
noteLengthValues.forEach((restLength) => {
|
|
5756
|
-
let restValue = new
|
|
5645
|
+
let restValue = new import_theory9.RhythmProps(restLength, false);
|
|
5757
5646
|
if (restValue.canDot()) {
|
|
5758
|
-
let dottedRestValue = new
|
|
5647
|
+
let dottedRestValue = new import_theory9.RhythmProps(restLength, true);
|
|
5759
5648
|
while (dottedRestValue.ticks <= remainingTicks) {
|
|
5760
5649
|
rests.push(dottedRestValue);
|
|
5761
5650
|
remainingTicks -= dottedRestValue.ticks;
|
|
@@ -5780,6 +5669,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5780
5669
|
if (!this.needLayout) {
|
|
5781
5670
|
return;
|
|
5782
5671
|
}
|
|
5672
|
+
this.staticObjectsCache.clear();
|
|
5783
5673
|
this.requestRectUpdate();
|
|
5784
5674
|
let { unitSize } = renderer;
|
|
5785
5675
|
this.postMeasureBreakWidth = this.hasPostMeasureBreak() ? DocumentSettings.PostMeasureBreakWidth * unitSize : 0;
|
|
@@ -5811,7 +5701,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5811
5701
|
if (this === this.row.getFirstMeasure()) {
|
|
5812
5702
|
this.row.getTabs().forEach((tab) => {
|
|
5813
5703
|
for (let stringId = 0; stringId < 6; stringId++) {
|
|
5814
|
-
let note = tab.getTuningStrings()[stringId].format(
|
|
5704
|
+
let note = tab.getTuningStrings()[stringId].format(import_theory9.PitchNotation.Helmholtz, import_theory9.SymbolSet.Unicode);
|
|
5815
5705
|
let obj = new ObjText(this, { text: note, scale: 0.8 }, 1, 0.5);
|
|
5816
5706
|
obj.layout(renderer);
|
|
5817
5707
|
obj.offset(this.tabStringNotesWidth * 0.8, tab.getStringY(stringId));
|
|
@@ -5827,6 +5717,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5827
5717
|
if (this.endRepeatPlayCountText) {
|
|
5828
5718
|
this.endRepeatPlayCountText.layout(renderer);
|
|
5829
5719
|
}
|
|
5720
|
+
this.layoutObjects.forEach((layoutObj) => layoutObj.layout(renderer));
|
|
5830
5721
|
let padding = renderer.unitSize;
|
|
5831
5722
|
this.leftSolidAreaWidth = this.tabStringNotesWidth + Math.max(0, ...this.signatures.map((signature) => signature.getRect().width)) + this.barLineLeft.getRect().width + padding;
|
|
5832
5723
|
this.rightSolidAreaWidth = padding + this.barLineRight.getRect().width;
|
|
@@ -5858,7 +5749,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5858
5749
|
let columnsAreaLeft = this.rect.left + this.leftSolidAreaWidth;
|
|
5859
5750
|
let columnsAreaRight = this.rect.right - this.rightSolidAreaWidth;
|
|
5860
5751
|
let columnsAreaWidth = columnsAreaRight - columnsAreaLeft;
|
|
5861
|
-
let columnsWidth =
|
|
5752
|
+
let columnsWidth = import_ts_utils_lib8.Utils.Math.sum(this.columns.map((col) => col.getRect().width));
|
|
5862
5753
|
let columnScale = columnsAreaWidth / columnsWidth;
|
|
5863
5754
|
let columnLeft = columnsAreaLeft;
|
|
5864
5755
|
this.columns.forEach((col) => {
|
|
@@ -5903,7 +5794,8 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5903
5794
|
...this.columns.filter((col) => !col.isEmpty()).map((col) => col.getRect().top),
|
|
5904
5795
|
this.barLineRight.getRect().top,
|
|
5905
5796
|
...this.connectives.map((c) => c.getRect().top),
|
|
5906
|
-
...this.beamGroups.filter((b) => !b.isEmpty()).map((b) => b.getRect().top)
|
|
5797
|
+
...this.beamGroups.filter((b) => !b.isEmpty()).map((b) => b.getRect().top),
|
|
5798
|
+
...this.layoutObjects.filter((o) => o.isPositionResolved()).map((o) => o.musicObj.getRect().top)
|
|
5907
5799
|
);
|
|
5908
5800
|
this.rect.bottom = Math.max(
|
|
5909
5801
|
...this.signatures.map((s) => s.getRect().bottom),
|
|
@@ -5912,12 +5804,20 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5912
5804
|
...this.columns.filter((col) => !col.isEmpty()).map((col) => col.getRect().bottom),
|
|
5913
5805
|
this.barLineRight.getRect().bottom,
|
|
5914
5806
|
...this.connectives.map((c) => c.getRect().bottom),
|
|
5915
|
-
...this.beamGroups.filter((b) => !b.isEmpty()).map((b) => b.getRect().bottom)
|
|
5807
|
+
...this.beamGroups.filter((b) => !b.isEmpty()).map((b) => b.getRect().bottom),
|
|
5808
|
+
...this.layoutObjects.filter((o) => o.isPositionResolved()).map((o) => o.musicObj.getRect().bottom)
|
|
5916
5809
|
);
|
|
5810
|
+
if (this === this.row.getLastMeasure()) {
|
|
5811
|
+
this.rect.right = Math.max(
|
|
5812
|
+
this.rect.right,
|
|
5813
|
+
...this.layoutObjects.filter((o) => o.isPositionResolved() && o.musicObj instanceof ObjFermata).map((o) => o.musicObj.getRect().right)
|
|
5814
|
+
);
|
|
5815
|
+
}
|
|
5917
5816
|
this.row.getNotationLines().forEach((line) => {
|
|
5918
5817
|
this.rect.top = Math.min(this.rect.top, line.calcTop());
|
|
5919
5818
|
this.rect.bottom = Math.max(this.rect.bottom, line.calcBottom());
|
|
5920
5819
|
});
|
|
5820
|
+
this.row.requestRectUpdate();
|
|
5921
5821
|
}
|
|
5922
5822
|
offset(dx, dy) {
|
|
5923
5823
|
this.signatures.forEach((signature) => signature.offset(dx, 0));
|
|
@@ -5930,7 +5830,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5930
5830
|
}
|
|
5931
5831
|
this.connectives.forEach((connective) => connective.offset(dx, 0));
|
|
5932
5832
|
this.beamGroups.forEach((beam) => beam.offset(dx, dy));
|
|
5933
|
-
this.layoutObjects.forEach((layoutObj) => layoutObj.
|
|
5833
|
+
this.layoutObjects.forEach((layoutObj) => layoutObj.offset(dx, 0));
|
|
5934
5834
|
this.rect.offsetInPlace(dx, dy);
|
|
5935
5835
|
this.requestRectUpdate();
|
|
5936
5836
|
}
|
|
@@ -5945,7 +5845,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5945
5845
|
for (let p = line.bottomLineDiatonicId; p <= line.topLineDiatonicId; p += 2) {
|
|
5946
5846
|
drawLine(line.getDiatonicIdY(p));
|
|
5947
5847
|
}
|
|
5948
|
-
} else {
|
|
5848
|
+
} else if (line instanceof ObjTab) {
|
|
5949
5849
|
for (let stringId = 0; stringId < 6; stringId++) {
|
|
5950
5850
|
drawLine(line.getStringY(stringId));
|
|
5951
5851
|
}
|
|
@@ -5968,7 +5868,7 @@ __publicField(_ObjMeasure, "MinFlexContentWidth", 10);
|
|
|
5968
5868
|
var ObjMeasure2 = _ObjMeasure;
|
|
5969
5869
|
|
|
5970
5870
|
// src/score/engine/layout-object.ts
|
|
5971
|
-
var
|
|
5871
|
+
var import_core14 = require("@tspro/web-music-score/core");
|
|
5972
5872
|
var WidenColumnList = [1 /* NoteLabel */, 6 /* ChordLabel */];
|
|
5973
5873
|
var RowAlignList = [2 /* Navigation */, 3 /* Ending */, 4 /* TempoAnnotation */, 5 /* DynamicsAnnotation */, 6 /* ChordLabel */];
|
|
5974
5874
|
function requireParentMeasure(p) {
|
|
@@ -5978,11 +5878,19 @@ function requireParentMeasure(p) {
|
|
|
5978
5878
|
}
|
|
5979
5879
|
p = p.getParent();
|
|
5980
5880
|
}
|
|
5981
|
-
throw new
|
|
5881
|
+
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Parent measure is required but not found!");
|
|
5982
5882
|
}
|
|
5883
|
+
var StaffGroup = class {
|
|
5884
|
+
constructor(groupName, staffsTabsAndGroups, verticalPosition) {
|
|
5885
|
+
this.groupName = groupName;
|
|
5886
|
+
this.staffsTabsAndGroups = staffsTabsAndGroups;
|
|
5887
|
+
this.verticalPosition = verticalPosition;
|
|
5888
|
+
}
|
|
5889
|
+
};
|
|
5983
5890
|
var LayoutObjectWrapper = class {
|
|
5984
|
-
constructor(musicObj, layoutGroupId, verticalPos) {
|
|
5891
|
+
constructor(musicObj, line, layoutGroupId, verticalPos) {
|
|
5985
5892
|
this.musicObj = musicObj;
|
|
5893
|
+
this.line = line;
|
|
5986
5894
|
this.layoutGroupId = layoutGroupId;
|
|
5987
5895
|
this.verticalPos = verticalPos;
|
|
5988
5896
|
__publicField(this, "anchor");
|
|
@@ -5990,15 +5898,15 @@ var LayoutObjectWrapper = class {
|
|
|
5990
5898
|
__publicField(this, "row");
|
|
5991
5899
|
__publicField(this, "layoutGroup");
|
|
5992
5900
|
__publicField(this, "positionResolved", true);
|
|
5993
|
-
this.measure = requireParentMeasure(musicObj);
|
|
5901
|
+
this.measure = requireParentMeasure(this.musicObj);
|
|
5994
5902
|
this.row = this.measure.row;
|
|
5995
5903
|
let anchor = this.musicObj.getParent();
|
|
5996
5904
|
if (!anchor) {
|
|
5997
|
-
throw new
|
|
5905
|
+
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Parent music object is required as an anchor.");
|
|
5998
5906
|
}
|
|
5999
5907
|
this.anchor = anchor;
|
|
6000
5908
|
this.anchor.addAnchoredLayoutObject(this);
|
|
6001
|
-
this.layoutGroup = this.
|
|
5909
|
+
this.layoutGroup = this.line.getLayoutGroup(layoutGroupId);
|
|
6002
5910
|
this.layoutGroup.add(this);
|
|
6003
5911
|
}
|
|
6004
5912
|
clearPositionResolved() {
|
|
@@ -6011,20 +5919,19 @@ var LayoutObjectWrapper = class {
|
|
|
6011
5919
|
return this.positionResolved;
|
|
6012
5920
|
}
|
|
6013
5921
|
resolveClosestToStaffY(renderer) {
|
|
6014
|
-
let { musicObj, measure, verticalPos } = this;
|
|
6015
|
-
let
|
|
6016
|
-
let
|
|
6017
|
-
let
|
|
6018
|
-
let
|
|
6019
|
-
let
|
|
6020
|
-
let staticObjects = measure.getStaticObjects();
|
|
5922
|
+
let { musicObj, measure, verticalPos, line } = this;
|
|
5923
|
+
let lineTop = line.getTopLineY();
|
|
5924
|
+
let lineBottom = line.getBottomLineY();
|
|
5925
|
+
let linePadding = renderer.unitSize * 2;
|
|
5926
|
+
let y = verticalPos === 1 /* Below */ ? lineBottom + linePadding + musicObj.getRect().toph : lineTop - linePadding - musicObj.getRect().bottomh;
|
|
5927
|
+
let staticObjects = measure.getStaticObjects(line);
|
|
6021
5928
|
let objShapeRects = musicObj.getShapeRects();
|
|
6022
5929
|
staticObjects.forEach((staticObj) => {
|
|
6023
5930
|
let staticShapeRects = staticObj.getShapeRects();
|
|
6024
5931
|
objShapeRects.forEach((objR) => {
|
|
6025
5932
|
staticShapeRects.forEach((staticR) => {
|
|
6026
5933
|
if (DivRect.overlapX(objR, staticR)) {
|
|
6027
|
-
y = verticalPos === 1 /*
|
|
5934
|
+
y = verticalPos === 1 /* Below */ ? Math.max(y, staticR.bottom + objR.toph + objR.centerY) : Math.min(y, staticR.top - objR.bottomh - objR.centerY);
|
|
6028
5935
|
}
|
|
6029
5936
|
});
|
|
6030
5937
|
});
|
|
@@ -6038,6 +5945,15 @@ var LayoutObjectWrapper = class {
|
|
|
6038
5945
|
return void 0;
|
|
6039
5946
|
}
|
|
6040
5947
|
}
|
|
5948
|
+
layout(renderer) {
|
|
5949
|
+
this.line.addObject(this);
|
|
5950
|
+
}
|
|
5951
|
+
offset(dx, dy) {
|
|
5952
|
+
this.musicObj.offset(dx, dy);
|
|
5953
|
+
}
|
|
5954
|
+
getRect() {
|
|
5955
|
+
return this.musicObj.getRect();
|
|
5956
|
+
}
|
|
6041
5957
|
};
|
|
6042
5958
|
var LayoutGroup = class {
|
|
6043
5959
|
constructor(layoutGroupId) {
|
|
@@ -6045,8 +5961,8 @@ var LayoutGroup = class {
|
|
|
6045
5961
|
__publicField(this, "layoutObjectTable", []);
|
|
6046
5962
|
__publicField(this, "rowAlign");
|
|
6047
5963
|
__publicField(this, "widensColumn");
|
|
6048
|
-
this.layoutObjectTable[0 /*
|
|
6049
|
-
this.layoutObjectTable[1 /*
|
|
5964
|
+
this.layoutObjectTable[0 /* Above */] = [];
|
|
5965
|
+
this.layoutObjectTable[1 /* Below */] = [];
|
|
6050
5966
|
this.rowAlign = RowAlignList.indexOf(layoutGroupId) >= 0;
|
|
6051
5967
|
this.widensColumn = WidenColumnList.indexOf(layoutGroupId) >= 0;
|
|
6052
5968
|
}
|
|
@@ -6074,6 +5990,333 @@ var LayoutGroup = class {
|
|
|
6074
5990
|
}
|
|
6075
5991
|
};
|
|
6076
5992
|
|
|
5993
|
+
// src/score/engine/obj-staff-and-tab.ts
|
|
5994
|
+
var ObjNotationLine4 = class extends MusicObject {
|
|
5995
|
+
constructor(parent) {
|
|
5996
|
+
super(parent);
|
|
5997
|
+
__publicField(this, "objects", []);
|
|
5998
|
+
__publicField(this, "layoutGroups", []);
|
|
5999
|
+
}
|
|
6000
|
+
addObject(o) {
|
|
6001
|
+
this.objects.push(o);
|
|
6002
|
+
}
|
|
6003
|
+
removeObjects() {
|
|
6004
|
+
this.objects.length = 0;
|
|
6005
|
+
}
|
|
6006
|
+
getLayoutGroup(lauoutGroupId) {
|
|
6007
|
+
let layoutGroup = this.layoutGroups[lauoutGroupId];
|
|
6008
|
+
if (!layoutGroup) {
|
|
6009
|
+
layoutGroup = this.layoutGroups[lauoutGroupId] = new LayoutGroup(lauoutGroupId);
|
|
6010
|
+
}
|
|
6011
|
+
return layoutGroup;
|
|
6012
|
+
}
|
|
6013
|
+
resetLayoutGroups(renderer) {
|
|
6014
|
+
this.layoutGroups.forEach((layoutGroup) => {
|
|
6015
|
+
if (layoutGroup) {
|
|
6016
|
+
layoutGroup.clearPositionAndLayout(renderer);
|
|
6017
|
+
}
|
|
6018
|
+
});
|
|
6019
|
+
}
|
|
6020
|
+
layoutLayoutGroups(renderer) {
|
|
6021
|
+
this.layoutGroups.forEach((layoutGroup) => {
|
|
6022
|
+
if (layoutGroup) {
|
|
6023
|
+
this.layoutLayoutGroup(renderer, layoutGroup, 0 /* Above */);
|
|
6024
|
+
this.layoutLayoutGroup(renderer, layoutGroup, 1 /* Below */);
|
|
6025
|
+
}
|
|
6026
|
+
});
|
|
6027
|
+
}
|
|
6028
|
+
setObjectY(layoutObj, y) {
|
|
6029
|
+
if (y === void 0) {
|
|
6030
|
+
return;
|
|
6031
|
+
}
|
|
6032
|
+
layoutObj.offset(0, y - layoutObj.getRect().centerY);
|
|
6033
|
+
layoutObj.setPositionResolved();
|
|
6034
|
+
}
|
|
6035
|
+
alignObjectsY(renderer, layoutObjArr) {
|
|
6036
|
+
layoutObjArr = layoutObjArr.filter((layoutObj) => !layoutObj.isPositionResolved());
|
|
6037
|
+
let rowY;
|
|
6038
|
+
layoutObjArr.forEach((layoutObj) => {
|
|
6039
|
+
let y = layoutObj.resolveClosestToStaffY(renderer);
|
|
6040
|
+
rowY = layoutObj.verticalPos === 1 /* Below */ ? Math.max(y, rowY != null ? rowY : y) : Math.min(y, rowY != null ? rowY : y);
|
|
6041
|
+
});
|
|
6042
|
+
layoutObjArr.forEach((layoutObj) => this.setObjectY(layoutObj, rowY));
|
|
6043
|
+
}
|
|
6044
|
+
layoutLayoutGroup(renderer, layoutGroup, verticalPos) {
|
|
6045
|
+
let rowLayoutObjs = layoutGroup.getLayoutObjects(verticalPos).filter((layoutObj) => !layoutObj.isPositionResolved());
|
|
6046
|
+
rowLayoutObjs.forEach((layoutObj) => {
|
|
6047
|
+
let { musicObj, anchor } = layoutObj;
|
|
6048
|
+
if (musicObj instanceof ObjEnding || musicObj instanceof ObjExtensionLine) {
|
|
6049
|
+
musicObj.layoutFitToMeasure(renderer);
|
|
6050
|
+
} else {
|
|
6051
|
+
musicObj.offset(anchor.getRect().centerX - musicObj.getRect().centerX, 0);
|
|
6052
|
+
}
|
|
6053
|
+
});
|
|
6054
|
+
if (layoutGroup.rowAlign) {
|
|
6055
|
+
this.alignObjectsY(renderer, rowLayoutObjs);
|
|
6056
|
+
} else {
|
|
6057
|
+
rowLayoutObjs.forEach((layoutObj) => {
|
|
6058
|
+
let link = layoutObj.musicObj.getLink();
|
|
6059
|
+
if (link && link.getHead() === layoutObj.musicObj) {
|
|
6060
|
+
let objectParts = [link.getHead(), ...link.getTails()];
|
|
6061
|
+
let layoutObjs = rowLayoutObjs.filter((layoutObj2) => objectParts.some((o) => o === layoutObj2.musicObj));
|
|
6062
|
+
this.alignObjectsY(renderer, layoutObjs);
|
|
6063
|
+
} else {
|
|
6064
|
+
this.alignObjectsY(renderer, [layoutObj]);
|
|
6065
|
+
}
|
|
6066
|
+
});
|
|
6067
|
+
}
|
|
6068
|
+
}
|
|
6069
|
+
};
|
|
6070
|
+
var ObjStaff = class extends ObjNotationLine4 {
|
|
6071
|
+
constructor(row, staffConfig, id) {
|
|
6072
|
+
super(row);
|
|
6073
|
+
this.row = row;
|
|
6074
|
+
this.staffConfig = staffConfig;
|
|
6075
|
+
this.id = id;
|
|
6076
|
+
__publicField(this, "clefImageAsset");
|
|
6077
|
+
__publicField(this, "clefLineDiatonicId");
|
|
6078
|
+
__publicField(this, "topLineDiatonicId");
|
|
6079
|
+
__publicField(this, "middleLineDiatonicId");
|
|
6080
|
+
__publicField(this, "bottomLineDiatonicId");
|
|
6081
|
+
__publicField(this, "minDiatonicId");
|
|
6082
|
+
__publicField(this, "maxDiatonicId");
|
|
6083
|
+
__publicField(this, "joinedGrandStaff");
|
|
6084
|
+
__publicField(this, "topLineY", 0);
|
|
6085
|
+
__publicField(this, "bottomLineY", 0);
|
|
6086
|
+
__publicField(this, "mi");
|
|
6087
|
+
const getDiatonicId = (noteName, isOctaveDown) => import_theory11.Note.getNote(noteName).diatonicId - (isOctaveDown ? 7 : 0);
|
|
6088
|
+
if (staffConfig.clef === "G" /* G */) {
|
|
6089
|
+
this.clefImageAsset = 0 /* TrebleClefPng */;
|
|
6090
|
+
this.clefLineDiatonicId = getDiatonicId("G4", staffConfig.isOctaveDown === true);
|
|
6091
|
+
this.middleLineDiatonicId = this.clefLineDiatonicId + 2;
|
|
6092
|
+
} else {
|
|
6093
|
+
this.clefImageAsset = 1 /* BassClefPng */;
|
|
6094
|
+
this.clefLineDiatonicId = getDiatonicId("F3", staffConfig.isOctaveDown === true);
|
|
6095
|
+
this.middleLineDiatonicId = this.clefLineDiatonicId - 2;
|
|
6096
|
+
}
|
|
6097
|
+
this.topLineDiatonicId = this.middleLineDiatonicId + 4;
|
|
6098
|
+
this.bottomLineDiatonicId = this.middleLineDiatonicId - 4;
|
|
6099
|
+
this.minDiatonicId = staffConfig.minNote !== void 0 ? Math.min(getDiatonicId(staffConfig.minNote, false), this.bottomLineDiatonicId) : void 0;
|
|
6100
|
+
this.maxDiatonicId = staffConfig.maxNote !== void 0 ? Math.max(getDiatonicId(staffConfig.maxNote, false), this.topLineDiatonicId) : void 0;
|
|
6101
|
+
this.mi = new MStaff(this);
|
|
6102
|
+
}
|
|
6103
|
+
getMusicInterface() {
|
|
6104
|
+
return this.mi;
|
|
6105
|
+
}
|
|
6106
|
+
get isOctaveDown() {
|
|
6107
|
+
return this.staffConfig.isOctaveDown === true;
|
|
6108
|
+
}
|
|
6109
|
+
get name() {
|
|
6110
|
+
var _a;
|
|
6111
|
+
return (_a = this.staffConfig.name) != null ? _a : "";
|
|
6112
|
+
}
|
|
6113
|
+
getTopLineY() {
|
|
6114
|
+
return this.topLineY;
|
|
6115
|
+
}
|
|
6116
|
+
getMiddleLineY() {
|
|
6117
|
+
return (this.topLineY + this.bottomLineY) / 2;
|
|
6118
|
+
}
|
|
6119
|
+
getBottomLineY() {
|
|
6120
|
+
return this.bottomLineY;
|
|
6121
|
+
}
|
|
6122
|
+
joinGrandStaff(staff) {
|
|
6123
|
+
if (staff !== this) {
|
|
6124
|
+
this.joinedGrandStaff = staff;
|
|
6125
|
+
}
|
|
6126
|
+
}
|
|
6127
|
+
getLineSpacing() {
|
|
6128
|
+
return (this.bottomLineY - this.topLineY) / 4;
|
|
6129
|
+
}
|
|
6130
|
+
getDiatonicSpacing() {
|
|
6131
|
+
return this.getLineSpacing() / 2;
|
|
6132
|
+
}
|
|
6133
|
+
containsDiatonicId(diatonicId) {
|
|
6134
|
+
import_theory11.Note.validateDiatonicId(diatonicId);
|
|
6135
|
+
return (this.minDiatonicId === void 0 || diatonicId >= this.minDiatonicId) && (this.maxDiatonicId === void 0 || diatonicId <= this.maxDiatonicId);
|
|
6136
|
+
}
|
|
6137
|
+
getDiatonicIdY(diatonicId) {
|
|
6138
|
+
if (this.containsDiatonicId(diatonicId)) {
|
|
6139
|
+
return this.bottomLineY + (this.bottomLineDiatonicId - diatonicId) * this.getDiatonicSpacing();
|
|
6140
|
+
} else if (this.joinedGrandStaff && this.joinedGrandStaff.containsDiatonicId(diatonicId)) {
|
|
6141
|
+
return this.joinedGrandStaff.getDiatonicIdY(diatonicId);
|
|
6142
|
+
} else {
|
|
6143
|
+
throw new import_core15.MusicError(import_core15.MusicErrorType.Score, "Staff does not contain diatonicId " + diatonicId);
|
|
6144
|
+
}
|
|
6145
|
+
}
|
|
6146
|
+
getActualStaff(diatonicId) {
|
|
6147
|
+
if (this.containsDiatonicId(diatonicId)) {
|
|
6148
|
+
return this;
|
|
6149
|
+
} else if (this.joinedGrandStaff && this.joinedGrandStaff.containsDiatonicId(diatonicId)) {
|
|
6150
|
+
return this.joinedGrandStaff;
|
|
6151
|
+
} else {
|
|
6152
|
+
throw new import_core15.MusicError(import_core15.MusicErrorType.Score, "Staff does not contain diatonicId " + diatonicId);
|
|
6153
|
+
}
|
|
6154
|
+
}
|
|
6155
|
+
getDiatonicIdAt(y) {
|
|
6156
|
+
let diatonicId = Math.round(this.bottomLineDiatonicId - (y - this.bottomLineY) / this.getDiatonicSpacing());
|
|
6157
|
+
return this.containsDiatonicId(diatonicId) ? diatonicId : void 0;
|
|
6158
|
+
}
|
|
6159
|
+
isLine(diatonicId) {
|
|
6160
|
+
return diatonicId % 2 === this.middleLineDiatonicId % 2;
|
|
6161
|
+
}
|
|
6162
|
+
isSpace(diatonicId) {
|
|
6163
|
+
return diatonicId % 2 !== this.middleLineDiatonicId % 2;
|
|
6164
|
+
}
|
|
6165
|
+
containsVoiceId(voiceId) {
|
|
6166
|
+
return !this.staffConfig.voiceIds || this.staffConfig.voiceIds.includes(voiceId);
|
|
6167
|
+
}
|
|
6168
|
+
isGrand() {
|
|
6169
|
+
return this.staffConfig.isGrand === true;
|
|
6170
|
+
}
|
|
6171
|
+
calcTop() {
|
|
6172
|
+
let top = this.topLineY;
|
|
6173
|
+
this.objects.forEach((o) => top = Math.min(top, o.getRect().top));
|
|
6174
|
+
if (this.maxDiatonicId !== void 0) {
|
|
6175
|
+
let y = this.getDiatonicIdY(this.maxDiatonicId);
|
|
6176
|
+
let y2 = this.getDiatonicIdY(this.maxDiatonicId - 1);
|
|
6177
|
+
top = Math.min(top, y - Math.abs(y2 - y) + 1);
|
|
6178
|
+
}
|
|
6179
|
+
return top;
|
|
6180
|
+
}
|
|
6181
|
+
calcBottom() {
|
|
6182
|
+
let bottom = this.bottomLineY;
|
|
6183
|
+
this.objects.forEach((o) => bottom = Math.max(bottom, o.getRect().bottom));
|
|
6184
|
+
if (this.minDiatonicId !== void 0) {
|
|
6185
|
+
let y = this.getDiatonicIdY(this.minDiatonicId);
|
|
6186
|
+
let y2 = this.getDiatonicIdY(this.minDiatonicId + 1);
|
|
6187
|
+
bottom = Math.max(bottom, y + Math.abs(y2 - y) - 1);
|
|
6188
|
+
}
|
|
6189
|
+
return bottom;
|
|
6190
|
+
}
|
|
6191
|
+
pick(x, y) {
|
|
6192
|
+
return [this];
|
|
6193
|
+
}
|
|
6194
|
+
layoutHeight(renderer) {
|
|
6195
|
+
let { unitSize } = renderer;
|
|
6196
|
+
let h = unitSize * DocumentSettings.StaffHeight;
|
|
6197
|
+
this.topLineY = -h / 2;
|
|
6198
|
+
this.bottomLineY = h / 2;
|
|
6199
|
+
this.rect = new DivRect(0, 0, this.topLineY, this.bottomLineY);
|
|
6200
|
+
}
|
|
6201
|
+
layoutWidth(renderer) {
|
|
6202
|
+
this.rect.left = this.row.getRect().left;
|
|
6203
|
+
this.rect.right = this.row.getRect().right;
|
|
6204
|
+
}
|
|
6205
|
+
offset(dx, dy) {
|
|
6206
|
+
this.topLineY += dy;
|
|
6207
|
+
this.bottomLineY += dy;
|
|
6208
|
+
this.objects.forEach((o) => {
|
|
6209
|
+
if (o.offsetInPlace) {
|
|
6210
|
+
o.offsetInPlace(0, dy);
|
|
6211
|
+
} else if (o.offset) {
|
|
6212
|
+
o.offset(0, dy);
|
|
6213
|
+
}
|
|
6214
|
+
});
|
|
6215
|
+
this.rect.offsetInPlace(dx, dy);
|
|
6216
|
+
}
|
|
6217
|
+
draw(renderer) {
|
|
6218
|
+
}
|
|
6219
|
+
};
|
|
6220
|
+
var ObjTab = class extends ObjNotationLine4 {
|
|
6221
|
+
constructor(row, tabConfig, id) {
|
|
6222
|
+
super(row);
|
|
6223
|
+
this.row = row;
|
|
6224
|
+
this.tabConfig = tabConfig;
|
|
6225
|
+
this.id = id;
|
|
6226
|
+
__publicField(this, "top", 0);
|
|
6227
|
+
__publicField(this, "bottom", 0);
|
|
6228
|
+
__publicField(this, "tuningName");
|
|
6229
|
+
__publicField(this, "tuningStrings");
|
|
6230
|
+
__publicField(this, "mi");
|
|
6231
|
+
if (import_ts_utils_lib9.Utils.Is.isArray(tabConfig.tuning)) {
|
|
6232
|
+
this.tuningName = void 0;
|
|
6233
|
+
this.tuningStrings = tabConfig.tuning.map((noteName) => import_theory11.Note.getNote(noteName)).reverse();
|
|
6234
|
+
} else if (typeof tabConfig.tuning === "string") {
|
|
6235
|
+
this.tuningName = (0, import_theory11.validateTuningName)(tabConfig.tuning);
|
|
6236
|
+
this.tuningStrings = (0, import_theory11.getTuningStrings)(this.tuningName);
|
|
6237
|
+
} else {
|
|
6238
|
+
this.tuningName = "Standard";
|
|
6239
|
+
this.tuningStrings = (0, import_theory11.getTuningStrings)(this.tuningName);
|
|
6240
|
+
}
|
|
6241
|
+
this.mi = new MTab(this);
|
|
6242
|
+
}
|
|
6243
|
+
getMusicInterface() {
|
|
6244
|
+
return this.mi;
|
|
6245
|
+
}
|
|
6246
|
+
get name() {
|
|
6247
|
+
var _a;
|
|
6248
|
+
return (_a = this.tabConfig.name) != null ? _a : "";
|
|
6249
|
+
}
|
|
6250
|
+
getTuningName() {
|
|
6251
|
+
return this.tuningName;
|
|
6252
|
+
}
|
|
6253
|
+
getTuningStrings() {
|
|
6254
|
+
return this.tuningStrings;
|
|
6255
|
+
}
|
|
6256
|
+
/** Return Y coordinate of string. */
|
|
6257
|
+
getStringY(stringId) {
|
|
6258
|
+
return this.top + (this.bottom - this.top) / 6 * (stringId + 0.5);
|
|
6259
|
+
}
|
|
6260
|
+
getTopStringY() {
|
|
6261
|
+
return this.getStringY(0);
|
|
6262
|
+
}
|
|
6263
|
+
getBottomStringY() {
|
|
6264
|
+
return this.getStringY(5);
|
|
6265
|
+
}
|
|
6266
|
+
getTopLineY() {
|
|
6267
|
+
return this.getTopStringY();
|
|
6268
|
+
}
|
|
6269
|
+
getBottomLineY() {
|
|
6270
|
+
return this.getBottomStringY();
|
|
6271
|
+
}
|
|
6272
|
+
getTop() {
|
|
6273
|
+
return this.top;
|
|
6274
|
+
}
|
|
6275
|
+
getBottom() {
|
|
6276
|
+
return this.bottom;
|
|
6277
|
+
}
|
|
6278
|
+
containsVoiceId(voiceId) {
|
|
6279
|
+
return !this.tabConfig.voiceIds || this.tabConfig.voiceIds.includes(voiceId);
|
|
6280
|
+
}
|
|
6281
|
+
containsDiatonicId(diatonicId) {
|
|
6282
|
+
return true;
|
|
6283
|
+
}
|
|
6284
|
+
calcTop() {
|
|
6285
|
+
return this.top;
|
|
6286
|
+
}
|
|
6287
|
+
calcBottom() {
|
|
6288
|
+
return this.bottom;
|
|
6289
|
+
}
|
|
6290
|
+
pick(x, y) {
|
|
6291
|
+
return [this];
|
|
6292
|
+
}
|
|
6293
|
+
layoutHeight(renderer) {
|
|
6294
|
+
let { unitSize } = renderer;
|
|
6295
|
+
let h = unitSize * DocumentSettings.TabHeight;
|
|
6296
|
+
this.top = -h / 2;
|
|
6297
|
+
this.bottom = h / 2;
|
|
6298
|
+
this.rect = new DivRect(0, 0, this.top, this.bottom);
|
|
6299
|
+
}
|
|
6300
|
+
layoutWidth(renderer) {
|
|
6301
|
+
this.rect.left = this.row.getRect().left;
|
|
6302
|
+
this.rect.right = this.row.getRect().right;
|
|
6303
|
+
}
|
|
6304
|
+
offset(dx, dy) {
|
|
6305
|
+
this.top += dy;
|
|
6306
|
+
this.bottom += dy;
|
|
6307
|
+
this.objects.forEach((o) => {
|
|
6308
|
+
if (o.offsetInPlace) {
|
|
6309
|
+
o.offsetInPlace(0, dy);
|
|
6310
|
+
} else if (o.offset) {
|
|
6311
|
+
o.offset(0, dy);
|
|
6312
|
+
}
|
|
6313
|
+
});
|
|
6314
|
+
this.rect.offsetInPlace(dx, dy);
|
|
6315
|
+
}
|
|
6316
|
+
draw(renderer) {
|
|
6317
|
+
}
|
|
6318
|
+
};
|
|
6319
|
+
|
|
6077
6320
|
// src/score/engine/obj-score-row.ts
|
|
6078
6321
|
var import_core16 = require("@tspro/web-music-score/core");
|
|
6079
6322
|
var ObjScoreRow = class extends MusicObject {
|
|
@@ -6102,7 +6345,7 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
6102
6345
|
return this.mi;
|
|
6103
6346
|
}
|
|
6104
6347
|
createNotationLines() {
|
|
6105
|
-
let notationLines = this.scoreConfig.map((cfg) => cfg.type === "staff" ? new ObjStaff(this, cfg) : new ObjTab(this, cfg));
|
|
6348
|
+
let notationLines = this.scoreConfig.map((cfg, index) => cfg.type === "staff" ? new ObjStaff(this, cfg, index) : new ObjTab(this, cfg, index));
|
|
6106
6349
|
for (let i = 0; i < notationLines.length - 1; i++) {
|
|
6107
6350
|
let treble = notationLines[i];
|
|
6108
6351
|
let bass = notationLines[i + 1];
|
|
@@ -6154,6 +6397,12 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
6154
6397
|
}
|
|
6155
6398
|
return void 0;
|
|
6156
6399
|
}
|
|
6400
|
+
resetLayoutGroups(renderer) {
|
|
6401
|
+
this.notationLines.forEach((line) => line.resetLayoutGroups(renderer));
|
|
6402
|
+
}
|
|
6403
|
+
layoutLayoutGroups(renderer) {
|
|
6404
|
+
this.notationLines.forEach((line) => line.layoutLayoutGroups(renderer));
|
|
6405
|
+
}
|
|
6157
6406
|
pick(x, y) {
|
|
6158
6407
|
if (!this.getRect().contains(x, y)) {
|
|
6159
6408
|
return [];
|
|
@@ -6234,7 +6483,6 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
6234
6483
|
this.minWidth = 0;
|
|
6235
6484
|
this.measures.forEach((m) => {
|
|
6236
6485
|
m.layout(renderer);
|
|
6237
|
-
this.rect.expandInPlace(new DivRect(0, 0, m.getRect().top, m.getRect().bottom));
|
|
6238
6486
|
this.minWidth += m.getMinWidth();
|
|
6239
6487
|
this.minWidth += m.getPostMeasureBreakWidth();
|
|
6240
6488
|
});
|
|
@@ -6268,6 +6516,13 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
6268
6516
|
m.layoutBeams(renderer);
|
|
6269
6517
|
});
|
|
6270
6518
|
}
|
|
6519
|
+
updateRect() {
|
|
6520
|
+
let left = this.measures.length > 0 ? this.measures[0].getRect().left : 0;
|
|
6521
|
+
let right = this.measures.length > 0 ? this.measures[this.measures.length - 1].getRect().right : 0;
|
|
6522
|
+
let top = Math.min(0, ...this.measures.map((m) => m.getRect().top));
|
|
6523
|
+
let bottom = Math.max(0, ...this.measures.map((m) => m.getRect().bottom));
|
|
6524
|
+
this.rect = new DivRect(left, right, top, bottom);
|
|
6525
|
+
}
|
|
6271
6526
|
alignStemsToBeams() {
|
|
6272
6527
|
this.measures.forEach((m) => m.alignStemsToBeams());
|
|
6273
6528
|
}
|
|
@@ -6284,7 +6539,6 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
6284
6539
|
cur.offset(0, prev.calcBottom() - cur.calcTop() + sep);
|
|
6285
6540
|
}
|
|
6286
6541
|
}
|
|
6287
|
-
this.requestRectUpdate();
|
|
6288
6542
|
this.measures.forEach((m) => {
|
|
6289
6543
|
m.requestRectUpdate();
|
|
6290
6544
|
m.getBarLineLeft().requestRectUpdate();
|
|
@@ -6297,59 +6551,12 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
6297
6551
|
});
|
|
6298
6552
|
});
|
|
6299
6553
|
});
|
|
6300
|
-
let lines = this.getNotationLines();
|
|
6301
|
-
this.rect.top = lines[0].calcTop();
|
|
6302
|
-
this.rect.bottom = lines[lines.length - 1].calcBottom();
|
|
6303
6554
|
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
|
-
}
|
|
6555
|
+
this.requestRectUpdate();
|
|
6350
6556
|
}
|
|
6351
6557
|
layoutPadding(renderer) {
|
|
6352
6558
|
let p = renderer.unitSize / 2;
|
|
6559
|
+
this.getRect();
|
|
6353
6560
|
this.rect.left -= p;
|
|
6354
6561
|
this.rect.right += p;
|
|
6355
6562
|
this.rect.top -= p;
|
|
@@ -6373,21 +6580,10 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
6373
6580
|
ctx.save();
|
|
6374
6581
|
ctx.rect(this.getRect().left, this.getRect().top, this.getRect().width, this.getRect().height);
|
|
6375
6582
|
ctx.clip();
|
|
6376
|
-
if (this.getFirstMeasure() && this.notationLines.length > 1 || this.notationLines
|
|
6583
|
+
if (this.getFirstMeasure() && (this.notationLines.length > 1 || this.notationLines[0] instanceof ObjTab)) {
|
|
6377
6584
|
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);
|
|
6585
|
+
let top = Math.min(...this.notationLines.map((line) => line.getTopLineY()));
|
|
6586
|
+
let bottom = Math.max(...this.notationLines.map((line) => line.getBottomLineY()));
|
|
6391
6587
|
renderer.drawLine(left, top, left, bottom);
|
|
6392
6588
|
}
|
|
6393
6589
|
this.measures.forEach((m) => m.draw(renderer));
|
|
@@ -6498,9 +6694,9 @@ var ObjDocument = class extends MusicObject {
|
|
|
6498
6694
|
__publicField(this, "measuresPerRow", Infinity);
|
|
6499
6695
|
__publicField(this, "curScoreConfig", [{ type: "staff", clef: "G" /* G */ }]);
|
|
6500
6696
|
__publicField(this, "header");
|
|
6501
|
-
__publicField(this, "layoutGroups", []);
|
|
6502
6697
|
__publicField(this, "newRowRequested", false);
|
|
6503
6698
|
__publicField(this, "allConnectiveProps", []);
|
|
6699
|
+
__publicField(this, "staffGroups", /* @__PURE__ */ new Map());
|
|
6504
6700
|
__publicField(this, "mi");
|
|
6505
6701
|
this.mi = new MDocument2(this);
|
|
6506
6702
|
}
|
|
@@ -6566,13 +6762,6 @@ var ObjDocument = class extends MusicObject {
|
|
|
6566
6762
|
addConnectiveProps(connectiveProps) {
|
|
6567
6763
|
this.allConnectiveProps.push(connectiveProps);
|
|
6568
6764
|
}
|
|
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
6765
|
setRenderer(renderer) {
|
|
6577
6766
|
if (this.renderer === renderer) {
|
|
6578
6767
|
return;
|
|
@@ -6638,6 +6827,12 @@ var ObjDocument = class extends MusicObject {
|
|
|
6638
6827
|
this.requestLayout();
|
|
6639
6828
|
return measure;
|
|
6640
6829
|
}
|
|
6830
|
+
addStaffGroup(groupName, layoutElements, verticalPosition) {
|
|
6831
|
+
this.staffGroups.set(groupName, new StaffGroup(groupName, layoutElements, verticalPosition));
|
|
6832
|
+
}
|
|
6833
|
+
getStaffGroup(groupName) {
|
|
6834
|
+
return this.staffGroups.get(groupName);
|
|
6835
|
+
}
|
|
6641
6836
|
getVoiceSymbols(voiceId) {
|
|
6642
6837
|
let voiceSymbols = [];
|
|
6643
6838
|
this.forEachMeasure((m) => voiceSymbols = voiceSymbols.concat(m.getVoiceSymbols(voiceId)));
|
|
@@ -6685,21 +6880,15 @@ var ObjDocument = class extends MusicObject {
|
|
|
6685
6880
|
this.forEachMeasure((m) => m.createExtensions());
|
|
6686
6881
|
this.allConnectiveProps.forEach((props) => props.removeConnectives());
|
|
6687
6882
|
this.allConnectiveProps.forEach((props) => props.createConnectives());
|
|
6688
|
-
|
|
6689
|
-
layoutGroups.forEach((layoutGroup) => layoutGroup.clearPositionAndLayout(renderer));
|
|
6883
|
+
this.rows.forEach((row) => row.resetLayoutGroups(renderer));
|
|
6690
6884
|
this.rows.forEach((row) => row.layout(renderer));
|
|
6691
6885
|
let rowWidth = Math.max(
|
|
6692
6886
|
DocumentSettings.DocumentMinWidth * unitSize,
|
|
6693
6887
|
...this.rows.map((row) => 1.4 * row.getMinWidth())
|
|
6694
6888
|
);
|
|
6695
6889
|
this.rows.forEach((row) => row.layoutWidth(renderer, rowWidth));
|
|
6890
|
+
this.rows.forEach((row) => row.layoutLayoutGroups(renderer));
|
|
6696
6891
|
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
6892
|
this.rows.forEach((row) => row.layoutPadding(renderer));
|
|
6704
6893
|
this.rect = new DivRect();
|
|
6705
6894
|
if (this.header) {
|
|
@@ -6924,21 +7113,64 @@ var DocumentBuilder = class {
|
|
|
6924
7113
|
this.getMeasure().addRest(voiceId, restLength, options);
|
|
6925
7114
|
return this;
|
|
6926
7115
|
}
|
|
6927
|
-
|
|
6928
|
-
assertArg(import_ts_utils_lib11.Utils.Is.
|
|
6929
|
-
|
|
7116
|
+
addFermataInternal(staffTabOrGroup, fermata) {
|
|
7117
|
+
assertArg(import_ts_utils_lib11.Utils.Is.isStringOrUndefined(staffTabOrGroup) || import_ts_utils_lib11.Utils.Is.isIntegerGte(staffTabOrGroup, 0), "staffTabOrGroup", staffTabOrGroup);
|
|
7118
|
+
assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(fermata, Fermata), "fermata", fermata);
|
|
7119
|
+
this.getMeasure().addFermata(staffTabOrGroup, fermata);
|
|
6930
7120
|
return this;
|
|
6931
7121
|
}
|
|
6932
|
-
|
|
7122
|
+
addFermata(fermata = 0 /* AtNote */) {
|
|
7123
|
+
return this.addFermataInternal(void 0, fermata);
|
|
7124
|
+
}
|
|
7125
|
+
/** @param staffTabOrGroup - staff/tab index (0=top), staff/tab name, or staff group name. */
|
|
7126
|
+
addFermataTo(staffTabOrGroup, fermata = 0 /* AtNote */) {
|
|
7127
|
+
return this.addFermataInternal(staffTabOrGroup, fermata);
|
|
7128
|
+
}
|
|
7129
|
+
addNavigationInternal(staffTabOrGroup, navigation, ...args) {
|
|
7130
|
+
assertArg(import_ts_utils_lib11.Utils.Is.isStringOrUndefined(staffTabOrGroup) || import_ts_utils_lib11.Utils.Is.isIntegerGte(staffTabOrGroup, 0), "staffTabOrGroup", staffTabOrGroup);
|
|
6933
7131
|
assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(navigation, Navigation), "navigation", navigation);
|
|
6934
7132
|
if (navigation === 9 /* EndRepeat */ && args.length > 0) {
|
|
6935
7133
|
assertArg(import_ts_utils_lib11.Utils.Is.isIntegerGte(args[0], 1), "playCount", args[0]);
|
|
6936
7134
|
} else if (navigation === 10 /* Ending */ && args.length > 0) {
|
|
6937
7135
|
assertArg(args.every((passage) => import_ts_utils_lib11.Utils.Is.isIntegerGte(passage, 1)), "passages", args);
|
|
6938
7136
|
}
|
|
6939
|
-
this.getMeasure().addNavigation(navigation, ...args);
|
|
7137
|
+
this.getMeasure().addNavigation(staffTabOrGroup, navigation, ...args);
|
|
7138
|
+
return this;
|
|
7139
|
+
}
|
|
7140
|
+
addNavigation(navigation, ...args) {
|
|
7141
|
+
return this.addNavigationInternal(void 0, navigation, ...args);
|
|
7142
|
+
}
|
|
7143
|
+
addNavigationTo(staffTabOrGroup, navigation, ...args) {
|
|
7144
|
+
return this.addNavigationInternal(staffTabOrGroup, navigation, ...args);
|
|
7145
|
+
}
|
|
7146
|
+
addLabelInternal(staffTabOrGroup, label, text) {
|
|
7147
|
+
assertArg(import_ts_utils_lib11.Utils.Is.isStringOrUndefined(staffTabOrGroup) || import_ts_utils_lib11.Utils.Is.isIntegerGte(staffTabOrGroup, 0), "staffTabOrGroup", staffTabOrGroup);
|
|
7148
|
+
assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(label, Label), "label", label);
|
|
7149
|
+
assertArg(import_ts_utils_lib11.Utils.Is.isString(text), "text", text);
|
|
7150
|
+
this.getMeasure().addLabel(staffTabOrGroup, label, text);
|
|
7151
|
+
return this;
|
|
7152
|
+
}
|
|
7153
|
+
addLabel(label, text) {
|
|
7154
|
+
return this.addLabelInternal(void 0, label, text);
|
|
7155
|
+
}
|
|
7156
|
+
/** @param staffTabOrGroup - staff/tab index (0=top), staff/tab name, or staff group name. */
|
|
7157
|
+
addLabelTo(staffTabOrGroup, label, text) {
|
|
7158
|
+
return this.addLabelInternal(staffTabOrGroup, label, text);
|
|
7159
|
+
}
|
|
7160
|
+
addAnnotationInternal(staffTabOrGroup, annotation, text) {
|
|
7161
|
+
assertArg(import_ts_utils_lib11.Utils.Is.isStringOrUndefined(staffTabOrGroup) || import_ts_utils_lib11.Utils.Is.isIntegerGte(staffTabOrGroup, 0), "staffTabOrGroup", staffTabOrGroup);
|
|
7162
|
+
assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(annotation, Annotation), "annotation", annotation);
|
|
7163
|
+
assertArg(import_ts_utils_lib11.Utils.Is.isString(text), "text", text);
|
|
7164
|
+
this.getMeasure().addAnnotation(staffTabOrGroup, annotation, text);
|
|
6940
7165
|
return this;
|
|
6941
7166
|
}
|
|
7167
|
+
addAnnotation(annotation, text) {
|
|
7168
|
+
return this.addAnnotationInternal(void 0, annotation, text);
|
|
7169
|
+
}
|
|
7170
|
+
/** @param staffTabOrGroup - staff/tab index (0=top), staff/tab name, or staff group name. */
|
|
7171
|
+
addAnnotationTo(staffTabOrGroup, annotation, text) {
|
|
7172
|
+
return this.addAnnotationInternal(staffTabOrGroup, annotation, text);
|
|
7173
|
+
}
|
|
6942
7174
|
addConnective(connective, ...args) {
|
|
6943
7175
|
assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(connective, Connective), "connective", connective);
|
|
6944
7176
|
if (connective === 0 /* Tie */) {
|
|
@@ -6960,24 +7192,30 @@ var DocumentBuilder = class {
|
|
|
6960
7192
|
}
|
|
6961
7193
|
return this;
|
|
6962
7194
|
}
|
|
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
7195
|
addExtension(extensionLength, extensionVisible) {
|
|
6976
7196
|
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
7197
|
assertArg(import_ts_utils_lib11.Utils.Is.isBooleanOrUndefined(extensionVisible), "extensionVisible", extensionVisible);
|
|
6978
7198
|
this.getMeasure().addExtension(extensionLength, extensionVisible != null ? extensionVisible : true);
|
|
6979
7199
|
return this;
|
|
6980
7200
|
}
|
|
7201
|
+
/**
|
|
7202
|
+
*
|
|
7203
|
+
* @param groupName - Name of staff group.
|
|
7204
|
+
* @param staffsTabsAndGroups - staff/tab index (0=top), staff/tab name, or staff group name. Single value or array.
|
|
7205
|
+
* @param verticalPosition - Vertical position, are elements added above, below or both.
|
|
7206
|
+
* @returns
|
|
7207
|
+
*/
|
|
7208
|
+
addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition = 3 /* Auto */) {
|
|
7209
|
+
assertArg(import_ts_utils_lib11.Utils.Is.isString(groupName) && groupName.length > 0, "groupName", groupName);
|
|
7210
|
+
assertArg(
|
|
7211
|
+
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)),
|
|
7212
|
+
"staffsTabsAndGroups",
|
|
7213
|
+
staffsTabsAndGroups
|
|
7214
|
+
);
|
|
7215
|
+
assertArg(import_ts_utils_lib11.Utils.Is.isEnumValue(verticalPosition, VerticalPosition), "verticalPosition", verticalPosition);
|
|
7216
|
+
this.doc.addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition);
|
|
7217
|
+
return this;
|
|
7218
|
+
}
|
|
6981
7219
|
endSong() {
|
|
6982
7220
|
this.getMeasure().endSong();
|
|
6983
7221
|
return this;
|
|
@@ -7749,6 +7987,7 @@ var import_core20 = require("@tspro/web-music-score/core");
|
|
|
7749
7987
|
StaffPreset,
|
|
7750
7988
|
Stem,
|
|
7751
7989
|
TieType,
|
|
7990
|
+
VerticalPosition,
|
|
7752
7991
|
getStringNumbers,
|
|
7753
7992
|
getVoiceIds
|
|
7754
7993
|
});
|