@tspro/web-music-score 4.1.0 → 4.2.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 -0
- package/README.md +64 -31
- 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-MHNTJ6FU.mjs → chunk-5NWLGWHS.mjs} +2 -2
- package/dist/chunk-7MNV5JN6.mjs +264 -0
- package/dist/core/index.js +2 -2
- package/dist/core/index.mjs +3 -3
- package/dist/iife/index.global.js +11 -11
- package/dist/{music-objects-DIaqNPjs.d.mts → music-objects-3Hxlkxy6.d.mts} +105 -19
- package/dist/{music-objects-xJJNlFwK.d.ts → music-objects-CI7IjsjE.d.ts} +105 -19
- package/dist/pieces/index.d.mts +2 -2
- package/dist/pieces/index.d.ts +2 -2
- package/dist/pieces/index.js +2 -2
- package/dist/pieces/index.mjs +3 -3
- package/dist/react-ui/index.d.mts +3 -3
- package/dist/react-ui/index.d.ts +3 -3
- package/dist/react-ui/index.js +1 -1
- package/dist/react-ui/index.mjs +2 -2
- package/dist/{scale-DQNA-YLD.d.ts → scale-DGx3tJH4.d.ts} +1 -1
- package/dist/{scale-bnD0WnMV.d.mts → scale-DQP3b9Zx.d.mts} +1 -1
- package/dist/score/index.d.mts +43 -21
- package/dist/score/index.d.ts +43 -21
- package/dist/score/index.js +776 -249
- package/dist/score/index.mjs +495 -219
- package/dist/{tempo-Bp1UzsrZ.d.ts → tempo-GrstpD9G.d.ts} +2 -0
- package/dist/{tempo-S85Q7uJA.d.mts → tempo-dkctPkCS.d.mts} +2 -0
- package/dist/theory/index.d.mts +3 -3
- package/dist/theory/index.d.ts +3 -3
- package/dist/theory/index.js +4 -1
- package/dist/theory/index.mjs +28 -269
- package/package.json +6 -2
package/dist/score/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* WebMusicScore v4.
|
|
1
|
+
/* WebMusicScore v4.2.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;
|
|
@@ -42,6 +42,8 @@ __export(score_exports, {
|
|
|
42
42
|
DynamicsAnnotation: () => DynamicsAnnotation,
|
|
43
43
|
Fermata: () => Fermata,
|
|
44
44
|
Label: () => Label,
|
|
45
|
+
LyricsAlign: () => LyricsAlign,
|
|
46
|
+
LyricsHyphen: () => LyricsHyphen,
|
|
45
47
|
MAccidental: () => MAccidental,
|
|
46
48
|
MArpeggio: () => MArpeggio,
|
|
47
49
|
MBarLineLeft: () => MBarLineLeft,
|
|
@@ -54,6 +56,7 @@ __export(score_exports, {
|
|
|
54
56
|
MFermata: () => MFermata,
|
|
55
57
|
MHeader: () => MHeader,
|
|
56
58
|
MImage: () => MImage,
|
|
59
|
+
MLyrics: () => MLyrics,
|
|
57
60
|
MMeasure: () => MMeasure,
|
|
58
61
|
MNoteGroup: () => MNoteGroup,
|
|
59
62
|
MPlaybackButtons: () => MPlaybackButtons,
|
|
@@ -85,6 +88,7 @@ __export(score_exports, {
|
|
|
85
88
|
TieType: () => TieType,
|
|
86
89
|
VerticalPosition: () => VerticalPosition,
|
|
87
90
|
getStringNumbers: () => getStringNumbers,
|
|
91
|
+
getVerseNumbers: () => getVerseNumbers,
|
|
88
92
|
getVoiceIds: () => getVoiceIds
|
|
89
93
|
});
|
|
90
94
|
module.exports = __toCommonJS(score_exports);
|
|
@@ -369,7 +373,7 @@ var DivRect = class _DivRect {
|
|
|
369
373
|
};
|
|
370
374
|
|
|
371
375
|
// src/score/pub/document-builder.ts
|
|
372
|
-
var
|
|
376
|
+
var import_ts_utils_lib15 = require("@tspro/ts-utils-lib");
|
|
373
377
|
|
|
374
378
|
// src/score/pub/types.ts
|
|
375
379
|
var StaffPreset = /* @__PURE__ */ ((StaffPreset3) => {
|
|
@@ -392,6 +396,9 @@ function getVoiceIds() {
|
|
|
392
396
|
function getStringNumbers() {
|
|
393
397
|
return [1, 2, 3, 4, 5, 6];
|
|
394
398
|
}
|
|
399
|
+
function getVerseNumbers() {
|
|
400
|
+
return [1, 2, 3];
|
|
401
|
+
}
|
|
395
402
|
var Stem = /* @__PURE__ */ ((Stem2) => {
|
|
396
403
|
Stem2["Auto"] = "auto";
|
|
397
404
|
Stem2["Up"] = "up";
|
|
@@ -429,6 +436,17 @@ var VerticalPosition = /* @__PURE__ */ ((VerticalPosition4) => {
|
|
|
429
436
|
VerticalPosition4["Both"] = "both";
|
|
430
437
|
return VerticalPosition4;
|
|
431
438
|
})(VerticalPosition || {});
|
|
439
|
+
var LyricsAlign = /* @__PURE__ */ ((LyricsAlign2) => {
|
|
440
|
+
LyricsAlign2["Left"] = "left";
|
|
441
|
+
LyricsAlign2["Center"] = "center";
|
|
442
|
+
LyricsAlign2["Right"] = "right";
|
|
443
|
+
return LyricsAlign2;
|
|
444
|
+
})(LyricsAlign || {});
|
|
445
|
+
var LyricsHyphen = /* @__PURE__ */ ((LyricsHyphen2) => {
|
|
446
|
+
LyricsHyphen2["Hyphen"] = "-";
|
|
447
|
+
LyricsHyphen2["Extender"] = "---";
|
|
448
|
+
return LyricsHyphen2;
|
|
449
|
+
})(LyricsHyphen || {});
|
|
432
450
|
var Fermata = /* @__PURE__ */ ((Fermata2) => {
|
|
433
451
|
Fermata2["AtNote"] = "atNote";
|
|
434
452
|
Fermata2["AtMeasureEnd"] = "atMeasureEnd";
|
|
@@ -982,11 +1000,11 @@ var Renderer = class {
|
|
|
982
1000
|
};
|
|
983
1001
|
|
|
984
1002
|
// src/score/engine/obj-staff-and-tab.ts
|
|
985
|
-
var
|
|
986
|
-
var
|
|
1003
|
+
var import_core16 = require("@tspro/web-music-score/core");
|
|
1004
|
+
var import_ts_utils_lib13 = require("@tspro/ts-utils-lib");
|
|
987
1005
|
|
|
988
1006
|
// src/score/engine/obj-measure.ts
|
|
989
|
-
var
|
|
1007
|
+
var import_ts_utils_lib12 = require("@tspro/ts-utils-lib");
|
|
990
1008
|
var import_theory9 = require("@tspro/web-music-score/theory");
|
|
991
1009
|
var import_theory10 = require("@tspro/web-music-score/theory");
|
|
992
1010
|
|
|
@@ -1577,7 +1595,7 @@ var ObjSignature = class extends MusicObject {
|
|
|
1577
1595
|
};
|
|
1578
1596
|
|
|
1579
1597
|
// src/score/engine/player.ts
|
|
1580
|
-
var
|
|
1598
|
+
var import_ts_utils_lib8 = require("@tspro/ts-utils-lib");
|
|
1581
1599
|
var import_theory7 = require("@tspro/web-music-score/theory");
|
|
1582
1600
|
var Audio = __toESM(require("@tspro/web-music-score/audio"));
|
|
1583
1601
|
|
|
@@ -3084,13 +3102,344 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
3084
3102
|
};
|
|
3085
3103
|
|
|
3086
3104
|
// src/score/engine/obj-rhythm-column.ts
|
|
3105
|
+
var import_core9 = require("@tspro/web-music-score/core");
|
|
3106
|
+
|
|
3107
|
+
// src/theory/rhythm.ts
|
|
3108
|
+
var import_ts_utils_lib5 = require("@tspro/ts-utils-lib");
|
|
3087
3109
|
var import_core8 = require("@tspro/web-music-score/core");
|
|
3110
|
+
var cmp = (a, b) => a === b ? 0 : a < b ? -1 : 1;
|
|
3111
|
+
var MaxTupletRatioValue = 12;
|
|
3112
|
+
var TicksMultiplier = 12 * 11 * 9 * 7 * 5;
|
|
3113
|
+
var NoteLength4 = /* @__PURE__ */ ((NoteLength10) => {
|
|
3114
|
+
NoteLength10["Whole"] = "1n";
|
|
3115
|
+
NoteLength10["WholeTriplet"] = "1t";
|
|
3116
|
+
NoteLength10["WholeDot"] = "1.";
|
|
3117
|
+
NoteLength10["Whole2Dots"] = "1..";
|
|
3118
|
+
NoteLength10["Whole12Dots"] = "1..";
|
|
3119
|
+
NoteLength10["Whole3Dots"] = "1...";
|
|
3120
|
+
NoteLength10["Whole4Dots"] = "1....";
|
|
3121
|
+
NoteLength10["Whole5Dots"] = "1.....";
|
|
3122
|
+
NoteLength10["Whole6Dots"] = "1......";
|
|
3123
|
+
NoteLength10["Half"] = "2n";
|
|
3124
|
+
NoteLength10["HalfTriplet"] = "2t";
|
|
3125
|
+
NoteLength10["HalfDot"] = "2.";
|
|
3126
|
+
NoteLength10["Half2Dots"] = "2..";
|
|
3127
|
+
NoteLength10["Half3Dots"] = "2...";
|
|
3128
|
+
NoteLength10["Half4Dots"] = "2....";
|
|
3129
|
+
NoteLength10["Half5Dots"] = "2.....";
|
|
3130
|
+
NoteLength10["Quarter"] = "4n";
|
|
3131
|
+
NoteLength10["QuarterTriplet"] = "4t";
|
|
3132
|
+
NoteLength10["QuarterDot"] = "4.";
|
|
3133
|
+
NoteLength10["Quarter2Dots"] = "4..";
|
|
3134
|
+
NoteLength10["Quarter3Dots"] = "4...";
|
|
3135
|
+
NoteLength10["Quarter4Dots"] = "4....";
|
|
3136
|
+
NoteLength10["Eighth"] = "8n";
|
|
3137
|
+
NoteLength10["EighthTriplet"] = "8t";
|
|
3138
|
+
NoteLength10["EighthDot"] = "8.";
|
|
3139
|
+
NoteLength10["Eighth2Dots"] = "8..";
|
|
3140
|
+
NoteLength10["Eighth3Dots"] = "8...";
|
|
3141
|
+
NoteLength10["Sixteenth"] = "16n";
|
|
3142
|
+
NoteLength10["SixteenthTriplet"] = "16t";
|
|
3143
|
+
NoteLength10["SixteenthDot"] = "16.";
|
|
3144
|
+
NoteLength10["Sixteenth2Dots"] = "16..";
|
|
3145
|
+
NoteLength10["ThirtySecond"] = "32n";
|
|
3146
|
+
NoteLength10["ThirtySecondTriplet"] = "32t";
|
|
3147
|
+
NoteLength10["ThirtySecondDot"] = "32.";
|
|
3148
|
+
NoteLength10["SixtyFourth"] = "64n";
|
|
3149
|
+
NoteLength10["SixtyFourthTriplet"] = "64t";
|
|
3150
|
+
return NoteLength10;
|
|
3151
|
+
})(NoteLength4 || {});
|
|
3152
|
+
function validateNoteLength(noteLength) {
|
|
3153
|
+
if (import_ts_utils_lib5.Utils.Is.isEnumValue(noteLength, NoteLength4)) {
|
|
3154
|
+
return noteLength;
|
|
3155
|
+
} else {
|
|
3156
|
+
throw new import_core8.MusicError(import_core8.MusicErrorType.InvalidArg, `Invalid noteLength: ${noteLength}`);
|
|
3157
|
+
}
|
|
3158
|
+
}
|
|
3159
|
+
var _NoteLengthProps = class _NoteLengthProps {
|
|
3160
|
+
constructor(noteLength) {
|
|
3161
|
+
/** Note length. */
|
|
3162
|
+
__publicField(this, "noteLength");
|
|
3163
|
+
/** Note size (whole=1, half=2, quarter=4, ...). */
|
|
3164
|
+
__publicField(this, "noteSize");
|
|
3165
|
+
/** Number of ticks (not altered by isTriplet). */
|
|
3166
|
+
__publicField(this, "ticks");
|
|
3167
|
+
/** Flag count. */
|
|
3168
|
+
__publicField(this, "flagCount");
|
|
3169
|
+
/** Dot count. */
|
|
3170
|
+
__publicField(this, "dotCount");
|
|
3171
|
+
/** Max dot count. */
|
|
3172
|
+
__publicField(this, "maxDotCount");
|
|
3173
|
+
/** Is triplet? */
|
|
3174
|
+
__publicField(this, "isTriplet");
|
|
3175
|
+
/** Has note stem. */
|
|
3176
|
+
__publicField(this, "hasStem");
|
|
3177
|
+
/** Is note head solid (black)? */
|
|
3178
|
+
__publicField(this, "isSolid");
|
|
3179
|
+
this.noteLength = validateNoteLength(noteLength);
|
|
3180
|
+
this.noteSize = parseInt(noteLength);
|
|
3181
|
+
this.isTriplet = noteLength.endsWith("t");
|
|
3182
|
+
this.maxDotCount = this.isTriplet ? 0 : Math.floor(Math.log2(_NoteLengthProps.ShortestNoteSize / this.noteSize));
|
|
3183
|
+
this.dotCount = import_ts_utils_lib5.Utils.Str.charCount(noteLength, ".");
|
|
3184
|
+
this.flagCount = this.noteSize > 4 ? Math.floor(Math.log2(this.noteSize / 4)) : 0;
|
|
3185
|
+
this.ticks = TicksMultiplier * _NoteLengthProps.ShortestNoteSize / this.noteSize;
|
|
3186
|
+
this.hasStem = this.noteSize > 1;
|
|
3187
|
+
this.isSolid = this.noteSize > 2;
|
|
3188
|
+
if (this.dotCount > this.maxDotCount) {
|
|
3189
|
+
throw new import_core8.MusicError(import_core8.MusicErrorType.Note, `dotCount ${this.dotCount} > maxDotCount ${this.maxDotCount}, for noteLength "${this.noteLength}".`);
|
|
3190
|
+
} else if (this.isTriplet && this.dotCount > 0) {
|
|
3191
|
+
throw new import_core8.MusicError(import_core8.MusicErrorType.Note, `noteLength "${this.noteLength}" is both triplet and dotted!`);
|
|
3192
|
+
}
|
|
3193
|
+
}
|
|
3194
|
+
/**
|
|
3195
|
+
* Get note length props.
|
|
3196
|
+
* @param noteLength - Note length.
|
|
3197
|
+
* @returns - Note length props.
|
|
3198
|
+
*/
|
|
3199
|
+
static get(noteLength) {
|
|
3200
|
+
let p = this.cache.get(noteLength);
|
|
3201
|
+
if (!p) {
|
|
3202
|
+
this.cache.set(noteLength, p = new _NoteLengthProps(noteLength));
|
|
3203
|
+
}
|
|
3204
|
+
return p;
|
|
3205
|
+
}
|
|
3206
|
+
/**
|
|
3207
|
+
* Create note length props.
|
|
3208
|
+
* @param noteLength - Note length or note size.
|
|
3209
|
+
* @param dotCount - Dot count.
|
|
3210
|
+
* @returns - Note length props.
|
|
3211
|
+
*/
|
|
3212
|
+
static create(noteLength, dotCount = 0) {
|
|
3213
|
+
let noteSize = typeof noteLength === "number" ? noteLength : this.get(noteLength).noteSize;
|
|
3214
|
+
return this.get(noteSize + (import_ts_utils_lib5.Utils.Is.isIntegerGte(dotCount, 1) ? ".".repeat(dotCount) : "n"));
|
|
3215
|
+
}
|
|
3216
|
+
/**
|
|
3217
|
+
* Compare note lengths/sizes. Whole (1) > half (2) > quarter (4), etc.
|
|
3218
|
+
* Ignores possible triplet property of note length.
|
|
3219
|
+
* @param a - NoteLengthProps, NoteLength/Str or noteSize
|
|
3220
|
+
* @param b - NoteLengthProps, NoteLength/Str or noteSize
|
|
3221
|
+
* @returns - -1: a < b, 0: a === b, +1: a > b (note length/size comparisons)
|
|
3222
|
+
*/
|
|
3223
|
+
static cmp(a, b) {
|
|
3224
|
+
let aNoteSize = a instanceof _NoteLengthProps ? a.noteSize : typeof a === "number" ? a : _NoteLengthProps.get(a).noteSize;
|
|
3225
|
+
let bNoteSize = b instanceof _NoteLengthProps ? b.noteSize : typeof b === "number" ? b : _NoteLengthProps.get(b).noteSize;
|
|
3226
|
+
return cmp(bNoteSize, aNoteSize);
|
|
3227
|
+
}
|
|
3228
|
+
/**
|
|
3229
|
+
* Compare note lengths/sizes for equality.
|
|
3230
|
+
* Ignores possible triplet property of note length.
|
|
3231
|
+
* @param a - NoteLengthProps, NoteLength/Str or noteSize
|
|
3232
|
+
* @param b - NoteLengthProps, NoteLength/Str or noteSize
|
|
3233
|
+
* @returns - true: a === b, false: a !== b (note length/size comparisons)
|
|
3234
|
+
*/
|
|
3235
|
+
static equals(a, b) {
|
|
3236
|
+
let aNoteSize = a instanceof _NoteLengthProps ? a.noteSize : typeof a === "number" ? a : _NoteLengthProps.get(a).noteSize;
|
|
3237
|
+
let bNoteSize = b instanceof _NoteLengthProps ? b.noteSize : typeof b === "number" ? b : _NoteLengthProps.get(b).noteSize;
|
|
3238
|
+
return aNoteSize === bNoteSize;
|
|
3239
|
+
}
|
|
3240
|
+
};
|
|
3241
|
+
/** Longest note size (e.g. 1 = whole note). */
|
|
3242
|
+
__publicField(_NoteLengthProps, "LongestNoteSize", Math.min(...import_ts_utils_lib5.Utils.Enum.getEnumValues(NoteLength4).map((noteLength) => parseInt(noteLength))));
|
|
3243
|
+
/** Shortest note size (e.g. 64 = sixtyfourth note). */
|
|
3244
|
+
__publicField(_NoteLengthProps, "ShortestNoteSize", Math.max(...import_ts_utils_lib5.Utils.Enum.getEnumValues(NoteLength4).map((noteLength) => parseInt(noteLength))));
|
|
3245
|
+
__publicField(_NoteLengthProps, "cache", /* @__PURE__ */ new Map());
|
|
3246
|
+
var NoteLengthProps4 = _NoteLengthProps;
|
|
3247
|
+
function validateTupletRatio(tupletRatio) {
|
|
3248
|
+
if (import_ts_utils_lib5.Utils.Is.isObject(tupletRatio) && import_ts_utils_lib5.Utils.Is.isIntegerBetween(tupletRatio.parts, 2, MaxTupletRatioValue) && import_ts_utils_lib5.Utils.Is.isIntegerBetween(tupletRatio.inTimeOf, 2, MaxTupletRatioValue)) {
|
|
3249
|
+
return tupletRatio;
|
|
3250
|
+
} else {
|
|
3251
|
+
throw new import_core8.MusicError(import_core8.MusicErrorType.Note, `Invalid tupletRatio ${JSON.stringify(tupletRatio)}`);
|
|
3252
|
+
}
|
|
3253
|
+
}
|
|
3254
|
+
var Tuplet4 = {
|
|
3255
|
+
/** Duplet: 2 in the time of 3 */
|
|
3256
|
+
Duplet: { parts: 2, inTimeOf: 3 },
|
|
3257
|
+
/** Triplet: 3 in the time of 2 */
|
|
3258
|
+
Triplet: { parts: 3, inTimeOf: 2 },
|
|
3259
|
+
/** Quadruplet: 4 in the time of 3 */
|
|
3260
|
+
Quadruplet: { parts: 4, inTimeOf: 3 }
|
|
3261
|
+
};
|
|
3262
|
+
var _RhythmProps = class _RhythmProps {
|
|
3263
|
+
constructor(noteLength, dotCount, tupletRatio) {
|
|
3264
|
+
/** Note length. */
|
|
3265
|
+
__publicField(this, "noteLength");
|
|
3266
|
+
/** Note size (whole=1, half=2, quarter=4, ...). */
|
|
3267
|
+
__publicField(this, "noteSize");
|
|
3268
|
+
/** Dot count. */
|
|
3269
|
+
__publicField(this, "dotCount");
|
|
3270
|
+
/** Tuplet ratio. */
|
|
3271
|
+
__publicField(this, "tupletRatio");
|
|
3272
|
+
/** Number of ticks. */
|
|
3273
|
+
__publicField(this, "ticks");
|
|
3274
|
+
/** Flag count. */
|
|
3275
|
+
__publicField(this, "flagCount");
|
|
3276
|
+
/** Has note stem. */
|
|
3277
|
+
__publicField(this, "hasStem");
|
|
3278
|
+
/** Is note head solid (black)? */
|
|
3279
|
+
__publicField(this, "isSolidNoteHead");
|
|
3280
|
+
this.noteLength = validateNoteLength(noteLength);
|
|
3281
|
+
let p = NoteLengthProps4.get(noteLength);
|
|
3282
|
+
this.noteSize = p.noteSize;
|
|
3283
|
+
this.ticks = p.ticks;
|
|
3284
|
+
this.flagCount = p.flagCount;
|
|
3285
|
+
this.dotCount = dotCount != null ? dotCount : p.dotCount;
|
|
3286
|
+
this.hasStem = p.hasStem;
|
|
3287
|
+
this.isSolidNoteHead = p.isSolid;
|
|
3288
|
+
if (import_ts_utils_lib5.Utils.Is.isObject(tupletRatio)) {
|
|
3289
|
+
this.tupletRatio = validateTupletRatio(tupletRatio);
|
|
3290
|
+
} else if (p.isTriplet) {
|
|
3291
|
+
this.tupletRatio = Tuplet4.Triplet;
|
|
3292
|
+
} else {
|
|
3293
|
+
this.tupletRatio = void 0;
|
|
3294
|
+
}
|
|
3295
|
+
if (this.dotCount > 0 && this.tupletRatio !== void 0) {
|
|
3296
|
+
throw new import_core8.MusicError(import_core8.MusicErrorType.Note, `Note cannot be both dotted and tuplet!`);
|
|
3297
|
+
} else if (this.dotCount > p.maxDotCount) {
|
|
3298
|
+
throw new import_core8.MusicError(import_core8.MusicErrorType.Note, `Too big dot count ${this.dotCount} for note length ${this.noteLength}.`);
|
|
3299
|
+
}
|
|
3300
|
+
for (let add = this.ticks / 2, i = 1; i <= this.dotCount; i++, add /= 2) {
|
|
3301
|
+
this.ticks += add;
|
|
3302
|
+
}
|
|
3303
|
+
if (this.tupletRatio) {
|
|
3304
|
+
this.ticks *= this.tupletRatio.inTimeOf / this.tupletRatio.parts;
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
/**
|
|
3308
|
+
* Get string presentation of rhythm props.
|
|
3309
|
+
* @returns - String presentation.
|
|
3310
|
+
*/
|
|
3311
|
+
toString() {
|
|
3312
|
+
let sym = _RhythmProps.NoteSymbolMap.get(this.noteSize);
|
|
3313
|
+
let dots = ".".repeat(this.dotCount);
|
|
3314
|
+
return sym ? sym + dots : "" + this.noteSize + (dots.length > 0 ? dots : "n");
|
|
3315
|
+
}
|
|
3316
|
+
/**
|
|
3317
|
+
* Get rhythm props with given arguments.
|
|
3318
|
+
* @param noteLength - Note length.
|
|
3319
|
+
* @param dotCount - Dot count.
|
|
3320
|
+
* @param tupletRatio - Tuplet ratio.
|
|
3321
|
+
* @returns - Rhythm props.
|
|
3322
|
+
*/
|
|
3323
|
+
static get(noteLength, dotCount, tupletRatio) {
|
|
3324
|
+
if (dotCount !== void 0 || tupletRatio !== void 0) {
|
|
3325
|
+
return new _RhythmProps(noteLength, dotCount, tupletRatio);
|
|
3326
|
+
} else {
|
|
3327
|
+
let rhythmProps = this.cache.get(noteLength);
|
|
3328
|
+
if (!rhythmProps) {
|
|
3329
|
+
this.cache.set(noteLength, rhythmProps = new _RhythmProps(noteLength));
|
|
3330
|
+
}
|
|
3331
|
+
return rhythmProps;
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
/**
|
|
3335
|
+
* Compare duration of rhythm props.
|
|
3336
|
+
* @param a - RhythmProps
|
|
3337
|
+
* @param b - RhythmProps
|
|
3338
|
+
* @returns - -1: a < b, 0: a === b, +1: a > b (duration comparisons)
|
|
3339
|
+
*/
|
|
3340
|
+
static cmp(a, b) {
|
|
3341
|
+
return cmp(a.ticks, b.ticks);
|
|
3342
|
+
}
|
|
3343
|
+
/**
|
|
3344
|
+
* Compare duration equality of rhythm props.
|
|
3345
|
+
* @param a - RhythmProps
|
|
3346
|
+
* @param b - RhythmProps
|
|
3347
|
+
* @returns - true: a === b, false: a !== b (duration comparisons)
|
|
3348
|
+
*/
|
|
3349
|
+
static equals(a, b) {
|
|
3350
|
+
return a.ticks === b.ticks;
|
|
3351
|
+
}
|
|
3352
|
+
};
|
|
3353
|
+
__publicField(_RhythmProps, "NoteSymbolMap", /* @__PURE__ */ new Map([[1, "\u{1D15D}"], [2, "\u{1D15E}"], [4, "\u{1D15F}"], [8, "\u{1D160}"], [16, "\u{1D161}"], [32, "\u{1D162}"], [64, "\u{1D163}"], [128, "\u{1D164}"]]));
|
|
3354
|
+
__publicField(_RhythmProps, "cache", /* @__PURE__ */ new Map());
|
|
3355
|
+
var RhythmProps3 = _RhythmProps;
|
|
3356
|
+
|
|
3357
|
+
// src/score/engine/obj-lyrics.ts
|
|
3358
|
+
var import_ts_utils_lib6 = require("@tspro/ts-utils-lib");
|
|
3359
|
+
var LyricsContainer = class {
|
|
3360
|
+
constructor(col, lyricsLength) {
|
|
3361
|
+
this.col = col;
|
|
3362
|
+
__publicField(this, "lyricsObjects", []);
|
|
3363
|
+
__publicField(this, "rhythmProps");
|
|
3364
|
+
this.rhythmProps = RhythmProps3.get(lyricsLength);
|
|
3365
|
+
}
|
|
3366
|
+
addLyricsObject(lyricsObj) {
|
|
3367
|
+
var _a;
|
|
3368
|
+
this.lyricsObjects.push(lyricsObj);
|
|
3369
|
+
(_a = lyricsObj.measure.getPrevLyricsObject(lyricsObj)) == null ? void 0 : _a.setNextLyricsObject(lyricsObj);
|
|
3370
|
+
}
|
|
3371
|
+
};
|
|
3372
|
+
var ObjLyrics = class extends MusicObject {
|
|
3373
|
+
constructor(col, verse, line, vpos, lyricsText, lyricsOptions) {
|
|
3374
|
+
super(col);
|
|
3375
|
+
this.col = col;
|
|
3376
|
+
this.verse = verse;
|
|
3377
|
+
this.line = line;
|
|
3378
|
+
this.vpos = vpos;
|
|
3379
|
+
__publicField(this, "nextLyricsObject");
|
|
3380
|
+
__publicField(this, "color", "black");
|
|
3381
|
+
__publicField(this, "hyphen");
|
|
3382
|
+
__publicField(this, "text");
|
|
3383
|
+
__publicField(this, "mi");
|
|
3384
|
+
let halign = (lyricsOptions == null ? void 0 : lyricsOptions.align) === "left" /* Left */ ? 0 : (lyricsOptions == null ? void 0 : lyricsOptions.align) === "right" /* Right */ ? 1 : 0.5;
|
|
3385
|
+
this.hyphen = import_ts_utils_lib6.Utils.Is.isEnumValue(lyricsOptions == null ? void 0 : lyricsOptions.hyphen, LyricsHyphen) ? lyricsOptions == null ? void 0 : lyricsOptions.hyphen : void 0;
|
|
3386
|
+
this.text = new ObjText(this, { text: lyricsText, color: this.color, scale: 0.8 }, halign, 0);
|
|
3387
|
+
this.rect = new DivRect();
|
|
3388
|
+
this.mi = new MLyrics(this);
|
|
3389
|
+
}
|
|
3390
|
+
getMusicInterface() {
|
|
3391
|
+
return this.mi;
|
|
3392
|
+
}
|
|
3393
|
+
get measure() {
|
|
3394
|
+
return this.col.measure;
|
|
3395
|
+
}
|
|
3396
|
+
getText() {
|
|
3397
|
+
return this.text.getText();
|
|
3398
|
+
}
|
|
3399
|
+
setNextLyricsObject(lyricsObj) {
|
|
3400
|
+
this.nextLyricsObject = lyricsObj;
|
|
3401
|
+
}
|
|
3402
|
+
pick(x, y) {
|
|
3403
|
+
return this.rect.contains(x, y) ? [this] : [];
|
|
3404
|
+
}
|
|
3405
|
+
layout(renderer) {
|
|
3406
|
+
this.text.layout(renderer);
|
|
3407
|
+
this.rect = this.text.getRect().copy();
|
|
3408
|
+
}
|
|
3409
|
+
offset(dx, dy) {
|
|
3410
|
+
this.text.offset(dx, dy);
|
|
3411
|
+
this.rect.offsetInPlace(dx, dy);
|
|
3412
|
+
}
|
|
3413
|
+
draw(renderer) {
|
|
3414
|
+
var _a;
|
|
3415
|
+
this.text.draw(renderer);
|
|
3416
|
+
const ctx = renderer.getCanvasContext();
|
|
3417
|
+
if (ctx && this.hyphen !== void 0) {
|
|
3418
|
+
let l = this.getRect();
|
|
3419
|
+
let r = (_a = this.nextLyricsObject) == null ? void 0 : _a.getRect();
|
|
3420
|
+
let hyphenw = renderer.unitSize * 1.5;
|
|
3421
|
+
let maxw = r ? (r.left - l.right) * 0.85 : hyphenw;
|
|
3422
|
+
let w = this.hyphen === "-" /* Hyphen */ ? Math.min(hyphenw, maxw) : maxw;
|
|
3423
|
+
if (w > 0) {
|
|
3424
|
+
ctx.lineWidth = renderer.lineWidth;
|
|
3425
|
+
ctx.strokeStyle = ctx.fillStyle = this.color;
|
|
3426
|
+
let cx = r ? (r.left + l.right) / 2 : l.right + w / 0.85;
|
|
3427
|
+
let cy = (l.top + l.bottom) / 2;
|
|
3428
|
+
ctx.moveTo(cx - w / 2, cy);
|
|
3429
|
+
ctx.lineTo(cx + w / 2, cy);
|
|
3430
|
+
ctx.stroke();
|
|
3431
|
+
}
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
};
|
|
3435
|
+
|
|
3436
|
+
// src/score/engine/obj-rhythm-column.ts
|
|
3088
3437
|
var noteHeadDataCompareFunc = (a, b) => {
|
|
3089
|
-
let
|
|
3090
|
-
if (
|
|
3091
|
-
|
|
3438
|
+
let cmp3 = import_theory6.Note.compareFunc(a.note, b.note);
|
|
3439
|
+
if (cmp3 === 0) {
|
|
3440
|
+
cmp3 = a.noteGroup.stemDir === b.noteGroup.stemDir ? 0 : a.noteGroup.stemDir === "up" /* Up */ ? 1 : -1;
|
|
3092
3441
|
}
|
|
3093
|
-
return
|
|
3442
|
+
return cmp3;
|
|
3094
3443
|
};
|
|
3095
3444
|
var ObjRhythmColumn = class extends MusicObject {
|
|
3096
3445
|
constructor(measure, positionTicks) {
|
|
@@ -3098,6 +3447,7 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3098
3447
|
this.measure = measure;
|
|
3099
3448
|
this.positionTicks = positionTicks;
|
|
3100
3449
|
__publicField(this, "voiceSymbol", []);
|
|
3450
|
+
__publicField(this, "lyricsContainers", []);
|
|
3101
3451
|
__publicField(this, "minDiatonicId");
|
|
3102
3452
|
__publicField(this, "maxDiatonicId");
|
|
3103
3453
|
__publicField(this, "staffMinDiatonicId", /* @__PURE__ */ new Map());
|
|
@@ -3127,7 +3477,7 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3127
3477
|
if (colId >= 0 && colId < this.measure.getColumnCount()) {
|
|
3128
3478
|
return this.measure.getColumn(colId + 1);
|
|
3129
3479
|
} else {
|
|
3130
|
-
throw new
|
|
3480
|
+
throw new import_core9.MusicError(import_core9.MusicErrorType.Score, "Cannot get next column in measure because current column's id in mesure is invalid.");
|
|
3131
3481
|
}
|
|
3132
3482
|
}
|
|
3133
3483
|
/**
|
|
@@ -3223,6 +3573,19 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3223
3573
|
getVoiceSymbol(voiceId) {
|
|
3224
3574
|
return this.voiceSymbol[voiceId];
|
|
3225
3575
|
}
|
|
3576
|
+
getLyricsContainerDatas() {
|
|
3577
|
+
return this.lyricsContainers;
|
|
3578
|
+
}
|
|
3579
|
+
getLyricsContainer(verse, line, vpos, lyricsLength) {
|
|
3580
|
+
let data = this.lyricsContainers.find((data2) => data2.verse === verse && data2.line === line && data2.vpos === vpos);
|
|
3581
|
+
if (data === void 0 && lyricsLength !== void 0) {
|
|
3582
|
+
data = { lyricsContainer: new LyricsContainer(this, (0, import_theory6.validateNoteLength)(lyricsLength)), verse, line, vpos };
|
|
3583
|
+
this.lyricsContainers.push(data);
|
|
3584
|
+
this.requestLayout();
|
|
3585
|
+
this.requestRectUpdate();
|
|
3586
|
+
}
|
|
3587
|
+
return data == null ? void 0 : data.lyricsContainer;
|
|
3588
|
+
}
|
|
3226
3589
|
getMinWidth() {
|
|
3227
3590
|
let maxNoteSize = Math.max(...this.voiceSymbol.map((s) => s.rhythmProps.noteSize));
|
|
3228
3591
|
let w = DocumentSettings.NoteHeadWidth;
|
|
@@ -3439,10 +3802,10 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3439
3802
|
};
|
|
3440
3803
|
|
|
3441
3804
|
// src/score/engine/extension.ts
|
|
3442
|
-
var
|
|
3805
|
+
var import_core10 = require("@tspro/web-music-score/core");
|
|
3443
3806
|
|
|
3444
3807
|
// src/score/engine/element-data.ts
|
|
3445
|
-
var
|
|
3808
|
+
var import_ts_utils_lib7 = require("@tspro/ts-utils-lib");
|
|
3446
3809
|
|
|
3447
3810
|
// src/score/engine/obj-special-text.ts
|
|
3448
3811
|
var _ObjSpecialText = class _ObjSpecialText extends MusicObject {
|
|
@@ -3564,23 +3927,23 @@ function getNavigationString(navigation) {
|
|
|
3564
3927
|
}
|
|
3565
3928
|
}
|
|
3566
3929
|
function isDynamicsText(text) {
|
|
3567
|
-
return
|
|
3930
|
+
return import_ts_utils_lib7.Utils.Is.isEnumValue(text, DynamicsAnnotation);
|
|
3568
3931
|
}
|
|
3569
3932
|
function getDynamicsVolume(text) {
|
|
3570
3933
|
if (/^(p+|f+|m|mp|mf)$/.test(text)) {
|
|
3571
|
-
let volume = 0.5 -
|
|
3572
|
-
return
|
|
3934
|
+
let volume = 0.5 - import_ts_utils_lib7.Utils.Str.charCount(text, "p") * 0.1 + import_ts_utils_lib7.Utils.Str.charCount(text, "f") * 0.1;
|
|
3935
|
+
return import_ts_utils_lib7.Utils.Math.clamp(volume, 0, 1);
|
|
3573
3936
|
} else {
|
|
3574
3937
|
return void 0;
|
|
3575
3938
|
}
|
|
3576
3939
|
}
|
|
3577
3940
|
function isTempoText(text) {
|
|
3578
|
-
return
|
|
3941
|
+
return import_ts_utils_lib7.Utils.Is.isEnumValue(text, TempoAnnotation);
|
|
3579
3942
|
}
|
|
3580
3943
|
function getAnnotation(text) {
|
|
3581
|
-
if (
|
|
3944
|
+
if (import_ts_utils_lib7.Utils.Is.isEnumValue(text, DynamicsAnnotation)) {
|
|
3582
3945
|
return "dynamics" /* Dynamics */;
|
|
3583
|
-
} else if (
|
|
3946
|
+
} else if (import_ts_utils_lib7.Utils.Is.isEnumValue(text, TempoAnnotation)) {
|
|
3584
3947
|
return "tempo" /* Tempo */;
|
|
3585
3948
|
} else {
|
|
3586
3949
|
return void 0;
|
|
@@ -3623,7 +3986,7 @@ var Extension = class extends MusicObjectLink {
|
|
|
3623
3986
|
if (head instanceof ObjText) {
|
|
3624
3987
|
head.updateAnchorY(getTextAnchorY(linePos));
|
|
3625
3988
|
} else {
|
|
3626
|
-
throw new
|
|
3989
|
+
throw new import_core10.MusicError(import_core10.MusicErrorType.Score, "Update anchor's y-coordinate is only implemented for text objects.");
|
|
3627
3990
|
}
|
|
3628
3991
|
}
|
|
3629
3992
|
isVisible() {
|
|
@@ -3736,7 +4099,7 @@ var PlayerColumnProps = class {
|
|
|
3736
4099
|
return this.speed;
|
|
3737
4100
|
}
|
|
3738
4101
|
getTempo() {
|
|
3739
|
-
let speed =
|
|
4102
|
+
let speed = import_ts_utils_lib8.Utils.Math.clamp(this.getSpeed(), 0.1, 10);
|
|
3740
4103
|
return (0, import_theory7.alterTempoSpeed)(this.measure.getTempo(), speed);
|
|
3741
4104
|
}
|
|
3742
4105
|
setVolume(volume) {
|
|
@@ -3761,7 +4124,7 @@ var PlayerColumnProps = class {
|
|
|
3761
4124
|
if (symbolsTicks.length === 0) {
|
|
3762
4125
|
return 0;
|
|
3763
4126
|
} else {
|
|
3764
|
-
return
|
|
4127
|
+
return import_ts_utils_lib8.Utils.Math.sum(symbolsTicks) / symbolsTicks.length;
|
|
3765
4128
|
}
|
|
3766
4129
|
}
|
|
3767
4130
|
}
|
|
@@ -3910,7 +4273,7 @@ var Player = class _Player {
|
|
|
3910
4273
|
} else if (layoutObj.musicObj.getLink() instanceof Extension) {
|
|
3911
4274
|
let extension = layoutObj.musicObj.getLink();
|
|
3912
4275
|
let { columnRange, extensionBreakText } = extension.getExtensionRangeInfo();
|
|
3913
|
-
let totalTicks =
|
|
4276
|
+
let totalTicks = import_ts_utils_lib8.Utils.Math.sum(columnRange.map((c) => c.getTicksToNextColumn()));
|
|
3914
4277
|
switch (text) {
|
|
3915
4278
|
case "accel." /* accel */: {
|
|
3916
4279
|
let startSpeed = curSpeed;
|
|
@@ -3964,11 +4327,11 @@ var Player = class _Player {
|
|
|
3964
4327
|
});
|
|
3965
4328
|
let speedArr = (_a = speedMap.get(col)) != null ? _a : [];
|
|
3966
4329
|
if (speedArr.length > 0) {
|
|
3967
|
-
curSpeed =
|
|
4330
|
+
curSpeed = import_ts_utils_lib8.Utils.Math.sum(speedArr) / speedArr.length;
|
|
3968
4331
|
}
|
|
3969
4332
|
let volumeArr = (_b = volumeMap.get(col)) != null ? _b : [];
|
|
3970
4333
|
if (volumeArr.length > 0) {
|
|
3971
|
-
curVolume =
|
|
4334
|
+
curVolume = import_ts_utils_lib8.Utils.Math.sum(volumeArr) / volumeArr.length;
|
|
3972
4335
|
}
|
|
3973
4336
|
col.getPlayerProps().setSpeed(curSpeed);
|
|
3974
4337
|
col.getPlayerProps().setVolume(curVolume);
|
|
@@ -4298,8 +4661,8 @@ var ObjBarLineRight = class extends ObjBarLine {
|
|
|
4298
4661
|
};
|
|
4299
4662
|
|
|
4300
4663
|
// src/score/engine/obj-ending.ts
|
|
4301
|
-
var
|
|
4302
|
-
var
|
|
4664
|
+
var import_ts_utils_lib9 = require("@tspro/ts-utils-lib");
|
|
4665
|
+
var import_core11 = require("@tspro/web-music-score/core");
|
|
4303
4666
|
var ObjEnding = class extends MusicObject {
|
|
4304
4667
|
constructor(measure, passages) {
|
|
4305
4668
|
super(measure);
|
|
@@ -4309,10 +4672,10 @@ var ObjEnding = class extends MusicObject {
|
|
|
4309
4672
|
__publicField(this, "shapeRects", []);
|
|
4310
4673
|
__publicField(this, "mi");
|
|
4311
4674
|
this.mi = new MEnding(this);
|
|
4312
|
-
if (!
|
|
4313
|
-
throw new
|
|
4314
|
-
} else if (!this.passages.every((p) =>
|
|
4315
|
-
throw new
|
|
4675
|
+
if (!import_ts_utils_lib9.Utils.Is.isIntegerGte(passages.length, 1)) {
|
|
4676
|
+
throw new import_core11.MusicError(import_core11.MusicErrorType.Score, "Passages is empty.");
|
|
4677
|
+
} else if (!this.passages.every((p) => import_ts_utils_lib9.Utils.Is.isIntegerGte(p, 1))) {
|
|
4678
|
+
throw new import_core11.MusicError(import_core11.MusicErrorType.Score, "Invalid passages: " + this.passages);
|
|
4316
4679
|
}
|
|
4317
4680
|
this.passages.sort((a, b) => a - b);
|
|
4318
4681
|
let text = this.passages.map((p) => p + ".").join("");
|
|
@@ -4520,14 +4883,14 @@ var ObjExtensionLine = class extends MusicObject {
|
|
|
4520
4883
|
};
|
|
4521
4884
|
|
|
4522
4885
|
// src/score/engine/obj-measure.ts
|
|
4523
|
-
var
|
|
4886
|
+
var import_core14 = require("@tspro/web-music-score/core");
|
|
4524
4887
|
|
|
4525
4888
|
// src/score/engine/connective-props.ts
|
|
4526
4889
|
var import_theory8 = require("@tspro/web-music-score/theory");
|
|
4527
4890
|
|
|
4528
4891
|
// src/score/engine/obj-connective.ts
|
|
4529
|
-
var
|
|
4530
|
-
var
|
|
4892
|
+
var import_ts_utils_lib10 = require("@tspro/ts-utils-lib");
|
|
4893
|
+
var import_core12 = require("@tspro/web-music-score/core");
|
|
4531
4894
|
var ObjConnective = class extends MusicObject {
|
|
4532
4895
|
constructor(connectiveProps, line, measure, leftNoteGroup, leftNoteId, ...args) {
|
|
4533
4896
|
super(measure);
|
|
@@ -4555,7 +4918,7 @@ var ObjConnective = class extends MusicObject {
|
|
|
4555
4918
|
this.rightNoteGroup = args[0];
|
|
4556
4919
|
this.rightNoteId = args[1];
|
|
4557
4920
|
this.tieType = void 0;
|
|
4558
|
-
} else if (
|
|
4921
|
+
} else if (import_ts_utils_lib10.Utils.Is.isEnumValue(args[0], TieType)) {
|
|
4559
4922
|
this.rightNoteGroup = void 0;
|
|
4560
4923
|
this.rightNoteId = void 0;
|
|
4561
4924
|
this.tieType = args[0];
|
|
@@ -4616,7 +4979,7 @@ var ObjConnective = class extends MusicObject {
|
|
|
4616
4979
|
rx = contentRect.right;
|
|
4617
4980
|
ry = leftPos.y + (rightPos.y - leftPos.y) * tLeft / (tLeft + tRight);
|
|
4618
4981
|
} else {
|
|
4619
|
-
throw new
|
|
4982
|
+
throw new import_core12.MusicError(import_core12.MusicErrorType.Score, "Cannot layout connective object because no valid left and right note groups.");
|
|
4620
4983
|
}
|
|
4621
4984
|
let spanDy = arcDir === "up" ? -1 : 1;
|
|
4622
4985
|
let arcHeight = spanDy * unitSize * Math.log2(rx - lx) / 3;
|
|
@@ -4625,7 +4988,7 @@ var ObjConnective = class extends MusicObject {
|
|
|
4625
4988
|
this.rx = rx;
|
|
4626
4989
|
this.ry = ry;
|
|
4627
4990
|
this.arcHeight = this.connectiveProps.connective === "slide" /* Slide */ ? 0 : arcHeight;
|
|
4628
|
-
let { nx, ny } =
|
|
4991
|
+
let { nx, ny } = import_ts_utils_lib10.Utils.Math.calcNormal(lx, ly, rx, ry);
|
|
4629
4992
|
this.cp1x = lx * 0.7 + rx * 0.3 + nx * this.arcHeight;
|
|
4630
4993
|
this.cp1y = ly * 0.7 + ry * 0.3 + ny * this.arcHeight;
|
|
4631
4994
|
this.cp2x = lx * 0.3 + rx * 0.7 + nx * this.arcHeight;
|
|
@@ -4685,8 +5048,8 @@ var ObjConnective = class extends MusicObject {
|
|
|
4685
5048
|
};
|
|
4686
5049
|
|
|
4687
5050
|
// src/score/engine/connective-props.ts
|
|
4688
|
-
var
|
|
4689
|
-
var
|
|
5051
|
+
var import_core13 = require("@tspro/web-music-score/core");
|
|
5052
|
+
var import_ts_utils_lib11 = require("@tspro/ts-utils-lib");
|
|
4690
5053
|
var ConnectiveProps = class {
|
|
4691
5054
|
constructor(connective, span, noteAnchor, startNoteGroup) {
|
|
4692
5055
|
this.connective = connective;
|
|
@@ -4756,7 +5119,7 @@ var ConnectiveProps = class {
|
|
|
4756
5119
|
this.computeParams();
|
|
4757
5120
|
let { connective, span } = this;
|
|
4758
5121
|
if (connective === "tie" /* Tie */) {
|
|
4759
|
-
if (
|
|
5122
|
+
if (import_ts_utils_lib11.Utils.Is.isEnumValue(span, TieType)) {
|
|
4760
5123
|
let leftNoteGroup = this.noteGroups[0];
|
|
4761
5124
|
for (let noteId = 0; noteId < leftNoteGroup.notes.length; noteId++) {
|
|
4762
5125
|
this.createObjConnectiveWithTieType(leftNoteGroup, noteId, span);
|
|
@@ -4821,15 +5184,16 @@ var ConnectiveProps = class {
|
|
|
4821
5184
|
addConnective(leftNoteGroup.measure, leftNoteGroup, leftNoteId, rightNoteGroup, rightNoteId);
|
|
4822
5185
|
addConnective(rightNoteGroup.measure, leftNoteGroup, leftNoteId, rightNoteGroup, rightNoteId);
|
|
4823
5186
|
} else {
|
|
4824
|
-
throw new
|
|
5187
|
+
throw new import_core13.MusicError(import_core13.MusicErrorType.Score, "Cannot create connective because it is jumping measures.");
|
|
4825
5188
|
}
|
|
4826
5189
|
}
|
|
4827
5190
|
};
|
|
4828
5191
|
|
|
4829
5192
|
// src/score/engine/obj-measure.ts
|
|
5193
|
+
var cmp2 = (a, b) => a === b ? 0 : a < b ? -1 : 1;
|
|
4830
5194
|
function validateVoiceId(voiceId) {
|
|
4831
|
-
if (getVoiceIds().indexOf(voiceId) < 0) {
|
|
4832
|
-
throw new
|
|
5195
|
+
if (typeof voiceId === "number" && getVoiceIds().indexOf(voiceId) < 0) {
|
|
5196
|
+
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Invalid voiceId: " + voiceId);
|
|
4833
5197
|
} else {
|
|
4834
5198
|
return voiceId;
|
|
4835
5199
|
}
|
|
@@ -4838,7 +5202,7 @@ function getExtensionTicks(extensionLength) {
|
|
|
4838
5202
|
if (typeof extensionLength === "string") {
|
|
4839
5203
|
extensionLength = [extensionLength];
|
|
4840
5204
|
}
|
|
4841
|
-
if (
|
|
5205
|
+
if (import_ts_utils_lib12.Utils.Is.isArray(extensionLength)) {
|
|
4842
5206
|
let totalTicks = 0;
|
|
4843
5207
|
for (let i = 0; i < extensionLength.length; ) {
|
|
4844
5208
|
let str = extensionLength[i];
|
|
@@ -4860,6 +5224,18 @@ function getExtensionTicks(extensionLength) {
|
|
|
4860
5224
|
return extensionLength;
|
|
4861
5225
|
}
|
|
4862
5226
|
}
|
|
5227
|
+
function getVerseLayoutGroupId(verse) {
|
|
5228
|
+
switch (verse) {
|
|
5229
|
+
case 1:
|
|
5230
|
+
return 7 /* LyricsVerse1 */;
|
|
5231
|
+
case 2:
|
|
5232
|
+
return 8 /* LyricsVerse2 */;
|
|
5233
|
+
case 3:
|
|
5234
|
+
return 9 /* LyricsVerse3 */;
|
|
5235
|
+
default:
|
|
5236
|
+
throw new import_core14.MusicError(import_core14.MusicErrorType.Unknown, "VerseNumber is not 1, 2 or 3.");
|
|
5237
|
+
}
|
|
5238
|
+
}
|
|
4863
5239
|
var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
4864
5240
|
constructor(row) {
|
|
4865
5241
|
super(row);
|
|
@@ -4904,6 +5280,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
4904
5280
|
// play twice.
|
|
4905
5281
|
__publicField(this, "endRepeatPlayCountText");
|
|
4906
5282
|
__publicField(this, "staticObjectsCache", /* @__PURE__ */ new Map());
|
|
5283
|
+
__publicField(this, "lyricsObjectsCache", /* @__PURE__ */ new Map());
|
|
4907
5284
|
__publicField(this, "mi");
|
|
4908
5285
|
this.mi = new MMeasure(this);
|
|
4909
5286
|
this.prevMeasure = row.doc.getLastMeasure();
|
|
@@ -5087,7 +5464,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5087
5464
|
this.alterKeySignature = args[0];
|
|
5088
5465
|
} else if (args[0] instanceof import_theory9.Scale) {
|
|
5089
5466
|
this.alterKeySignature = args[0];
|
|
5090
|
-
} else if (
|
|
5467
|
+
} else if (import_ts_utils_lib12.Utils.Is.isNonEmptyString(args[0])) {
|
|
5091
5468
|
if (args.length === 1) {
|
|
5092
5469
|
this.alterKeySignature = (0, import_theory9.getScale)(args[0]);
|
|
5093
5470
|
} else if (args.length === 2) {
|
|
@@ -5096,7 +5473,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5096
5473
|
let scaleType = (0, import_theory9.validateScaleType)("" + args[1]);
|
|
5097
5474
|
this.alterKeySignature = (0, import_theory9.getScale)(tonic, scaleType);
|
|
5098
5475
|
} catch (e) {
|
|
5099
|
-
throw new
|
|
5476
|
+
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot set key signature because invalid args: " + args);
|
|
5100
5477
|
}
|
|
5101
5478
|
}
|
|
5102
5479
|
}
|
|
@@ -5198,7 +5575,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5198
5575
|
let grp = this.doc.getStaffGroup(staffTabOrGroup);
|
|
5199
5576
|
if (grp && !prevGroups.includes(staffTabOrGroup)) {
|
|
5200
5577
|
let curGroups = [...prevGroups, staffTabOrGroup];
|
|
5201
|
-
(
|
|
5578
|
+
(import_ts_utils_lib12.Utils.Is.isArray(grp.staffsTabsAndGroups) ? grp.staffsTabsAndGroups : [grp.staffsTabsAndGroups]).forEach((staffTabOrGroup2) => {
|
|
5202
5579
|
switch (grp.verticalPosition) {
|
|
5203
5580
|
case "above" /* Above */:
|
|
5204
5581
|
addToStaffTabOrGroup(staffTabOrGroup2, 0 /* Above */, curGroups);
|
|
@@ -5225,7 +5602,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5225
5602
|
} else {
|
|
5226
5603
|
addToStaffTabOrGroup(0, defaultVerticalPos);
|
|
5227
5604
|
}
|
|
5228
|
-
} else if (
|
|
5605
|
+
} else if (import_ts_utils_lib12.Utils.Is.isArray(staffTabOrGroups)) {
|
|
5229
5606
|
staffTabOrGroups.forEach((staffTabOrGroup) => addToStaffTabOrGroup(staffTabOrGroup, defaultVerticalPos));
|
|
5230
5607
|
} else {
|
|
5231
5608
|
addToStaffTabOrGroup(staffTabOrGroups, defaultVerticalPos);
|
|
@@ -5234,7 +5611,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5234
5611
|
addFermata(staffTabOrGroups, fermata) {
|
|
5235
5612
|
let anchor = fermata === "atMeasureEnd" /* AtMeasureEnd */ ? this.barLineRight : this.lastAddedRhythmColumn;
|
|
5236
5613
|
if (!anchor) {
|
|
5237
|
-
throw new
|
|
5614
|
+
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot add Fermata because anchor is undefined.");
|
|
5238
5615
|
}
|
|
5239
5616
|
this.forEachStaffGroup(staffTabOrGroups, 0 /* Above */, (line, vpos) => {
|
|
5240
5617
|
this.addLayoutObject(new ObjFermata(anchor, vpos), line, 0 /* Fermata */, vpos);
|
|
@@ -5250,7 +5627,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5250
5627
|
switch (navigation) {
|
|
5251
5628
|
case "ending" /* Ending */:
|
|
5252
5629
|
if (this.navigationSet.has(navigation)) {
|
|
5253
|
-
throw new
|
|
5630
|
+
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot add ending beasure measure already has one.");
|
|
5254
5631
|
}
|
|
5255
5632
|
let anchor = this;
|
|
5256
5633
|
let passages = args;
|
|
@@ -5309,10 +5686,10 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5309
5686
|
case "endRepeat" /* EndRepeat */:
|
|
5310
5687
|
if (args.length === 0) {
|
|
5311
5688
|
this.endRepeatPlayCount = 2;
|
|
5312
|
-
} else if (
|
|
5689
|
+
} else if (import_ts_utils_lib12.Utils.Is.isIntegerGte(args[0], 2)) {
|
|
5313
5690
|
this.endRepeatPlayCount = args[0];
|
|
5314
5691
|
} else {
|
|
5315
|
-
throw new
|
|
5692
|
+
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Invalid end repeat play count (should be 2 or greater integer): " + args[0]);
|
|
5316
5693
|
}
|
|
5317
5694
|
if (this.endRepeatPlayCount !== 2) {
|
|
5318
5695
|
let textProps = {
|
|
@@ -5337,9 +5714,9 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5337
5714
|
addAnnotation(staffTabOrGroups, annotation, text) {
|
|
5338
5715
|
let anchor = this.lastAddedRhythmColumn;
|
|
5339
5716
|
if (!anchor) {
|
|
5340
|
-
throw new
|
|
5717
|
+
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot add annotation because anchor is undefined.");
|
|
5341
5718
|
} else if (text.length === 0) {
|
|
5342
|
-
throw new
|
|
5719
|
+
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot add annotation because annotation text is empty.");
|
|
5343
5720
|
}
|
|
5344
5721
|
let textProps = { text };
|
|
5345
5722
|
let layoutGroupId;
|
|
@@ -5366,9 +5743,9 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5366
5743
|
addLabel(staffTabOrGroups, label, text) {
|
|
5367
5744
|
let anchor = this.lastAddedRhythmColumn;
|
|
5368
5745
|
if (!anchor) {
|
|
5369
|
-
throw new
|
|
5746
|
+
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot add label because anchor is undefined.");
|
|
5370
5747
|
} else if (text.length === 0) {
|
|
5371
|
-
throw new
|
|
5748
|
+
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot add label because label text is empty.");
|
|
5372
5749
|
}
|
|
5373
5750
|
let textProps = { text };
|
|
5374
5751
|
let layoutGroupId;
|
|
@@ -5393,18 +5770,18 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5393
5770
|
addConnective(connective, ...args) {
|
|
5394
5771
|
let anchor = this.lastAddedRhythmSymbol;
|
|
5395
5772
|
if (!(anchor instanceof ObjNoteGroup)) {
|
|
5396
|
-
throw new
|
|
5773
|
+
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Connective can be added to note group only.");
|
|
5397
5774
|
}
|
|
5398
5775
|
if (connective === "tie" /* Tie */) {
|
|
5399
|
-
let tieSpan =
|
|
5400
|
-
let noteAnchor =
|
|
5776
|
+
let tieSpan = import_ts_utils_lib12.Utils.Is.isInteger(args[0]) || import_ts_utils_lib12.Utils.Is.isEnumValue(args[0], TieType) ? args[0] : 2;
|
|
5777
|
+
let noteAnchor = import_ts_utils_lib12.Utils.Is.isEnumValue(args[1], NoteAnchor) ? args[1] : "auto" /* Auto */;
|
|
5401
5778
|
anchor.startConnective(new ConnectiveProps("tie" /* Tie */, tieSpan, noteAnchor, anchor));
|
|
5402
5779
|
} else if (connective === "slur" /* Slur */) {
|
|
5403
|
-
let slurSpan =
|
|
5404
|
-
let noteAnchor =
|
|
5780
|
+
let slurSpan = import_ts_utils_lib12.Utils.Is.isInteger(args[0]) ? args[0] : 2;
|
|
5781
|
+
let noteAnchor = import_ts_utils_lib12.Utils.Is.isEnumValue(args[1], NoteAnchor) ? args[1] : "auto" /* Auto */;
|
|
5405
5782
|
anchor.startConnective(new ConnectiveProps("slur" /* Slur */, slurSpan, noteAnchor, anchor));
|
|
5406
5783
|
} else if (connective === "slide" /* Slide */) {
|
|
5407
|
-
let noteAnchor =
|
|
5784
|
+
let noteAnchor = import_ts_utils_lib12.Utils.Is.isEnumValue(args[0], NoteAnchor) ? args[0] : "auto" /* Auto */;
|
|
5408
5785
|
anchor.startConnective(new ConnectiveProps("slide" /* Slide */, 2, noteAnchor, anchor));
|
|
5409
5786
|
}
|
|
5410
5787
|
}
|
|
@@ -5417,11 +5794,11 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5417
5794
|
let extension = new Extension(musicObj, anchor, getExtensionTicks(extensionLength), extensionVisible, lineStyle, linePos);
|
|
5418
5795
|
musicObj.setLink(extension);
|
|
5419
5796
|
} else {
|
|
5420
|
-
throw new
|
|
5797
|
+
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot add extension becaue no compatible music object to attach it to.");
|
|
5421
5798
|
}
|
|
5422
5799
|
});
|
|
5423
5800
|
if (this.addExtensionToMusicObjects.length === 0) {
|
|
5424
|
-
throw new
|
|
5801
|
+
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Cannot add extension because music object to attach it to is undefined.");
|
|
5425
5802
|
}
|
|
5426
5803
|
this.disableExtension();
|
|
5427
5804
|
this.requestLayout();
|
|
@@ -5458,10 +5835,11 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5458
5835
|
this.doc.requestNewRow();
|
|
5459
5836
|
this.disableExtension();
|
|
5460
5837
|
}
|
|
5461
|
-
addRhythmSymbol(
|
|
5462
|
-
|
|
5838
|
+
addRhythmSymbol(symbol) {
|
|
5839
|
+
var _a, _b;
|
|
5840
|
+
let { col, voiceId } = symbol;
|
|
5463
5841
|
col.setVoiceSymbol(voiceId, symbol);
|
|
5464
|
-
this.
|
|
5842
|
+
(_b = (_a = this.voiceSymbols)[voiceId]) != null ? _b : _a[voiceId] = [];
|
|
5465
5843
|
this.voiceSymbols[voiceId].push(symbol);
|
|
5466
5844
|
if (symbol.oldStyleTriplet) {
|
|
5467
5845
|
this.createOldStyleTriplets(voiceId);
|
|
@@ -5474,25 +5852,40 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5474
5852
|
let realNotes = notes.map((note) => typeof note === "string" ? import_theory9.Note.getNote(note) : note);
|
|
5475
5853
|
let col = this.getRhythmColumn(voiceId);
|
|
5476
5854
|
let noteGroup = new ObjNoteGroup(col, voiceId, realNotes, noteLength, options, tupletRatio);
|
|
5477
|
-
this.addRhythmSymbol(
|
|
5855
|
+
this.addRhythmSymbol(noteGroup);
|
|
5478
5856
|
return noteGroup;
|
|
5479
5857
|
}
|
|
5480
5858
|
addRest(voiceId, restLength, options, tupletRatio) {
|
|
5481
5859
|
let col = this.getRhythmColumn(voiceId);
|
|
5482
5860
|
let rest = new ObjRest(col, voiceId, restLength, options, tupletRatio);
|
|
5483
|
-
this.addRhythmSymbol(
|
|
5861
|
+
this.addRhythmSymbol(rest);
|
|
5484
5862
|
return rest;
|
|
5485
5863
|
}
|
|
5864
|
+
addLyrics(staffTabOrGroups, verse, lyricsLength, lyricsText, lyricsOptions) {
|
|
5865
|
+
this.forEachStaffGroup(staffTabOrGroups, 1 /* Below */, (line, vpos) => {
|
|
5866
|
+
let col = this.getRhythmColumn({ verse, line, vpos });
|
|
5867
|
+
let lyricsContainer = col.getLyricsContainer(verse, line, vpos, (0, import_theory9.validateNoteLength)(lyricsLength));
|
|
5868
|
+
if (lyricsContainer) {
|
|
5869
|
+
let lyricsObj = new ObjLyrics(col, verse, line, vpos, lyricsText, lyricsOptions);
|
|
5870
|
+
let lyricsArr = this.getLyricsObjects(lyricsObj.line, lyricsObj.vpos, lyricsObj.verse);
|
|
5871
|
+
lyricsArr.push(lyricsObj);
|
|
5872
|
+
lyricsArr.sort((a, b) => cmp2(a.col.positionTicks, b.col.positionTicks));
|
|
5873
|
+
lyricsContainer.addLyricsObject(lyricsObj);
|
|
5874
|
+
this.addLayoutObject(lyricsObj, line, getVerseLayoutGroupId(verse), vpos);
|
|
5875
|
+
}
|
|
5876
|
+
this.lastAddedRhythmColumn = col;
|
|
5877
|
+
});
|
|
5878
|
+
}
|
|
5486
5879
|
/**
|
|
5487
5880
|
*
|
|
5488
5881
|
* @param positionTicks - get ObjRhythmColumn with positionTicks. Insert new if necessary.
|
|
5489
5882
|
* @returns
|
|
5490
5883
|
*/
|
|
5491
|
-
getRhythmColumn(
|
|
5884
|
+
getRhythmColumn(arg) {
|
|
5492
5885
|
let positionTicks = 0;
|
|
5493
5886
|
for (let i = this.columns.length - 1; i >= 0 && positionTicks === 0; i--) {
|
|
5494
5887
|
let col = this.columns[i];
|
|
5495
|
-
let symbol = col.getVoiceSymbol(
|
|
5888
|
+
let symbol = typeof arg === "number" ? col.getVoiceSymbol(arg) : col.getLyricsContainer(arg.verse, arg.line, arg.vpos);
|
|
5496
5889
|
if (symbol) {
|
|
5497
5890
|
positionTicks = col.positionTicks + symbol.rhythmProps.ticks;
|
|
5498
5891
|
}
|
|
@@ -5507,7 +5900,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5507
5900
|
return col2;
|
|
5508
5901
|
}
|
|
5509
5902
|
}
|
|
5510
|
-
throw new
|
|
5903
|
+
throw new import_core14.MusicError(import_core14.MusicErrorType.Score, "Error in rhythm column. Should never get here.");
|
|
5511
5904
|
}
|
|
5512
5905
|
getMeasureTicks() {
|
|
5513
5906
|
return this.getTimeSignature().measureTicks;
|
|
@@ -5559,6 +5952,38 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5559
5952
|
getStaffLineRight() {
|
|
5560
5953
|
return this.barLineRight.getRect().centerX;
|
|
5561
5954
|
}
|
|
5955
|
+
getLyricsObjects(line, vpos, verse) {
|
|
5956
|
+
let vposMap = this.lyricsObjectsCache.get(line);
|
|
5957
|
+
if (vposMap === void 0) {
|
|
5958
|
+
vposMap = /* @__PURE__ */ new Map();
|
|
5959
|
+
this.lyricsObjectsCache.set(line, vposMap);
|
|
5960
|
+
}
|
|
5961
|
+
let verseMap = vposMap.get(vpos);
|
|
5962
|
+
if (verseMap === void 0) {
|
|
5963
|
+
verseMap = /* @__PURE__ */ new Map();
|
|
5964
|
+
vposMap.set(vpos, verseMap);
|
|
5965
|
+
}
|
|
5966
|
+
let lyricsArr = verseMap.get(verse);
|
|
5967
|
+
if (lyricsArr === void 0) {
|
|
5968
|
+
lyricsArr = [];
|
|
5969
|
+
verseMap.set(verse, lyricsArr);
|
|
5970
|
+
}
|
|
5971
|
+
return lyricsArr;
|
|
5972
|
+
}
|
|
5973
|
+
getPrevLyricsObject(lyricsObj) {
|
|
5974
|
+
var _a;
|
|
5975
|
+
let lyricsArr = this.getLyricsObjects(lyricsObj.line, lyricsObj.vpos, lyricsObj.verse);
|
|
5976
|
+
let i = lyricsArr.indexOf(lyricsObj);
|
|
5977
|
+
if (i > 0) {
|
|
5978
|
+
return lyricsArr[i - 1];
|
|
5979
|
+
} else if (i === 0) {
|
|
5980
|
+
let lyricsArr2 = (_a = lyricsObj.measure.getPrevMeasure()) == null ? void 0 : _a.getLyricsObjects(lyricsObj.line, lyricsObj.vpos, lyricsObj.verse);
|
|
5981
|
+
if (lyricsArr2 && lyricsArr2.length > 0) {
|
|
5982
|
+
return lyricsArr2[lyricsArr2.length - 1];
|
|
5983
|
+
}
|
|
5984
|
+
}
|
|
5985
|
+
return void 0;
|
|
5986
|
+
}
|
|
5562
5987
|
getStaticObjects(line) {
|
|
5563
5988
|
let staticObjects = this.staticObjectsCache.get(line);
|
|
5564
5989
|
if (!staticObjects) {
|
|
@@ -5727,10 +6152,9 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5727
6152
|
return this.barLineRight;
|
|
5728
6153
|
}
|
|
5729
6154
|
getVoiceSymbols(voiceId) {
|
|
6155
|
+
var _a, _b;
|
|
5730
6156
|
validateVoiceId(voiceId);
|
|
5731
|
-
|
|
5732
|
-
this.voiceSymbols[voiceId] = [];
|
|
5733
|
-
}
|
|
6157
|
+
(_b = (_a = this.voiceSymbols)[voiceId]) != null ? _b : _a[voiceId] = [];
|
|
5734
6158
|
return this.voiceSymbols[voiceId];
|
|
5735
6159
|
}
|
|
5736
6160
|
completeRests(voiceId) {
|
|
@@ -5741,7 +6165,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5741
6165
|
this.completeRests(getVoiceIds().filter((id) => this.getConsumedTicks(id) > 0));
|
|
5742
6166
|
}
|
|
5743
6167
|
return;
|
|
5744
|
-
} else if (
|
|
6168
|
+
} else if (import_ts_utils_lib12.Utils.Is.isArray(voiceId)) {
|
|
5745
6169
|
voiceId.forEach((id) => this.completeRests(id));
|
|
5746
6170
|
return;
|
|
5747
6171
|
} else {
|
|
@@ -5856,7 +6280,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5856
6280
|
let columnsAreaLeft = this.rect.left + this.leftSolidAreaWidth;
|
|
5857
6281
|
let columnsAreaRight = this.rect.right - this.rightSolidAreaWidth;
|
|
5858
6282
|
let columnsAreaWidth = columnsAreaRight - columnsAreaLeft;
|
|
5859
|
-
let columnsWidth =
|
|
6283
|
+
let columnsWidth = import_ts_utils_lib12.Utils.Math.sum(this.columns.map((col) => col.getRect().width));
|
|
5860
6284
|
let columnScale = columnsAreaWidth / columnsWidth;
|
|
5861
6285
|
let columnLeft = columnsAreaLeft;
|
|
5862
6286
|
this.columns.forEach((col) => {
|
|
@@ -5975,9 +6399,21 @@ __publicField(_ObjMeasure, "MinFlexContentWidth", 10);
|
|
|
5975
6399
|
var ObjMeasure2 = _ObjMeasure;
|
|
5976
6400
|
|
|
5977
6401
|
// src/score/engine/layout-object.ts
|
|
5978
|
-
var
|
|
5979
|
-
var WidenColumnList = [
|
|
5980
|
-
|
|
6402
|
+
var import_core15 = require("@tspro/web-music-score/core");
|
|
6403
|
+
var WidenColumnList = [
|
|
6404
|
+
1 /* NoteLabel */,
|
|
6405
|
+
6 /* ChordLabel */
|
|
6406
|
+
];
|
|
6407
|
+
var RowAlignList = [
|
|
6408
|
+
2 /* Navigation */,
|
|
6409
|
+
3 /* Ending */,
|
|
6410
|
+
4 /* TempoAnnotation */,
|
|
6411
|
+
5 /* DynamicsAnnotation */,
|
|
6412
|
+
6 /* ChordLabel */,
|
|
6413
|
+
7 /* LyricsVerse1 */,
|
|
6414
|
+
8 /* LyricsVerse2 */,
|
|
6415
|
+
9 /* LyricsVerse3 */
|
|
6416
|
+
];
|
|
5981
6417
|
function requireParentMeasure(p) {
|
|
5982
6418
|
while (p) {
|
|
5983
6419
|
if (p instanceof ObjMeasure2) {
|
|
@@ -5985,7 +6421,7 @@ function requireParentMeasure(p) {
|
|
|
5985
6421
|
}
|
|
5986
6422
|
p = p.getParent();
|
|
5987
6423
|
}
|
|
5988
|
-
throw new
|
|
6424
|
+
throw new import_core15.MusicError(import_core15.MusicErrorType.Score, "Parent measure is required but not found!");
|
|
5989
6425
|
}
|
|
5990
6426
|
var StaffGroup = class {
|
|
5991
6427
|
constructor(groupName, staffsTabsAndGroups, verticalPosition) {
|
|
@@ -6009,7 +6445,7 @@ var LayoutObjectWrapper = class {
|
|
|
6009
6445
|
this.row = this.measure.row;
|
|
6010
6446
|
let anchor = this.musicObj.getParent();
|
|
6011
6447
|
if (!anchor) {
|
|
6012
|
-
throw new
|
|
6448
|
+
throw new import_core15.MusicError(import_core15.MusicErrorType.Score, "Parent music object is required as an anchor.");
|
|
6013
6449
|
}
|
|
6014
6450
|
this.anchor = anchor;
|
|
6015
6451
|
this.anchor.addAnchoredLayoutObject(this);
|
|
@@ -6201,7 +6637,7 @@ var ObjStaff = class extends ObjNotationLine4 {
|
|
|
6201
6637
|
this.clefLineDiatonicId = getDiatonicId("F3", staffConfig.isOctaveDown === true);
|
|
6202
6638
|
this.middleLineDiatonicId = this.clefLineDiatonicId - 2;
|
|
6203
6639
|
} else {
|
|
6204
|
-
throw new
|
|
6640
|
+
throw new import_core16.MusicError(import_core16.MusicErrorType.Score, `Invalid staffConfig.clef ${staffConfig.clef}.`);
|
|
6205
6641
|
}
|
|
6206
6642
|
this.topLineDiatonicId = this.middleLineDiatonicId + 4;
|
|
6207
6643
|
this.bottomLineDiatonicId = this.middleLineDiatonicId - 4;
|
|
@@ -6249,7 +6685,7 @@ var ObjStaff = class extends ObjNotationLine4 {
|
|
|
6249
6685
|
} else if (this.joinedGrandStaff && this.joinedGrandStaff.containsDiatonicId(diatonicId)) {
|
|
6250
6686
|
return this.joinedGrandStaff.getDiatonicIdY(diatonicId);
|
|
6251
6687
|
} else {
|
|
6252
|
-
throw new
|
|
6688
|
+
throw new import_core16.MusicError(import_core16.MusicErrorType.Score, "Staff does not contain diatonicId " + diatonicId);
|
|
6253
6689
|
}
|
|
6254
6690
|
}
|
|
6255
6691
|
getActualStaff(diatonicId) {
|
|
@@ -6258,7 +6694,7 @@ var ObjStaff = class extends ObjNotationLine4 {
|
|
|
6258
6694
|
} else if (this.joinedGrandStaff && this.joinedGrandStaff.containsDiatonicId(diatonicId)) {
|
|
6259
6695
|
return this.joinedGrandStaff;
|
|
6260
6696
|
} else {
|
|
6261
|
-
throw new
|
|
6697
|
+
throw new import_core16.MusicError(import_core16.MusicErrorType.Score, "Staff does not contain diatonicId " + diatonicId);
|
|
6262
6698
|
}
|
|
6263
6699
|
}
|
|
6264
6700
|
getDiatonicIdAt(y) {
|
|
@@ -6337,7 +6773,7 @@ var ObjTab = class extends ObjNotationLine4 {
|
|
|
6337
6773
|
__publicField(this, "tuningName");
|
|
6338
6774
|
__publicField(this, "tuningStrings");
|
|
6339
6775
|
__publicField(this, "mi");
|
|
6340
|
-
if (
|
|
6776
|
+
if (import_ts_utils_lib13.Utils.Is.isArray(tabConfig.tuning)) {
|
|
6341
6777
|
this.tuningName = void 0;
|
|
6342
6778
|
this.tuningStrings = tabConfig.tuning.map((noteName) => import_theory11.Note.getNote(noteName)).reverse();
|
|
6343
6779
|
} else if (typeof tabConfig.tuning === "string") {
|
|
@@ -6427,7 +6863,7 @@ var ObjTab = class extends ObjNotationLine4 {
|
|
|
6427
6863
|
};
|
|
6428
6864
|
|
|
6429
6865
|
// src/score/engine/obj-score-row.ts
|
|
6430
|
-
var
|
|
6866
|
+
var import_core17 = require("@tspro/web-music-score/core");
|
|
6431
6867
|
var ObjScoreRow = class extends MusicObject {
|
|
6432
6868
|
constructor(doc, prevRow, scoreConfig) {
|
|
6433
6869
|
super(doc);
|
|
@@ -6485,7 +6921,7 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
6485
6921
|
if (topStaff) {
|
|
6486
6922
|
return topStaff;
|
|
6487
6923
|
} else {
|
|
6488
|
-
throw new
|
|
6924
|
+
throw new import_core17.MusicError(import_core17.MusicErrorType.Score, "Top staff is required!");
|
|
6489
6925
|
}
|
|
6490
6926
|
}
|
|
6491
6927
|
getBottomStaff() {
|
|
@@ -6493,7 +6929,7 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
6493
6929
|
if (bottomStaff) {
|
|
6494
6930
|
return bottomStaff;
|
|
6495
6931
|
} else {
|
|
6496
|
-
throw new
|
|
6932
|
+
throw new import_core17.MusicError(import_core17.MusicErrorType.Score, "Bottom staff is required!");
|
|
6497
6933
|
}
|
|
6498
6934
|
}
|
|
6499
6935
|
getStaff(diatonicId) {
|
|
@@ -6792,7 +7228,7 @@ var ObjHeader = class extends MusicObject {
|
|
|
6792
7228
|
};
|
|
6793
7229
|
|
|
6794
7230
|
// src/score/engine/obj-document.ts
|
|
6795
|
-
var
|
|
7231
|
+
var import_ts_utils_lib14 = require("@tspro/ts-utils-lib");
|
|
6796
7232
|
var ObjDocument = class extends MusicObject {
|
|
6797
7233
|
constructor() {
|
|
6798
7234
|
super(void 0);
|
|
@@ -6813,7 +7249,7 @@ var ObjDocument = class extends MusicObject {
|
|
|
6813
7249
|
return this.mi;
|
|
6814
7250
|
}
|
|
6815
7251
|
setScoreConfiguration(config) {
|
|
6816
|
-
if (
|
|
7252
|
+
if (import_ts_utils_lib14.Utils.Is.isEnumValue(config, StaffPreset)) {
|
|
6817
7253
|
switch (config) {
|
|
6818
7254
|
default:
|
|
6819
7255
|
case "treble" /* Treble */:
|
|
@@ -6841,7 +7277,7 @@ var ObjDocument = class extends MusicObject {
|
|
|
6841
7277
|
];
|
|
6842
7278
|
break;
|
|
6843
7279
|
}
|
|
6844
|
-
} else if (
|
|
7280
|
+
} else if (import_ts_utils_lib14.Utils.Is.isArray(config)) {
|
|
6845
7281
|
this.curScoreConfig = config;
|
|
6846
7282
|
} else {
|
|
6847
7283
|
this.curScoreConfig = [config];
|
|
@@ -7068,10 +7504,10 @@ var ObjDocument = class extends MusicObject {
|
|
|
7068
7504
|
|
|
7069
7505
|
// src/score/pub/document-builder.ts
|
|
7070
7506
|
var import_theory13 = require("@tspro/web-music-score/theory");
|
|
7071
|
-
var
|
|
7507
|
+
var import_core18 = require("@tspro/web-music-score/core");
|
|
7072
7508
|
function assertArg(condition, argName, argValue) {
|
|
7073
7509
|
if (!condition) {
|
|
7074
|
-
throw new
|
|
7510
|
+
throw new import_core18.MusicError(import_core18.MusicErrorType.Score, `Invalid arg: ${argName} = ${argValue}`);
|
|
7075
7511
|
}
|
|
7076
7512
|
}
|
|
7077
7513
|
function isNote(note) {
|
|
@@ -7083,56 +7519,64 @@ function isNote(note) {
|
|
|
7083
7519
|
}
|
|
7084
7520
|
}
|
|
7085
7521
|
function isVoiceId(value) {
|
|
7086
|
-
return
|
|
7522
|
+
return import_ts_utils_lib15.Utils.Is.isNumber(value) && getVoiceIds().indexOf(value) >= 0;
|
|
7087
7523
|
}
|
|
7088
7524
|
function isStringNumber(value) {
|
|
7089
|
-
return
|
|
7525
|
+
return import_ts_utils_lib15.Utils.Is.isNumber(value) && getStringNumbers().indexOf(value) >= 0;
|
|
7526
|
+
}
|
|
7527
|
+
function isVerseNumber(value) {
|
|
7528
|
+
return import_ts_utils_lib15.Utils.Is.isNumber(value) && getVerseNumbers().indexOf(value) >= 0;
|
|
7090
7529
|
}
|
|
7091
7530
|
function assertStaffConfig(staffConfig) {
|
|
7092
|
-
assertArg(
|
|
7531
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isObject(staffConfig), "staffConfig", staffConfig);
|
|
7093
7532
|
assertArg(staffConfig.type === "staff", "staffConfig.type", staffConfig.type);
|
|
7094
|
-
assertArg(
|
|
7095
|
-
assertArg(
|
|
7096
|
-
assertArg(
|
|
7097
|
-
assertArg(
|
|
7098
|
-
assertArg(
|
|
7099
|
-
assertArg(
|
|
7533
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValue(staffConfig.clef, Clef), "staffConfig.clef", staffConfig.clef);
|
|
7534
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isBooleanOrUndefined(staffConfig.isOctaveDown), "staffConfig.isOctaveDown", staffConfig.isOctaveDown);
|
|
7535
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isUndefined(staffConfig.minNote) || isNote(staffConfig.minNote), "staffConfig.minNote", staffConfig.minNote);
|
|
7536
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isUndefined(staffConfig.maxNote) || isNote(staffConfig.maxNote), "staffConfig.maxNote", staffConfig.maxNote);
|
|
7537
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isUndefined(staffConfig.voiceIds) || import_ts_utils_lib15.Utils.Is.isArray(staffConfig.voiceIds) && staffConfig.voiceIds.every((voiceId) => import_ts_utils_lib15.Utils.Is.isNumber(voiceId)), "staffConfig.voiceIds", staffConfig.voiceIds);
|
|
7538
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isBooleanOrUndefined(staffConfig.isGrand), "staffConfig.isGrand", staffConfig.isGrand);
|
|
7100
7539
|
}
|
|
7101
7540
|
function assertTabConfig(tabConfig) {
|
|
7102
|
-
assertArg(
|
|
7541
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isObject(tabConfig), "tabConfig", tabConfig);
|
|
7103
7542
|
assertArg(tabConfig.type === "tab", "tabConfig.type", tabConfig.type);
|
|
7104
7543
|
if (typeof tabConfig.tuning === "string") {
|
|
7105
7544
|
assertArg(import_theory13.TuningNameList.includes(tabConfig.tuning), "tabConfig.tuning", tabConfig.tuning);
|
|
7106
|
-
} else if (
|
|
7545
|
+
} else if (import_ts_utils_lib15.Utils.Is.isArray(tabConfig.tuning)) {
|
|
7107
7546
|
assertArg(tabConfig.tuning.length === getStringNumbers().length && tabConfig.tuning.every((s) => isNote(s)), "tabConfig.tuning", tabConfig.tuning);
|
|
7108
7547
|
}
|
|
7109
|
-
assertArg(
|
|
7548
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isUndefined(tabConfig.voiceIds) || import_ts_utils_lib15.Utils.Is.isArray(tabConfig.voiceIds) && tabConfig.voiceIds.every((voiceId) => import_ts_utils_lib15.Utils.Is.isNumber(voiceId)), "tabConfig.voiceIds", tabConfig.voiceIds);
|
|
7549
|
+
}
|
|
7550
|
+
function assertNoteOptions(noteOptions) {
|
|
7551
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isObject(noteOptions), "noteOptions", noteOptions);
|
|
7552
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isBooleanOrUndefined(noteOptions.dotted) || import_ts_utils_lib15.Utils.Is.isIntegerGte(noteOptions.dotted, 0), "noteOptions.dotted", noteOptions.dotted);
|
|
7553
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValueOrUndefined(noteOptions.stem, Stem), "noteOptions.stem", noteOptions.stem);
|
|
7554
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isStringOrUndefined(noteOptions.color), "noteOptions.color", noteOptions.color);
|
|
7555
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isBooleanOrUndefined(noteOptions.arpeggio) || import_ts_utils_lib15.Utils.Is.isEnumValue(noteOptions.arpeggio, Arpeggio), "noteOptions.arpeggio", noteOptions.arpeggio);
|
|
7556
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isBooleanOrUndefined(noteOptions.staccato), "noteOptions.staccato", noteOptions.staccato);
|
|
7557
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isBooleanOrUndefined(noteOptions.diamond), "noteOptions.diamond", noteOptions.diamond);
|
|
7558
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isBooleanOrUndefined(noteOptions.triplet), "noteOptions.triplet", noteOptions.triplet);
|
|
7559
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isUndefined(noteOptions.string) || isStringNumber(noteOptions.string) || import_ts_utils_lib15.Utils.Is.isNonEmptyArray(noteOptions.string) && noteOptions.string.every((string) => isStringNumber(string)), "noteOptions.string", noteOptions.string);
|
|
7560
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isUndefined(noteOptions.tieSpan), 'NoteOptions.tieSpan was removed. Use addConnective("tie", tieSpan)', "");
|
|
7561
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isUndefined(noteOptions.slurSpan), 'NoteOptions.slurSpan was removed. Use addConnective("slur", slurSpan)', "");
|
|
7110
7562
|
}
|
|
7111
|
-
function
|
|
7112
|
-
assertArg(
|
|
7113
|
-
assertArg(
|
|
7114
|
-
assertArg(
|
|
7115
|
-
assertArg(
|
|
7116
|
-
assertArg(
|
|
7117
|
-
assertArg(
|
|
7118
|
-
assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.diamond), "noteOptions.diamond", options.diamond);
|
|
7119
|
-
assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.triplet), "noteOptions.triplet", options.triplet);
|
|
7120
|
-
assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(options.string) || isStringNumber(options.string) || import_ts_utils_lib13.Utils.Is.isNonEmptyArray(options.string) && options.string.every((string) => isStringNumber(string)), "noteOptions.string", options.string);
|
|
7121
|
-
assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(options.tieSpan), 'NoteOptions.tieSpan was removed. Use addConnective("tie", tieSpan)', "");
|
|
7122
|
-
assertArg(import_ts_utils_lib13.Utils.Is.isUndefined(options.slurSpan), 'NoteOptions.slurSpan was removed. Use addConnective("slur", slurSpan)', "");
|
|
7563
|
+
function assertRestOptions(restOptions) {
|
|
7564
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isObject(restOptions), "restOptions", restOptions);
|
|
7565
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isBooleanOrUndefined(restOptions.dotted) || import_ts_utils_lib15.Utils.Is.isIntegerGte(restOptions.dotted, 0), "restOptions.dotted", restOptions.dotted);
|
|
7566
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isStringOrUndefined(restOptions.staffPos) || import_ts_utils_lib15.Utils.Is.isInteger(restOptions.staffPos) || restOptions.staffPos instanceof import_theory13.Note, "restOptions.staffPos", restOptions.staffPos);
|
|
7567
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isStringOrUndefined(restOptions.color), "restOptions.color", restOptions.color);
|
|
7568
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isBooleanOrUndefined(restOptions.hide), "restOptions.hide", restOptions.hide);
|
|
7569
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isBooleanOrUndefined(restOptions.triplet), "restOptions.triplet", restOptions.triplet);
|
|
7123
7570
|
}
|
|
7124
|
-
function
|
|
7125
|
-
assertArg(
|
|
7126
|
-
assertArg(
|
|
7127
|
-
assertArg(
|
|
7128
|
-
assertArg(import_ts_utils_lib13.Utils.Is.isStringOrUndefined(options.color), "restOptions.color", options.color);
|
|
7129
|
-
assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.hide), "restOptions.hide", options.hide);
|
|
7130
|
-
assertArg(import_ts_utils_lib13.Utils.Is.isBooleanOrUndefined(options.triplet), "restOptions.triplet", options.triplet);
|
|
7571
|
+
function assertLyricsOptions(lyricsOptions) {
|
|
7572
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isObject(lyricsOptions), "lyricsOptions", lyricsOptions);
|
|
7573
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValueOrUndefined(lyricsOptions.align, LyricsAlign), "lyricsOptions.align", lyricsOptions.align);
|
|
7574
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValueOrUndefined(lyricsOptions.hyphen, LyricsHyphen), "lyricsOptions.hyphen", lyricsOptions.hyphen);
|
|
7131
7575
|
}
|
|
7132
7576
|
function assertStaffTabOrGRoups(staffTabOrGroups) {
|
|
7133
7577
|
assertArg(
|
|
7134
|
-
|
|
7135
|
-
(staffTabOrGroup) =>
|
|
7578
|
+
import_ts_utils_lib15.Utils.Is.isStringOrUndefined(staffTabOrGroups) || import_ts_utils_lib15.Utils.Is.isIntegerGte(staffTabOrGroups, 0) || import_ts_utils_lib15.Utils.Is.isNonEmptyArray(staffTabOrGroups) && staffTabOrGroups.every(
|
|
7579
|
+
(staffTabOrGroup) => import_ts_utils_lib15.Utils.Is.isString(staffTabOrGroup) || import_ts_utils_lib15.Utils.Is.isIntegerGte(staffTabOrGroup, 0)
|
|
7136
7580
|
),
|
|
7137
7581
|
"staffTabOrGroup",
|
|
7138
7582
|
staffTabOrGroups
|
|
@@ -7160,22 +7604,23 @@ var DocumentBuilder = class {
|
|
|
7160
7604
|
*/
|
|
7161
7605
|
constructor() {
|
|
7162
7606
|
__publicField(this, "doc");
|
|
7607
|
+
__publicField(this, "currentLyricsAlign", "center" /* Center */);
|
|
7163
7608
|
this.doc = new ObjDocument();
|
|
7164
7609
|
}
|
|
7165
7610
|
setScoreConfiguration(config) {
|
|
7166
|
-
if (
|
|
7611
|
+
if (import_ts_utils_lib15.Utils.Is.isEnumValue(config, StaffPreset)) {
|
|
7167
7612
|
this.doc.setScoreConfiguration(config);
|
|
7168
|
-
} else if (
|
|
7613
|
+
} else if (import_ts_utils_lib15.Utils.Is.isObject(config) && config.type === "staff") {
|
|
7169
7614
|
assertStaffConfig(config);
|
|
7170
7615
|
this.doc.setScoreConfiguration(config);
|
|
7171
|
-
} else if (
|
|
7616
|
+
} else if (import_ts_utils_lib15.Utils.Is.isObject(config) && config.type === "tab") {
|
|
7172
7617
|
assertTabConfig(config);
|
|
7173
7618
|
this.doc.setScoreConfiguration(config);
|
|
7174
|
-
} else if (
|
|
7619
|
+
} else if (import_ts_utils_lib15.Utils.Is.isNonEmptyArray(config)) {
|
|
7175
7620
|
config.forEach((c) => {
|
|
7176
|
-
if (
|
|
7621
|
+
if (import_ts_utils_lib15.Utils.Is.isObject(c) && c.type === "staff") {
|
|
7177
7622
|
assertStaffConfig(c);
|
|
7178
|
-
} else if (
|
|
7623
|
+
} else if (import_ts_utils_lib15.Utils.Is.isObject(c) && c.type === "tab") {
|
|
7179
7624
|
assertTabConfig(c);
|
|
7180
7625
|
} else {
|
|
7181
7626
|
assertArg(false, "config", config);
|
|
@@ -7206,9 +7651,9 @@ var DocumentBuilder = class {
|
|
|
7206
7651
|
* @returns - This document builder instance.
|
|
7207
7652
|
*/
|
|
7208
7653
|
setHeader(title, composer, arranger) {
|
|
7209
|
-
assertArg(
|
|
7210
|
-
assertArg(
|
|
7211
|
-
assertArg(
|
|
7654
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isStringOrUndefined(title), "title", title);
|
|
7655
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isStringOrUndefined(composer), "composer", composer);
|
|
7656
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isStringOrUndefined(arranger), "arranger", arranger);
|
|
7212
7657
|
this.doc.setHeader(title, composer, arranger);
|
|
7213
7658
|
return this;
|
|
7214
7659
|
}
|
|
@@ -7218,7 +7663,7 @@ var DocumentBuilder = class {
|
|
|
7218
7663
|
* @returns - This document builder instance.
|
|
7219
7664
|
*/
|
|
7220
7665
|
setMeasuresPerRow(measuresPerRow) {
|
|
7221
|
-
assertArg(
|
|
7666
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isIntegerGte(measuresPerRow, 1) || import_ts_utils_lib15.Utils.Is.isPosInfinity(measuresPerRow), "measuresPerRow", measuresPerRow);
|
|
7222
7667
|
this.doc.setMeasuresPerRow(measuresPerRow);
|
|
7223
7668
|
return this;
|
|
7224
7669
|
}
|
|
@@ -7231,16 +7676,16 @@ var DocumentBuilder = class {
|
|
|
7231
7676
|
return this;
|
|
7232
7677
|
}
|
|
7233
7678
|
setKeySignature(...args) {
|
|
7234
|
-
assertArg(args[0] instanceof import_theory13.Scale || args[0] instanceof import_theory13.KeySignature ||
|
|
7679
|
+
assertArg(args[0] instanceof import_theory13.Scale || args[0] instanceof import_theory13.KeySignature || import_ts_utils_lib15.Utils.Is.isNonEmptyString(args[0]) && (args.length === 1 || import_ts_utils_lib15.Utils.Is.isEnumValue(args[1], import_theory13.ScaleType)), "keySignature", args);
|
|
7235
7680
|
this.getMeasure().setKeySignature(...args);
|
|
7236
7681
|
return this;
|
|
7237
7682
|
}
|
|
7238
7683
|
setTimeSignature(...args) {
|
|
7239
7684
|
if (args[0] instanceof import_theory13.TimeSignature) {
|
|
7240
7685
|
this.getMeasure().setTimeSignature(args[0]);
|
|
7241
|
-
} else if (
|
|
7686
|
+
} else if (import_ts_utils_lib15.Utils.Is.isEnumValue(args[0], import_theory13.TimeSignatures) && import_ts_utils_lib15.Utils.Is.isEnumValueOrUndefined(args[1], import_theory13.BeamGrouping)) {
|
|
7242
7687
|
this.getMeasure().setTimeSignature(new import_theory13.TimeSignature(args[0], args[1]));
|
|
7243
|
-
} else if (
|
|
7688
|
+
} else if (import_ts_utils_lib15.Utils.Is.isIntegerGte(args[0], 1) && import_ts_utils_lib15.Utils.Is.isIntegerGte(args[1], 1) && import_ts_utils_lib15.Utils.Is.isEnumValueOrUndefined(args[2], import_theory13.BeamGrouping)) {
|
|
7244
7689
|
this.getMeasure().setTimeSignature(new import_theory13.TimeSignature(args[0], args[1], args[2]));
|
|
7245
7690
|
} else {
|
|
7246
7691
|
assertArg(false, "timeSignature args", args);
|
|
@@ -7248,65 +7693,71 @@ var DocumentBuilder = class {
|
|
|
7248
7693
|
return this;
|
|
7249
7694
|
}
|
|
7250
7695
|
setTempo(beatsPerMinute, beatLength, dotted) {
|
|
7251
|
-
assertArg(
|
|
7696
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isIntegerGte(beatsPerMinute, 1), "beatsPerMinute", beatsPerMinute);
|
|
7252
7697
|
if (beatLength === void 0) {
|
|
7253
|
-
assertArg(
|
|
7698
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isUndefined(dotted), "dotted", dotted);
|
|
7254
7699
|
} else {
|
|
7255
|
-
assertArg(
|
|
7256
|
-
assertArg(
|
|
7700
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValue(beatLength, import_theory13.NoteLength) || isNoteLength(beatLength), "beatLength", beatLength);
|
|
7701
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isBooleanOrUndefined(dotted) || import_ts_utils_lib15.Utils.Is.isIntegerGte(dotted, 0), "dotted", dotted);
|
|
7257
7702
|
}
|
|
7258
7703
|
this.getMeasure().setTempo(beatsPerMinute, beatLength, dotted);
|
|
7259
7704
|
return this;
|
|
7260
7705
|
}
|
|
7261
7706
|
/**
|
|
7262
|
-
* Add note
|
|
7707
|
+
* Add note to current measure.
|
|
7263
7708
|
* @param voiceId - Voice id to add note to.
|
|
7264
|
-
* @param note -
|
|
7709
|
+
* @param note - Instance of Note or string, single value (e.g. "C4") or array (e.g. ["C4", "E4", "G4"]).
|
|
7265
7710
|
* @param noteLength - Note length (e.g. "4n").
|
|
7266
|
-
* @param
|
|
7711
|
+
* @param noteOptions - Note options.
|
|
7267
7712
|
* @returns - This document builder instance.
|
|
7268
7713
|
*/
|
|
7269
|
-
addNote(voiceId, note, noteLength,
|
|
7714
|
+
addNote(voiceId, note, noteLength, noteOptions) {
|
|
7270
7715
|
assertArg(isVoiceId(voiceId), "voiceId", voiceId);
|
|
7271
|
-
assertArg(
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7716
|
+
assertArg(
|
|
7717
|
+
note instanceof import_theory13.Note || import_ts_utils_lib15.Utils.Is.isNonEmptyString(note) || import_ts_utils_lib15.Utils.Is.isArray(note) && note.every((note2) => note2 instanceof import_theory13.Note || import_ts_utils_lib15.Utils.Is.isNonEmptyString(note2)),
|
|
7718
|
+
"note",
|
|
7719
|
+
note
|
|
7720
|
+
);
|
|
7721
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
|
|
7722
|
+
noteOptions != null ? noteOptions : noteOptions = {};
|
|
7723
|
+
assertNoteOptions(noteOptions);
|
|
7724
|
+
if (import_ts_utils_lib15.Utils.Is.isArray(note)) {
|
|
7725
|
+
note.forEach((note2) => this.getMeasure().addNoteGroup(voiceId, [note2], noteLength, noteOptions));
|
|
7726
|
+
} else {
|
|
7727
|
+
this.getMeasure().addNoteGroup(voiceId, [note], noteLength, noteOptions);
|
|
7275
7728
|
}
|
|
7276
|
-
this.getMeasure().addNoteGroup(voiceId, [note], noteLength, options);
|
|
7277
7729
|
return this;
|
|
7278
7730
|
}
|
|
7279
7731
|
/**
|
|
7732
|
+
* Add chord to current measure.
|
|
7280
7733
|
* @param voiceId - Voice id to add chord to.
|
|
7281
7734
|
* @param notes - Array of notes, each instance of Note or string (e.g. "D4").
|
|
7282
7735
|
* @param noteLength - Note length (e.g. "4n").
|
|
7283
|
-
* @param
|
|
7736
|
+
* @param noteOptions - Note options.
|
|
7284
7737
|
* @returns - This document builder instance.
|
|
7285
7738
|
*/
|
|
7286
|
-
addChord(voiceId, notes, noteLength,
|
|
7739
|
+
addChord(voiceId, notes, noteLength, noteOptions) {
|
|
7287
7740
|
assertArg(isVoiceId(voiceId), "voiceId", voiceId);
|
|
7288
|
-
assertArg(
|
|
7289
|
-
assertArg(
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
this.getMeasure().addNoteGroup(voiceId, notes, noteLength, options);
|
|
7741
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isNonEmptyArray(notes) && notes.every((note) => note instanceof import_theory13.Note || import_ts_utils_lib15.Utils.Is.isNonEmptyString(note)), "notes", notes);
|
|
7742
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
|
|
7743
|
+
noteOptions != null ? noteOptions : noteOptions = {};
|
|
7744
|
+
assertNoteOptions(noteOptions);
|
|
7745
|
+
this.getMeasure().addNoteGroup(voiceId, notes, noteLength, noteOptions);
|
|
7294
7746
|
return this;
|
|
7295
7747
|
}
|
|
7296
7748
|
/**
|
|
7297
|
-
*
|
|
7749
|
+
* Add rest to current measure.
|
|
7298
7750
|
* @param voiceId - Voice id to add rest to.
|
|
7299
7751
|
* @param restLength - Rest length (e.g. "4n").
|
|
7300
|
-
* @param
|
|
7752
|
+
* @param restOptions - Rest options.
|
|
7301
7753
|
* @returns - This document builder instance.
|
|
7302
7754
|
*/
|
|
7303
|
-
addRest(voiceId, restLength,
|
|
7755
|
+
addRest(voiceId, restLength, restOptions) {
|
|
7304
7756
|
assertArg(isVoiceId(voiceId), "voiceId", voiceId);
|
|
7305
|
-
assertArg(
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
this.getMeasure().addRest(voiceId, restLength, options);
|
|
7757
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValue(restLength, import_theory13.NoteLength) || isNoteLength(restLength), "restLength", restLength);
|
|
7758
|
+
restOptions != null ? restOptions : restOptions = {};
|
|
7759
|
+
assertRestOptions(restOptions);
|
|
7760
|
+
this.getMeasure().addRest(voiceId, restLength, restOptions);
|
|
7310
7761
|
return this;
|
|
7311
7762
|
}
|
|
7312
7763
|
/**
|
|
@@ -7326,39 +7777,47 @@ var DocumentBuilder = class {
|
|
|
7326
7777
|
*/
|
|
7327
7778
|
addTuplet(voiceId, tupletRatio, tupletBuilder) {
|
|
7328
7779
|
assertArg(isVoiceId(voiceId), "voiceId", voiceId);
|
|
7329
|
-
assertArg(
|
|
7330
|
-
assertArg(isTupletRatio(tupletRatio) &&
|
|
7780
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isFunction(tupletBuilder), "tupletBuilder", tupletBuilder);
|
|
7781
|
+
assertArg(isTupletRatio(tupletRatio) && import_ts_utils_lib15.Utils.Is.isBooleanOrUndefined(tupletRatio.showRatio), "tupletRatio", tupletRatio);
|
|
7331
7782
|
let tupletSymbols = [];
|
|
7332
7783
|
const helper = {
|
|
7333
|
-
addNote: (note, noteLength,
|
|
7334
|
-
assertArg(
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7784
|
+
addNote: (note, noteLength, noteOptions) => {
|
|
7785
|
+
assertArg(
|
|
7786
|
+
note instanceof import_theory13.Note || import_ts_utils_lib15.Utils.Is.isNonEmptyString(note) || import_ts_utils_lib15.Utils.Is.isArray(note) && note.every((note2) => note2 instanceof import_theory13.Note || import_ts_utils_lib15.Utils.Is.isNonEmptyString(note2)),
|
|
7787
|
+
"note",
|
|
7788
|
+
note
|
|
7789
|
+
);
|
|
7790
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
|
|
7791
|
+
noteOptions != null ? noteOptions : noteOptions = {};
|
|
7792
|
+
delete noteOptions.triplet;
|
|
7793
|
+
assertNoteOptions(noteOptions);
|
|
7794
|
+
if (import_ts_utils_lib15.Utils.Is.isArray(note)) {
|
|
7795
|
+
note.forEach((note2) => {
|
|
7796
|
+
let s = this.getMeasure().addNoteGroup(voiceId, [note2], noteLength, noteOptions, tupletRatio);
|
|
7797
|
+
tupletSymbols.push(s);
|
|
7798
|
+
});
|
|
7799
|
+
} else {
|
|
7800
|
+
let s = this.getMeasure().addNoteGroup(voiceId, [note], noteLength, noteOptions, tupletRatio);
|
|
7801
|
+
tupletSymbols.push(s);
|
|
7339
7802
|
}
|
|
7340
|
-
let s = this.getMeasure().addNoteGroup(voiceId, [note], noteLength, options, tupletRatio);
|
|
7341
|
-
tupletSymbols.push(s);
|
|
7342
7803
|
return helper;
|
|
7343
7804
|
},
|
|
7344
|
-
addChord: (notes, noteLength,
|
|
7345
|
-
assertArg(
|
|
7346
|
-
assertArg(
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
let s = this.getMeasure().addNoteGroup(voiceId, notes, noteLength, options, tupletRatio);
|
|
7805
|
+
addChord: (notes, noteLength, noteOptions) => {
|
|
7806
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isNonEmptyArray(notes) && notes.every((note) => note instanceof import_theory13.Note || import_ts_utils_lib15.Utils.Is.isNonEmptyString(note)), "notes", notes);
|
|
7807
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
|
|
7808
|
+
noteOptions != null ? noteOptions : noteOptions = {};
|
|
7809
|
+
delete noteOptions.triplet;
|
|
7810
|
+
assertNoteOptions(noteOptions);
|
|
7811
|
+
let s = this.getMeasure().addNoteGroup(voiceId, notes, noteLength, noteOptions, tupletRatio);
|
|
7352
7812
|
tupletSymbols.push(s);
|
|
7353
7813
|
return helper;
|
|
7354
7814
|
},
|
|
7355
|
-
addRest: (restLength,
|
|
7356
|
-
assertArg(
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
let s = this.getMeasure().addRest(voiceId, restLength, options, tupletRatio);
|
|
7815
|
+
addRest: (restLength, restOptions) => {
|
|
7816
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValue(restLength, import_theory13.NoteLength) || isNoteLength(restLength), "restLength", restLength);
|
|
7817
|
+
restOptions != null ? restOptions : restOptions = {};
|
|
7818
|
+
delete restOptions.triplet;
|
|
7819
|
+
assertRestOptions(restOptions);
|
|
7820
|
+
let s = this.getMeasure().addRest(voiceId, restLength, restOptions, tupletRatio);
|
|
7362
7821
|
tupletSymbols.push(s);
|
|
7363
7822
|
return helper;
|
|
7364
7823
|
}
|
|
@@ -7367,9 +7826,52 @@ var DocumentBuilder = class {
|
|
|
7367
7826
|
ObjBeamGroup.createTuplet(tupletSymbols, tupletRatio);
|
|
7368
7827
|
return this;
|
|
7369
7828
|
}
|
|
7829
|
+
addLyricsInternal(staffTabOrGroups, verse, lyricsLength, lyricsText, lyricsOptions) {
|
|
7830
|
+
var _a;
|
|
7831
|
+
assertStaffTabOrGRoups(staffTabOrGroups);
|
|
7832
|
+
assertArg(isVerseNumber(verse), "verse", verse);
|
|
7833
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValue(lyricsLength, import_theory13.NoteLength), "lyricsLength", lyricsLength);
|
|
7834
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isString(lyricsText) || import_ts_utils_lib15.Utils.Is.isArray(lyricsText) && lyricsText.every((text) => import_ts_utils_lib15.Utils.Is.isString(text)), "lyricsText", lyricsText);
|
|
7835
|
+
lyricsOptions != null ? lyricsOptions : lyricsOptions = {};
|
|
7836
|
+
assertLyricsOptions(lyricsOptions);
|
|
7837
|
+
if (lyricsOptions.align !== void 0) {
|
|
7838
|
+
this.currentLyricsAlign = lyricsOptions.align;
|
|
7839
|
+
} else {
|
|
7840
|
+
(_a = lyricsOptions.align) != null ? _a : lyricsOptions.align = this.currentLyricsAlign;
|
|
7841
|
+
}
|
|
7842
|
+
if (import_ts_utils_lib15.Utils.Is.isArray(lyricsText)) {
|
|
7843
|
+
lyricsText.forEach((text) => this.getMeasure().addLyrics(staffTabOrGroups, verse, lyricsLength, text, lyricsOptions));
|
|
7844
|
+
} else {
|
|
7845
|
+
this.getMeasure().addLyrics(staffTabOrGroups, verse, lyricsLength, lyricsText, lyricsOptions);
|
|
7846
|
+
}
|
|
7847
|
+
return this;
|
|
7848
|
+
}
|
|
7849
|
+
/**
|
|
7850
|
+
* Add lyrics to current measure.
|
|
7851
|
+
* @param verse - Verse number (e.g. 1).
|
|
7852
|
+
* @param lyricsLength - Lyrics text length (e.g. "2n").
|
|
7853
|
+
* @param lyricsText - Lyrics text (empty space if omitted), single value or array.
|
|
7854
|
+
* @param lyricsOptions - Lyrics options.
|
|
7855
|
+
* @returns - This document builder instance.
|
|
7856
|
+
*/
|
|
7857
|
+
addLyrics(verse, lyricsLength, lyricsText, lyricsOptions) {
|
|
7858
|
+
return this.addLyricsInternal(void 0, verse, lyricsLength, lyricsText != null ? lyricsText : "", lyricsOptions);
|
|
7859
|
+
}
|
|
7860
|
+
/**
|
|
7861
|
+
* Add lyrics to current measure to given staff/tab/group.
|
|
7862
|
+
* @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name.
|
|
7863
|
+
* @param verse - Verse number (e.g. 1).
|
|
7864
|
+
* @param lyricsLength - Lyrics text length (e.g. "2n").
|
|
7865
|
+
* @param lyricsText - Lyrics text (empty space if omitted), single value or array.
|
|
7866
|
+
* @param lyricsOptions - Lyrics options.
|
|
7867
|
+
* @returns - This document builder instance.
|
|
7868
|
+
*/
|
|
7869
|
+
addLyricsTo(staffTabOrGroups, verse, lyricsLength, lyricsText, lyricsOptions) {
|
|
7870
|
+
return this.addLyricsInternal(staffTabOrGroups, verse, lyricsLength, lyricsText != null ? lyricsText : "", lyricsOptions);
|
|
7871
|
+
}
|
|
7370
7872
|
addFermataInternal(staffTabOrGroups, fermata) {
|
|
7371
7873
|
assertStaffTabOrGRoups(staffTabOrGroups);
|
|
7372
|
-
assertArg(
|
|
7874
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValue(fermata, Fermata), "fermata", fermata);
|
|
7373
7875
|
this.getMeasure().addFermata(staffTabOrGroups, fermata);
|
|
7374
7876
|
return this;
|
|
7375
7877
|
}
|
|
@@ -7392,11 +7894,11 @@ var DocumentBuilder = class {
|
|
|
7392
7894
|
}
|
|
7393
7895
|
addNavigationInternal(staffTabOrGroups, navigation, ...args) {
|
|
7394
7896
|
assertStaffTabOrGRoups(staffTabOrGroups);
|
|
7395
|
-
assertArg(
|
|
7897
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValue(navigation, Navigation), "navigation", navigation);
|
|
7396
7898
|
if (navigation === "endRepeat" /* EndRepeat */ && args.length > 0) {
|
|
7397
|
-
assertArg(
|
|
7899
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isIntegerGte(args[0], 1), "playCount", args[0]);
|
|
7398
7900
|
} else if (navigation === "ending" /* Ending */ && args.length > 0) {
|
|
7399
|
-
assertArg(args.every((passage) =>
|
|
7901
|
+
assertArg(args.every((passage) => import_ts_utils_lib15.Utils.Is.isIntegerGte(passage, 1)), "passages", args);
|
|
7400
7902
|
}
|
|
7401
7903
|
this.getMeasure().addNavigation(staffTabOrGroups, navigation, ...args);
|
|
7402
7904
|
return this;
|
|
@@ -7410,11 +7912,11 @@ var DocumentBuilder = class {
|
|
|
7410
7912
|
addAnnotationInternal(staffTabOrGroups, annotation, text) {
|
|
7411
7913
|
annotation != null ? annotation : annotation = getAnnotation(text);
|
|
7412
7914
|
if (annotation === void 0) {
|
|
7413
|
-
throw new
|
|
7915
|
+
throw new import_core18.MusicError(import_core18.MusicErrorType.Score, `Annotation text "${text}" is not known annotation.`);
|
|
7414
7916
|
}
|
|
7415
7917
|
assertStaffTabOrGRoups(staffTabOrGroups);
|
|
7416
|
-
assertArg(
|
|
7417
|
-
assertArg(
|
|
7918
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValue(annotation, Annotation), "annotation", annotation);
|
|
7919
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isNonEmptyString(text), "text", text);
|
|
7418
7920
|
this.getMeasure().addAnnotation(staffTabOrGroups, annotation, text);
|
|
7419
7921
|
return this;
|
|
7420
7922
|
}
|
|
@@ -7434,8 +7936,8 @@ var DocumentBuilder = class {
|
|
|
7434
7936
|
}
|
|
7435
7937
|
addLabelInternal(staffTabOrGroups, label, text) {
|
|
7436
7938
|
assertStaffTabOrGRoups(staffTabOrGroups);
|
|
7437
|
-
assertArg(
|
|
7438
|
-
assertArg(
|
|
7939
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValue(label, Label), "label", label);
|
|
7940
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isNonEmptyString(text), "text", text);
|
|
7439
7941
|
this.getMeasure().addLabel(staffTabOrGroups, label, text);
|
|
7440
7942
|
return this;
|
|
7441
7943
|
}
|
|
@@ -7459,21 +7961,21 @@ var DocumentBuilder = class {
|
|
|
7459
7961
|
return this.addLabelInternal(staffTabOrGroups, label, text);
|
|
7460
7962
|
}
|
|
7461
7963
|
addConnective(connective, ...args) {
|
|
7462
|
-
assertArg(
|
|
7964
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValue(connective, Connective), "connective", connective);
|
|
7463
7965
|
if (connective === "tie" /* Tie */) {
|
|
7464
|
-
assertArg(
|
|
7465
|
-
assertArg(
|
|
7966
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isIntegerOrUndefined(args[0]) || import_ts_utils_lib15.Utils.Is.isEnumValue(args[0], TieType), "tieSpan", args[0]);
|
|
7967
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValueOrUndefined(args[1], NoteAnchor), "noteAnchor", args[1]);
|
|
7466
7968
|
let tieSpan = args[0];
|
|
7467
7969
|
let noteAnchor = args[1];
|
|
7468
7970
|
this.getMeasure().addConnective(connective, tieSpan, noteAnchor);
|
|
7469
7971
|
} else if (connective === "slur" /* Slur */) {
|
|
7470
|
-
assertArg(
|
|
7471
|
-
assertArg(
|
|
7972
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isIntegerOrUndefined(args[0]), "slurSpan", args[0]);
|
|
7973
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValueOrUndefined(args[1], NoteAnchor), "noteAnchor", args[1]);
|
|
7472
7974
|
let slurSpan = args[0];
|
|
7473
7975
|
let noteAnchor = args[1];
|
|
7474
7976
|
this.getMeasure().addConnective(connective, slurSpan, noteAnchor);
|
|
7475
7977
|
} else if (connective === "slide" /* Slide */) {
|
|
7476
|
-
assertArg(
|
|
7978
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValueOrUndefined(args[0], NoteAnchor), "noteAnchor", args[0]);
|
|
7477
7979
|
let noteAnchor = args[0];
|
|
7478
7980
|
this.getMeasure().addConnective(connective, noteAnchor);
|
|
7479
7981
|
}
|
|
@@ -7492,18 +7994,18 @@ var DocumentBuilder = class {
|
|
|
7492
7994
|
* @returns - This document builder instance.
|
|
7493
7995
|
*/
|
|
7494
7996
|
addExtension(extensionBuilder) {
|
|
7495
|
-
assertArg(
|
|
7997
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isFunctionOrUndefined(extensionBuilder), "addExtension() has new usage, for e.g. addExtension(ext => ext.measures(2)). Please refer to README or API Reference.", extensionBuilder);
|
|
7496
7998
|
let ticks = 0;
|
|
7497
7999
|
let visible = true;
|
|
7498
8000
|
const helper = {
|
|
7499
8001
|
notes: (noteLength, noteCount) => {
|
|
7500
|
-
assertArg(
|
|
7501
|
-
assertArg(
|
|
8002
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValue(noteLength, import_theory13.NoteLength) || isNoteLength(noteLength), "noteLength", noteLength);
|
|
8003
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isUndefined(noteCount) || import_ts_utils_lib15.Utils.Is.isNumber(noteCount) && noteCount >= 0, "noteCount", noteCount);
|
|
7502
8004
|
ticks += import_theory13.RhythmProps.get(noteLength).ticks * (noteCount != null ? noteCount : 1);
|
|
7503
8005
|
return helper;
|
|
7504
8006
|
},
|
|
7505
8007
|
measures: (measureCount) => {
|
|
7506
|
-
assertArg(
|
|
8008
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isNumber(measureCount) && measureCount >= 1, "measureCount", measureCount);
|
|
7507
8009
|
ticks += this.getMeasure().getMeasureTicks() * measureCount;
|
|
7508
8010
|
return helper;
|
|
7509
8011
|
},
|
|
@@ -7532,13 +8034,13 @@ var DocumentBuilder = class {
|
|
|
7532
8034
|
* @returns - This document builder instance.
|
|
7533
8035
|
*/
|
|
7534
8036
|
addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition = "auto" /* Auto */) {
|
|
7535
|
-
assertArg(
|
|
8037
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isNonEmptyString(groupName), "groupName", groupName);
|
|
7536
8038
|
assertArg(
|
|
7537
|
-
|
|
8039
|
+
import_ts_utils_lib15.Utils.Is.isNonEmptyString(staffsTabsAndGroups) || import_ts_utils_lib15.Utils.Is.isIntegerGte(staffsTabsAndGroups, 0) || import_ts_utils_lib15.Utils.Is.isNonEmptyArray(staffsTabsAndGroups) && staffsTabsAndGroups.every((line) => import_ts_utils_lib15.Utils.Is.isNonEmptyString(line) || import_ts_utils_lib15.Utils.Is.isIntegerGte(line, 0)),
|
|
7538
8040
|
"staffsTabsAndGroups",
|
|
7539
8041
|
staffsTabsAndGroups
|
|
7540
8042
|
);
|
|
7541
|
-
assertArg(
|
|
8043
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isEnumValue(verticalPosition, VerticalPosition), "verticalPosition", verticalPosition);
|
|
7542
8044
|
this.doc.addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition);
|
|
7543
8045
|
return this;
|
|
7544
8046
|
}
|
|
@@ -7573,7 +8075,7 @@ var DocumentBuilder = class {
|
|
|
7573
8075
|
* @returns - This document builder instance.
|
|
7574
8076
|
*/
|
|
7575
8077
|
completeRests(voiceId) {
|
|
7576
|
-
assertArg(
|
|
8078
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isUndefined(voiceId) || isVoiceId(voiceId) || import_ts_utils_lib15.Utils.Is.isArray(voiceId) && voiceId.every((id) => isVoiceId(id)), "voiceId", voiceId);
|
|
7577
8079
|
this.getMeasure().completeRests(voiceId);
|
|
7578
8080
|
return this;
|
|
7579
8081
|
}
|
|
@@ -7585,8 +8087,8 @@ var DocumentBuilder = class {
|
|
|
7585
8087
|
* @returns - This document builder instance.
|
|
7586
8088
|
*/
|
|
7587
8089
|
addScaleArpeggio(scale, bottomNote, numOctaves) {
|
|
7588
|
-
assertArg(
|
|
7589
|
-
assertArg(
|
|
8090
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isNonEmptyString(bottomNote), "bottomNote", bottomNote);
|
|
8091
|
+
assertArg(import_ts_utils_lib15.Utils.Is.isIntegerGte(numOctaves, 1), "numOctaves", numOctaves);
|
|
7590
8092
|
let ts = this.getMeasure().getTimeSignature();
|
|
7591
8093
|
let notes = scale.getScaleNotes(bottomNote, numOctaves);
|
|
7592
8094
|
for (let i = 0; i < notes.length; i++) {
|
|
@@ -7602,7 +8104,7 @@ var DocumentBuilder = class {
|
|
|
7602
8104
|
};
|
|
7603
8105
|
|
|
7604
8106
|
// src/score/pub/event.ts
|
|
7605
|
-
var
|
|
8107
|
+
var import_core19 = require("@tspro/web-music-score/core");
|
|
7606
8108
|
var ScoreEvent = class {
|
|
7607
8109
|
/**
|
|
7608
8110
|
* Create new score event instance.
|
|
@@ -7639,7 +8141,7 @@ var ScoreObjectEvent = class extends ScoreEvent {
|
|
|
7639
8141
|
this.renderer = renderer;
|
|
7640
8142
|
this.objects = objects;
|
|
7641
8143
|
if (arguments.length === 0) {
|
|
7642
|
-
throw new
|
|
8144
|
+
throw new import_core19.MusicError(import_core19.MusicErrorType.Score, "Empty array in score object event!");
|
|
7643
8145
|
}
|
|
7644
8146
|
}
|
|
7645
8147
|
/** Top object getter. */
|
|
@@ -7658,24 +8160,24 @@ var ScoreObjectEvent = class extends ScoreEvent {
|
|
|
7658
8160
|
|
|
7659
8161
|
// src/score/pub/music-interface.ts
|
|
7660
8162
|
var Audio2 = __toESM(require("@tspro/web-music-score/audio"));
|
|
7661
|
-
var
|
|
8163
|
+
var import_ts_utils_lib17 = require("@tspro/ts-utils-lib");
|
|
7662
8164
|
|
|
7663
8165
|
// src/score/pub/music-objects.ts
|
|
7664
|
-
var
|
|
7665
|
-
var
|
|
8166
|
+
var import_ts_utils_lib16 = require("@tspro/ts-utils-lib");
|
|
8167
|
+
var import_core20 = require("@tspro/web-music-score/core");
|
|
7666
8168
|
function assertArg2(condition, argName, argValue) {
|
|
7667
8169
|
if (!condition) {
|
|
7668
|
-
throw new
|
|
8170
|
+
throw new import_core20.MusicError(import_core20.MusicErrorType.Score, `Invalid arg: ${argName} = ${argValue}`);
|
|
7669
8171
|
}
|
|
7670
8172
|
}
|
|
7671
8173
|
function isVoiceId2(value) {
|
|
7672
|
-
return
|
|
8174
|
+
return import_ts_utils_lib16.Utils.Is.isNumber(value) && getVoiceIds().indexOf(value) >= 0;
|
|
7673
8175
|
}
|
|
7674
8176
|
function getNotationLine(line) {
|
|
7675
8177
|
if (line instanceof ObjStaff || line instanceof ObjTab) {
|
|
7676
8178
|
return line.getMusicInterface();
|
|
7677
8179
|
} else {
|
|
7678
|
-
throw new
|
|
8180
|
+
throw new import_core20.MusicError(import_core20.MusicErrorType.Score, `Notation line not staff nor tab.`);
|
|
7679
8181
|
}
|
|
7680
8182
|
}
|
|
7681
8183
|
var MusicInterface6 = class {
|
|
@@ -7845,7 +8347,7 @@ var _MDocument = class _MDocument extends MusicInterface6 {
|
|
|
7845
8347
|
* @returns - Player instance.
|
|
7846
8348
|
*/
|
|
7847
8349
|
play(playStateChangeListener) {
|
|
7848
|
-
assertArg2(
|
|
8350
|
+
assertArg2(import_ts_utils_lib16.Utils.Is.isFunctionOrUndefined(playStateChangeListener), "playStateChangeListener", playStateChangeListener);
|
|
7849
8351
|
return new MPlayer(this, playStateChangeListener).play();
|
|
7850
8352
|
}
|
|
7851
8353
|
};
|
|
@@ -7875,7 +8377,7 @@ var _MEnding = class _MEnding extends MusicInterface6 {
|
|
|
7875
8377
|
* @returns - Boolean whether this ending has asked passage number.
|
|
7876
8378
|
*/
|
|
7877
8379
|
hasPassage(passage) {
|
|
7878
|
-
assertArg2(
|
|
8380
|
+
assertArg2(import_ts_utils_lib16.Utils.Is.isIntegerGte(passage, 1), "passage", passage);
|
|
7879
8381
|
return this.obj.hasPassage(passage);
|
|
7880
8382
|
}
|
|
7881
8383
|
};
|
|
@@ -8027,7 +8529,7 @@ var _MStaffTabBarLine = class _MStaffTabBarLine extends MusicInterface6 {
|
|
|
8027
8529
|
if (barLine instanceof ObjBarLineLeft || barLine instanceof ObjBarLineRight) {
|
|
8028
8530
|
return barLine.getMusicInterface();
|
|
8029
8531
|
} else {
|
|
8030
|
-
throw new
|
|
8532
|
+
throw new import_core20.MusicError(import_core20.MusicErrorType.Score, `Bar line not let nor right.`);
|
|
8031
8533
|
}
|
|
8032
8534
|
}
|
|
8033
8535
|
/**
|
|
@@ -8454,6 +8956,27 @@ var _MText = class _MText extends MusicInterface6 {
|
|
|
8454
8956
|
/** Object name. */
|
|
8455
8957
|
__publicField(_MText, "Name", "Text");
|
|
8456
8958
|
var MText = _MText;
|
|
8959
|
+
var _MLyrics = class _MLyrics extends MusicInterface6 {
|
|
8960
|
+
/** @internal */
|
|
8961
|
+
constructor(obj) {
|
|
8962
|
+
super(_MLyrics.Name);
|
|
8963
|
+
this.obj = obj;
|
|
8964
|
+
}
|
|
8965
|
+
/** @internal */
|
|
8966
|
+
getMusicObject() {
|
|
8967
|
+
return this.obj;
|
|
8968
|
+
}
|
|
8969
|
+
/**
|
|
8970
|
+
* Get lyrics text.
|
|
8971
|
+
* @returns - Lyrics text.
|
|
8972
|
+
*/
|
|
8973
|
+
getText() {
|
|
8974
|
+
return this.obj.getText();
|
|
8975
|
+
}
|
|
8976
|
+
};
|
|
8977
|
+
/** Object name. */
|
|
8978
|
+
__publicField(_MLyrics, "Name", "Lyrics");
|
|
8979
|
+
var MLyrics = _MLyrics;
|
|
8457
8980
|
var _MExtensionLine = class _MExtensionLine extends MusicInterface6 {
|
|
8458
8981
|
/** @internal */
|
|
8459
8982
|
constructor(obj) {
|
|
@@ -8470,10 +8993,10 @@ __publicField(_MExtensionLine, "Name", "ExtensionLine");
|
|
|
8470
8993
|
var MExtensionLine = _MExtensionLine;
|
|
8471
8994
|
|
|
8472
8995
|
// src/score/pub/music-interface.ts
|
|
8473
|
-
var
|
|
8996
|
+
var import_core21 = require("@tspro/web-music-score/core");
|
|
8474
8997
|
function assertArg3(condition, argName, argValue) {
|
|
8475
8998
|
if (!condition) {
|
|
8476
|
-
throw new
|
|
8999
|
+
throw new import_core21.MusicError(import_core21.MusicErrorType.Score, `Invalid arg: ${argName} = ${argValue}`);
|
|
8477
9000
|
}
|
|
8478
9001
|
}
|
|
8479
9002
|
function require_t(t, message) {
|
|
@@ -8492,7 +9015,7 @@ var _MPlayer = class _MPlayer {
|
|
|
8492
9015
|
constructor(doc, playStateChangeListener) {
|
|
8493
9016
|
__publicField(this, "player");
|
|
8494
9017
|
assertArg3(doc instanceof MDocument2, "doc", doc);
|
|
8495
|
-
assertArg3(
|
|
9018
|
+
assertArg3(import_ts_utils_lib17.Utils.Is.isFunctionOrUndefined(playStateChangeListener), "playStateChangeListener", playStateChangeListener);
|
|
8496
9019
|
this.player = new Player();
|
|
8497
9020
|
this.player.setDocument(doc.getMusicObject());
|
|
8498
9021
|
this.player.setCursorPositionChangeListener((cursorRect) => doc.getMusicObject().updateCursorRect(cursorRect));
|
|
@@ -8550,7 +9073,7 @@ var MRenderer2 = class {
|
|
|
8550
9073
|
* @returns - This renderer instance.
|
|
8551
9074
|
*/
|
|
8552
9075
|
setDocument(doc) {
|
|
8553
|
-
assertArg3(
|
|
9076
|
+
assertArg3(import_ts_utils_lib17.Utils.Is.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
|
|
8554
9077
|
this.renderer.setDocument(doc);
|
|
8555
9078
|
return this;
|
|
8556
9079
|
}
|
|
@@ -8560,7 +9083,7 @@ var MRenderer2 = class {
|
|
|
8560
9083
|
* @returns - This renderer instance.
|
|
8561
9084
|
*/
|
|
8562
9085
|
setCanvas(canvas) {
|
|
8563
|
-
canvas = require_t(
|
|
9086
|
+
canvas = require_t(import_ts_utils_lib17.Utils.Dom.getCanvas(canvas), typeof canvas === "string" ? "Cannot set renderer canvas because invalid canvas id: " + canvas : "Cannot set renderer canvas because given canvas is undefined.");
|
|
8564
9087
|
this.renderer.setCanvas(canvas);
|
|
8565
9088
|
return this;
|
|
8566
9089
|
}
|
|
@@ -8569,7 +9092,7 @@ var MRenderer2 = class {
|
|
|
8569
9092
|
* @param scoreEventListener - Score event listener.
|
|
8570
9093
|
*/
|
|
8571
9094
|
setScoreEventListener(scoreEventListener) {
|
|
8572
|
-
assertArg3(
|
|
9095
|
+
assertArg3(import_ts_utils_lib17.Utils.Is.isFunctionOrUndefined(scoreEventListener), "scoreEventListener", scoreEventListener);
|
|
8573
9096
|
this.renderer.setScoreEventListener(scoreEventListener);
|
|
8574
9097
|
}
|
|
8575
9098
|
/**
|
|
@@ -8643,7 +9166,7 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
8643
9166
|
* @returns
|
|
8644
9167
|
*/
|
|
8645
9168
|
setDocument(doc) {
|
|
8646
|
-
assertArg3(
|
|
9169
|
+
assertArg3(import_ts_utils_lib17.Utils.Is.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
|
|
8647
9170
|
this.onStop();
|
|
8648
9171
|
if (doc) {
|
|
8649
9172
|
this.player = new MPlayer(doc, (playState) => {
|
|
@@ -8687,9 +9210,9 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
8687
9210
|
* @returns - This playback buttons class instance.
|
|
8688
9211
|
*/
|
|
8689
9212
|
setPlayButton(btn, btnLabel) {
|
|
8690
|
-
assertArg3(
|
|
9213
|
+
assertArg3(import_ts_utils_lib17.Utils.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
|
|
8691
9214
|
_MPlaybackButtons.removeOnClickListeners(this.playButton, this.onPlay);
|
|
8692
|
-
this.playButton = require_t(
|
|
9215
|
+
this.playButton = require_t(import_ts_utils_lib17.Utils.Dom.getButton(btn), "Play button required!");
|
|
8693
9216
|
this.playLabel = btnLabel != null ? btnLabel : "Play";
|
|
8694
9217
|
_MPlaybackButtons.removeOnClickListeners(this.playButton, "all");
|
|
8695
9218
|
_MPlaybackButtons.addOnClickListener(this.playButton, this.onPlay);
|
|
@@ -8703,9 +9226,9 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
8703
9226
|
* @returns - This playback buttons class instance.
|
|
8704
9227
|
*/
|
|
8705
9228
|
setStopButton(btn, btnLabel) {
|
|
8706
|
-
assertArg3(
|
|
9229
|
+
assertArg3(import_ts_utils_lib17.Utils.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
|
|
8707
9230
|
_MPlaybackButtons.removeOnClickListeners(this.stopButton, this.onStop);
|
|
8708
|
-
this.stopButton = require_t(
|
|
9231
|
+
this.stopButton = require_t(import_ts_utils_lib17.Utils.Dom.getButton(btn), "Stop button required!");
|
|
8709
9232
|
this.stopLabel = btnLabel != null ? btnLabel : "Stop";
|
|
8710
9233
|
_MPlaybackButtons.removeOnClickListeners(this.stopButton, "all");
|
|
8711
9234
|
_MPlaybackButtons.addOnClickListener(this.stopButton, this.onStop);
|
|
@@ -8720,10 +9243,10 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
8720
9243
|
* @returns - This playback buttons class instance.
|
|
8721
9244
|
*/
|
|
8722
9245
|
setPlayStopButton(btn, playLabel, stopLabel) {
|
|
8723
|
-
assertArg3(
|
|
8724
|
-
assertArg3(
|
|
9246
|
+
assertArg3(import_ts_utils_lib17.Utils.Is.isStringOrUndefined(playLabel), "playLabel", playLabel);
|
|
9247
|
+
assertArg3(import_ts_utils_lib17.Utils.Is.isStringOrUndefined(stopLabel), "stopLabel", stopLabel);
|
|
8725
9248
|
_MPlaybackButtons.removeOnClickListeners(this.playStopButton, this.onPlayStop);
|
|
8726
|
-
this.playStopButton = require_t(
|
|
9249
|
+
this.playStopButton = require_t(import_ts_utils_lib17.Utils.Dom.getButton(btn), "Play/stop button required!");
|
|
8727
9250
|
this.playLabel = playLabel != null ? playLabel : "Play";
|
|
8728
9251
|
this.stopLabel = stopLabel != null ? stopLabel : "Stop";
|
|
8729
9252
|
_MPlaybackButtons.removeOnClickListeners(this.playStopButton, "all");
|
|
@@ -8738,9 +9261,9 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
8738
9261
|
* @returns - This playback buttons class instance.
|
|
8739
9262
|
*/
|
|
8740
9263
|
setPauseButton(btn, btnLabel) {
|
|
8741
|
-
assertArg3(
|
|
9264
|
+
assertArg3(import_ts_utils_lib17.Utils.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
|
|
8742
9265
|
_MPlaybackButtons.removeOnClickListeners(this.pauseButton, this.onPause);
|
|
8743
|
-
this.pauseButton = require_t(
|
|
9266
|
+
this.pauseButton = require_t(import_ts_utils_lib17.Utils.Dom.getButton(btn), "Pause button required!");
|
|
8744
9267
|
this.pauseLabel = btnLabel != null ? btnLabel : "Pause";
|
|
8745
9268
|
_MPlaybackButtons.removeOnClickListeners(this.pauseButton, "all");
|
|
8746
9269
|
_MPlaybackButtons.addOnClickListener(this.pauseButton, this.onPause);
|
|
@@ -8762,7 +9285,7 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
8762
9285
|
}
|
|
8763
9286
|
}
|
|
8764
9287
|
static addOnClickListener(btn, onClick) {
|
|
8765
|
-
assertArg3(
|
|
9288
|
+
assertArg3(import_ts_utils_lib17.Utils.Is.isFunction(onClick), "onClick", onClick);
|
|
8766
9289
|
btn.addEventListener("click", onClick);
|
|
8767
9290
|
let clickListeners = this.savedOnClickListeners.get(btn) || [];
|
|
8768
9291
|
this.savedOnClickListeners.set(btn, [...clickListeners, onClick]);
|
|
@@ -8772,8 +9295,8 @@ __publicField(_MPlaybackButtons, "savedOnClickListeners", /* @__PURE__ */ new Ma
|
|
|
8772
9295
|
var MPlaybackButtons = _MPlaybackButtons;
|
|
8773
9296
|
|
|
8774
9297
|
// src/score/index.ts
|
|
8775
|
-
var
|
|
8776
|
-
(0,
|
|
9298
|
+
var import_core22 = require("@tspro/web-music-score/core");
|
|
9299
|
+
(0, import_core22.init)();
|
|
8777
9300
|
// Annotate the CommonJS export names for ESM import in node:
|
|
8778
9301
|
0 && (module.exports = {
|
|
8779
9302
|
Annotation,
|
|
@@ -8785,6 +9308,8 @@ var import_core21 = require("@tspro/web-music-score/core");
|
|
|
8785
9308
|
DynamicsAnnotation,
|
|
8786
9309
|
Fermata,
|
|
8787
9310
|
Label,
|
|
9311
|
+
LyricsAlign,
|
|
9312
|
+
LyricsHyphen,
|
|
8788
9313
|
MAccidental,
|
|
8789
9314
|
MArpeggio,
|
|
8790
9315
|
MBarLineLeft,
|
|
@@ -8797,6 +9322,7 @@ var import_core21 = require("@tspro/web-music-score/core");
|
|
|
8797
9322
|
MFermata,
|
|
8798
9323
|
MHeader,
|
|
8799
9324
|
MImage,
|
|
9325
|
+
MLyrics,
|
|
8800
9326
|
MMeasure,
|
|
8801
9327
|
MNoteGroup,
|
|
8802
9328
|
MPlaybackButtons,
|
|
@@ -8828,6 +9354,7 @@ var import_core21 = require("@tspro/web-music-score/core");
|
|
|
8828
9354
|
TieType,
|
|
8829
9355
|
VerticalPosition,
|
|
8830
9356
|
getStringNumbers,
|
|
9357
|
+
getVerseNumbers,
|
|
8831
9358
|
getVoiceIds
|
|
8832
9359
|
});
|
|
8833
9360
|
//# sourceMappingURL=index.js.map
|