@tspro/web-music-score 5.3.0 → 5.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/LICENSE +1 -1
- package/README.md +6 -4
- package/dist/audio/index.d.mts +1 -1
- package/dist/audio/index.d.ts +1 -1
- package/dist/audio/index.js +3 -3
- package/dist/audio/index.mjs +6 -6
- package/dist/audio-cg/index.js +1 -1
- package/dist/audio-cg/index.mjs +3 -3
- package/dist/audio-synth/index.js +1 -1
- package/dist/audio-synth/index.mjs +3 -3
- package/dist/{chunk-PMDIUO22.mjs → chunk-5I5KENEC.mjs} +2 -2
- package/dist/chunk-6P4ECBUH.mjs +37 -0
- package/dist/{chunk-ZBA5XLYR.mjs → chunk-A5SMODAT.mjs} +21 -21
- package/dist/{chunk-C6UQDKWU.mjs → chunk-U2ACCEHX.mjs} +2 -2
- package/dist/core/index.js +2 -2
- package/dist/core/index.mjs +6 -31
- package/dist/{guitar-BsSayRsH.d.ts → guitar-CNOxM4ZK.d.ts} +1 -1
- package/dist/{guitar-DdexKdN6.d.mts → guitar-DXlB-9vK.d.mts} +1 -1
- package/dist/iife/audio-cg.global.js +1 -1
- package/dist/iife/index.global.js +18 -11
- package/dist/{music-objects-BGiRQIXW.d.mts → music-objects-DYMqx839.d.mts} +66 -260
- package/dist/{music-objects-Ih9vCl4p.d.ts → music-objects-DumXKWJp.d.ts} +66 -260
- package/dist/{note-eA2xPPiG.d.mts → note-RVXvpfyV.d.mts} +13 -1
- package/dist/{note-CgCIBwvR.d.ts → note-RVXvpfyV.d.ts} +14 -2
- package/dist/pieces/index.d.mts +3 -3
- package/dist/pieces/index.d.ts +3 -3
- package/dist/pieces/index.js +1 -1
- package/dist/pieces/index.mjs +2 -2
- package/dist/react-ui/index.d.mts +9 -9
- package/dist/react-ui/index.d.ts +9 -9
- package/dist/react-ui/index.js +12 -14
- package/dist/react-ui/index.mjs +14 -16
- package/dist/{scale-CBW4eTz7.d.ts → scale-C8gHC448.d.mts} +3 -3
- package/dist/{scale-DQP3b9Zx.d.mts → scale-CUYFBo-8.d.ts} +3 -3
- package/dist/score/index.d.mts +232 -6
- package/dist/score/index.d.ts +232 -6
- package/dist/score/index.js +1122 -975
- package/dist/score/index.mjs +978 -861
- package/dist/{tempo-dkctPkCS.d.mts → tempo-BlCGZuYg.d.mts} +14 -2
- package/dist/{tempo-DMt3iwz9.d.ts → tempo-DwuZsv2T.d.ts} +14 -2
- package/dist/theory/index.d.mts +6 -6
- package/dist/theory/index.d.ts +6 -6
- package/dist/theory/index.js +88 -86
- package/dist/theory/index.mjs +85 -81
- package/package.json +5 -4
package/dist/score/index.mjs
CHANGED
|
@@ -1,43 +1,45 @@
|
|
|
1
|
-
/* WebMusicScore v5.
|
|
1
|
+
/* WebMusicScore v5.4.1 | (c) 2023-2025 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
|
|
2
|
+
import {
|
|
3
|
+
MusicError
|
|
4
|
+
} from "../chunk-6P4ECBUH.mjs";
|
|
2
5
|
import {
|
|
3
6
|
NoteLengthProps,
|
|
4
7
|
RhythmProps,
|
|
5
8
|
validateNoteLength
|
|
6
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-A5SMODAT.mjs";
|
|
7
10
|
import {
|
|
8
11
|
__publicField
|
|
9
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-U2ACCEHX.mjs";
|
|
10
13
|
|
|
11
14
|
// src/score/pub/div-rect.ts
|
|
12
15
|
import { Utils } from "@tspro/ts-utils-lib";
|
|
13
|
-
import { MusicError, MusicErrorType } from "@tspro/web-music-score/core";
|
|
14
16
|
var DivRect = class _DivRect {
|
|
15
17
|
constructor(...args) {
|
|
16
18
|
__publicField(this, "left");
|
|
17
|
-
__publicField(this, "
|
|
19
|
+
__publicField(this, "anchorX");
|
|
18
20
|
__publicField(this, "right");
|
|
19
21
|
__publicField(this, "top");
|
|
20
|
-
__publicField(this, "
|
|
22
|
+
__publicField(this, "anchorY");
|
|
21
23
|
__publicField(this, "bottom");
|
|
22
24
|
if (args.length === 6) {
|
|
23
25
|
this.left = args[0];
|
|
24
|
-
this.
|
|
26
|
+
this.anchorX = args[1];
|
|
25
27
|
this.right = args[2];
|
|
26
28
|
this.top = args[3];
|
|
27
|
-
this.
|
|
29
|
+
this.anchorY = args[4];
|
|
28
30
|
this.bottom = args[5];
|
|
29
31
|
} else if (args.length === 4) {
|
|
30
32
|
this.left = args[0];
|
|
31
33
|
this.right = args[1];
|
|
32
|
-
this.
|
|
34
|
+
this.anchorX = (this.left + this.right) / 2;
|
|
33
35
|
this.top = args[2];
|
|
34
36
|
this.bottom = args[3];
|
|
35
|
-
this.
|
|
37
|
+
this.anchorY = (this.top + this.bottom) / 2;
|
|
36
38
|
} else if (args.length === 0) {
|
|
37
|
-
this.left = this.
|
|
38
|
-
this.top = this.
|
|
39
|
+
this.left = this.anchorX = this.right = 0;
|
|
40
|
+
this.top = this.anchorY = this.bottom = 0;
|
|
39
41
|
} else {
|
|
40
|
-
throw new
|
|
42
|
+
throw new TypeError(`Invalid DivRect args: ${args}`);
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
/**
|
|
@@ -45,7 +47,7 @@ var DivRect = class _DivRect {
|
|
|
45
47
|
*
|
|
46
48
|
* @param left - Left coordinate.
|
|
47
49
|
* @param top - Top coordinate.
|
|
48
|
-
* @param width -
|
|
50
|
+
* @param width - Width.
|
|
49
51
|
* @param height - Height.
|
|
50
52
|
* @returns - DivRect.
|
|
51
53
|
*/
|
|
@@ -53,7 +55,7 @@ var DivRect = class _DivRect {
|
|
|
53
55
|
return new _DivRect(left, left + width, top, top + height);
|
|
54
56
|
}
|
|
55
57
|
/**
|
|
56
|
-
* Create rect from
|
|
58
|
+
* Create rect from anchorX, anchorY, width, height arguments.
|
|
57
59
|
*
|
|
58
60
|
* @param centerX - Center x-coordinate.
|
|
59
61
|
* @param centerY - Center y-coordinate.
|
|
@@ -62,7 +64,14 @@ var DivRect = class _DivRect {
|
|
|
62
64
|
* @returns - DivRect.
|
|
63
65
|
*/
|
|
64
66
|
static createCentered(centerX, centerY, width, height) {
|
|
65
|
-
return new _DivRect(
|
|
67
|
+
return new _DivRect(
|
|
68
|
+
centerX - width / 2,
|
|
69
|
+
centerX,
|
|
70
|
+
centerX + width / 2,
|
|
71
|
+
centerY - height / 2,
|
|
72
|
+
centerY,
|
|
73
|
+
centerY + height / 2
|
|
74
|
+
);
|
|
66
75
|
}
|
|
67
76
|
/**
|
|
68
77
|
* Create rect from sections.
|
|
@@ -76,6 +85,22 @@ var DivRect = class _DivRect {
|
|
|
76
85
|
static createSections(leftw, rightw, toph, bottomh) {
|
|
77
86
|
return new _DivRect(-leftw, 0, rightw, -toph, 0, bottomh);
|
|
78
87
|
}
|
|
88
|
+
/** @deprecated - Renamed to anchorX. */
|
|
89
|
+
get centerX() {
|
|
90
|
+
return this.anchorX;
|
|
91
|
+
}
|
|
92
|
+
/** @deprecated - Renamed to anchorX. */
|
|
93
|
+
set centerX(x) {
|
|
94
|
+
this.anchorX = x;
|
|
95
|
+
}
|
|
96
|
+
/** @deprecated - Renamed to anchorY. */
|
|
97
|
+
get centerY() {
|
|
98
|
+
return this.anchorY;
|
|
99
|
+
}
|
|
100
|
+
/** @deprecated - Renamed to anchorY. */
|
|
101
|
+
set centerY(y) {
|
|
102
|
+
this.anchorY = y;
|
|
103
|
+
}
|
|
79
104
|
/**
|
|
80
105
|
* Width getter.
|
|
81
106
|
*/
|
|
@@ -92,25 +117,25 @@ var DivRect = class _DivRect {
|
|
|
92
117
|
* Left section width getter.
|
|
93
118
|
*/
|
|
94
119
|
get leftw() {
|
|
95
|
-
return this.
|
|
120
|
+
return this.anchorX - this.left;
|
|
96
121
|
}
|
|
97
122
|
/**
|
|
98
123
|
* Right section width getter.
|
|
99
124
|
*/
|
|
100
125
|
get rightw() {
|
|
101
|
-
return this.right - this.
|
|
126
|
+
return this.right - this.anchorX;
|
|
102
127
|
}
|
|
103
128
|
/**
|
|
104
129
|
* Top section height getter.
|
|
105
130
|
*/
|
|
106
131
|
get toph() {
|
|
107
|
-
return this.
|
|
132
|
+
return this.anchorY - this.top;
|
|
108
133
|
}
|
|
109
134
|
/**
|
|
110
135
|
* Bottom section height getter.
|
|
111
136
|
*/
|
|
112
137
|
get bottomh() {
|
|
113
|
-
return this.bottom - this.
|
|
138
|
+
return this.bottom - this.anchorY;
|
|
114
139
|
}
|
|
115
140
|
/**
|
|
116
141
|
* Does this Rect contain given (x, y)-point?
|
|
@@ -143,7 +168,7 @@ var DivRect = class _DivRect {
|
|
|
143
168
|
return a.right > b.left && a.left < b.right;
|
|
144
169
|
}
|
|
145
170
|
/**
|
|
146
|
-
* Check if
|
|
171
|
+
* Check if given rects are equal.
|
|
147
172
|
* @param a - DivRect a.
|
|
148
173
|
* @param b - DivRect b.
|
|
149
174
|
* @returns - True/false.
|
|
@@ -154,17 +179,25 @@ var DivRect = class _DivRect {
|
|
|
154
179
|
} else if (a == null || b == null) {
|
|
155
180
|
return false;
|
|
156
181
|
} else {
|
|
157
|
-
return a === b || a.left === b.left && a.
|
|
182
|
+
return a === b || a.left === b.left && a.anchorX === b.anchorX && a.right === b.right && a.top === b.top && a.anchorY === b.anchorY && a.bottom === b.bottom;
|
|
158
183
|
}
|
|
159
184
|
}
|
|
160
185
|
/**
|
|
161
|
-
* Check if
|
|
186
|
+
* Check if this rect equals with another rect.
|
|
187
|
+
* @param other - The other rect.
|
|
188
|
+
* @returns - True/false.
|
|
189
|
+
*/
|
|
190
|
+
equals(other) {
|
|
191
|
+
return _DivRect.equals(this, other);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Check if edges of given rects are equal, ignoring anchorX and anchorY.
|
|
162
195
|
*
|
|
163
196
|
* @param a - DivRect a.
|
|
164
197
|
* @param b - DivRect b.
|
|
165
198
|
* @returns - True/false.
|
|
166
199
|
*/
|
|
167
|
-
static
|
|
200
|
+
static equalsEdges(a, b) {
|
|
168
201
|
if (a == null && b == null) {
|
|
169
202
|
return true;
|
|
170
203
|
} else if (a == null || b == null) {
|
|
@@ -173,13 +206,26 @@ var DivRect = class _DivRect {
|
|
|
173
206
|
return a === b || a.left === b.left && a.right === b.right && a.top === b.top && a.bottom === b.bottom;
|
|
174
207
|
}
|
|
175
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* Check if edges of this Rect equals with given Rect, ignoring anchorX and anchorY.
|
|
211
|
+
*
|
|
212
|
+
* @param other - The other DivRect.
|
|
213
|
+
* @returns - True/false.
|
|
214
|
+
*/
|
|
215
|
+
equalsEdges(other) {
|
|
216
|
+
return _DivRect.equalsEdges(this, other);
|
|
217
|
+
}
|
|
218
|
+
/** @deprecated - Use `DivRect.equalsEdges()` instead. */
|
|
219
|
+
static equalsFrame(a, b) {
|
|
220
|
+
return _DivRect.equalsEdges(a, b);
|
|
221
|
+
}
|
|
176
222
|
/**
|
|
177
223
|
* Created duplicate of this Rect.
|
|
178
224
|
*
|
|
179
225
|
* @returns - Duplicate.
|
|
180
226
|
*/
|
|
181
227
|
copy() {
|
|
182
|
-
return new _DivRect(this.left, this.
|
|
228
|
+
return new _DivRect(this.left, this.anchorX, this.right, this.top, this.anchorY, this.bottom);
|
|
183
229
|
}
|
|
184
230
|
/**
|
|
185
231
|
* Move this rect by (dx, dy). Modifies this Rect.
|
|
@@ -190,10 +236,10 @@ var DivRect = class _DivRect {
|
|
|
190
236
|
*/
|
|
191
237
|
offsetInPlace(dx, dy) {
|
|
192
238
|
this.left += dx;
|
|
193
|
-
this.
|
|
239
|
+
this.anchorX += dx;
|
|
194
240
|
this.right += dx;
|
|
195
241
|
this.top += dy;
|
|
196
|
-
this.
|
|
242
|
+
this.anchorY += dy;
|
|
197
243
|
this.bottom += dy;
|
|
198
244
|
return this;
|
|
199
245
|
}
|
|
@@ -238,10 +284,10 @@ var DivRect = class _DivRect {
|
|
|
238
284
|
clipInPlace(clipRect) {
|
|
239
285
|
this.left = Math.max(this.left, clipRect.left);
|
|
240
286
|
this.right = Math.min(this.right, clipRect.right);
|
|
241
|
-
this.
|
|
287
|
+
this.anchorX = Utils.Math.clamp(this.anchorX, this.left, this.right);
|
|
242
288
|
this.top = Math.max(this.top, clipRect.top);
|
|
243
289
|
this.bottom = Math.min(this.bottom, clipRect.bottom);
|
|
244
|
-
this.
|
|
290
|
+
this.anchorY = Utils.Math.clamp(this.anchorY, this.top, this.bottom);
|
|
245
291
|
return this;
|
|
246
292
|
}
|
|
247
293
|
/**
|
|
@@ -254,7 +300,7 @@ var DivRect = class _DivRect {
|
|
|
254
300
|
return this.copy().clipInPlace(clipRect);
|
|
255
301
|
}
|
|
256
302
|
/**
|
|
257
|
-
* Scale Rect. Anchor pos is (
|
|
303
|
+
* Scale Rect. Anchor pos is (anchorX, anchorY). Modifies this Rect.
|
|
258
304
|
*
|
|
259
305
|
* @param scaleX - Scale x-amount.
|
|
260
306
|
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
@@ -262,14 +308,14 @@ var DivRect = class _DivRect {
|
|
|
262
308
|
*/
|
|
263
309
|
scaleInPlace(scaleX, scaleY) {
|
|
264
310
|
scaleY = scaleY != null ? scaleY : scaleX;
|
|
265
|
-
this.left = this.
|
|
266
|
-
this.right = this.
|
|
267
|
-
this.top = this.
|
|
268
|
-
this.bottom = this.
|
|
311
|
+
this.left = this.anchorX - this.leftw * scaleX;
|
|
312
|
+
this.right = this.anchorX + this.rightw * scaleX;
|
|
313
|
+
this.top = this.anchorY - this.toph * scaleY;
|
|
314
|
+
this.bottom = this.anchorY + this.bottomh * scaleY;
|
|
269
315
|
return this;
|
|
270
316
|
}
|
|
271
317
|
/**
|
|
272
|
-
* Scale Rect. Anchor pos is (
|
|
318
|
+
* Scale Rect. Anchor pos is (anchorX, anchorY). Immutable, returns modified copy.
|
|
273
319
|
*
|
|
274
320
|
* @param scaleX - Scale x-amount.
|
|
275
321
|
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
@@ -288,17 +334,18 @@ var DivRect = class _DivRect {
|
|
|
288
334
|
};
|
|
289
335
|
|
|
290
336
|
// src/score/pub/document-builder.ts
|
|
291
|
-
import { Utils as
|
|
337
|
+
import { Guard as Guard12, Utils as Utils12 } from "@tspro/ts-utils-lib";
|
|
292
338
|
|
|
293
339
|
// src/score/pub/types.ts
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
340
|
+
import { Guard } from "@tspro/ts-utils-lib";
|
|
341
|
+
var StaffPreset = /* @__PURE__ */ ((StaffPreset2) => {
|
|
342
|
+
StaffPreset2["Treble"] = "treble";
|
|
343
|
+
StaffPreset2["Bass"] = "bass";
|
|
344
|
+
StaffPreset2["Grand"] = "grand";
|
|
345
|
+
StaffPreset2["GuitarTreble"] = "guitarTreble";
|
|
346
|
+
StaffPreset2["GuitarTab"] = "guitarTab";
|
|
347
|
+
StaffPreset2["GuitarCombined"] = "guitarCombined";
|
|
348
|
+
return StaffPreset2;
|
|
302
349
|
})(StaffPreset || {});
|
|
303
350
|
var Clef = /* @__PURE__ */ ((Clef2) => {
|
|
304
351
|
Clef2["G"] = "G";
|
|
@@ -308,12 +355,42 @@ var Clef = /* @__PURE__ */ ((Clef2) => {
|
|
|
308
355
|
function getVoiceIds() {
|
|
309
356
|
return [0, 1, 2, 3];
|
|
310
357
|
}
|
|
358
|
+
function isVoiceId(voiceId) {
|
|
359
|
+
return Guard.isIncluded(voiceId, getVoiceIds());
|
|
360
|
+
}
|
|
361
|
+
function validateVoiceId(voiceId) {
|
|
362
|
+
if (isVoiceId(voiceId)) {
|
|
363
|
+
return voiceId;
|
|
364
|
+
} else {
|
|
365
|
+
throw new MusicError(6 /* Score */, `Voice id ${voiceId} is invalid!`);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
311
368
|
function getStringNumbers() {
|
|
312
369
|
return [1, 2, 3, 4, 5, 6];
|
|
313
370
|
}
|
|
371
|
+
function isStringNumber(stringNum) {
|
|
372
|
+
return Guard.isIncluded(stringNum, getStringNumbers());
|
|
373
|
+
}
|
|
374
|
+
function validateStringNumber(stringNum) {
|
|
375
|
+
if (isStringNumber(stringNum)) {
|
|
376
|
+
return stringNum;
|
|
377
|
+
} else {
|
|
378
|
+
throw new MusicError(6 /* Score */, `String number ${stringNum} is invalid!`);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
314
381
|
function getVerseNumbers() {
|
|
315
382
|
return [1, 2, 3];
|
|
316
383
|
}
|
|
384
|
+
function isVerseNumber(verse) {
|
|
385
|
+
return Guard.isIncluded(verse, getVerseNumbers());
|
|
386
|
+
}
|
|
387
|
+
function validateVerseNumber(verseNum) {
|
|
388
|
+
if (isVerseNumber(verseNum)) {
|
|
389
|
+
return verseNum;
|
|
390
|
+
} else {
|
|
391
|
+
throw new MusicError(6 /* Score */, `Verse number ${verseNum} is invalid!`);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
317
394
|
var Stem = /* @__PURE__ */ ((Stem2) => {
|
|
318
395
|
Stem2["Auto"] = "auto";
|
|
319
396
|
Stem2["Up"] = "up";
|
|
@@ -344,12 +421,12 @@ var Connective = /* @__PURE__ */ ((Connective2) => {
|
|
|
344
421
|
Connective2["Slide"] = "slide";
|
|
345
422
|
return Connective2;
|
|
346
423
|
})(Connective || {});
|
|
347
|
-
var VerticalPosition = /* @__PURE__ */ ((
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
return
|
|
424
|
+
var VerticalPosition = /* @__PURE__ */ ((VerticalPosition3) => {
|
|
425
|
+
VerticalPosition3["Auto"] = "auto";
|
|
426
|
+
VerticalPosition3["Above"] = "above";
|
|
427
|
+
VerticalPosition3["Below"] = "below";
|
|
428
|
+
VerticalPosition3["Both"] = "both";
|
|
429
|
+
return VerticalPosition3;
|
|
353
430
|
})(VerticalPosition || {});
|
|
354
431
|
var LyricsAlign = /* @__PURE__ */ ((LyricsAlign2) => {
|
|
355
432
|
LyricsAlign2["Left"] = "left";
|
|
@@ -420,6 +497,7 @@ var PlayState = /* @__PURE__ */ ((PlayState2) => {
|
|
|
420
497
|
})(PlayState || {});
|
|
421
498
|
|
|
422
499
|
// src/score/engine/music-object.ts
|
|
500
|
+
import { AnchoredRect } from "@tspro/ts-utils-lib";
|
|
423
501
|
var MusicObjectLink = class {
|
|
424
502
|
constructor(head) {
|
|
425
503
|
__publicField(this, "head");
|
|
@@ -448,7 +526,7 @@ var MusicObject = class {
|
|
|
448
526
|
this.parent = parent;
|
|
449
527
|
__publicField(this, "anchoredLayoutObjects", []);
|
|
450
528
|
__publicField(this, "link");
|
|
451
|
-
__publicField(this, "rect", new
|
|
529
|
+
__publicField(this, "rect", new AnchoredRect());
|
|
452
530
|
__publicField(this, "needRectUpdate", true);
|
|
453
531
|
}
|
|
454
532
|
getParent() {
|
|
@@ -500,7 +578,7 @@ import { Note as Note9 } from "@tspro/web-music-score/theory";
|
|
|
500
578
|
import { getTuningStrings, Note as Note8, validateTuningName } from "@tspro/web-music-score/theory";
|
|
501
579
|
|
|
502
580
|
// src/score/engine/render-context.ts
|
|
503
|
-
import { Utils as Utils2,
|
|
581
|
+
import { Utils as Utils2, Vec, Device, UniMap, AnchoredRect as AnchoredRect2 } from "@tspro/ts-utils-lib";
|
|
504
582
|
|
|
505
583
|
// src/score/engine/settings.ts
|
|
506
584
|
var DebugSettings = {
|
|
@@ -510,6 +588,8 @@ var DebugSettings = {
|
|
|
510
588
|
var DocumentSettings = {
|
|
511
589
|
DocumentScale: 1,
|
|
512
590
|
DocumentMinWidth: 75,
|
|
591
|
+
MinColumnsWidth: 10,
|
|
592
|
+
ColumnWidthScale: 1.7,
|
|
513
593
|
PostMeasureBreakWidth: 10,
|
|
514
594
|
NoteDotSpace: 0.5,
|
|
515
595
|
NoteAccSpace: 0.5,
|
|
@@ -545,7 +625,7 @@ var G_clef_default = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAACWCAYA
|
|
|
545
625
|
var HilightStaffPosRectColor = "#55cc55";
|
|
546
626
|
var HilightObjectRectColor = "#55cc55";
|
|
547
627
|
var PlayPosIndicatorColor = "#44aa44";
|
|
548
|
-
var ImageAssets =
|
|
628
|
+
var ImageAssets = new UniMap([
|
|
549
629
|
[0 /* G_Clef */, { src: G_clef_default }],
|
|
550
630
|
[1 /* F_Clef */, { src: F_clef_default }]
|
|
551
631
|
]);
|
|
@@ -614,7 +694,7 @@ var RenderContext = class {
|
|
|
614
694
|
}
|
|
615
695
|
finishImageAsset(asset) {
|
|
616
696
|
asset.finished = true;
|
|
617
|
-
let allFinished =
|
|
697
|
+
let allFinished = ImageAssets.every((asset2) => asset2.finished === true);
|
|
618
698
|
if (allFinished) {
|
|
619
699
|
this.onLoad();
|
|
620
700
|
}
|
|
@@ -662,7 +742,7 @@ var RenderContext = class {
|
|
|
662
742
|
return this.scoreEventListener !== void 0;
|
|
663
743
|
}
|
|
664
744
|
getMousePos(e) {
|
|
665
|
-
return new
|
|
745
|
+
return new Vec(e.offsetX, e.offsetY);
|
|
666
746
|
}
|
|
667
747
|
updateCurStaffPos(staffPos, click) {
|
|
668
748
|
let changed = !staffPosEquals(staffPos, this.curStaffPos);
|
|
@@ -879,7 +959,7 @@ var RenderContext = class {
|
|
|
879
959
|
toph = unitSize * (0.5 + flagCount - adj);
|
|
880
960
|
bottomh = unitSize * (1 + flagCount + adj);
|
|
881
961
|
}
|
|
882
|
-
return new
|
|
962
|
+
return new AnchoredRect2(-leftw, 0, rightw, -toph, 0, bottomh);
|
|
883
963
|
}
|
|
884
964
|
drawRest(restSize, x, y) {
|
|
885
965
|
let { unitSize } = this;
|
|
@@ -1101,7 +1181,7 @@ var RenderContext = class {
|
|
|
1101
1181
|
}
|
|
1102
1182
|
drawBrace(rect, side) {
|
|
1103
1183
|
if (this.ctx) {
|
|
1104
|
-
let { left, right, width, top, bottom,
|
|
1184
|
+
let { left, right, width, top, bottom, anchorY } = rect;
|
|
1105
1185
|
if (side === "right") {
|
|
1106
1186
|
[left, right, width] = [right, left, -width];
|
|
1107
1187
|
}
|
|
@@ -1111,18 +1191,18 @@ var RenderContext = class {
|
|
|
1111
1191
|
left + width * 0.1,
|
|
1112
1192
|
top,
|
|
1113
1193
|
left + width * 0.8,
|
|
1114
|
-
|
|
1194
|
+
anchorY,
|
|
1115
1195
|
left,
|
|
1116
|
-
|
|
1196
|
+
anchorY
|
|
1117
1197
|
);
|
|
1118
1198
|
this.ctx.moveTo(right, bottom);
|
|
1119
1199
|
this.ctx.bezierCurveTo(
|
|
1120
1200
|
left + width * 0.1,
|
|
1121
1201
|
bottom,
|
|
1122
1202
|
left + width * 0.8,
|
|
1123
|
-
|
|
1203
|
+
anchorY,
|
|
1124
1204
|
left,
|
|
1125
|
-
|
|
1205
|
+
anchorY
|
|
1126
1206
|
);
|
|
1127
1207
|
this.ctx.stroke();
|
|
1128
1208
|
}
|
|
@@ -1131,10 +1211,10 @@ var RenderContext = class {
|
|
|
1131
1211
|
|
|
1132
1212
|
// src/score/engine/obj-staff-and-tab.ts
|
|
1133
1213
|
import { MusicError as MusicError15, MusicErrorType as MusicErrorType15 } from "@tspro/web-music-score/core";
|
|
1134
|
-
import { Utils as
|
|
1214
|
+
import { AnchoredRect as AnchoredRect22, Guard as Guard9, UniMap as UniMap7, Utils as Utils10 } from "@tspro/ts-utils-lib";
|
|
1135
1215
|
|
|
1136
1216
|
// src/score/engine/obj-measure.ts
|
|
1137
|
-
import {
|
|
1217
|
+
import { Guard as Guard8, IndexArray as IndexArray2, UniMap as UniMap5, TriMap as TriMap2, ValueSet, Utils as Utils9, asMulti, AnchoredRect as AnchoredRect20 } from "@tspro/ts-utils-lib";
|
|
1138
1218
|
import { getScale, Scale, validateScaleType, Note as Note7, RhythmProps as RhythmProps5, KeySignature as KeySignature2, getDefaultKeySignature, PitchNotation, SymbolSet, validateNoteLength as validateNoteLength2, NoteLengthProps as NoteLengthProps5 } from "@tspro/web-music-score/theory";
|
|
1139
1219
|
import { getDefaultTempo, getDefaultTimeSignature } from "@tspro/web-music-score/theory";
|
|
1140
1220
|
|
|
@@ -1164,6 +1244,7 @@ var AccidentalState = class {
|
|
|
1164
1244
|
import { Note as Note2, getTempoString, KeySignature } from "@tspro/web-music-score/theory";
|
|
1165
1245
|
|
|
1166
1246
|
// src/score/engine/obj-image.ts
|
|
1247
|
+
import { AnchoredRect as AnchoredRect3 } from "@tspro/ts-utils-lib";
|
|
1167
1248
|
var ObjImage = class extends MusicObject {
|
|
1168
1249
|
constructor(parent, image, anchorX, anchorY, imageScale) {
|
|
1169
1250
|
super(parent);
|
|
@@ -1186,9 +1267,9 @@ var ObjImage = class extends MusicObject {
|
|
|
1186
1267
|
try {
|
|
1187
1268
|
let w = image.naturalWidth * imageScale * unitSize;
|
|
1188
1269
|
let h = image.naturalHeight * imageScale * unitSize;
|
|
1189
|
-
this.rect =
|
|
1270
|
+
this.rect = AnchoredRect3.createSections(w * anchorX, w * (1 - anchorX), h * anchorY, h * (1 - anchorY));
|
|
1190
1271
|
} catch (err) {
|
|
1191
|
-
this.rect = new
|
|
1272
|
+
this.rect = new AnchoredRect3();
|
|
1192
1273
|
}
|
|
1193
1274
|
}
|
|
1194
1275
|
offset(dx, dy) {
|
|
@@ -1197,12 +1278,13 @@ var ObjImage = class extends MusicObject {
|
|
|
1197
1278
|
draw(ctx) {
|
|
1198
1279
|
let r = this.rect;
|
|
1199
1280
|
ctx.drawDebugRect(r);
|
|
1200
|
-
ctx.drawImage(this.image, r.
|
|
1281
|
+
ctx.drawImage(this.image, r.anchorX - r.leftw, r.anchorY - r.toph, r.width, r.height);
|
|
1201
1282
|
}
|
|
1202
1283
|
};
|
|
1203
1284
|
|
|
1204
1285
|
// src/score/engine/obj-accidental.ts
|
|
1205
1286
|
import { MusicError as MusicError3, MusicErrorType as MusicErrorType3 } from "@tspro/web-music-score/core";
|
|
1287
|
+
import { AnchoredRect as AnchoredRect4 } from "@tspro/ts-utils-lib";
|
|
1206
1288
|
var ObjAccidental = class extends MusicObject {
|
|
1207
1289
|
constructor(parent, diatonicId, accidental, color = "black") {
|
|
1208
1290
|
super(parent);
|
|
@@ -1222,19 +1304,19 @@ var ObjAccidental = class extends MusicObject {
|
|
|
1222
1304
|
let { unitSize } = ctx;
|
|
1223
1305
|
switch (this.accidental) {
|
|
1224
1306
|
case -2:
|
|
1225
|
-
this.rect =
|
|
1307
|
+
this.rect = AnchoredRect4.createSections(unitSize * 1.25, unitSize * 1.25, unitSize * 4, unitSize * 1.2);
|
|
1226
1308
|
break;
|
|
1227
1309
|
case -1:
|
|
1228
|
-
this.rect =
|
|
1310
|
+
this.rect = AnchoredRect4.createSections(unitSize * 0.75, unitSize * 0.75, unitSize * 4, unitSize * 1.2);
|
|
1229
1311
|
break;
|
|
1230
1312
|
case 0:
|
|
1231
|
-
this.rect =
|
|
1313
|
+
this.rect = AnchoredRect4.createSections(unitSize * 0.75, unitSize * 0.75, unitSize * 2.2, unitSize * 2.2);
|
|
1232
1314
|
break;
|
|
1233
1315
|
case 1:
|
|
1234
|
-
this.rect =
|
|
1316
|
+
this.rect = AnchoredRect4.createSections(unitSize * 0.75, unitSize * 0.75, unitSize * 2, unitSize * 2);
|
|
1235
1317
|
break;
|
|
1236
1318
|
case 2:
|
|
1237
|
-
this.rect =
|
|
1319
|
+
this.rect = AnchoredRect4.createSections(unitSize * 1, unitSize * 1, unitSize * 1, unitSize * 1);
|
|
1238
1320
|
break;
|
|
1239
1321
|
default:
|
|
1240
1322
|
throw new MusicError3(MusicErrorType3.Score, "Invalid accidental value: " + this.accidental);
|
|
@@ -1247,8 +1329,8 @@ var ObjAccidental = class extends MusicObject {
|
|
|
1247
1329
|
ctx.drawDebugRect(this.rect);
|
|
1248
1330
|
let { unitSize } = ctx;
|
|
1249
1331
|
let { accidental } = this;
|
|
1250
|
-
let x = this.rect.
|
|
1251
|
-
let y = this.rect.
|
|
1332
|
+
let x = this.rect.anchorX;
|
|
1333
|
+
let y = this.rect.anchorY;
|
|
1252
1334
|
ctx.color(this.color);
|
|
1253
1335
|
const draw_b = (x2, y2) => {
|
|
1254
1336
|
ctx.lineWidth(1).beginPath().moveTo(x2 - unitSize * 0.75, y2 - unitSize * 4).lineTo(x2 - unitSize * 0.75, y2 + unitSize * 1.1).bezierCurveTo(
|
|
@@ -1277,6 +1359,7 @@ var ObjAccidental = class extends MusicObject {
|
|
|
1277
1359
|
};
|
|
1278
1360
|
|
|
1279
1361
|
// src/score/engine/obj-text.ts
|
|
1362
|
+
import { AnchoredRect as AnchoredRect5 } from "@tspro/ts-utils-lib";
|
|
1280
1363
|
var DefaultBoxedPadding = 0.5;
|
|
1281
1364
|
var ObjText = class extends MusicObject {
|
|
1282
1365
|
constructor(parent, text, anchorX, anchorY) {
|
|
@@ -1313,7 +1396,7 @@ var ObjText = class extends MusicObject {
|
|
|
1313
1396
|
if (this.textLines.length === 0) {
|
|
1314
1397
|
this.textLines = [""];
|
|
1315
1398
|
}
|
|
1316
|
-
this.rect = new
|
|
1399
|
+
this.rect = new AnchoredRect5();
|
|
1317
1400
|
this.mi = new MText(this);
|
|
1318
1401
|
}
|
|
1319
1402
|
getMusicInterface() {
|
|
@@ -1325,14 +1408,14 @@ var ObjText = class extends MusicObject {
|
|
|
1325
1408
|
updateAnchorX(anchorX) {
|
|
1326
1409
|
this.anchorX = anchorX;
|
|
1327
1410
|
let { width } = this.rect;
|
|
1328
|
-
this.rect.left = this.rect.
|
|
1329
|
-
this.rect.right = this.rect.
|
|
1411
|
+
this.rect.left = this.rect.anchorX - width * anchorX;
|
|
1412
|
+
this.rect.right = this.rect.anchorX + width * (1 - anchorX);
|
|
1330
1413
|
}
|
|
1331
1414
|
updateAnchorY(anchorY) {
|
|
1332
1415
|
this.anchorY = anchorY;
|
|
1333
1416
|
let { height } = this.rect;
|
|
1334
|
-
this.rect.top = this.rect.
|
|
1335
|
-
this.rect.bottom = this.rect.
|
|
1417
|
+
this.rect.top = this.rect.anchorY - height * anchorY;
|
|
1418
|
+
this.rect.bottom = this.rect.anchorY + height * (1 - anchorY);
|
|
1336
1419
|
}
|
|
1337
1420
|
pick(x, y) {
|
|
1338
1421
|
return this.rect.contains(x, y) ? [this] : [];
|
|
@@ -1349,7 +1432,7 @@ var ObjText = class extends MusicObject {
|
|
|
1349
1432
|
if (this.boxed === "square" || this.boxed === "circle") {
|
|
1350
1433
|
h = w = Math.max(h, w);
|
|
1351
1434
|
}
|
|
1352
|
-
this.rect =
|
|
1435
|
+
this.rect = AnchoredRect5.createSections(w * anchorX, w * (1 - anchorX), h * anchorY, h * (1 - anchorY));
|
|
1353
1436
|
}
|
|
1354
1437
|
offset(dx, dy) {
|
|
1355
1438
|
this.rect.offsetInPlace(dx, dy);
|
|
@@ -1371,12 +1454,12 @@ var ObjText = class extends MusicObject {
|
|
|
1371
1454
|
let textHeight = lineCount * lineHeight;
|
|
1372
1455
|
let fixY = -lineHeight * (italic ? 0.25 : 0.2);
|
|
1373
1456
|
let p = padding * ctx.unitSize;
|
|
1374
|
-
let
|
|
1375
|
-
let
|
|
1457
|
+
let aX = (rect.left + p) * (1 - anchorX) + (rect.right - p) * anchorX;
|
|
1458
|
+
let aY = (rect.top + p) * (1 - anchorY) + (rect.bottom - p) * anchorY;
|
|
1376
1459
|
ctx.color(this.color);
|
|
1377
1460
|
this.textLines.forEach((textLine, i) => {
|
|
1378
|
-
let x =
|
|
1379
|
-
let y =
|
|
1461
|
+
let x = aX - lineWidths[i] * anchorX;
|
|
1462
|
+
let y = aY - textHeight * anchorY + lineHeight * (i + 1) + fixY;
|
|
1380
1463
|
ctx.fillText(textLine, x, y);
|
|
1381
1464
|
});
|
|
1382
1465
|
switch (this.boxed) {
|
|
@@ -1386,12 +1469,8 @@ var ObjText = class extends MusicObject {
|
|
|
1386
1469
|
break;
|
|
1387
1470
|
case "circle":
|
|
1388
1471
|
case "ellipse":
|
|
1389
|
-
let x = (rect.left + rect.right) / 2;
|
|
1390
|
-
let y = (rect.top + rect.bottom) / 2;
|
|
1391
|
-
let rx = (rect.right - rect.left) / 2;
|
|
1392
|
-
let ry = (rect.bottom - rect.top) / 2;
|
|
1393
1472
|
ctx.beginPath();
|
|
1394
|
-
ctx.ellipse(
|
|
1473
|
+
ctx.ellipse(rect.centerX, rect.centerY, rect.width / 2, rect.height / 2, 0, 0, 2 * Math.PI);
|
|
1395
1474
|
ctx.stroke();
|
|
1396
1475
|
break;
|
|
1397
1476
|
}
|
|
@@ -1400,6 +1479,7 @@ var ObjText = class extends MusicObject {
|
|
|
1400
1479
|
|
|
1401
1480
|
// src/score/engine/obj-signature.ts
|
|
1402
1481
|
import { MusicError as MusicError4, MusicErrorType as MusicErrorType4 } from "@tspro/web-music-score/core";
|
|
1482
|
+
import { AnchoredRect as AnchoredRect6 } from "@tspro/ts-utils-lib";
|
|
1403
1483
|
var ObjStaffSignature = class extends MusicObject {
|
|
1404
1484
|
constructor(measure, staff) {
|
|
1405
1485
|
super(measure);
|
|
@@ -1558,7 +1638,7 @@ var ObjStaffSignature = class extends MusicObject {
|
|
|
1558
1638
|
let { staff } = this;
|
|
1559
1639
|
let paddingX = unitSize;
|
|
1560
1640
|
let x = 0;
|
|
1561
|
-
this.rect = new
|
|
1641
|
+
this.rect = new AnchoredRect6();
|
|
1562
1642
|
if (this.clefImage) {
|
|
1563
1643
|
x += paddingX;
|
|
1564
1644
|
this.clefImage.layout(ctx);
|
|
@@ -1568,7 +1648,7 @@ var ObjStaffSignature = class extends MusicObject {
|
|
|
1568
1648
|
if (this.eightBelowClef) {
|
|
1569
1649
|
let r = this.clefImage.getRect();
|
|
1570
1650
|
this.eightBelowClef.layout(ctx);
|
|
1571
|
-
this.eightBelowClef.offset(r.
|
|
1651
|
+
this.eightBelowClef.offset(r.centerX, Math.max(r.anchorY + r.height * 0.3, staff.getBottomLineY()));
|
|
1572
1652
|
this.rect.expandInPlace(this.eightBelowClef.getRect());
|
|
1573
1653
|
}
|
|
1574
1654
|
}
|
|
@@ -1727,7 +1807,7 @@ var ObjTabSignature = class extends MusicObject {
|
|
|
1727
1807
|
let paddingX = unitSize;
|
|
1728
1808
|
let x = 0;
|
|
1729
1809
|
let topLineY = tab.getTopLineY();
|
|
1730
|
-
this.rect = new
|
|
1810
|
+
this.rect = new AnchoredRect6();
|
|
1731
1811
|
if (this.measureNumber) {
|
|
1732
1812
|
this.measureNumber.layout(ctx);
|
|
1733
1813
|
this.measureNumber.offset(0, topLineY);
|
|
@@ -1738,11 +1818,11 @@ var ObjTabSignature = class extends MusicObject {
|
|
|
1738
1818
|
(_b = this.beatSizeText) == null ? void 0 : _b.layout(ctx);
|
|
1739
1819
|
let tsWidth = Math.max((_d = (_c = this.beatCountText) == null ? void 0 : _c.getRect().width) != null ? _d : 0, (_f = (_e = this.beatSizeText) == null ? void 0 : _e.getRect().width) != null ? _f : 0);
|
|
1740
1820
|
if (this.beatCountText) {
|
|
1741
|
-
this.beatCountText.offset(0 + tsWidth / 2 + paddingX, tab.getRect().
|
|
1821
|
+
this.beatCountText.offset(0 + tsWidth / 2 + paddingX, tab.getRect().anchorY - this.beatCountText.getRect().bottomh);
|
|
1742
1822
|
this.rect.expandInPlace(this.beatCountText.getRect());
|
|
1743
1823
|
}
|
|
1744
1824
|
if (this.beatSizeText) {
|
|
1745
|
-
this.beatSizeText.offset(0 + tsWidth / 2 + paddingX, tab.getRect().
|
|
1825
|
+
this.beatSizeText.offset(0 + tsWidth / 2 + paddingX, tab.getRect().anchorY + this.beatSizeText.getRect().toph);
|
|
1746
1826
|
this.rect.expandInPlace(this.beatSizeText.getRect());
|
|
1747
1827
|
}
|
|
1748
1828
|
if (this.tempoText) {
|
|
@@ -1770,7 +1850,7 @@ var ObjTabSignature = class extends MusicObject {
|
|
|
1770
1850
|
};
|
|
1771
1851
|
|
|
1772
1852
|
// src/score/engine/player.ts
|
|
1773
|
-
import { Utils as Utils5 } from "@tspro/ts-utils-lib";
|
|
1853
|
+
import { Rect as Rect2, UniMap as UniMap3, Utils as Utils5 } from "@tspro/ts-utils-lib";
|
|
1774
1854
|
import { NoteLength as NoteLength4, RhythmProps as RhythmProps4, alterTempoSpeed } from "@tspro/web-music-score/theory";
|
|
1775
1855
|
import * as Audio from "@tspro/web-music-score/audio";
|
|
1776
1856
|
|
|
@@ -1778,6 +1858,7 @@ import * as Audio from "@tspro/web-music-score/audio";
|
|
|
1778
1858
|
import { Note as Note5 } from "@tspro/web-music-score/theory";
|
|
1779
1859
|
|
|
1780
1860
|
// src/score/engine/obj-arpeggio.ts
|
|
1861
|
+
import { AnchoredRect as AnchoredRect7 } from "@tspro/ts-utils-lib";
|
|
1781
1862
|
var ObjArpeggio = class extends MusicObject {
|
|
1782
1863
|
constructor(col, line, arpeggioDir) {
|
|
1783
1864
|
super(col);
|
|
@@ -1808,7 +1889,7 @@ var ObjArpeggio = class extends MusicObject {
|
|
|
1808
1889
|
this.numCycles = Math.ceil((bottom - top) / this.cycleHeight) + 2;
|
|
1809
1890
|
let width = unitSize * 2;
|
|
1810
1891
|
let height = this.numCycles * this.cycleHeight;
|
|
1811
|
-
this.rect = new
|
|
1892
|
+
this.rect = new AnchoredRect7(-width / 2, width / 2, -height / 2 - this.topArrowHeight, height / 2 + this.bottomArrowHeight);
|
|
1812
1893
|
}
|
|
1813
1894
|
offset(dx, dy) {
|
|
1814
1895
|
this.rect.offsetInPlace(dx, dy);
|
|
@@ -1820,21 +1901,21 @@ var ObjArpeggio = class extends MusicObject {
|
|
|
1820
1901
|
ctx.lineWidth(2);
|
|
1821
1902
|
ctx.beginPath();
|
|
1822
1903
|
for (let i = 0, y = rect.top + topArrowHeight; i < this.numCycles; i++, y += this.cycleHeight) {
|
|
1823
|
-
ctx.moveTo(rect.
|
|
1824
|
-
ctx.quadraticCurveTo(rect.left, y + this.cycleHeight / 4, rect.
|
|
1825
|
-
ctx.quadraticCurveTo(rect.right, y + this.cycleHeight * 3 / 4, rect.
|
|
1904
|
+
ctx.moveTo(rect.anchorX, y);
|
|
1905
|
+
ctx.quadraticCurveTo(rect.left, y + this.cycleHeight / 4, rect.anchorX, y + this.cycleHeight / 2);
|
|
1906
|
+
ctx.quadraticCurveTo(rect.right, y + this.cycleHeight * 3 / 4, rect.anchorX, y + this.cycleHeight);
|
|
1826
1907
|
}
|
|
1827
1908
|
ctx.stroke();
|
|
1828
1909
|
if (topArrowHeight > 0) {
|
|
1829
1910
|
ctx.beginPath();
|
|
1830
|
-
ctx.moveTo(rect.
|
|
1911
|
+
ctx.moveTo(rect.anchorX, rect.top);
|
|
1831
1912
|
ctx.lineTo(rect.right, rect.top + topArrowHeight);
|
|
1832
1913
|
ctx.lineTo(rect.left, rect.top + topArrowHeight);
|
|
1833
1914
|
ctx.fill();
|
|
1834
1915
|
}
|
|
1835
1916
|
if (bottomArrowHeight > 0) {
|
|
1836
1917
|
ctx.beginPath();
|
|
1837
|
-
ctx.moveTo(rect.
|
|
1918
|
+
ctx.moveTo(rect.anchorX, rect.bottom);
|
|
1838
1919
|
ctx.lineTo(rect.left, rect.bottom - bottomArrowHeight);
|
|
1839
1920
|
ctx.lineTo(rect.right, rect.bottom - bottomArrowHeight);
|
|
1840
1921
|
ctx.fill();
|
|
@@ -1845,6 +1926,7 @@ var ObjArpeggio = class extends MusicObject {
|
|
|
1845
1926
|
// src/score/engine/obj-rest.ts
|
|
1846
1927
|
import { Note as Note3, NoteLengthProps as NoteLengthProps2, RhythmProps as RhythmProps2, Tuplet } from "@tspro/web-music-score/theory";
|
|
1847
1928
|
import { MusicError as MusicError5, MusicErrorType as MusicErrorType5 } from "@tspro/web-music-score/core";
|
|
1929
|
+
import { AnchoredRect as AnchoredRect8 } from "@tspro/ts-utils-lib";
|
|
1848
1930
|
function getDiatonicIdFromStaffPos(staffPos) {
|
|
1849
1931
|
if (typeof staffPos === "number") {
|
|
1850
1932
|
return Note3.getChromaticNote(staffPos).diatonicId;
|
|
@@ -1861,7 +1943,7 @@ var ObjStaffRest = class extends MusicObject {
|
|
|
1861
1943
|
super(staff);
|
|
1862
1944
|
this.staff = staff;
|
|
1863
1945
|
this.rest = rest;
|
|
1864
|
-
__publicField(this, "restRect", new
|
|
1946
|
+
__publicField(this, "restRect", new AnchoredRect8());
|
|
1865
1947
|
__publicField(this, "dotRects", []);
|
|
1866
1948
|
__publicField(this, "mi");
|
|
1867
1949
|
staff.addObject(this);
|
|
@@ -1880,7 +1962,7 @@ var ObjStaffRest = class extends MusicObject {
|
|
|
1880
1962
|
this.rest.requestRectUpdate();
|
|
1881
1963
|
}
|
|
1882
1964
|
updateRect() {
|
|
1883
|
-
this.rect = this.restRect.
|
|
1965
|
+
this.rect = this.restRect.clone();
|
|
1884
1966
|
this.dotRects.forEach((r) => this.rect.expandInPlace(r));
|
|
1885
1967
|
}
|
|
1886
1968
|
};
|
|
@@ -1986,9 +2068,9 @@ var _ObjRest = class _ObjRest extends MusicObject {
|
|
|
1986
2068
|
getBeamCoords() {
|
|
1987
2069
|
return this.staffObjects.map((obj) => {
|
|
1988
2070
|
let staff = obj.staff;
|
|
1989
|
-
let x = obj.getRect().
|
|
2071
|
+
let x = obj.getRect().anchorX;
|
|
1990
2072
|
let y = this.stemDir === "up" /* Up */ ? obj.getRect().top : obj.getRect().bottom;
|
|
1991
|
-
let stemHeight = Math.abs(obj.getRect().
|
|
2073
|
+
let stemHeight = Math.abs(obj.getRect().anchorY - y);
|
|
1992
2074
|
return { staff, x, y, stemHeight };
|
|
1993
2075
|
});
|
|
1994
2076
|
}
|
|
@@ -2042,17 +2124,18 @@ var _ObjRest = class _ObjRest extends MusicObject {
|
|
|
2042
2124
|
let dotWidth = DocumentSettings.DotSize * unitSize;
|
|
2043
2125
|
let dotX = obj.restRect.rightw + (DocumentSettings.RestDotSpace + DocumentSettings.DotSize * unitSize) + i * DocumentSettings.DotSize * unitSize * 1.5;
|
|
2044
2126
|
let dotY = this.getRestDotVerticalDisplacement(noteSize) * unitSize;
|
|
2045
|
-
obj.dotRects.push(
|
|
2127
|
+
obj.dotRects.push(AnchoredRect8.createCentered(dotX, dotY, dotWidth, dotWidth));
|
|
2046
2128
|
}
|
|
2047
2129
|
obj.offset(0, staff.getDiatonicIdY(diatonicId));
|
|
2048
2130
|
this.staffObjects.push(obj);
|
|
2131
|
+
this.measure.addStaticObject(staff, obj);
|
|
2049
2132
|
});
|
|
2050
2133
|
}
|
|
2051
2134
|
updateRect() {
|
|
2052
2135
|
if (this.staffObjects.length === 0) {
|
|
2053
|
-
this.rect = new
|
|
2136
|
+
this.rect = new AnchoredRect8();
|
|
2054
2137
|
} else {
|
|
2055
|
-
this.rect = this.staffObjects[0].getRect().
|
|
2138
|
+
this.rect = this.staffObjects[0].getRect().clone();
|
|
2056
2139
|
if (this.staffObjects.length > 1) {
|
|
2057
2140
|
for (let i = 1; i < this.staffObjects.length; i++) {
|
|
2058
2141
|
this.rect.expandInPlace(this.staffObjects[i].getRect());
|
|
@@ -2073,10 +2156,8 @@ var _ObjRest = class _ObjRest extends MusicObject {
|
|
|
2073
2156
|
ctx.color(this.color).lineWidth(1);
|
|
2074
2157
|
this.staffObjects.forEach((obj) => {
|
|
2075
2158
|
let { dotRects, restRect } = obj;
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
ctx.drawRest(noteSize, x, y);
|
|
2079
|
-
dotRects.forEach((r) => ctx.fillCircle(r.centerX, r.centerY, r.width / 2));
|
|
2159
|
+
ctx.drawRest(noteSize, restRect.anchorX, restRect.anchorY);
|
|
2160
|
+
dotRects.forEach((r) => ctx.fillCircle(r.anchorX, r.anchorY, r.width / 2));
|
|
2080
2161
|
});
|
|
2081
2162
|
}
|
|
2082
2163
|
};
|
|
@@ -2084,18 +2165,18 @@ __publicField(_ObjRest, "UndefinedDiatonicId", Infinity);
|
|
|
2084
2165
|
var ObjRest = _ObjRest;
|
|
2085
2166
|
|
|
2086
2167
|
// src/score/engine/obj-note-group.ts
|
|
2087
|
-
import { Utils as Utils3 } from "@tspro/ts-utils-lib";
|
|
2168
|
+
import { AnchoredRect as AnchoredRect9, Guard as Guard2, Utils as Utils3 } from "@tspro/ts-utils-lib";
|
|
2088
2169
|
import { Note as Note4, NoteLengthProps as NoteLengthProps3, RhythmProps as RhythmProps3, Tuplet as Tuplet2 } from "@tspro/web-music-score/theory";
|
|
2089
2170
|
import { MusicError as MusicError6, MusicErrorType as MusicErrorType6 } from "@tspro/web-music-score/core";
|
|
2090
2171
|
function getArpeggio(a) {
|
|
2091
|
-
return
|
|
2172
|
+
return Guard2.isEnumValue(a, Arpeggio) ? a : a === true ? "up" /* Up */ : void 0;
|
|
2092
2173
|
}
|
|
2093
2174
|
function sortNotesAndStrings(notes, strings) {
|
|
2094
2175
|
let stringArr = Utils3.Arr.isArray(strings) ? strings : strings !== void 0 ? [strings] : [];
|
|
2095
2176
|
let noteStringData = notes.map((note, i) => {
|
|
2096
2177
|
return { note, string: stringArr[i] };
|
|
2097
2178
|
});
|
|
2098
|
-
noteStringData = Utils3.Arr.
|
|
2179
|
+
noteStringData = Utils3.Arr.removeDuplicates(noteStringData, (a, b) => Note4.equals(a.note, b.note)).sort((a, b) => Note4.compareFunc(a.note, b.note));
|
|
2099
2180
|
return {
|
|
2100
2181
|
sortedNotes: noteStringData.map((e) => e.note),
|
|
2101
2182
|
sortedStrings: noteStringData.every((e) => e.string === void 0) ? void 0 : noteStringData.map((e) => e.string)
|
|
@@ -2133,7 +2214,7 @@ var ObjStaffNoteGroup = class extends MusicObject {
|
|
|
2133
2214
|
return [this];
|
|
2134
2215
|
}
|
|
2135
2216
|
updateRect() {
|
|
2136
|
-
this.rect = this.noteHeadRects[0].
|
|
2217
|
+
this.rect = this.noteHeadRects[0].clone();
|
|
2137
2218
|
this.noteHeadRects.forEach((r) => this.rect.expandInPlace(r));
|
|
2138
2219
|
if (this.stemTip) this.rect.expandInPlace(this.stemTip);
|
|
2139
2220
|
if (this.stemBase) this.rect.expandInPlace(this.stemBase);
|
|
@@ -2144,9 +2225,9 @@ var ObjStaffNoteGroup = class extends MusicObject {
|
|
|
2144
2225
|
getRect() {
|
|
2145
2226
|
let bottomNoteRect = this.noteHeadRects[0];
|
|
2146
2227
|
let topNoteRect = this.noteHeadRects[this.noteHeadRects.length - 1];
|
|
2147
|
-
if (this.prevTopNoteY !== topNoteRect.
|
|
2148
|
-
this.prevTopNoteY = topNoteRect.
|
|
2149
|
-
this.prevBottomNoteY = bottomNoteRect.
|
|
2228
|
+
if (this.prevTopNoteY !== topNoteRect.anchorY || this.prevBottomNoteY !== bottomNoteRect.anchorY) {
|
|
2229
|
+
this.prevTopNoteY = topNoteRect.anchorY;
|
|
2230
|
+
this.prevBottomNoteY = bottomNoteRect.anchorY;
|
|
2150
2231
|
this.requestRectUpdate();
|
|
2151
2232
|
}
|
|
2152
2233
|
return super.getRect();
|
|
@@ -2179,7 +2260,7 @@ var ObjTabNoteGroup = class extends MusicObject {
|
|
|
2179
2260
|
return this.getRect().contains(x, y) ? [this] : [];
|
|
2180
2261
|
}
|
|
2181
2262
|
updateRect() {
|
|
2182
|
-
this.rect = this.fretNumbers[0].getRect().
|
|
2263
|
+
this.rect = this.fretNumbers[0].getRect().clone();
|
|
2183
2264
|
this.fretNumbers.forEach((fn) => this.rect.expandInPlace(fn.getRect()));
|
|
2184
2265
|
}
|
|
2185
2266
|
offset(dx, dy) {
|
|
@@ -2215,13 +2296,15 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2215
2296
|
__publicField(this, "beamGroup");
|
|
2216
2297
|
__publicField(this, "staffObjects", []);
|
|
2217
2298
|
__publicField(this, "tabObjects", []);
|
|
2299
|
+
__publicField(this, "isNoteDisplaced");
|
|
2218
2300
|
__publicField(this, "mi");
|
|
2219
|
-
if (!
|
|
2301
|
+
if (!Guard2.isIntegerGte(notes.length, 1)) {
|
|
2220
2302
|
throw new MusicError6(MusicErrorType6.Score, "Cannot create note group object because notes array is empty.");
|
|
2221
2303
|
}
|
|
2222
2304
|
let { sortedNotes, sortedStrings } = sortNotesAndStrings(notes, options == null ? void 0 : options.string);
|
|
2223
2305
|
this.notes = sortedNotes;
|
|
2224
2306
|
this.setStringsNumbers = sortedStrings;
|
|
2307
|
+
this.isNoteDisplaced = this.notes.map(() => false);
|
|
2225
2308
|
this.setDiatonicId = Math.round((this.minDiatonicId + this.maxDiatonicId) / 2);
|
|
2226
2309
|
this.runningDiatonicId = this.setDiatonicId;
|
|
2227
2310
|
this.runningStemDir = "up" /* Up */;
|
|
@@ -2259,6 +2342,10 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2259
2342
|
get stemDir() {
|
|
2260
2343
|
return this.runningStemDir;
|
|
2261
2344
|
}
|
|
2345
|
+
setNoteDisplacement(note, isDisplaced) {
|
|
2346
|
+
let i = this.notes.indexOf(note);
|
|
2347
|
+
if (i >= 0) this.isNoteDisplaced[i] = isDisplaced;
|
|
2348
|
+
}
|
|
2262
2349
|
enableConnective(line) {
|
|
2263
2350
|
return line.containsVoiceId(this.voiceId) && (line instanceof ObjTab || line.containsDiatonicId(this.runningDiatonicId));
|
|
2264
2351
|
}
|
|
@@ -2276,20 +2363,6 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2276
2363
|
this.runningStemDir = stemDir;
|
|
2277
2364
|
this.runningStringNumbers = stringNumbers;
|
|
2278
2365
|
}
|
|
2279
|
-
getStaticObjects(line) {
|
|
2280
|
-
let staticObjects = [];
|
|
2281
|
-
this.staffObjects.forEach((obj) => {
|
|
2282
|
-
if (obj.staff === line) {
|
|
2283
|
-
staticObjects.push(obj);
|
|
2284
|
-
}
|
|
2285
|
-
});
|
|
2286
|
-
this.tabObjects.forEach((obj) => {
|
|
2287
|
-
if (obj.tab === line) {
|
|
2288
|
-
staticObjects.push(obj);
|
|
2289
|
-
}
|
|
2290
|
-
});
|
|
2291
|
-
return staticObjects;
|
|
2292
|
-
}
|
|
2293
2366
|
pick(x, y) {
|
|
2294
2367
|
if (!this.getRect().contains(x, y)) {
|
|
2295
2368
|
return [];
|
|
@@ -2323,7 +2396,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2323
2396
|
let obj = this.staffObjects.find((obj2) => obj2.staff === line);
|
|
2324
2397
|
if (!obj || noteIndex < 0 || noteIndex >= obj.noteHeadRects.length) {
|
|
2325
2398
|
let r = this.getRect();
|
|
2326
|
-
return { x: r.
|
|
2399
|
+
return { x: r.anchorX, y: r.bottom };
|
|
2327
2400
|
}
|
|
2328
2401
|
let noteHeadRect = obj.noteHeadRects[noteIndex];
|
|
2329
2402
|
let stemTip = obj.stemTip;
|
|
@@ -2331,8 +2404,8 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2331
2404
|
let hasStem = stemTip !== void 0;
|
|
2332
2405
|
let stemSide = !hasStem ? void 0 : stemDir === "up" /* Up */ ? "right" : "left";
|
|
2333
2406
|
let padding = noteHeadRect.height / 2;
|
|
2334
|
-
let
|
|
2335
|
-
let
|
|
2407
|
+
let anchorX = noteHeadRect.anchorX;
|
|
2408
|
+
let anchorY = noteHeadRect.anchorY;
|
|
2336
2409
|
let leftX = noteHeadRect.left - padding;
|
|
2337
2410
|
let rightX = noteHeadRect.right + padding;
|
|
2338
2411
|
let aboveY = noteHeadRect.top - padding;
|
|
@@ -2344,27 +2417,27 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2344
2417
|
}
|
|
2345
2418
|
switch (noteAnchor) {
|
|
2346
2419
|
case "center" /* Center */:
|
|
2347
|
-
return side === "left" ? { x: rightX, y:
|
|
2420
|
+
return side === "left" ? { x: rightX, y: anchorY } : { x: leftX, y: anchorY };
|
|
2348
2421
|
case "above" /* Above */:
|
|
2349
2422
|
if (!hasStem || stemDir === "down" /* Down */) {
|
|
2350
|
-
return { x:
|
|
2423
|
+
return { x: anchorX, y: aboveY };
|
|
2351
2424
|
} else {
|
|
2352
2425
|
return {
|
|
2353
|
-
x: side === "left" && stemSide === "right" ? rightX : side === "right" && stemSide === "left" ? leftX :
|
|
2426
|
+
x: side === "left" && stemSide === "right" ? rightX : side === "right" && stemSide === "left" ? leftX : anchorX,
|
|
2354
2427
|
y: aboveY
|
|
2355
2428
|
};
|
|
2356
2429
|
}
|
|
2357
2430
|
case "below" /* Below */:
|
|
2358
2431
|
if (!hasStem || stemDir === "up" /* Up */) {
|
|
2359
|
-
return { x:
|
|
2432
|
+
return { x: anchorX, y: belowY };
|
|
2360
2433
|
} else {
|
|
2361
2434
|
return {
|
|
2362
|
-
x: side === "left" && stemSide === "right" ? rightX : side === "right" && stemSide === "left" ? leftX :
|
|
2435
|
+
x: side === "left" && stemSide === "right" ? rightX : side === "right" && stemSide === "left" ? leftX : anchorX,
|
|
2363
2436
|
y: belowY
|
|
2364
2437
|
};
|
|
2365
2438
|
}
|
|
2366
2439
|
case "stemTip" /* StemTip */:
|
|
2367
|
-
return { x:
|
|
2440
|
+
return { x: anchorX, y: stemTip.anchorY + (stemDir === "up" /* Up */ ? -padding : padding) };
|
|
2368
2441
|
default:
|
|
2369
2442
|
throw new MusicError6(MusicErrorType6.Score, "Invalid noteAnchor: " + noteAnchor);
|
|
2370
2443
|
}
|
|
@@ -2382,12 +2455,12 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2382
2455
|
let rightFretNumber = connectiveProps.noteGroups[1].getFretNumber(line, 0);
|
|
2383
2456
|
let slideUp = leftFretNumber === void 0 || rightFretNumber === void 0 || leftFretNumber <= rightFretNumber;
|
|
2384
2457
|
if (side === "left") {
|
|
2385
|
-
y = (slideUp ? r.
|
|
2458
|
+
y = (slideUp ? r.anchorY + r.bottomh : r.anchorY - r.toph) * s;
|
|
2386
2459
|
} else {
|
|
2387
|
-
y = (slideUp ? r.
|
|
2460
|
+
y = (slideUp ? r.anchorY - r.toph : r.anchorY + r.bottomh) * s;
|
|
2388
2461
|
}
|
|
2389
2462
|
} else {
|
|
2390
|
-
y = r.
|
|
2463
|
+
y = r.anchorY + r.bottomh * s;
|
|
2391
2464
|
}
|
|
2392
2465
|
return { x, y };
|
|
2393
2466
|
} else {
|
|
@@ -2457,9 +2530,9 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2457
2530
|
return this.staffObjects.map((obj) => {
|
|
2458
2531
|
var _a, _b, _c, _d;
|
|
2459
2532
|
let staff = obj.staff;
|
|
2460
|
-
let x = (_b = (_a = obj.stemTip) == null ? void 0 : _a.
|
|
2461
|
-
let y = (_d = (_c = obj.stemTip) == null ? void 0 : _c.
|
|
2462
|
-
let stemHeight = this.stemDir === "up" /* Up */ ? Math.abs(obj.noteHeadRects[0].
|
|
2533
|
+
let x = (_b = (_a = obj.stemTip) == null ? void 0 : _a.anchorX) != null ? _b : obj.noteHeadRects[0].anchorX;
|
|
2534
|
+
let y = (_d = (_c = obj.stemTip) == null ? void 0 : _c.anchorY) != null ? _d : this.stemDir === "up" /* Up */ ? obj.getRect().top : obj.getRect().bottom;
|
|
2535
|
+
let stemHeight = this.stemDir === "up" /* Up */ ? Math.abs(obj.noteHeadRects[0].anchorY - y) : Math.abs(obj.noteHeadRects[obj.noteHeadRects.length - 1].anchorY - y);
|
|
2463
2536
|
return { staff, x, y, stemHeight };
|
|
2464
2537
|
});
|
|
2465
2538
|
}
|
|
@@ -2548,14 +2621,14 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2548
2621
|
let isBottomNote = noteIndex === 0;
|
|
2549
2622
|
let isTopNote = noteIndex === this.notes.length - 1;
|
|
2550
2623
|
let noteStaff = (_a = staff.getActualStaff(note.diatonicId)) != null ? _a : staff;
|
|
2551
|
-
let noteX = this.
|
|
2624
|
+
let noteX = this.isNoteDisplaced[noteIndex] ? noteHeadWidth * (stemDir === "down" /* Down */ ? -1 : 1) : 0;
|
|
2552
2625
|
let noteY = noteStaff.getDiatonicIdY(note.diatonicId);
|
|
2553
2626
|
let isNoteOnLine = noteStaff.isLine(note.diatonicId);
|
|
2554
2627
|
if (isBottomNote && stemDir === "up" /* Up */) stemBaseStaff = noteStaff;
|
|
2555
2628
|
if (isTopNote && stemDir === "up" /* Up */) stemTipStaff = noteStaff;
|
|
2556
2629
|
if (isBottomNote && stemDir === "down" /* Down */) stemTipStaff = noteStaff;
|
|
2557
2630
|
if (isTopNote && stemDir === "down" /* Down */) stemBaseStaff = noteStaff;
|
|
2558
|
-
let noteHeadRect = obj.noteHeadRects[noteIndex] =
|
|
2631
|
+
let noteHeadRect = obj.noteHeadRects[noteIndex] = AnchoredRect9.createCentered(noteX, noteY, noteHeadWidth, noteHeadHeight);
|
|
2559
2632
|
noteStaff.addObject(noteHeadRect);
|
|
2560
2633
|
if (accState.needAccidental(note)) {
|
|
2561
2634
|
let acc = obj.accidentals[noteIndex] = new ObjAccidental(this, note.diatonicId, note.accidental, this.color);
|
|
@@ -2568,7 +2641,7 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2568
2641
|
for (let i = 0; i < dotCount; i++) {
|
|
2569
2642
|
let dotX = noteHeadRect.right + DocumentSettings.NoteDotSpace * unitSize + dotWidth / 2 + i * dotWidth * 1.5;
|
|
2570
2643
|
let dotY = noteY + this.getDotVerticalDisplacement(staff, note.diatonicId, stemDir) * unitSize;
|
|
2571
|
-
let r =
|
|
2644
|
+
let r = AnchoredRect9.createCentered(dotX, dotY, dotWidth, dotWidth);
|
|
2572
2645
|
obj.dotRects.push(r);
|
|
2573
2646
|
noteStaff.addObject(r);
|
|
2574
2647
|
}
|
|
@@ -2576,27 +2649,27 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2576
2649
|
if (stemDir === "up" /* Up */ && isBottomNote) {
|
|
2577
2650
|
let dotX = noteX;
|
|
2578
2651
|
let dotY = noteY + unitSize * (isNoteOnLine ? 3 : 2);
|
|
2579
|
-
let r =
|
|
2652
|
+
let r = AnchoredRect9.createCentered(dotX, dotY, dotWidth, dotWidth);
|
|
2580
2653
|
obj.dotRects.push(r);
|
|
2581
2654
|
stemBaseStaff.addObject(r);
|
|
2582
2655
|
} else if (stemDir === "down" /* Down */ && isTopNote) {
|
|
2583
2656
|
let dotX = noteX;
|
|
2584
2657
|
let dotY = noteY - unitSize * (isNoteOnLine ? 3 : 2);
|
|
2585
|
-
let r =
|
|
2658
|
+
let r = AnchoredRect9.createCentered(dotX, dotY, dotWidth, dotWidth);
|
|
2586
2659
|
obj.dotRects.push(r);
|
|
2587
2660
|
stemBaseStaff.addObject(r);
|
|
2588
2661
|
}
|
|
2589
2662
|
}
|
|
2590
2663
|
});
|
|
2591
|
-
let bottomNoteY = obj.noteHeadRects[0].
|
|
2592
|
-
let topNoteY = obj.noteHeadRects[obj.noteHeadRects.length - 1].
|
|
2664
|
+
let bottomNoteY = obj.noteHeadRects[0].anchorY;
|
|
2665
|
+
let topNoteY = obj.noteHeadRects[obj.noteHeadRects.length - 1].anchorY;
|
|
2593
2666
|
let stemX = stemDir === "up" /* Up */ ? noteHeadWidth / 2 : -noteHeadWidth / 2;
|
|
2594
2667
|
let stemHeight = this.getStemHeight(ctx);
|
|
2595
2668
|
let stemTipY = stemDir === "up" /* Up */ ? topNoteY - stemHeight : bottomNoteY + stemHeight;
|
|
2596
2669
|
let stemBaseY = stemDir === "up" /* Up */ ? bottomNoteY : topNoteY;
|
|
2597
2670
|
if (hasStem) {
|
|
2598
|
-
obj.stemTip = new
|
|
2599
|
-
obj.stemBase = new
|
|
2671
|
+
obj.stemTip = new AnchoredRect9(stemX, stemX, stemTipY, stemTipY);
|
|
2672
|
+
obj.stemBase = new AnchoredRect9(stemX, stemX, stemBaseY, stemBaseY);
|
|
2600
2673
|
stemTipStaff.addObject(obj.stemTip);
|
|
2601
2674
|
stemBaseStaff.addObject(obj.stemBase);
|
|
2602
2675
|
}
|
|
@@ -2605,11 +2678,12 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2605
2678
|
let flagHeight = flagCount === 0 ? 0 : DocumentSettings.FlagHeight * unitSize;
|
|
2606
2679
|
for (let i = 0; i < flagCount; i++) {
|
|
2607
2680
|
let flagAddY = i * unitSize * DocumentSettings.FlagSeparation;
|
|
2608
|
-
let r = obj.flagRects[i] = stemDir === "up" /* Up */ ? new
|
|
2681
|
+
let r = obj.flagRects[i] = stemDir === "up" /* Up */ ? new AnchoredRect9(stemX, stemX + flagWidth, stemTipY + flagAddY, stemTipY + flagHeight + flagAddY) : new AnchoredRect9(stemX, stemX + flagWidth, stemTipY - flagHeight - flagAddY, stemTipY - flagAddY);
|
|
2609
2682
|
stemTipStaff.addObject(r);
|
|
2610
2683
|
}
|
|
2611
2684
|
}
|
|
2612
2685
|
this.staffObjects.push(obj);
|
|
2686
|
+
this.measure.addStaticObject(staff, obj);
|
|
2613
2687
|
});
|
|
2614
2688
|
this.tabObjects.length = 0;
|
|
2615
2689
|
row.getTabs().forEach((tab) => {
|
|
@@ -2619,12 +2693,12 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2619
2693
|
let obj = new ObjTabNoteGroup(tab, this);
|
|
2620
2694
|
this.notes.forEach((note, noteIndex) => {
|
|
2621
2695
|
let stringNumber = this.runningStringNumbers[noteIndex];
|
|
2622
|
-
if (
|
|
2696
|
+
if (Guard2.isIntegerBetween(stringNumber, 1, 6)) {
|
|
2623
2697
|
let fretId = note.chromaticId - tab.getTuningStrings()[stringNumber - 1].chromaticId;
|
|
2624
2698
|
let color = fretId < 0 ? "red" : "black";
|
|
2625
2699
|
let fretNumber = new ObjText(this, { text: String(fretId), color, bgcolor: "white" }, 0.5, 0.5);
|
|
2626
2700
|
fretNumber.layout(ctx);
|
|
2627
|
-
let x = this.col.getRect().
|
|
2701
|
+
let x = this.col.getRect().anchorX;
|
|
2628
2702
|
let y = tab.getStringY(stringNumber - 1);
|
|
2629
2703
|
fretNumber.offset(x, y);
|
|
2630
2704
|
obj.fretNumbers.push(fretNumber);
|
|
@@ -2633,16 +2707,17 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2633
2707
|
if (obj.fretNumbers.length > 0) {
|
|
2634
2708
|
this.tabObjects.push(obj);
|
|
2635
2709
|
tab.addObject(obj);
|
|
2710
|
+
this.measure.addStaticObject(tab, obj);
|
|
2636
2711
|
}
|
|
2637
2712
|
});
|
|
2638
2713
|
}
|
|
2639
2714
|
updateRect() {
|
|
2640
2715
|
if (this.staffObjects.length > 0) {
|
|
2641
|
-
this.rect = this.staffObjects[0].noteHeadRects[0].
|
|
2716
|
+
this.rect = this.staffObjects[0].noteHeadRects[0].clone();
|
|
2642
2717
|
} else if (this.tabObjects.length > 0 && this.tabObjects[0].fretNumbers.length > 0) {
|
|
2643
|
-
this.rect = this.tabObjects[0].fretNumbers[0].getRect().
|
|
2718
|
+
this.rect = this.tabObjects[0].fretNumbers[0].getRect().clone();
|
|
2644
2719
|
} else {
|
|
2645
|
-
this.rect = new
|
|
2720
|
+
this.rect = new AnchoredRect9();
|
|
2646
2721
|
return;
|
|
2647
2722
|
}
|
|
2648
2723
|
this.staffObjects.forEach((obj) => this.rect.expandInPlace(obj.getRect()));
|
|
@@ -2650,9 +2725,10 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2650
2725
|
}
|
|
2651
2726
|
setStemTipY(staff, stemTipY) {
|
|
2652
2727
|
let obj = this.staffObjects.find((obj2) => obj2.staff === staff);
|
|
2653
|
-
if (this.hasBeamCount() && (obj == null ? void 0 : obj.stemTip) && stemTipY !== obj.stemTip.
|
|
2654
|
-
obj.stemTip.top = obj.stemTip.
|
|
2728
|
+
if (this.hasBeamCount() && (obj == null ? void 0 : obj.stemTip) && stemTipY !== obj.stemTip.anchorY) {
|
|
2729
|
+
obj.stemTip.top = obj.stemTip.anchorY = obj.stemTip.bottom = stemTipY;
|
|
2655
2730
|
this.requestRectUpdate();
|
|
2731
|
+
this.col.requestRectUpdate();
|
|
2656
2732
|
}
|
|
2657
2733
|
}
|
|
2658
2734
|
offset(dx, dy) {
|
|
@@ -2672,31 +2748,31 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2672
2748
|
if (this.diamond) {
|
|
2673
2749
|
if (isSolidNoteHead) {
|
|
2674
2750
|
ctx.beginPath();
|
|
2675
|
-
ctx.moveTo(r.
|
|
2676
|
-
ctx.lineTo(r.right, r.
|
|
2677
|
-
ctx.lineTo(r.
|
|
2678
|
-
ctx.lineTo(r.left, r.
|
|
2679
|
-
ctx.lineTo(r.
|
|
2751
|
+
ctx.moveTo(r.anchorX, r.top);
|
|
2752
|
+
ctx.lineTo(r.right, r.anchorY);
|
|
2753
|
+
ctx.lineTo(r.anchorX, r.bottom);
|
|
2754
|
+
ctx.lineTo(r.left, r.anchorY);
|
|
2755
|
+
ctx.lineTo(r.anchorX, r.top);
|
|
2680
2756
|
ctx.fill();
|
|
2681
2757
|
} else {
|
|
2682
2758
|
ctx.beginPath();
|
|
2683
2759
|
ctx.lineWidth(2.5);
|
|
2684
|
-
ctx.moveTo(r.
|
|
2685
|
-
ctx.lineTo(r.right, r.
|
|
2686
|
-
ctx.moveTo(r.left, r.
|
|
2687
|
-
ctx.lineTo(r.
|
|
2760
|
+
ctx.moveTo(r.anchorX, r.top);
|
|
2761
|
+
ctx.lineTo(r.right, r.anchorY);
|
|
2762
|
+
ctx.moveTo(r.left, r.anchorY);
|
|
2763
|
+
ctx.lineTo(r.anchorX, r.bottom);
|
|
2688
2764
|
ctx.stroke();
|
|
2689
2765
|
ctx.beginPath();
|
|
2690
2766
|
ctx.lineWidth(1);
|
|
2691
|
-
ctx.moveTo(r.right, r.
|
|
2692
|
-
ctx.lineTo(r.
|
|
2693
|
-
ctx.moveTo(r.
|
|
2694
|
-
ctx.lineTo(r.left, r.
|
|
2767
|
+
ctx.moveTo(r.right, r.anchorY);
|
|
2768
|
+
ctx.lineTo(r.anchorX, r.bottom);
|
|
2769
|
+
ctx.moveTo(r.anchorX, r.top);
|
|
2770
|
+
ctx.lineTo(r.left, r.anchorY);
|
|
2695
2771
|
ctx.stroke();
|
|
2696
2772
|
}
|
|
2697
2773
|
} else {
|
|
2698
2774
|
ctx.beginPath();
|
|
2699
|
-
ctx.ellipse(r.
|
|
2775
|
+
ctx.ellipse(r.anchorX, r.anchorY, r.leftw, r.toph, -0.3, 0, Math.PI * 2);
|
|
2700
2776
|
if (isSolidNoteHead) {
|
|
2701
2777
|
ctx.fill();
|
|
2702
2778
|
} else {
|
|
@@ -2704,11 +2780,11 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2704
2780
|
}
|
|
2705
2781
|
}
|
|
2706
2782
|
});
|
|
2707
|
-
obj.dotRects.forEach((r) => ctx.fillCircle(r.
|
|
2783
|
+
obj.dotRects.forEach((r) => ctx.fillCircle(r.anchorX, r.anchorY, r.width / 2));
|
|
2708
2784
|
if (obj.stemTip && obj.stemBase) {
|
|
2709
2785
|
ctx.beginPath();
|
|
2710
|
-
ctx.moveTo(obj.stemBase.
|
|
2711
|
-
ctx.lineTo(obj.stemTip.
|
|
2786
|
+
ctx.moveTo(obj.stemBase.anchorX, obj.stemBase.anchorY);
|
|
2787
|
+
ctx.lineTo(obj.stemTip.anchorX, obj.stemTip.anchorY);
|
|
2712
2788
|
ctx.stroke();
|
|
2713
2789
|
}
|
|
2714
2790
|
obj.flagRects.forEach((rect) => ctx.drawFlag(rect, stemDir === "up" /* Up */ ? "up" : "down"));
|
|
@@ -2739,28 +2815,20 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2739
2815
|
|
|
2740
2816
|
// src/score/engine/obj-rhythm-column.ts
|
|
2741
2817
|
import { MusicError as MusicError7, MusicErrorType as MusicErrorType7 } from "@tspro/web-music-score/core";
|
|
2742
|
-
import {
|
|
2743
|
-
var noteHeadDataCompareFunc = (a, b) => {
|
|
2744
|
-
let cmp = Note5.compareFunc(a.note, b.note);
|
|
2745
|
-
if (cmp === 0) {
|
|
2746
|
-
cmp = a.noteGroup.stemDir === b.noteGroup.stemDir ? 0 : a.noteGroup.stemDir === "up" /* Up */ ? 1 : -1;
|
|
2747
|
-
}
|
|
2748
|
-
return cmp;
|
|
2749
|
-
};
|
|
2818
|
+
import { IndexArray, UniMap as UniMap2, TriMap, AnchoredRect as AnchoredRect10 } from "@tspro/ts-utils-lib";
|
|
2750
2819
|
var ObjRhythmColumn = class extends MusicObject {
|
|
2751
2820
|
constructor(measure, positionTicks) {
|
|
2752
2821
|
super(measure);
|
|
2753
2822
|
this.measure = measure;
|
|
2754
2823
|
this.positionTicks = positionTicks;
|
|
2755
|
-
__publicField(this, "voiceSymbol",
|
|
2756
|
-
__publicField(this, "lyricsObject", new
|
|
2824
|
+
__publicField(this, "voiceSymbol", new IndexArray());
|
|
2825
|
+
__publicField(this, "lyricsObject", new TriMap());
|
|
2757
2826
|
__publicField(this, "minDiatonicId");
|
|
2758
2827
|
__publicField(this, "maxDiatonicId");
|
|
2759
|
-
__publicField(this, "staffMinDiatonicId",
|
|
2760
|
-
__publicField(this, "staffMaxDiatonicId",
|
|
2828
|
+
__publicField(this, "staffMinDiatonicId", new UniMap2());
|
|
2829
|
+
__publicField(this, "staffMaxDiatonicId", new UniMap2());
|
|
2761
2830
|
__publicField(this, "arpeggioDir");
|
|
2762
2831
|
__publicField(this, "arpeggios", []);
|
|
2763
|
-
__publicField(this, "noteHeadDisplacements", []);
|
|
2764
2832
|
__publicField(this, "playerProps");
|
|
2765
2833
|
__publicField(this, "needLayout", true);
|
|
2766
2834
|
__publicField(this, "shapeRects", []);
|
|
@@ -2810,22 +2878,6 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
2810
2878
|
this.getRect();
|
|
2811
2879
|
return this.shapeRects;
|
|
2812
2880
|
}
|
|
2813
|
-
getStaticObjects(line) {
|
|
2814
|
-
let staticObjects = [];
|
|
2815
|
-
this.voiceSymbol.forEach((symbol) => {
|
|
2816
|
-
if (symbol) {
|
|
2817
|
-
symbol.getRect();
|
|
2818
|
-
symbol.getStaticObjects(line).forEach((obj) => staticObjects.push(obj));
|
|
2819
|
-
}
|
|
2820
|
-
});
|
|
2821
|
-
this.arpeggios.forEach((arpeggio) => {
|
|
2822
|
-
if (arpeggio.line === line) {
|
|
2823
|
-
arpeggio.getRect();
|
|
2824
|
-
staticObjects.push(arpeggio);
|
|
2825
|
-
}
|
|
2826
|
-
});
|
|
2827
|
-
return staticObjects;
|
|
2828
|
-
}
|
|
2829
2881
|
get doc() {
|
|
2830
2882
|
return this.measure.doc;
|
|
2831
2883
|
}
|
|
@@ -2833,12 +2885,22 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
2833
2885
|
return this.measure.row;
|
|
2834
2886
|
}
|
|
2835
2887
|
pick(x, y) {
|
|
2836
|
-
|
|
2837
|
-
|
|
2888
|
+
const thisContainsXY = this.getRect().contains(x, y);
|
|
2889
|
+
for (let i = 0; i < this.voiceSymbol.length; i++) {
|
|
2890
|
+
let sym = this.voiceSymbol.get(i);
|
|
2891
|
+
if (sym instanceof ObjRest) {
|
|
2892
|
+
let arr = sym.pick(x, y);
|
|
2893
|
+
if (arr.length > 0) {
|
|
2894
|
+
return thisContainsXY ? [this, ...arr] : arr;
|
|
2895
|
+
}
|
|
2896
|
+
}
|
|
2838
2897
|
}
|
|
2898
|
+
if (!thisContainsXY)
|
|
2899
|
+
return [];
|
|
2839
2900
|
for (let i = 0; i < this.voiceSymbol.length; i++) {
|
|
2840
|
-
|
|
2841
|
-
|
|
2901
|
+
let sym = this.voiceSymbol.get(i);
|
|
2902
|
+
if (sym instanceof ObjNoteGroup) {
|
|
2903
|
+
let arr = sym.pick(x, y);
|
|
2842
2904
|
if (arr.length > 0) {
|
|
2843
2905
|
return [this, ...arr];
|
|
2844
2906
|
}
|
|
@@ -2861,7 +2923,7 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
2861
2923
|
}
|
|
2862
2924
|
setVoiceSymbol(voiceId, symbol) {
|
|
2863
2925
|
validateVoiceId(voiceId);
|
|
2864
|
-
this.voiceSymbol
|
|
2926
|
+
this.voiceSymbol.set(voiceId, symbol);
|
|
2865
2927
|
if (symbol instanceof ObjRest && !symbol.hide) {
|
|
2866
2928
|
this.row.getStaves().forEach((staff) => {
|
|
2867
2929
|
let diatonicId = symbol.getDiatonicId(staff);
|
|
@@ -2874,13 +2936,13 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
2874
2936
|
if (symbol.arpeggio !== void 0) {
|
|
2875
2937
|
this.arpeggioDir = symbol.arpeggio;
|
|
2876
2938
|
}
|
|
2877
|
-
this.
|
|
2939
|
+
this.updateNoteDisplacements();
|
|
2878
2940
|
}
|
|
2879
2941
|
this.requestLayout();
|
|
2880
2942
|
this.requestRectUpdate();
|
|
2881
2943
|
}
|
|
2882
2944
|
getVoiceSymbol(voiceId) {
|
|
2883
|
-
return this.voiceSymbol
|
|
2945
|
+
return this.voiceSymbol.get(voiceId);
|
|
2884
2946
|
}
|
|
2885
2947
|
getLyricsObject(verse, line, vpos) {
|
|
2886
2948
|
return this.lyricsObject.get(verse, line, vpos);
|
|
@@ -2888,73 +2950,50 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
2888
2950
|
addLyricsObject(lyricsObj) {
|
|
2889
2951
|
this.lyricsObject.set(lyricsObj.verse, lyricsObj.line, lyricsObj.vpos, lyricsObj);
|
|
2890
2952
|
}
|
|
2891
|
-
|
|
2892
|
-
let
|
|
2893
|
-
let w = DocumentSettings.NoteHeadWidth;
|
|
2894
|
-
switch (maxNoteSize) {
|
|
2895
|
-
case 1:
|
|
2896
|
-
return w * 5;
|
|
2897
|
-
// whole note
|
|
2898
|
-
case 2:
|
|
2899
|
-
return w * 3;
|
|
2900
|
-
// half note
|
|
2901
|
-
case 4:
|
|
2902
|
-
return w * 2;
|
|
2903
|
-
// quarter note
|
|
2904
|
-
default:
|
|
2905
|
-
return w;
|
|
2906
|
-
}
|
|
2907
|
-
}
|
|
2908
|
-
setupNoteHeadDisplacements() {
|
|
2909
|
-
this.noteHeadDisplacements = [];
|
|
2953
|
+
updateNoteDisplacements() {
|
|
2954
|
+
let data = [];
|
|
2910
2955
|
this.voiceSymbol.forEach((symbol) => {
|
|
2911
2956
|
if (symbol instanceof ObjNoteGroup) {
|
|
2912
2957
|
symbol.notes.forEach((note) => {
|
|
2913
|
-
|
|
2958
|
+
symbol.setNoteDisplacement(note, false);
|
|
2959
|
+
data.push({ noteGroup: symbol, note });
|
|
2914
2960
|
});
|
|
2915
2961
|
}
|
|
2916
2962
|
});
|
|
2917
|
-
|
|
2918
|
-
|
|
2963
|
+
const noteHeadDataCompareFunc = (a, b) => {
|
|
2964
|
+
let cmp = Note5.compareFunc(a.note, b.note);
|
|
2965
|
+
return cmp === 0 ? a.noteGroup.stemDir === b.noteGroup.stemDir ? 0 : a.noteGroup.stemDir === "up" /* Up */ ? 1 : -1 : cmp;
|
|
2966
|
+
};
|
|
2967
|
+
data.sort(noteHeadDataCompareFunc);
|
|
2968
|
+
if (data.length < 2) {
|
|
2919
2969
|
return;
|
|
2920
2970
|
}
|
|
2921
|
-
for (let i = 0; i <
|
|
2922
|
-
let cur =
|
|
2923
|
-
let next =
|
|
2971
|
+
for (let i = 0; i < data.length; i++) {
|
|
2972
|
+
let cur = data[i];
|
|
2973
|
+
let next = data[i + 1];
|
|
2924
2974
|
if (next && cur.note.diatonicId === next.note.diatonicId) {
|
|
2925
|
-
cur.
|
|
2926
|
-
}
|
|
2927
|
-
}
|
|
2928
|
-
for (let i = 0; i <
|
|
2929
|
-
let prev =
|
|
2930
|
-
let cur =
|
|
2931
|
-
let next =
|
|
2932
|
-
if (cur.
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
} else if (next && next.note.diatonicId - cur.note.diatonicId <= 1) {
|
|
2939
|
-
cur.displacement = next.displacement === 0 ? d : 0;
|
|
2975
|
+
cur.isDisplaced = next.isDisplaced = false;
|
|
2976
|
+
}
|
|
2977
|
+
}
|
|
2978
|
+
for (let i = 0; i < data.length; i++) {
|
|
2979
|
+
let prev = data[i - 1];
|
|
2980
|
+
let cur = data[i];
|
|
2981
|
+
let next = data[i + 1];
|
|
2982
|
+
if (cur.isDisplaced === void 0) {
|
|
2983
|
+
if (prev && cur.note.diatonicId - prev.note.diatonicId <= 1) {
|
|
2984
|
+
cur.isDisplaced = !prev.isDisplaced;
|
|
2985
|
+
} else if (next && next.note.diatonicId - cur.note.diatonicId <= 1) {
|
|
2986
|
+
cur.isDisplaced = !next.isDisplaced;
|
|
2987
|
+
}
|
|
2940
2988
|
}
|
|
2941
2989
|
}
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
return data.displacement;
|
|
2947
|
-
} else {
|
|
2948
|
-
return 0;
|
|
2949
|
-
}
|
|
2990
|
+
data.forEach((el) => {
|
|
2991
|
+
var _a;
|
|
2992
|
+
return el.noteGroup.setNoteDisplacement(el.note, (_a = el.isDisplaced) != null ? _a : false);
|
|
2993
|
+
});
|
|
2950
2994
|
}
|
|
2951
2995
|
isEmpty() {
|
|
2952
|
-
|
|
2953
|
-
if (this.voiceSymbol[i] !== void 0 && !this.voiceSymbol[i].isEmpty()) {
|
|
2954
|
-
return false;
|
|
2955
|
-
}
|
|
2956
|
-
}
|
|
2957
|
-
return true;
|
|
2996
|
+
return this.voiceSymbol.size === 0 || this.voiceSymbol.every((symbol) => symbol.isEmpty());
|
|
2958
2997
|
}
|
|
2959
2998
|
getPlayerNotes() {
|
|
2960
2999
|
let playerNotes = [];
|
|
@@ -3001,13 +3040,9 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3001
3040
|
if (!this.needLayout) {
|
|
3002
3041
|
return;
|
|
3003
3042
|
}
|
|
3004
|
-
this.requestRectUpdate();
|
|
3005
|
-
this.rect = new DivRect();
|
|
3006
3043
|
let { row } = this;
|
|
3007
|
-
let
|
|
3008
|
-
let
|
|
3009
|
-
let leftw = halfMinWidth;
|
|
3010
|
-
let rightw = halfMinWidth;
|
|
3044
|
+
let leftw = 0;
|
|
3045
|
+
let rightw = 0;
|
|
3011
3046
|
this.voiceSymbol.forEach((symbol) => {
|
|
3012
3047
|
symbol.layout(ctx, accState);
|
|
3013
3048
|
let r = symbol.getRect();
|
|
@@ -3015,30 +3050,28 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3015
3050
|
rightw = Math.max(rightw, r.rightw);
|
|
3016
3051
|
});
|
|
3017
3052
|
if (this.arpeggioDir !== void 0) {
|
|
3018
|
-
|
|
3019
|
-
this.arpeggios
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
return arpeggio;
|
|
3053
|
+
this.arpeggios = row.getNotationLines().map((line) => new ObjArpeggio(this, line, this.getArpeggioDir()));
|
|
3054
|
+
this.arpeggios.forEach((a) => a.layout(ctx));
|
|
3055
|
+
const arpeggioWidth = this.arpeggios.map((a) => a.getRect().width).reduce((accState2, cur) => Math.max(accState2, cur)) + ctx.unitSize;
|
|
3056
|
+
this.arpeggios.forEach((a) => {
|
|
3057
|
+
a.offset(-leftw - arpeggioWidth + a.getRect().leftw, a.line.getRect().anchorY - a.getRect().anchorY);
|
|
3058
|
+
a.line.addObject(a);
|
|
3059
|
+
this.measure.addStaticObject(a.line, a);
|
|
3026
3060
|
});
|
|
3027
3061
|
leftw += arpeggioWidth;
|
|
3028
3062
|
} else {
|
|
3029
3063
|
this.arpeggios = [];
|
|
3030
3064
|
}
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3065
|
+
const noteSizes = this.voiceSymbol.mapToArray((s) => s.rhythmProps.noteSize);
|
|
3066
|
+
const maxNoteSize = Math.min(8, Math.max(1, ...noteSizes));
|
|
3067
|
+
const MinColumnWidth = Math.ceil(8 / maxNoteSize) * DocumentSettings.NoteHeadWidth * ctx.unitSize * 0.75;
|
|
3068
|
+
leftw = Math.max(leftw, MinColumnWidth / 2);
|
|
3069
|
+
rightw = Math.max(rightw, MinColumnWidth / 2);
|
|
3070
|
+
leftw *= DocumentSettings.ColumnWidthScale;
|
|
3071
|
+
rightw *= DocumentSettings.ColumnWidthScale;
|
|
3072
|
+
this.rect = new AnchoredRect10(-leftw, 0, rightw, 0, 0, 0);
|
|
3073
|
+
this.requestRectUpdate();
|
|
3038
3074
|
this.voiceSymbol.forEach((symbol) => symbol.updateAccidentalState(accState));
|
|
3039
|
-
this.rect.left = -leftw;
|
|
3040
|
-
this.rect.centerX = 0;
|
|
3041
|
-
this.rect.right = rightw;
|
|
3042
3075
|
this.row.getStaves().forEach((staff) => {
|
|
3043
3076
|
let minDiatonicId = void 0;
|
|
3044
3077
|
let maxDiatonicId = void 0;
|
|
@@ -3066,20 +3099,56 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3066
3099
|
}
|
|
3067
3100
|
});
|
|
3068
3101
|
}
|
|
3102
|
+
layoutReserveSpace(ctx) {
|
|
3103
|
+
const columns = this.measure.getColumns();
|
|
3104
|
+
const extraSpace = ctx.unitSize;
|
|
3105
|
+
this.getAnchoredLayoutObjects().forEach((obj) => {
|
|
3106
|
+
if (obj.layoutGroup.reserveSpace) {
|
|
3107
|
+
const i = columns.indexOf(this);
|
|
3108
|
+
if (i < 0) return;
|
|
3109
|
+
const leftOverflow = obj.getRect().leftw - this.getRect().leftw;
|
|
3110
|
+
if (leftOverflow > 0) {
|
|
3111
|
+
const prevCol = columns[i - 1];
|
|
3112
|
+
if (prevCol) {
|
|
3113
|
+
prevCol.getAnchoredLayoutObjects().forEach((prevObj) => {
|
|
3114
|
+
if (prevObj.layoutGroupId === obj.layoutGroupId) {
|
|
3115
|
+
const rightOverflow2 = prevObj.getRect().rightw - prevCol.getRect().rightw;
|
|
3116
|
+
this.rect.left -= Math.max(rightOverflow2 + leftOverflow, 0) + extraSpace;
|
|
3117
|
+
this.requestRectUpdate();
|
|
3118
|
+
}
|
|
3119
|
+
});
|
|
3120
|
+
}
|
|
3121
|
+
}
|
|
3122
|
+
const rightOverflow = obj.getRect().rightw - this.getRect().rightw;
|
|
3123
|
+
if (rightOverflow > 0) {
|
|
3124
|
+
const nextCol = columns[i + 1];
|
|
3125
|
+
if (nextCol) {
|
|
3126
|
+
nextCol.getAnchoredLayoutObjects().forEach((nextObj) => {
|
|
3127
|
+
if (nextObj.layoutGroupId === obj.layoutGroupId) {
|
|
3128
|
+
const leftOverflow2 = nextObj.getRect().leftw - nextCol.getRect().leftw;
|
|
3129
|
+
this.rect.right += Math.max(rightOverflow + leftOverflow2, 0) + extraSpace;
|
|
3130
|
+
this.requestRectUpdate();
|
|
3131
|
+
}
|
|
3132
|
+
});
|
|
3133
|
+
}
|
|
3134
|
+
}
|
|
3135
|
+
}
|
|
3136
|
+
});
|
|
3137
|
+
}
|
|
3069
3138
|
layoutDone() {
|
|
3070
3139
|
this.needLayout = false;
|
|
3071
3140
|
}
|
|
3072
3141
|
updateRect() {
|
|
3073
3142
|
this.shapeRects = [
|
|
3074
|
-
...this.voiceSymbol.filter((s) =>
|
|
3075
|
-
...this.arpeggios.map((a) => a.getRect().
|
|
3143
|
+
...this.voiceSymbol.filter((s) => s !== void 0).mapToArray((s) => s.getRect().clone()),
|
|
3144
|
+
...this.arpeggios.map((a) => a.getRect().clone())
|
|
3076
3145
|
];
|
|
3077
3146
|
this.rect.top = Math.min(...this.shapeRects.map((r) => r.top));
|
|
3078
3147
|
this.rect.bottom = Math.max(...this.shapeRects.map((r) => r.bottom));
|
|
3079
|
-
this.rect.
|
|
3148
|
+
this.rect.anchorY = (this.rect.top + this.rect.bottom) / 2;
|
|
3080
3149
|
}
|
|
3081
3150
|
offset(dx, dy) {
|
|
3082
|
-
this.voiceSymbol.forEach((symbol) => symbol
|
|
3151
|
+
this.voiceSymbol.forEach((symbol) => symbol.offset(dx, 0));
|
|
3083
3152
|
this.arpeggios.forEach((arpeggio) => arpeggio.offset(dx, 0));
|
|
3084
3153
|
this.shapeRects.forEach((r) => r.offsetInPlace(dx, dy));
|
|
3085
3154
|
this.rect.offsetInPlace(dx, dy);
|
|
@@ -3089,17 +3158,13 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3089
3158
|
let minDiatonicId = this.staffMinDiatonicId.get(staff);
|
|
3090
3159
|
let maxDiatonicId = this.staffMaxDiatonicId.get(staff);
|
|
3091
3160
|
if (minDiatonicId !== void 0) {
|
|
3092
|
-
ctx.drawLedgerLines(staff, minDiatonicId, this.getRect().
|
|
3161
|
+
ctx.drawLedgerLines(staff, minDiatonicId, this.getRect().anchorX);
|
|
3093
3162
|
}
|
|
3094
3163
|
if (maxDiatonicId !== void 0) {
|
|
3095
|
-
ctx.drawLedgerLines(staff, maxDiatonicId, this.getRect().
|
|
3096
|
-
}
|
|
3097
|
-
});
|
|
3098
|
-
this.voiceSymbol.forEach((symbol) => {
|
|
3099
|
-
if (symbol) {
|
|
3100
|
-
symbol.draw(ctx);
|
|
3164
|
+
ctx.drawLedgerLines(staff, maxDiatonicId, this.getRect().anchorX);
|
|
3101
3165
|
}
|
|
3102
3166
|
});
|
|
3167
|
+
this.voiceSymbol.forEach((symbol) => symbol.draw(ctx));
|
|
3103
3168
|
this.arpeggios.forEach((arpeggio) => arpeggio.draw(ctx));
|
|
3104
3169
|
}
|
|
3105
3170
|
};
|
|
@@ -3108,9 +3173,10 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3108
3173
|
import { MusicError as MusicError8, MusicErrorType as MusicErrorType8 } from "@tspro/web-music-score/core";
|
|
3109
3174
|
|
|
3110
3175
|
// src/score/engine/element-data.ts
|
|
3111
|
-
import { Utils as Utils4 } from "@tspro/ts-utils-lib";
|
|
3176
|
+
import { Guard as Guard3, Utils as Utils4 } from "@tspro/ts-utils-lib";
|
|
3112
3177
|
|
|
3113
3178
|
// src/score/engine/obj-special-text.ts
|
|
3179
|
+
import { AnchoredRect as AnchoredRect11 } from "@tspro/ts-utils-lib";
|
|
3114
3180
|
var _ObjSpecialText = class _ObjSpecialText extends MusicObject {
|
|
3115
3181
|
constructor(parent, text) {
|
|
3116
3182
|
super(parent);
|
|
@@ -3155,14 +3221,14 @@ var _ObjSpecialText = class _ObjSpecialText extends MusicObject {
|
|
|
3155
3221
|
let codaText = this.components[1];
|
|
3156
3222
|
codaSym.layout(ctx);
|
|
3157
3223
|
codaText.layout(ctx);
|
|
3158
|
-
codaSym.offset(0,
|
|
3224
|
+
codaSym.offset(0, codaText.getRect().centerY);
|
|
3159
3225
|
codaText.offset(codaSym.getRect().right, 0);
|
|
3160
|
-
this.rect = new
|
|
3226
|
+
this.rect = new AnchoredRect11(
|
|
3161
3227
|
codaSym.getRect().left,
|
|
3162
|
-
codaSym.getRect().
|
|
3228
|
+
codaSym.getRect().anchorX,
|
|
3163
3229
|
codaText.getRect().right,
|
|
3164
3230
|
codaText.getRect().top,
|
|
3165
|
-
codaText.getRect().
|
|
3231
|
+
codaText.getRect().anchorY,
|
|
3166
3232
|
codaText.getRect().bottom
|
|
3167
3233
|
);
|
|
3168
3234
|
break;
|
|
@@ -3172,14 +3238,14 @@ var _ObjSpecialText = class _ObjSpecialText extends MusicObject {
|
|
|
3172
3238
|
let codaSym = this.components[1];
|
|
3173
3239
|
toCodaText.layout(ctx);
|
|
3174
3240
|
codaSym.layout(ctx);
|
|
3175
|
-
codaSym.offset(0,
|
|
3241
|
+
codaSym.offset(0, toCodaText.getRect().centerY);
|
|
3176
3242
|
toCodaText.offset(codaSym.getRect().left, 0);
|
|
3177
|
-
this.rect = new
|
|
3243
|
+
this.rect = new AnchoredRect11(
|
|
3178
3244
|
toCodaText.getRect().left,
|
|
3179
|
-
codaSym.getRect().
|
|
3245
|
+
codaSym.getRect().anchorX,
|
|
3180
3246
|
codaSym.getRect().right,
|
|
3181
3247
|
toCodaText.getRect().top,
|
|
3182
|
-
toCodaText.getRect().
|
|
3248
|
+
toCodaText.getRect().anchorY,
|
|
3183
3249
|
toCodaText.getRect().bottom
|
|
3184
3250
|
);
|
|
3185
3251
|
break;
|
|
@@ -3187,7 +3253,7 @@ var _ObjSpecialText = class _ObjSpecialText extends MusicObject {
|
|
|
3187
3253
|
default: {
|
|
3188
3254
|
let text = this.components[0];
|
|
3189
3255
|
text.layout(ctx);
|
|
3190
|
-
this.rect = text.getRect().
|
|
3256
|
+
this.rect = text.getRect().clone();
|
|
3191
3257
|
break;
|
|
3192
3258
|
}
|
|
3193
3259
|
}
|
|
@@ -3230,7 +3296,7 @@ function getNavigationString(navigation) {
|
|
|
3230
3296
|
}
|
|
3231
3297
|
}
|
|
3232
3298
|
function isDynamicsText(text) {
|
|
3233
|
-
return
|
|
3299
|
+
return Guard3.isEnumValue(text, DynamicsAnnotation);
|
|
3234
3300
|
}
|
|
3235
3301
|
function getDynamicsVolume(text) {
|
|
3236
3302
|
if (/^(p+|f+|m|mp|mf)$/.test(text)) {
|
|
@@ -3241,12 +3307,12 @@ function getDynamicsVolume(text) {
|
|
|
3241
3307
|
}
|
|
3242
3308
|
}
|
|
3243
3309
|
function isTempoText(text) {
|
|
3244
|
-
return
|
|
3310
|
+
return Guard3.isEnumValue(text, TempoAnnotation);
|
|
3245
3311
|
}
|
|
3246
3312
|
function getAnnotation(text) {
|
|
3247
|
-
if (
|
|
3313
|
+
if (Guard3.isEnumValue(text, DynamicsAnnotation)) {
|
|
3248
3314
|
return "dynamics" /* Dynamics */;
|
|
3249
|
-
} else if (
|
|
3315
|
+
} else if (Guard3.isEnumValue(text, TempoAnnotation)) {
|
|
3250
3316
|
return "tempo" /* Tempo */;
|
|
3251
3317
|
} else {
|
|
3252
3318
|
return void 0;
|
|
@@ -3550,24 +3616,17 @@ var Player = class _Player {
|
|
|
3550
3616
|
}
|
|
3551
3617
|
let curSpeed = 1;
|
|
3552
3618
|
let curVolume = getDefaultVolume();
|
|
3553
|
-
let speedMap =
|
|
3554
|
-
let volumeMap =
|
|
3555
|
-
const pushSpeed = (col, speed) =>
|
|
3556
|
-
|
|
3557
|
-
return speedMap.set(col, [...(_a = speedMap.get(col)) != null ? _a : [], speed]);
|
|
3558
|
-
};
|
|
3559
|
-
const pushVolume = (col, volume) => {
|
|
3560
|
-
var _a;
|
|
3561
|
-
return volumeMap.set(col, [...(_a = volumeMap.get(col)) != null ? _a : [], volume]);
|
|
3562
|
-
};
|
|
3619
|
+
let speedMap = new UniMap3();
|
|
3620
|
+
let volumeMap = new UniMap3();
|
|
3621
|
+
const pushSpeed = (col, speed) => speedMap.getOrCreate(col, []).push(speed);
|
|
3622
|
+
const pushVolume = (col, volume) => volumeMap.getOrCreate(col, []).push(volume);
|
|
3563
3623
|
this.playerColumnSequence.forEach((col) => {
|
|
3564
|
-
var _a, _b;
|
|
3565
3624
|
if (!(col instanceof ObjRhythmColumn)) {
|
|
3566
3625
|
return;
|
|
3567
3626
|
}
|
|
3568
3627
|
col.getAnchoredLayoutObjects().forEach((layoutObj) => {
|
|
3569
|
-
var
|
|
3570
|
-
let text = (
|
|
3628
|
+
var _a;
|
|
3629
|
+
let text = (_a = layoutObj.getTextContent()) != null ? _a : "";
|
|
3571
3630
|
let vol;
|
|
3572
3631
|
if (text === "a tempo" /* a_tempo */) {
|
|
3573
3632
|
curSpeed = 1;
|
|
@@ -3628,11 +3687,11 @@ var Player = class _Player {
|
|
|
3628
3687
|
}
|
|
3629
3688
|
}
|
|
3630
3689
|
});
|
|
3631
|
-
let speedArr =
|
|
3690
|
+
let speedArr = speedMap.getOrDefault(col, []);
|
|
3632
3691
|
if (speedArr.length > 0) {
|
|
3633
3692
|
curSpeed = Utils5.Math.sum(speedArr) / speedArr.length;
|
|
3634
3693
|
}
|
|
3635
|
-
let volumeArr =
|
|
3694
|
+
let volumeArr = volumeMap.getOrDefault(col, []);
|
|
3636
3695
|
if (volumeArr.length > 0) {
|
|
3637
3696
|
curVolume = Utils5.Math.sum(volumeArr) / volumeArr.length;
|
|
3638
3697
|
}
|
|
@@ -3752,14 +3811,14 @@ var Player = class _Player {
|
|
|
3752
3811
|
return void 0;
|
|
3753
3812
|
}
|
|
3754
3813
|
let measure = col.measure;
|
|
3755
|
-
let x = col.getRect().
|
|
3756
|
-
let top = measure.row.getRect()
|
|
3757
|
-
|
|
3758
|
-
return new DivRect(x, x, top, bottom);
|
|
3814
|
+
let x = col.getRect().anchorX;
|
|
3815
|
+
let { top, height } = measure.row.getRect();
|
|
3816
|
+
return new Rect2(x, top, 0, height);
|
|
3759
3817
|
}
|
|
3760
3818
|
};
|
|
3761
3819
|
|
|
3762
3820
|
// src/score/engine/obj-bar-line.ts
|
|
3821
|
+
import { AnchoredRect as AnchoredRect13 } from "@tspro/ts-utils-lib";
|
|
3763
3822
|
var ObjStaffTabBarLine = class extends MusicObject {
|
|
3764
3823
|
constructor(barLine, line) {
|
|
3765
3824
|
super(line);
|
|
@@ -3846,36 +3905,36 @@ var ObjBarLine = class extends MusicObject {
|
|
|
3846
3905
|
bottom = line.getBottomLineY();
|
|
3847
3906
|
switch (barLineType) {
|
|
3848
3907
|
case 0 /* None */:
|
|
3849
|
-
obj.setRect(new
|
|
3908
|
+
obj.setRect(new AnchoredRect13(0, 0, 0, top, 0, bottom));
|
|
3850
3909
|
break;
|
|
3851
3910
|
case 1 /* Single */:
|
|
3852
|
-
obj.setRect(new
|
|
3911
|
+
obj.setRect(new AnchoredRect13(-thinW, 0, 0, top, 0, bottom));
|
|
3853
3912
|
addVerticalLine(-thinW, thinW);
|
|
3854
3913
|
break;
|
|
3855
3914
|
case 2 /* Double */:
|
|
3856
|
-
obj.setRect(new
|
|
3915
|
+
obj.setRect(new AnchoredRect13(-thinW - spaceW - thinW, 0, 0, top, 0, bottom));
|
|
3857
3916
|
addVerticalLine(-thinW - spaceW - thinW, thinW);
|
|
3858
3917
|
addVerticalLine(-thinW, thinW);
|
|
3859
3918
|
break;
|
|
3860
3919
|
case 3 /* EndSong */:
|
|
3861
|
-
obj.setRect(new
|
|
3920
|
+
obj.setRect(new AnchoredRect13(-thicW - spaceW - thinW, 0, 0, top, 0, bottom));
|
|
3862
3921
|
addVerticalLine(-thinW - spaceW - thicW, thinW);
|
|
3863
3922
|
addVerticalLine(-thicW, thicW);
|
|
3864
3923
|
break;
|
|
3865
3924
|
case 4 /* StartRepeat */:
|
|
3866
|
-
obj.setRect(new
|
|
3925
|
+
obj.setRect(new AnchoredRect13(0, 0, thicW + spaceW + thinW + spaceW + dotW, top, 0, bottom));
|
|
3867
3926
|
addVerticalLine(0, thicW);
|
|
3868
3927
|
addVerticalLine(thicW + spaceW, thinW);
|
|
3869
3928
|
addDotPair(thicW + spaceW + thinW + spaceW + dotRadius);
|
|
3870
3929
|
break;
|
|
3871
3930
|
case 5 /* EndRepeat */:
|
|
3872
|
-
obj.setRect(new
|
|
3931
|
+
obj.setRect(new AnchoredRect13(-thicW - spaceW - thinW - spaceW - dotW, 0, 0, top, 0, bottom));
|
|
3873
3932
|
addVerticalLine(-thinW - spaceW - thicW, thinW);
|
|
3874
3933
|
addVerticalLine(-thicW, thicW);
|
|
3875
3934
|
addDotPair(-thinW - spaceW - thicW - spaceW - dotRadius);
|
|
3876
3935
|
break;
|
|
3877
3936
|
case 6 /* EndStartRepeat */:
|
|
3878
|
-
obj.setRect(new
|
|
3937
|
+
obj.setRect(new AnchoredRect13(-dotW - spaceW - thinW - spaceW - thicW / 2, 0, thicW / 2 + spaceW + thinW + spaceW + dotW, top, 0, bottom));
|
|
3879
3938
|
addVerticalLine(-thicW / 2, thicW);
|
|
3880
3939
|
addVerticalLine(-thicW / 2 - spaceW - thinW, thinW);
|
|
3881
3940
|
addVerticalLine(thicW / 2 + spaceW, thinW);
|
|
@@ -3891,12 +3950,12 @@ var ObjBarLine = class extends MusicObject {
|
|
|
3891
3950
|
}
|
|
3892
3951
|
updateRect() {
|
|
3893
3952
|
if (this.staffTabObjects.length > 0) {
|
|
3894
|
-
this.rect = this.staffTabObjects[0].getRect().
|
|
3953
|
+
this.rect = this.staffTabObjects[0].getRect().clone();
|
|
3895
3954
|
for (let i = 1; i < this.staffTabObjects.length; i++) {
|
|
3896
3955
|
this.rect.expandInPlace(this.staffTabObjects[i].getRect());
|
|
3897
3956
|
}
|
|
3898
3957
|
} else {
|
|
3899
|
-
this.rect = new
|
|
3958
|
+
this.rect = new AnchoredRect13();
|
|
3900
3959
|
}
|
|
3901
3960
|
}
|
|
3902
3961
|
offset(dx, dy) {
|
|
@@ -3981,7 +4040,7 @@ var ObjBarLineRight = class extends ObjBarLine {
|
|
|
3981
4040
|
};
|
|
3982
4041
|
|
|
3983
4042
|
// src/score/engine/obj-ending.ts
|
|
3984
|
-
import {
|
|
4043
|
+
import { AnchoredRect as AnchoredRect14, Guard as Guard4 } from "@tspro/ts-utils-lib";
|
|
3985
4044
|
import { MusicError as MusicError9, MusicErrorType as MusicErrorType9 } from "@tspro/web-music-score/core";
|
|
3986
4045
|
var ObjEnding = class extends MusicObject {
|
|
3987
4046
|
constructor(measure, passages) {
|
|
@@ -3992,9 +4051,9 @@ var ObjEnding = class extends MusicObject {
|
|
|
3992
4051
|
__publicField(this, "shapeRects", []);
|
|
3993
4052
|
__publicField(this, "mi");
|
|
3994
4053
|
this.mi = new MEnding(this);
|
|
3995
|
-
if (!
|
|
4054
|
+
if (!Guard4.isIntegerGte(passages.length, 1)) {
|
|
3996
4055
|
throw new MusicError9(MusicErrorType9.Score, "Passages is empty.");
|
|
3997
|
-
} else if (!this.passages.every((p) =>
|
|
4056
|
+
} else if (!this.passages.every((p) => Guard4.isIntegerGte(p, 1))) {
|
|
3998
4057
|
throw new MusicError9(MusicErrorType9.Score, "Invalid passages: " + this.passages);
|
|
3999
4058
|
}
|
|
4000
4059
|
this.passages.sort((a, b) => a - b);
|
|
@@ -4022,8 +4081,8 @@ var ObjEnding = class extends MusicObject {
|
|
|
4022
4081
|
return this.rect.contains(x, y) ? [this] : [];
|
|
4023
4082
|
}
|
|
4024
4083
|
layout(ctx) {
|
|
4025
|
-
this.rect = new
|
|
4026
|
-
this.shapeRects = [this.rect.
|
|
4084
|
+
this.rect = new AnchoredRect14();
|
|
4085
|
+
this.shapeRects = [this.rect.clone()];
|
|
4027
4086
|
}
|
|
4028
4087
|
layoutFitToMeasure(ctx) {
|
|
4029
4088
|
let { unitSize } = ctx;
|
|
@@ -4032,13 +4091,13 @@ var ObjEnding = class extends MusicObject {
|
|
|
4032
4091
|
let textRect = this.endingText.getRect();
|
|
4033
4092
|
let measureContent = measure.getColumnsContentRect();
|
|
4034
4093
|
let endingHeight = textRect.height;
|
|
4035
|
-
this.rect = new
|
|
4094
|
+
this.rect = new AnchoredRect14(measureContent.left + unitSize, measureContent.right - unitSize, -endingHeight, 0);
|
|
4036
4095
|
this.endingText.offset(this.rect.left + unitSize / 2, this.rect.bottom);
|
|
4037
4096
|
this.shapeRects = [
|
|
4038
|
-
new
|
|
4039
|
-
new
|
|
4040
|
-
new
|
|
4041
|
-
this.endingText.getRect().
|
|
4097
|
+
new AnchoredRect14(this.rect.left, this.rect.left + 1, this.rect.top, this.rect.bottom),
|
|
4098
|
+
new AnchoredRect14(this.rect.left, this.rect.right, this.rect.top, this.rect.top + 1),
|
|
4099
|
+
new AnchoredRect14(this.rect.right - 1, this.rect.right, this.rect.top, this.rect.bottom),
|
|
4100
|
+
this.endingText.getRect().clone()
|
|
4042
4101
|
];
|
|
4043
4102
|
}
|
|
4044
4103
|
offset(dx, dy) {
|
|
@@ -4063,7 +4122,7 @@ var ObjEnding = class extends MusicObject {
|
|
|
4063
4122
|
};
|
|
4064
4123
|
|
|
4065
4124
|
// src/score/engine/obj-beam-group.ts
|
|
4066
|
-
import { Utils as
|
|
4125
|
+
import { AnchoredRect as AnchoredRect15, Utils as Utils6 } from "@tspro/ts-utils-lib";
|
|
4067
4126
|
import { NoteLength as NoteLength5, Tuplet as Tuplet3, NoteLengthProps as NoteLengthProps4 } from "@tspro/web-music-score/theory";
|
|
4068
4127
|
import { MusicError as MusicError10, MusicErrorType as MusicErrorType10 } from "@tspro/web-music-score/core";
|
|
4069
4128
|
var adjustBeamAngle = (dx, dy) => {
|
|
@@ -4093,7 +4152,7 @@ var BeamPoint = class {
|
|
|
4093
4152
|
this.beamGroup.requestRectUpdate();
|
|
4094
4153
|
}
|
|
4095
4154
|
getRect() {
|
|
4096
|
-
return new
|
|
4155
|
+
return new AnchoredRect15(this.x, this.x, this.x, this.y - this.topBeamsHeight, this.y, this.y + this.bottomBeamsHeight);
|
|
4097
4156
|
}
|
|
4098
4157
|
};
|
|
4099
4158
|
var ObjStaffBeamGroup = class extends MusicObject {
|
|
@@ -4123,9 +4182,9 @@ var ObjStaffBeamGroup = class extends MusicObject {
|
|
|
4123
4182
|
}
|
|
4124
4183
|
updateRect() {
|
|
4125
4184
|
if (this.points.length > 0) {
|
|
4126
|
-
this.rect = this.points[0].getRect().
|
|
4185
|
+
this.rect = this.points[0].getRect().clone();
|
|
4127
4186
|
} else if (this.tupletNumber) {
|
|
4128
|
-
this.rect = this.tupletNumber.getRect().
|
|
4187
|
+
this.rect = this.tupletNumber.getRect().clone();
|
|
4129
4188
|
}
|
|
4130
4189
|
this.points.forEach((pt) => this.rect.expandInPlace(pt.getRect()));
|
|
4131
4190
|
if (this.tupletNumber) {
|
|
@@ -4371,7 +4430,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
|
|
|
4371
4430
|
symbolY.forEach((symY, i) => {
|
|
4372
4431
|
let symX = symbolX[i];
|
|
4373
4432
|
if (symX !== void 0 && symY !== void 0) {
|
|
4374
|
-
let beamY =
|
|
4433
|
+
let beamY = Utils6.Math.interpolateY(leftX, leftY, rightX, rightY, symX);
|
|
4375
4434
|
let raiseY = symY - beamY;
|
|
4376
4435
|
if (stemDir === "up" /* Up */ && raiseY < 0) {
|
|
4377
4436
|
raiseBeamY = Math.min(raiseBeamY, raiseY);
|
|
@@ -4386,8 +4445,8 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
|
|
|
4386
4445
|
let obj = new ObjStaffBeamGroup(mainStaff, this);
|
|
4387
4446
|
if (type === 2 /* TupletGroup */) {
|
|
4388
4447
|
let ef = unitSize / (rightX - leftX);
|
|
4389
|
-
let l =
|
|
4390
|
-
let r =
|
|
4448
|
+
let l = Utils6.Math.interpolateCoord(leftX, leftY + groupLineDy, rightX, rightY + groupLineDy, -ef);
|
|
4449
|
+
let r = Utils6.Math.interpolateCoord(leftX, leftY + groupLineDy, rightX, rightY + groupLineDy, 1 + ef);
|
|
4391
4450
|
obj.points.push(new BeamPoint(leftStaff, this, leftSymbol, l.x, l.y));
|
|
4392
4451
|
obj.points.push(new BeamPoint(rightStaff, this, rightSymbol, r.x, r.y));
|
|
4393
4452
|
obj.tupletNumberOffsetY = 0;
|
|
@@ -4436,10 +4495,10 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
|
|
|
4436
4495
|
}
|
|
4437
4496
|
updateRect() {
|
|
4438
4497
|
if (this.staffObjects.length === 0) {
|
|
4439
|
-
this.rect = new
|
|
4498
|
+
this.rect = new AnchoredRect15();
|
|
4440
4499
|
} else {
|
|
4441
4500
|
this.staffObjects.forEach((obj) => obj.updateRect());
|
|
4442
|
-
this.rect = this.staffObjects[0].getRect().
|
|
4501
|
+
this.rect = this.staffObjects[0].getRect().clone();
|
|
4443
4502
|
for (let i = 1; i < this.staffObjects.length; i++) {
|
|
4444
4503
|
this.rect.expandInPlace(this.staffObjects[i].getRect());
|
|
4445
4504
|
}
|
|
@@ -4453,7 +4512,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
|
|
|
4453
4512
|
obj.points.forEach((pt) => {
|
|
4454
4513
|
if (pt.symbol instanceof ObjNoteGroup) {
|
|
4455
4514
|
if (pt !== left && pt !== right) {
|
|
4456
|
-
pt.y =
|
|
4515
|
+
pt.y = Utils6.Math.interpolateY(left.x, left.y, right.x, right.y, pt.x);
|
|
4457
4516
|
}
|
|
4458
4517
|
pt.symbol.setStemTipY(pt.staff, pt.y);
|
|
4459
4518
|
}
|
|
@@ -4461,7 +4520,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
|
|
|
4461
4520
|
}
|
|
4462
4521
|
if (obj.tupletNumber) {
|
|
4463
4522
|
let y = (left.y + right.y) / 2 + obj.tupletNumberOffsetY;
|
|
4464
|
-
obj.tupletNumber.offset(0, -obj.tupletNumber.getRect().
|
|
4523
|
+
obj.tupletNumber.offset(0, -obj.tupletNumber.getRect().anchorY + y);
|
|
4465
4524
|
}
|
|
4466
4525
|
});
|
|
4467
4526
|
}
|
|
@@ -4480,8 +4539,8 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
|
|
|
4480
4539
|
let { x: rx, y: ry } = obj.points[obj.points.length - 1];
|
|
4481
4540
|
if (obj.tupletNumber) {
|
|
4482
4541
|
let tf = obj.tupletNumber.getRect().width / (rx - lx) * 1.2;
|
|
4483
|
-
let lc =
|
|
4484
|
-
let rc =
|
|
4542
|
+
let lc = Utils6.Math.interpolateCoord(lx, ly, rx, ry, 0.5 - tf / 2);
|
|
4543
|
+
let rc = Utils6.Math.interpolateCoord(lx, ly, rx, ry, 0.5 + tf / 2);
|
|
4485
4544
|
ctx.strokeLine(lx, ly, lc.x, lc.y);
|
|
4486
4545
|
ctx.strokeLine(rc.x, rc.y, rx, ry);
|
|
4487
4546
|
} else {
|
|
@@ -4595,6 +4654,7 @@ var ObjBeamGroup = class _ObjBeamGroup extends MusicObject {
|
|
|
4595
4654
|
};
|
|
4596
4655
|
|
|
4597
4656
|
// src/score/engine/obj-fermata.ts
|
|
4657
|
+
import { AnchoredRect as AnchoredRect16 } from "@tspro/ts-utils-lib";
|
|
4598
4658
|
var ObjFermata = class extends MusicObject {
|
|
4599
4659
|
constructor(parent, pos) {
|
|
4600
4660
|
super(parent);
|
|
@@ -4622,7 +4682,7 @@ var ObjFermata = class extends MusicObject {
|
|
|
4622
4682
|
let { unitSize } = ctx;
|
|
4623
4683
|
let width = unitSize * 4;
|
|
4624
4684
|
let height = unitSize * 3;
|
|
4625
|
-
this.rect = new
|
|
4685
|
+
this.rect = new AnchoredRect16(-width / 2, width / 2, -height, 0);
|
|
4626
4686
|
}
|
|
4627
4687
|
offset(dx, dy) {
|
|
4628
4688
|
this.rect.offsetInPlace(dx, dy);
|
|
@@ -4650,6 +4710,7 @@ var ObjFermata = class extends MusicObject {
|
|
|
4650
4710
|
};
|
|
4651
4711
|
|
|
4652
4712
|
// src/score/engine/obj-extension-line.ts
|
|
4713
|
+
import { AnchoredRect as AnchoredRect17 } from "@tspro/ts-utils-lib";
|
|
4653
4714
|
var ObjExtensionLine = class extends MusicObject {
|
|
4654
4715
|
constructor(measure, line, extension, leftObj, rightObj) {
|
|
4655
4716
|
super(measure);
|
|
@@ -4670,7 +4731,7 @@ var ObjExtensionLine = class extends MusicObject {
|
|
|
4670
4731
|
}
|
|
4671
4732
|
getLineLeft() {
|
|
4672
4733
|
if (this.leftObj instanceof ObjBarLineLeft) {
|
|
4673
|
-
return this.leftObj.getRect().
|
|
4734
|
+
return this.leftObj.getRect().anchorX;
|
|
4674
4735
|
} else {
|
|
4675
4736
|
return this.leftObj.getRect().right;
|
|
4676
4737
|
}
|
|
@@ -4685,7 +4746,7 @@ var ObjExtensionLine = class extends MusicObject {
|
|
|
4685
4746
|
return (col.getRect().right + col.measure.getBarLineRight().getRect().left) / 2;
|
|
4686
4747
|
}
|
|
4687
4748
|
} else {
|
|
4688
|
-
return this.rightObj.getRect().
|
|
4749
|
+
return this.rightObj.getRect().anchorX;
|
|
4689
4750
|
}
|
|
4690
4751
|
}
|
|
4691
4752
|
layoutFitToMeasure(ctx) {
|
|
@@ -4693,13 +4754,13 @@ var ObjExtensionLine = class extends MusicObject {
|
|
|
4693
4754
|
let lineLeft = this.getLineLeft();
|
|
4694
4755
|
let lineRight = this.getLineRight();
|
|
4695
4756
|
let lineRectH = unitSize;
|
|
4696
|
-
this.rect = new
|
|
4757
|
+
this.rect = new AnchoredRect17(lineLeft, lineRight, -lineRectH / 2, lineRectH / 2);
|
|
4697
4758
|
}
|
|
4698
4759
|
pick(x, y) {
|
|
4699
4760
|
return this.rect.contains(x, y) ? [this] : [];
|
|
4700
4761
|
}
|
|
4701
4762
|
layout(ctx) {
|
|
4702
|
-
this.rect = new
|
|
4763
|
+
this.rect = new AnchoredRect17();
|
|
4703
4764
|
}
|
|
4704
4765
|
offset(dx, dy) {
|
|
4705
4766
|
this.rect.offsetInPlace(dx, dy);
|
|
@@ -4710,12 +4771,12 @@ var ObjExtensionLine = class extends MusicObject {
|
|
|
4710
4771
|
ctx.setLineDash([7, 3]);
|
|
4711
4772
|
}
|
|
4712
4773
|
ctx.color("black").lineWidth(1);
|
|
4713
|
-
ctx.strokeLine(rect.left, rect.
|
|
4774
|
+
ctx.strokeLine(rect.left, rect.anchorY, rect.right, rect.anchorY);
|
|
4714
4775
|
ctx.setLineDash([]);
|
|
4715
4776
|
let tails = this.extension.getTails();
|
|
4716
4777
|
if (tails.length > 0 && this === tails[tails.length - 1]) {
|
|
4717
|
-
let tipH = rect.
|
|
4718
|
-
ctx.strokeLine(rect.right, rect.
|
|
4778
|
+
let tipH = rect.anchorY > this.line.getRect().anchorY ? -ctx.unitSize : ctx.unitSize;
|
|
4779
|
+
ctx.strokeLine(rect.right, rect.anchorY, rect.right, rect.anchorY + tipH);
|
|
4719
4780
|
}
|
|
4720
4781
|
}
|
|
4721
4782
|
};
|
|
@@ -4727,7 +4788,7 @@ import { MusicError as MusicError13, MusicErrorType as MusicErrorType13 } from "
|
|
|
4727
4788
|
import { Note as Note6 } from "@tspro/web-music-score/theory";
|
|
4728
4789
|
|
|
4729
4790
|
// src/score/engine/obj-connective.ts
|
|
4730
|
-
import { Utils as
|
|
4791
|
+
import { AnchoredRect as AnchoredRect18, Guard as Guard5, Utils as Utils7 } from "@tspro/ts-utils-lib";
|
|
4731
4792
|
import { MusicError as MusicError11, MusicErrorType as MusicErrorType11 } from "@tspro/web-music-score/core";
|
|
4732
4793
|
var ObjConnective = class extends MusicObject {
|
|
4733
4794
|
constructor(connectiveProps, line, measure, leftNoteGroup, leftNoteId, ...args) {
|
|
@@ -4758,7 +4819,7 @@ var ObjConnective = class extends MusicObject {
|
|
|
4758
4819
|
this.rightNoteGroup = args[0];
|
|
4759
4820
|
this.rightNoteId = args[1];
|
|
4760
4821
|
this.tieType = void 0;
|
|
4761
|
-
} else if (
|
|
4822
|
+
} else if (Guard5.isEnumValue(args[0], TieType)) {
|
|
4762
4823
|
this.rightNoteGroup = void 0;
|
|
4763
4824
|
this.rightNoteId = void 0;
|
|
4764
4825
|
this.tieType = args[0];
|
|
@@ -4828,12 +4889,12 @@ var ObjConnective = class extends MusicObject {
|
|
|
4828
4889
|
this.rx = rx;
|
|
4829
4890
|
this.ry = ry;
|
|
4830
4891
|
this.arcHeight = this.connectiveProps.connective === "slide" /* Slide */ ? 0 : arcHeight;
|
|
4831
|
-
let { nx, ny } =
|
|
4892
|
+
let { nx, ny } = Utils7.Math.calcNormal(lx, ly, rx, ry);
|
|
4832
4893
|
this.cp1x = lx * 0.7 + rx * 0.3 + nx * this.arcHeight;
|
|
4833
4894
|
this.cp1y = ly * 0.7 + ry * 0.3 + ny * this.arcHeight;
|
|
4834
4895
|
this.cp2x = lx * 0.3 + rx * 0.7 + nx * this.arcHeight;
|
|
4835
4896
|
this.cp2y = ly * 0.3 + ry * 0.7 + ny * this.arcHeight;
|
|
4836
|
-
this.rect = new
|
|
4897
|
+
this.rect = new AnchoredRect18(
|
|
4837
4898
|
Math.min(this.lx, this.cp1x, this.cp2x, this.rx),
|
|
4838
4899
|
Math.max(this.lx, this.cp1x, this.cp2x, this.rx),
|
|
4839
4900
|
Math.min(this.ly, this.cp1y, this.cp2y, this.ry),
|
|
@@ -4884,7 +4945,7 @@ var ObjConnective = class extends MusicObject {
|
|
|
4884
4945
|
|
|
4885
4946
|
// src/score/engine/connective-props.ts
|
|
4886
4947
|
import { MusicError as MusicError12, MusicErrorType as MusicErrorType12 } from "@tspro/web-music-score/core";
|
|
4887
|
-
import {
|
|
4948
|
+
import { Guard as Guard6 } from "@tspro/ts-utils-lib";
|
|
4888
4949
|
var ConnectiveProps = class {
|
|
4889
4950
|
constructor(connective, span, noteAnchor, startNoteGroup) {
|
|
4890
4951
|
this.connective = connective;
|
|
@@ -4957,7 +5018,7 @@ var ConnectiveProps = class {
|
|
|
4957
5018
|
this.noteGroups[0].row.getNotationLines().forEach((line) => {
|
|
4958
5019
|
this.computeParams(line);
|
|
4959
5020
|
if (connective === "tie" /* Tie */) {
|
|
4960
|
-
if (
|
|
5021
|
+
if (Guard6.isEnumValue(span, TieType)) {
|
|
4961
5022
|
let leftNoteGroup = this.noteGroups[0];
|
|
4962
5023
|
for (let noteId = 0; noteId < leftNoteGroup.notes.length; noteId++) {
|
|
4963
5024
|
this.createObjConnectiveWithTieType(line, leftNoteGroup, noteId, span);
|
|
@@ -5029,7 +5090,7 @@ var ConnectiveProps = class {
|
|
|
5029
5090
|
};
|
|
5030
5091
|
|
|
5031
5092
|
// src/score/engine/obj-lyrics.ts
|
|
5032
|
-
import {
|
|
5093
|
+
import { Guard as Guard7 } from "@tspro/ts-utils-lib";
|
|
5033
5094
|
var ObjLyrics = class extends MusicObject {
|
|
5034
5095
|
constructor(col, verse, line, vpos, lyricsLength, lyricsText, lyricsOptions) {
|
|
5035
5096
|
super(col);
|
|
@@ -5045,9 +5106,9 @@ var ObjLyrics = class extends MusicObject {
|
|
|
5045
5106
|
__publicField(this, "mi");
|
|
5046
5107
|
this.rhythmProps = RhythmProps.get(lyricsLength);
|
|
5047
5108
|
let halign = (lyricsOptions == null ? void 0 : lyricsOptions.align) === "left" /* Left */ ? 0 : (lyricsOptions == null ? void 0 : lyricsOptions.align) === "right" /* Right */ ? 1 : 0.5;
|
|
5048
|
-
this.hyphen =
|
|
5109
|
+
this.hyphen = Guard7.isEnumValue(lyricsOptions == null ? void 0 : lyricsOptions.hyphen, LyricsHyphen) ? lyricsOptions == null ? void 0 : lyricsOptions.hyphen : void 0;
|
|
5049
5110
|
this.text = new ObjText(this, { text: lyricsText, color: this.color, scale: 0.8 }, halign, 0);
|
|
5050
|
-
this.rect =
|
|
5111
|
+
this.rect = this.text.getRect().clone();
|
|
5051
5112
|
this.mi = new MLyrics(this);
|
|
5052
5113
|
}
|
|
5053
5114
|
getMusicInterface() {
|
|
@@ -5063,11 +5124,11 @@ var ObjLyrics = class extends MusicObject {
|
|
|
5063
5124
|
this.nextLyricsObject = lyricsObj;
|
|
5064
5125
|
}
|
|
5065
5126
|
pick(x, y) {
|
|
5066
|
-
return this.
|
|
5127
|
+
return this.getRect().contains(x, y) ? [this] : [];
|
|
5067
5128
|
}
|
|
5068
5129
|
layout(ctx) {
|
|
5069
5130
|
this.text.layout(ctx);
|
|
5070
|
-
this.rect = this.text.getRect().
|
|
5131
|
+
this.rect = this.text.getRect().clone();
|
|
5071
5132
|
}
|
|
5072
5133
|
offset(dx, dy) {
|
|
5073
5134
|
this.text.offset(dx, dy);
|
|
@@ -5084,8 +5145,8 @@ var ObjLyrics = class extends MusicObject {
|
|
|
5084
5145
|
let maxw = r ? (r.left - l.right) * 0.85 : hyphenw;
|
|
5085
5146
|
let w = this.hyphen === "-" /* Hyphen */ ? Math.min(hyphenw, maxw) : maxw;
|
|
5086
5147
|
if (w > 0) {
|
|
5087
|
-
let cx = r ? (
|
|
5088
|
-
let cy =
|
|
5148
|
+
let cx = r ? (l.right + r.left) / 2 : l.right + w / 0.85;
|
|
5149
|
+
let cy = l.centerY;
|
|
5089
5150
|
ctx.moveTo(cx - w / 2, cy);
|
|
5090
5151
|
ctx.lineTo(cx + w / 2, cy);
|
|
5091
5152
|
ctx.stroke();
|
|
@@ -5095,7 +5156,7 @@ var ObjLyrics = class extends MusicObject {
|
|
|
5095
5156
|
};
|
|
5096
5157
|
|
|
5097
5158
|
// src/score/engine/obj-tab-rhythm.ts
|
|
5098
|
-
import { Utils as
|
|
5159
|
+
import { AnchoredRect as AnchoredRect19, UniMap as UniMap4, Utils as Utils8 } from "@tspro/ts-utils-lib";
|
|
5099
5160
|
var ObjTabRhythm = class extends MusicObject {
|
|
5100
5161
|
constructor(measure, tab) {
|
|
5101
5162
|
super(measure);
|
|
@@ -5104,9 +5165,9 @@ var ObjTabRhythm = class extends MusicObject {
|
|
|
5104
5165
|
__publicField(this, "voiceId");
|
|
5105
5166
|
__publicField(this, "mi");
|
|
5106
5167
|
// Keep non-static
|
|
5107
|
-
__publicField(this, "tupletPartsTextObjMap",
|
|
5168
|
+
__publicField(this, "tupletPartsTextObjMap", new UniMap4());
|
|
5108
5169
|
this.voiceId = getVoiceIds().filter((voiceId) => tab.containsVoiceId(voiceId));
|
|
5109
|
-
this.rect = new
|
|
5170
|
+
this.rect = new AnchoredRect19();
|
|
5110
5171
|
this.mi = new MTabRhythm(this);
|
|
5111
5172
|
}
|
|
5112
5173
|
getMusicInterface() {
|
|
@@ -5117,9 +5178,9 @@ var ObjTabRhythm = class extends MusicObject {
|
|
|
5117
5178
|
}
|
|
5118
5179
|
layout(ctx) {
|
|
5119
5180
|
let columns = this.measure.getColumns();
|
|
5120
|
-
let numColsInVoiceId = getVoiceIds().map((voiceId) =>
|
|
5121
|
-
this.voiceId.sort((a, b) =>
|
|
5122
|
-
this.rect = new
|
|
5181
|
+
let numColsInVoiceId = getVoiceIds().map((voiceId) => Utils8.Math.sum(columns.map((col) => col.getVoiceSymbol(voiceId) ? 1 : 0)));
|
|
5182
|
+
this.voiceId.sort((a, b) => Utils8.Math.cmp(numColsInVoiceId[a], numColsInVoiceId[b]));
|
|
5183
|
+
this.rect = new AnchoredRect19();
|
|
5123
5184
|
}
|
|
5124
5185
|
hasTuplets() {
|
|
5125
5186
|
return this.measure.getBeamGroups().some((beamGroup) => beamGroup.isTuplet());
|
|
@@ -5127,13 +5188,13 @@ var ObjTabRhythm = class extends MusicObject {
|
|
|
5127
5188
|
layoutFitToMeasure(ctx) {
|
|
5128
5189
|
let { unitSize, fontSize } = ctx;
|
|
5129
5190
|
let { measure } = this;
|
|
5130
|
-
let
|
|
5191
|
+
let cr = measure.getColumnsContentRect();
|
|
5131
5192
|
let stemHeight = unitSize * 5;
|
|
5132
|
-
this.rect.left = left;
|
|
5133
|
-
this.rect.
|
|
5134
|
-
this.rect.right = right;
|
|
5193
|
+
this.rect.left = cr.left;
|
|
5194
|
+
this.rect.anchorX = cr.centerX;
|
|
5195
|
+
this.rect.right = cr.right;
|
|
5135
5196
|
this.rect.top = this.hasTuplets() ? -fontSize : 0;
|
|
5136
|
-
this.rect.
|
|
5197
|
+
this.rect.anchorY = 0;
|
|
5137
5198
|
this.rect.bottom = stemHeight;
|
|
5138
5199
|
}
|
|
5139
5200
|
offset(dx, dy) {
|
|
@@ -5146,8 +5207,8 @@ var ObjTabRhythm = class extends MusicObject {
|
|
|
5146
5207
|
let flagSize = unitSize;
|
|
5147
5208
|
let dotSpace = unitSize;
|
|
5148
5209
|
let dotWidth = unitSize * 0.25;
|
|
5149
|
-
let { bottom,
|
|
5150
|
-
let stemTop =
|
|
5210
|
+
let { bottom, anchorY } = this.getRect();
|
|
5211
|
+
let stemTop = anchorY;
|
|
5151
5212
|
let stemBottom = bottom;
|
|
5152
5213
|
let columns = this.measure.getColumns();
|
|
5153
5214
|
for (let colId = 0; colId < columns.length; colId++) {
|
|
@@ -5161,7 +5222,7 @@ var ObjTabRhythm = class extends MusicObject {
|
|
|
5161
5222
|
for (let j = 0; j < symbols.length; j++) {
|
|
5162
5223
|
let sym = symbols[j];
|
|
5163
5224
|
let nextSym = symbols[j + 1];
|
|
5164
|
-
let colX = sym.col.getRect().
|
|
5225
|
+
let colX = sym.col.getRect().anchorX;
|
|
5165
5226
|
if (sym instanceof ObjNoteGroup) {
|
|
5166
5227
|
if (sym.rhythmProps.noteSize >= 2) {
|
|
5167
5228
|
ctx.lineWidth(sym.rhythmProps.noteSize === 4 ? 2 : 1);
|
|
@@ -5170,7 +5231,7 @@ var ObjTabRhythm = class extends MusicObject {
|
|
|
5170
5231
|
ctx.lineWidth(1);
|
|
5171
5232
|
if (symbols.length === 1) {
|
|
5172
5233
|
for (let i = 0; i < sym.rhythmProps.flagCount; i++) {
|
|
5173
|
-
ctx.drawFlag(new
|
|
5234
|
+
ctx.drawFlag(new AnchoredRect19(colX, colX + flagSize, stemTop + i * flagSize, stemTop + (i + 2) * flagSize), "up");
|
|
5174
5235
|
}
|
|
5175
5236
|
}
|
|
5176
5237
|
for (let i = 0; i < sym.rhythmProps.dotCount; i++) {
|
|
@@ -5192,8 +5253,8 @@ var ObjTabRhythm = class extends MusicObject {
|
|
|
5192
5253
|
if (nextSym) {
|
|
5193
5254
|
let left = sym;
|
|
5194
5255
|
let right = nextSym;
|
|
5195
|
-
let leftX = left.col.getRect().
|
|
5196
|
-
let rightX = right.col.getRect().
|
|
5256
|
+
let leftX = left.col.getRect().anchorX;
|
|
5257
|
+
let rightX = right.col.getRect().anchorX;
|
|
5197
5258
|
let leftBeamCount = left.hasTuplet() ? 1 : left instanceof ObjNoteGroup ? left.getRightBeamCount() : 1;
|
|
5198
5259
|
let rightBeamCount = right.hasTuplet() ? 1 : right instanceof ObjNoteGroup ? right.getLeftBeamCount() : 1;
|
|
5199
5260
|
let maxBeamCount = Math.max(leftBeamCount, rightBeamCount);
|
|
@@ -5212,14 +5273,14 @@ var ObjTabRhythm = class extends MusicObject {
|
|
|
5212
5273
|
}
|
|
5213
5274
|
}
|
|
5214
5275
|
if (beamGroup && beamGroup.isTuplet()) {
|
|
5215
|
-
let cx = (symbols[0].col.getRect().
|
|
5276
|
+
let cx = (symbols[0].col.getRect().anchorX + symbols[symbols.length - 1].col.getRect().anchorX) / 2;
|
|
5216
5277
|
let text = beamGroup.getTupletRatioText();
|
|
5217
5278
|
let textObj = this.tupletPartsTextObjMap.get(text);
|
|
5218
5279
|
if (!textObj) {
|
|
5219
5280
|
this.tupletPartsTextObjMap.set(text, textObj = new ObjText(this, { text, scale: 0.75 }, 0.5, 0.5));
|
|
5220
5281
|
textObj.layout(ctx);
|
|
5221
5282
|
}
|
|
5222
|
-
textObj.offset(-textObj.getRect().
|
|
5283
|
+
textObj.offset(-textObj.getRect().anchorX, -textObj.getRect().anchorY);
|
|
5223
5284
|
textObj.offset(cx, stemTop - fontSize / 2);
|
|
5224
5285
|
textObj.draw(ctx);
|
|
5225
5286
|
}
|
|
@@ -5235,18 +5296,11 @@ var ObjTabRhythm = class extends MusicObject {
|
|
|
5235
5296
|
};
|
|
5236
5297
|
|
|
5237
5298
|
// src/score/engine/obj-measure.ts
|
|
5238
|
-
function validateVoiceId(voiceId) {
|
|
5239
|
-
if (typeof voiceId === "number" && getVoiceIds().indexOf(voiceId) < 0) {
|
|
5240
|
-
throw new MusicError13(MusicErrorType13.Score, "Invalid voiceId: " + voiceId);
|
|
5241
|
-
} else {
|
|
5242
|
-
return voiceId;
|
|
5243
|
-
}
|
|
5244
|
-
}
|
|
5245
5299
|
function getExtensionTicks(extensionLength) {
|
|
5246
5300
|
if (typeof extensionLength === "string") {
|
|
5247
5301
|
extensionLength = [extensionLength];
|
|
5248
5302
|
}
|
|
5249
|
-
if (
|
|
5303
|
+
if (Guard8.isArray(extensionLength)) {
|
|
5250
5304
|
let totalTicks = 0;
|
|
5251
5305
|
for (let i = 0; i < extensionLength.length; ) {
|
|
5252
5306
|
let str = extensionLength[i];
|
|
@@ -5280,7 +5334,27 @@ function getVerseLayoutGroupId(verse) {
|
|
|
5280
5334
|
throw new MusicError13(MusicErrorType13.Unknown, "VerseNumber is not 1, 2 or 3.");
|
|
5281
5335
|
}
|
|
5282
5336
|
}
|
|
5283
|
-
var
|
|
5337
|
+
var MeasureRegions = class {
|
|
5338
|
+
constructor() {
|
|
5339
|
+
__publicField(this, "tabTuning_0", 0);
|
|
5340
|
+
__publicField(this, "signature_1", 0);
|
|
5341
|
+
__publicField(this, "leftBarLine_2", 0);
|
|
5342
|
+
__publicField(this, "padding_3", 0);
|
|
5343
|
+
__publicField(this, "columnsMin_4", 0);
|
|
5344
|
+
__publicField(this, "padding_5", 0);
|
|
5345
|
+
__publicField(this, "rightBarLine_6", 0);
|
|
5346
|
+
}
|
|
5347
|
+
get leftSolid() {
|
|
5348
|
+
return this.tabTuning_0 + this.signature_1 + this.leftBarLine_2 + this.padding_3;
|
|
5349
|
+
}
|
|
5350
|
+
get columnsMin() {
|
|
5351
|
+
return this.columnsMin_4;
|
|
5352
|
+
}
|
|
5353
|
+
get rightSolid() {
|
|
5354
|
+
return this.padding_5 + this.rightBarLine_6;
|
|
5355
|
+
}
|
|
5356
|
+
};
|
|
5357
|
+
var ObjMeasure = class extends MusicObject {
|
|
5284
5358
|
constructor(row, options) {
|
|
5285
5359
|
super(row);
|
|
5286
5360
|
this.row = row;
|
|
@@ -5300,13 +5374,10 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5300
5374
|
__publicField(this, "barLineRight");
|
|
5301
5375
|
__publicField(this, "connectives", []);
|
|
5302
5376
|
__publicField(this, "beamGroups", []);
|
|
5303
|
-
__publicField(this, "tabStringNotesWidth", 0);
|
|
5304
5377
|
__publicField(this, "measureId");
|
|
5378
|
+
__publicField(this, "regions", new MeasureRegions());
|
|
5305
5379
|
__publicField(this, "needLayout", true);
|
|
5306
|
-
__publicField(this, "
|
|
5307
|
-
__publicField(this, "minColumnsAreaWidth", 0);
|
|
5308
|
-
__publicField(this, "rightSolidAreaWidth", 0);
|
|
5309
|
-
__publicField(this, "voiceSymbols", []);
|
|
5380
|
+
__publicField(this, "voiceSymbols", asMulti(new IndexArray2()));
|
|
5310
5381
|
__publicField(this, "lastAddedRhythmColumn");
|
|
5311
5382
|
__publicField(this, "lastAddedRhythmSymbol");
|
|
5312
5383
|
__publicField(this, "addExtensionToMusicObjects", []);
|
|
@@ -5315,14 +5386,14 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5315
5386
|
__publicField(this, "passCount", 0);
|
|
5316
5387
|
// How many times player has passed this measure.
|
|
5317
5388
|
__publicField(this, "needBeamsUpdate", true);
|
|
5318
|
-
__publicField(this, "navigationSet",
|
|
5389
|
+
__publicField(this, "navigationSet", new ValueSet());
|
|
5319
5390
|
__publicField(this, "isEndSong", false);
|
|
5320
5391
|
__publicField(this, "isEndSection", false);
|
|
5321
5392
|
__publicField(this, "endRepeatPlayCount", 2);
|
|
5322
5393
|
// play twice.
|
|
5323
5394
|
__publicField(this, "endRepeatPlayCountText");
|
|
5324
|
-
__publicField(this, "staticObjectsCache",
|
|
5325
|
-
__publicField(this, "lyricsObjectsCache", new
|
|
5395
|
+
__publicField(this, "staticObjectsCache", new UniMap5());
|
|
5396
|
+
__publicField(this, "lyricsObjectsCache", new TriMap2());
|
|
5326
5397
|
__publicField(this, "mi");
|
|
5327
5398
|
this.mi = new MMeasure(this);
|
|
5328
5399
|
this.prevMeasure = row.doc.getLastMeasure();
|
|
@@ -5363,7 +5434,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5363
5434
|
updateRunningArguments(runningArgs) {
|
|
5364
5435
|
var _a;
|
|
5365
5436
|
runningArgs != null ? runningArgs : runningArgs = [];
|
|
5366
|
-
let numVoices =
|
|
5437
|
+
let numVoices = Utils9.Math.sum(getVoiceIds().map((voiceId) => this.getVoiceSymbols(voiceId).length > 0 ? 1 : 0));
|
|
5367
5438
|
getVoiceIds().forEach((voiceId) => {
|
|
5368
5439
|
var _a2;
|
|
5369
5440
|
const getDefaultDiatonicId = () => {
|
|
@@ -5522,7 +5593,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5522
5593
|
this.alterKeySignature = args[0];
|
|
5523
5594
|
} else if (args[0] instanceof Scale) {
|
|
5524
5595
|
this.alterKeySignature = args[0];
|
|
5525
|
-
} else if (
|
|
5596
|
+
} else if (Guard8.isNonEmptyString(args[0])) {
|
|
5526
5597
|
if (args.length === 1) {
|
|
5527
5598
|
this.alterKeySignature = getScale(args[0]);
|
|
5528
5599
|
} else if (args.length === 2) {
|
|
@@ -5633,7 +5704,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5633
5704
|
let grp = this.doc.getStaffGroup(staffTabOrGroup);
|
|
5634
5705
|
if (grp && !prevGroups.includes(staffTabOrGroup)) {
|
|
5635
5706
|
let curGroups = [...prevGroups, staffTabOrGroup];
|
|
5636
|
-
(
|
|
5707
|
+
(Guard8.isArray(grp.staffsTabsAndGroups) ? grp.staffsTabsAndGroups : [grp.staffsTabsAndGroups]).forEach((staffTabOrGroup2) => {
|
|
5637
5708
|
switch (grp.verticalPosition) {
|
|
5638
5709
|
case "above" /* Above */:
|
|
5639
5710
|
addToStaffTabOrGroup(staffTabOrGroup2, 0 /* Above */, curGroups);
|
|
@@ -5660,7 +5731,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5660
5731
|
} else {
|
|
5661
5732
|
addToStaffTabOrGroup(0, defaultVerticalPos);
|
|
5662
5733
|
}
|
|
5663
|
-
} else if (
|
|
5734
|
+
} else if (Guard8.isArray(staffTabOrGroups)) {
|
|
5664
5735
|
staffTabOrGroups.forEach((staffTabOrGroup) => addToStaffTabOrGroup(staffTabOrGroup, defaultVerticalPos));
|
|
5665
5736
|
} else {
|
|
5666
5737
|
addToStaffTabOrGroup(staffTabOrGroups, defaultVerticalPos);
|
|
@@ -5744,7 +5815,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5744
5815
|
case "endRepeat" /* EndRepeat */:
|
|
5745
5816
|
if (args.length === 0) {
|
|
5746
5817
|
this.endRepeatPlayCount = 2;
|
|
5747
|
-
} else if (
|
|
5818
|
+
} else if (Guard8.isIntegerGte(args[0], 2)) {
|
|
5748
5819
|
this.endRepeatPlayCount = args[0];
|
|
5749
5820
|
} else {
|
|
5750
5821
|
throw new MusicError13(MusicErrorType13.Score, "Invalid end repeat play count (should be 2 or greater integer): " + args[0]);
|
|
@@ -5831,15 +5902,15 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5831
5902
|
throw new MusicError13(MusicErrorType13.Score, "Connective can be added to note group only.");
|
|
5832
5903
|
}
|
|
5833
5904
|
if (connective === "tie" /* Tie */) {
|
|
5834
|
-
let tieSpan =
|
|
5835
|
-
let noteAnchor =
|
|
5905
|
+
let tieSpan = Guard8.isInteger(args[0]) || Guard8.isEnumValue(args[0], TieType) ? args[0] : 2;
|
|
5906
|
+
let noteAnchor = Guard8.isEnumValue(args[1], NoteAnchor) ? args[1] : "auto" /* Auto */;
|
|
5836
5907
|
anchor.startConnective(new ConnectiveProps("tie" /* Tie */, tieSpan, noteAnchor, anchor));
|
|
5837
5908
|
} else if (connective === "slur" /* Slur */) {
|
|
5838
|
-
let slurSpan =
|
|
5839
|
-
let noteAnchor =
|
|
5909
|
+
let slurSpan = Guard8.isInteger(args[0]) ? args[0] : 2;
|
|
5910
|
+
let noteAnchor = Guard8.isEnumValue(args[1], NoteAnchor) ? args[1] : "auto" /* Auto */;
|
|
5840
5911
|
anchor.startConnective(new ConnectiveProps("slur" /* Slur */, slurSpan, noteAnchor, anchor));
|
|
5841
5912
|
} else if (connective === "slide" /* Slide */) {
|
|
5842
|
-
let noteAnchor =
|
|
5913
|
+
let noteAnchor = Guard8.isEnumValue(args[0], NoteAnchor) ? args[0] : "auto" /* Auto */;
|
|
5843
5914
|
anchor.startConnective(new ConnectiveProps("slide" /* Slide */, 2, noteAnchor, anchor));
|
|
5844
5915
|
}
|
|
5845
5916
|
}
|
|
@@ -5894,11 +5965,9 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5894
5965
|
this.disableExtension();
|
|
5895
5966
|
}
|
|
5896
5967
|
addRhythmSymbol(symbol) {
|
|
5897
|
-
var _a, _b;
|
|
5898
5968
|
let { col, voiceId } = symbol;
|
|
5899
5969
|
col.setVoiceSymbol(voiceId, symbol);
|
|
5900
|
-
|
|
5901
|
-
this.voiceSymbols[voiceId].push(symbol);
|
|
5970
|
+
this.voiceSymbols.add(voiceId, symbol);
|
|
5902
5971
|
if (symbol.oldStyleTriplet) {
|
|
5903
5972
|
this.createOldStyleTriplets(voiceId);
|
|
5904
5973
|
}
|
|
@@ -5925,9 +5994,9 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5925
5994
|
let col = this.getRhythmColumn({ verse, line, vpos });
|
|
5926
5995
|
let lyricsObj = new ObjLyrics(col, verse, line, vpos, validateNoteLength2(lyricsLength), lyricsText, lyricsOptions);
|
|
5927
5996
|
col.addLyricsObject(lyricsObj);
|
|
5928
|
-
let lyricsArr = this.
|
|
5997
|
+
let lyricsArr = this.lyricsObjectsCache.getOrCreate(line, vpos, verse, []);
|
|
5929
5998
|
lyricsArr.push(lyricsObj);
|
|
5930
|
-
lyricsArr.sort((a, b) =>
|
|
5999
|
+
lyricsArr.sort((a, b) => Utils9.Math.cmp(a.col.positionTicks, b.col.positionTicks));
|
|
5931
6000
|
(_a = lyricsObj.measure.getPrevLyricsObject(lyricsObj)) == null ? void 0 : _a.setNextLyricsObject(lyricsObj);
|
|
5932
6001
|
this.addLayoutObject(lyricsObj, line, getVerseLayoutGroupId(verse), vpos);
|
|
5933
6002
|
this.lastAddedRhythmColumn = col;
|
|
@@ -5976,55 +6045,48 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5976
6045
|
}
|
|
5977
6046
|
// Get content rect excluding signature
|
|
5978
6047
|
getColumnsContentRect() {
|
|
5979
|
-
return new
|
|
5980
|
-
this.barLineLeft.getRect().
|
|
5981
|
-
this.barLineRight.getRect().
|
|
6048
|
+
return new AnchoredRect20(
|
|
6049
|
+
this.barLineLeft.getRect().anchorX,
|
|
6050
|
+
this.barLineRight.getRect().anchorX,
|
|
5982
6051
|
this.getRect().top,
|
|
5983
6052
|
this.getRect().bottom
|
|
5984
6053
|
);
|
|
5985
6054
|
}
|
|
5986
|
-
|
|
5987
|
-
return this.
|
|
6055
|
+
getLeftSolidWidth() {
|
|
6056
|
+
return this.regions.leftSolid;
|
|
5988
6057
|
}
|
|
5989
|
-
|
|
5990
|
-
return this.
|
|
6058
|
+
getMinColumnsWidth() {
|
|
6059
|
+
return this.regions.columnsMin;
|
|
5991
6060
|
}
|
|
5992
|
-
|
|
5993
|
-
return this.
|
|
6061
|
+
getRightSolidWidth() {
|
|
6062
|
+
return this.regions.rightSolid;
|
|
5994
6063
|
}
|
|
5995
|
-
|
|
5996
|
-
return this.
|
|
6064
|
+
getTotalSolidWidth() {
|
|
6065
|
+
return this.getLeftSolidWidth() + this.getRightSolidWidth();
|
|
5997
6066
|
}
|
|
5998
6067
|
getMinWidth() {
|
|
5999
|
-
return this.
|
|
6068
|
+
return this.getLeftSolidWidth() + this.getMinColumnsWidth() + this.getRightSolidWidth();
|
|
6000
6069
|
}
|
|
6001
6070
|
getStaffLineLeft() {
|
|
6002
6071
|
let prev = this.getPrevMeasure();
|
|
6003
6072
|
if (prev && prev.row === this.row && !prev.hasPostMeasureBreak()) {
|
|
6004
6073
|
return prev.getStaffLineRight();
|
|
6005
6074
|
} else {
|
|
6006
|
-
return this.getRect().left + this.
|
|
6075
|
+
return this.getRect().left + this.regions.tabTuning_0;
|
|
6007
6076
|
}
|
|
6008
6077
|
}
|
|
6009
6078
|
getStaffLineRight() {
|
|
6010
|
-
return this.barLineRight.getRect().
|
|
6011
|
-
}
|
|
6012
|
-
getLyricsObjects(line, vpos, verse) {
|
|
6013
|
-
let lyricsObjs = this.lyricsObjectsCache.get(line, vpos, verse);
|
|
6014
|
-
if (!lyricsObjs) {
|
|
6015
|
-
this.lyricsObjectsCache.set(line, vpos, verse, lyricsObjs = []);
|
|
6016
|
-
}
|
|
6017
|
-
return lyricsObjs;
|
|
6079
|
+
return this.barLineRight.getRect().anchorX;
|
|
6018
6080
|
}
|
|
6019
6081
|
getPrevLyricsObject(lyricsObj) {
|
|
6020
6082
|
var _a;
|
|
6021
6083
|
let { line, verse, vpos } = lyricsObj;
|
|
6022
|
-
let lyricsArr = this.
|
|
6084
|
+
let lyricsArr = this.lyricsObjectsCache.getOrDefault(line, vpos, verse, []);
|
|
6023
6085
|
let i = lyricsArr.indexOf(lyricsObj);
|
|
6024
6086
|
if (i > 0) {
|
|
6025
6087
|
return lyricsArr[i - 1];
|
|
6026
6088
|
} else if (i === 0) {
|
|
6027
|
-
let lyricsArr2 = (_a = lyricsObj.measure.getPrevMeasure()) == null ? void 0 : _a.
|
|
6089
|
+
let lyricsArr2 = (_a = lyricsObj.measure.getPrevMeasure()) == null ? void 0 : _a.lyricsObjectsCache.get(line, vpos, verse);
|
|
6028
6090
|
if (lyricsArr2 && lyricsArr2.length > 0) {
|
|
6029
6091
|
return lyricsArr2[lyricsArr2.length - 1];
|
|
6030
6092
|
}
|
|
@@ -6032,14 +6094,13 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
6032
6094
|
return void 0;
|
|
6033
6095
|
}
|
|
6034
6096
|
getStaticObjects(line) {
|
|
6035
|
-
let staticObjects = this.staticObjectsCache.get(line);
|
|
6036
|
-
if (!staticObjects) {
|
|
6037
|
-
staticObjects = [];
|
|
6038
|
-
this.getColumns().forEach((col) => col.getStaticObjects(line).forEach((obj) => staticObjects == null ? void 0 : staticObjects.push(obj)));
|
|
6039
|
-
this.staticObjectsCache.set(line, staticObjects);
|
|
6040
|
-
}
|
|
6041
6097
|
let layoutObjects = this.layoutObjects.filter((layoutObj) => layoutObj.line === line && layoutObj.isPositionResolved()).map((layoutObj) => layoutObj.musicObj);
|
|
6042
|
-
|
|
6098
|
+
let staticObjects = layoutObjects.length > 0 ? [...this.staticObjectsCache.getOrDefault(line, []), ...layoutObjects] : this.staticObjectsCache.getOrDefault(line, []);
|
|
6099
|
+
staticObjects.forEach((obj) => obj.getRect());
|
|
6100
|
+
return staticObjects;
|
|
6101
|
+
}
|
|
6102
|
+
addStaticObject(line, staticObj) {
|
|
6103
|
+
this.staticObjectsCache.getOrCreate(line, []).push(staticObj);
|
|
6043
6104
|
}
|
|
6044
6105
|
removeLayoutObjects(musicObj) {
|
|
6045
6106
|
this.layoutObjects = this.layoutObjects.filter((layoutObj) => {
|
|
@@ -6138,7 +6199,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
6138
6199
|
let beamGroupSize = ts.beamGroupSizes[groupId];
|
|
6139
6200
|
let beamGroupSizeList = [beamGroupSize];
|
|
6140
6201
|
if (beamGroupSize.length > 1) {
|
|
6141
|
-
beamGroupSizeList.unshift([
|
|
6202
|
+
beamGroupSizeList.unshift([Utils9.Math.sum(beamGroupSize)]);
|
|
6142
6203
|
}
|
|
6143
6204
|
let beamCreated = false;
|
|
6144
6205
|
let groupStartTicksSave = groupStartTicks;
|
|
@@ -6153,7 +6214,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
6153
6214
|
let symbolEndTicks = symbolStartTicks + symbol.rhythmProps.ticks;
|
|
6154
6215
|
return symbolStartTicks >= groupStartTicks && symbolEndTicks <= groupEndTicks;
|
|
6155
6216
|
});
|
|
6156
|
-
let groupSymbolsTicks =
|
|
6217
|
+
let groupSymbolsTicks = Utils9.Math.sum(groupSymbols.map((sym) => sym.rhythmProps.ticks));
|
|
6157
6218
|
if (groupSymbolsTicks === beamGroupTicks && groupSymbols.every((n) => n instanceof ObjNoteGroup) && (groupSymbols.every((n) => n.rhythmProps.flagCount === 1) || beamGroupSizeList.length === 0)) {
|
|
6158
6219
|
if (ObjBeamGroup.createBeam(groupSymbols)) {
|
|
6159
6220
|
beamCreated = true;
|
|
@@ -6174,10 +6235,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
6174
6235
|
return this.barLineRight;
|
|
6175
6236
|
}
|
|
6176
6237
|
getVoiceSymbols(voiceId) {
|
|
6177
|
-
|
|
6178
|
-
validateVoiceId(voiceId);
|
|
6179
|
-
(_b = (_a = this.voiceSymbols)[voiceId]) != null ? _b : _a[voiceId] = [];
|
|
6180
|
-
return this.voiceSymbols[voiceId];
|
|
6238
|
+
return this.voiceSymbols.getAll(voiceId);
|
|
6181
6239
|
}
|
|
6182
6240
|
completeRests(voiceId) {
|
|
6183
6241
|
if (voiceId === void 0) {
|
|
@@ -6187,7 +6245,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
6187
6245
|
this.completeRests(getVoiceIds().filter((id) => this.getConsumedTicks(id) > 0));
|
|
6188
6246
|
}
|
|
6189
6247
|
return;
|
|
6190
|
-
} else if (
|
|
6248
|
+
} else if (Guard8.isArray(voiceId)) {
|
|
6191
6249
|
voiceId.forEach((id) => this.completeRests(id));
|
|
6192
6250
|
return;
|
|
6193
6251
|
} else {
|
|
@@ -6228,7 +6286,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
6228
6286
|
this.postMeasureBreakWidth = this.hasPostMeasureBreak() ? DocumentSettings.PostMeasureBreakWidth * unitSize : 0;
|
|
6229
6287
|
let isFirstMeasureInRow = this === this.row.getFirstMeasure();
|
|
6230
6288
|
let isAfterMeasureBreak = ((_a = this.getPrevMeasure()) == null ? void 0 : _a.hasPostMeasureBreak()) === true;
|
|
6231
|
-
this.
|
|
6289
|
+
this.regions.tabTuning_0 = isFirstMeasureInRow && this.row.hasTab ? unitSize * 4 : 0;
|
|
6232
6290
|
let showClef = isFirstMeasureInRow || isAfterMeasureBreak;
|
|
6233
6291
|
let showMeasureNumber = this.options.showNumber === false ? false : this.options.showNumber === true || isFirstMeasureInRow && !this.row.isFirstRow();
|
|
6234
6292
|
let showKeySignature = isFirstMeasureInRow || isAfterMeasureBreak || !!this.alterKeySignature;
|
|
@@ -6265,7 +6323,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
6265
6323
|
let note = tab.getTuningStrings()[stringId].format(PitchNotation.Helmholtz, SymbolSet.Unicode);
|
|
6266
6324
|
let obj = new ObjText(this, { text: note, scale: 0.8 }, 1, 0.5);
|
|
6267
6325
|
obj.layout(ctx);
|
|
6268
|
-
obj.offset(this.
|
|
6326
|
+
obj.offset(this.regions.tabTuning_0 * 0.8, tab.getStringY(stringId));
|
|
6269
6327
|
this.tabStringNotes.push(obj);
|
|
6270
6328
|
tab.addObject(obj);
|
|
6271
6329
|
}
|
|
@@ -6274,50 +6332,62 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
6274
6332
|
this.barLineLeft.layout(ctx);
|
|
6275
6333
|
const accState = new AccidentalState(this);
|
|
6276
6334
|
this.columns.forEach((col) => col.layout(ctx, accState));
|
|
6335
|
+
this.columns.forEach((col) => col.layoutReserveSpace(ctx));
|
|
6277
6336
|
this.barLineRight.layout(ctx);
|
|
6278
|
-
if (this.endRepeatPlayCountText)
|
|
6337
|
+
if (this.endRepeatPlayCountText)
|
|
6279
6338
|
this.endRepeatPlayCountText.layout(ctx);
|
|
6280
|
-
|
|
6281
|
-
this.layoutObjects.forEach((layoutObj) => layoutObj.layout(ctx));
|
|
6339
|
+
this.layoutObjects.forEach((obj) => obj.layout(ctx));
|
|
6282
6340
|
let padding = ctx.unitSize;
|
|
6283
|
-
this.
|
|
6284
|
-
this.
|
|
6285
|
-
this.
|
|
6286
|
-
this.
|
|
6287
|
-
|
|
6341
|
+
this.regions.signature_1 = Math.max(0, ...this.signatures.map((signature) => signature.getRect().width));
|
|
6342
|
+
this.regions.leftBarLine_2 = this.barLineLeft.getRect().width;
|
|
6343
|
+
this.regions.padding_3 = padding;
|
|
6344
|
+
this.regions.columnsMin_4 = Math.max(
|
|
6345
|
+
DocumentSettings.MinColumnsWidth * unitSize,
|
|
6346
|
+
this.columns.map((col) => col.getRect().width).reduce((acc, cur) => acc + cur)
|
|
6347
|
+
);
|
|
6348
|
+
this.regions.padding_5 = padding;
|
|
6349
|
+
this.regions.rightBarLine_6 = this.barLineRight.getRect().width;
|
|
6288
6350
|
}
|
|
6289
6351
|
layoutWidth(ctx, width) {
|
|
6352
|
+
var _a;
|
|
6290
6353
|
if (!this.needLayout) {
|
|
6291
6354
|
return;
|
|
6292
6355
|
}
|
|
6293
6356
|
width = Math.max(width, this.getMinWidth());
|
|
6294
|
-
this.rect = new
|
|
6295
|
-
this.rect.
|
|
6357
|
+
this.rect = new AnchoredRect20();
|
|
6358
|
+
this.rect.anchorX = this.rect.left + width / 2;
|
|
6296
6359
|
this.rect.right = this.rect.left + width;
|
|
6297
6360
|
let rect;
|
|
6298
6361
|
this.signatures.forEach((signature) => {
|
|
6299
6362
|
rect = signature.getRect();
|
|
6300
|
-
signature.offset(this.rect.left + this.
|
|
6363
|
+
signature.offset(this.rect.left + this.regions.tabTuning_0 - rect.left, -rect.anchorY);
|
|
6301
6364
|
});
|
|
6302
6365
|
let signaturesWidth = Math.max(0, ...this.signatures.map((signature) => signature.getRect().width));
|
|
6303
6366
|
rect = this.barLineLeft.getRect();
|
|
6304
|
-
this.barLineLeft.offset(this.rect.left + this.
|
|
6367
|
+
this.barLineLeft.offset(this.rect.left + this.regions.tabTuning_0 + signaturesWidth - rect.left, -rect.anchorY);
|
|
6305
6368
|
rect = this.barLineRight.getRect();
|
|
6306
|
-
this.barLineRight.offset(this.rect.right - rect.right, -rect.
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
let
|
|
6311
|
-
let
|
|
6312
|
-
let
|
|
6313
|
-
let
|
|
6314
|
-
let columnScale = columnsAreaWidth / columnsWidth;
|
|
6315
|
-
let columnLeft = columnsAreaLeft;
|
|
6369
|
+
this.barLineRight.offset(this.rect.right - rect.right, -rect.anchorY);
|
|
6370
|
+
(_a = this.endRepeatPlayCountText) == null ? void 0 : _a.offset(this.barLineRight.getRect().left, this.barLineRight.getRect().top);
|
|
6371
|
+
let columnsLeft = this.rect.left + this.regions.leftSolid;
|
|
6372
|
+
let columnsRight = this.rect.right - this.regions.rightSolid;
|
|
6373
|
+
let columnsWidth = columnsRight - columnsLeft;
|
|
6374
|
+
let columnsMinWidth = this.regions.columnsMin;
|
|
6375
|
+
let columnScale = columnsWidth / columnsMinWidth;
|
|
6376
|
+
let curColumnLeft = columnsLeft;
|
|
6316
6377
|
this.columns.forEach((col) => {
|
|
6317
6378
|
rect = col.getRect();
|
|
6318
|
-
let
|
|
6319
|
-
col.offset(
|
|
6320
|
-
|
|
6379
|
+
let columnAnchorX = curColumnLeft + rect.leftw * columnScale;
|
|
6380
|
+
col.offset(columnAnchorX - rect.anchorX, -rect.anchorY);
|
|
6381
|
+
curColumnLeft += rect.width * columnScale;
|
|
6382
|
+
});
|
|
6383
|
+
getVoiceIds().forEach((voiceId) => {
|
|
6384
|
+
const symbols = this.getVoiceSymbols(voiceId);
|
|
6385
|
+
const onlyRest = symbols.length === 1 && symbols[0] instanceof ObjRest ? symbols[0] : void 0;
|
|
6386
|
+
if (!onlyRest) return;
|
|
6387
|
+
const isOnlySymbolInCol = getVoiceIds().map((voiceId2) => onlyRest.col.getVoiceSymbol(voiceId2)).filter((sym) => sym !== void 0 && sym !== onlyRest).length === 0;
|
|
6388
|
+
if (isOnlySymbolInCol) return;
|
|
6389
|
+
const r = this.getColumnsContentRect();
|
|
6390
|
+
onlyRest.offset(r.centerX - onlyRest.getRect().anchorX, 0);
|
|
6321
6391
|
});
|
|
6322
6392
|
}
|
|
6323
6393
|
layoutConnectives(ctx) {
|
|
@@ -6425,29 +6495,40 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
6425
6495
|
this.beamGroups.forEach((beam) => beam.draw(ctx));
|
|
6426
6496
|
}
|
|
6427
6497
|
};
|
|
6428
|
-
__publicField(_ObjMeasure, "MinFlexContentWidth", 10);
|
|
6429
|
-
var ObjMeasure2 = _ObjMeasure;
|
|
6430
6498
|
|
|
6431
6499
|
// src/score/engine/layout-object.ts
|
|
6432
6500
|
import { MusicError as MusicError14, MusicErrorType as MusicErrorType14 } from "@tspro/web-music-score/core";
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
];
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6501
|
+
import { AnchoredRect as AnchoredRect21, asMulti as asMulti2, IndexArray as IndexArray3, UniMap as UniMap6 } from "@tspro/ts-utils-lib";
|
|
6502
|
+
var LayoutGroupId = /* @__PURE__ */ ((LayoutGroupId2) => {
|
|
6503
|
+
LayoutGroupId2[LayoutGroupId2["TabRhythm"] = 0] = "TabRhythm";
|
|
6504
|
+
LayoutGroupId2[LayoutGroupId2["Fermata"] = 1] = "Fermata";
|
|
6505
|
+
LayoutGroupId2[LayoutGroupId2["NoteLabel"] = 2] = "NoteLabel";
|
|
6506
|
+
LayoutGroupId2[LayoutGroupId2["Navigation"] = 3] = "Navigation";
|
|
6507
|
+
LayoutGroupId2[LayoutGroupId2["Ending"] = 4] = "Ending";
|
|
6508
|
+
LayoutGroupId2[LayoutGroupId2["TempoAnnotation"] = 5] = "TempoAnnotation";
|
|
6509
|
+
LayoutGroupId2[LayoutGroupId2["DynamicsAnnotation"] = 6] = "DynamicsAnnotation";
|
|
6510
|
+
LayoutGroupId2[LayoutGroupId2["ChordLabel"] = 7] = "ChordLabel";
|
|
6511
|
+
LayoutGroupId2[LayoutGroupId2["LyricsVerse1"] = 8] = "LyricsVerse1";
|
|
6512
|
+
LayoutGroupId2[LayoutGroupId2["LyricsVerse2"] = 9] = "LyricsVerse2";
|
|
6513
|
+
LayoutGroupId2[LayoutGroupId2["LyricsVerse3"] = 10] = "LyricsVerse3";
|
|
6514
|
+
return LayoutGroupId2;
|
|
6515
|
+
})(LayoutGroupId || {});
|
|
6516
|
+
var LayoutGroupIdAttrs = new UniMap6([
|
|
6517
|
+
[0 /* TabRhythm */, { rowAlign: true }],
|
|
6518
|
+
[1 /* Fermata */, { reserveSpace: true }],
|
|
6519
|
+
[2 /* NoteLabel */, { reserveSpace: true }],
|
|
6520
|
+
[3 /* Navigation */, { rowAlign: true }],
|
|
6521
|
+
[4 /* Ending */, { rowAlign: true, padding: 2 }],
|
|
6522
|
+
[5 /* TempoAnnotation */, { rowAlign: true, padding: 2 }],
|
|
6523
|
+
[6 /* DynamicsAnnotation */, { rowAlign: true, padding: 2 }],
|
|
6524
|
+
[7 /* ChordLabel */, { reserveSpace: true, rowAlign: true }],
|
|
6525
|
+
[8 /* LyricsVerse1 */, { reserveSpace: true, rowAlign: true }],
|
|
6526
|
+
[9 /* LyricsVerse2 */, { reserveSpace: true, rowAlign: true }],
|
|
6527
|
+
[10 /* LyricsVerse3 */, { reserveSpace: true, rowAlign: true }]
|
|
6528
|
+
]);
|
|
6448
6529
|
function requireParentMeasure(p) {
|
|
6449
6530
|
while (p) {
|
|
6450
|
-
if (p instanceof
|
|
6531
|
+
if (p instanceof ObjMeasure) {
|
|
6451
6532
|
return p;
|
|
6452
6533
|
}
|
|
6453
6534
|
p = p.getParent();
|
|
@@ -6483,7 +6564,7 @@ var LayoutObjectWrapper = class {
|
|
|
6483
6564
|
this.layoutGroup = this.line.getLayoutGroup(layoutGroupId);
|
|
6484
6565
|
this.layoutGroup.add(this);
|
|
6485
6566
|
}
|
|
6486
|
-
|
|
6567
|
+
resetPositionResolved() {
|
|
6487
6568
|
this.positionResolved = false;
|
|
6488
6569
|
}
|
|
6489
6570
|
setPositionResolved() {
|
|
@@ -6504,8 +6585,8 @@ var LayoutObjectWrapper = class {
|
|
|
6504
6585
|
let staticShapeRects = staticObj.getShapeRects();
|
|
6505
6586
|
objShapeRects.forEach((objR) => {
|
|
6506
6587
|
staticShapeRects.forEach((staticR) => {
|
|
6507
|
-
if (
|
|
6508
|
-
y = verticalPos === 1 /* Below */ ? Math.max(y, staticR.bottom + objR.toph + objR.
|
|
6588
|
+
if (AnchoredRect21.overlapX(objR, staticR)) {
|
|
6589
|
+
y = verticalPos === 1 /* Below */ ? Math.max(y, staticR.bottom + objR.toph + objR.anchorY) : Math.min(y, staticR.top - objR.bottomh - objR.anchorY);
|
|
6509
6590
|
}
|
|
6510
6591
|
});
|
|
6511
6592
|
});
|
|
@@ -6532,35 +6613,33 @@ var LayoutObjectWrapper = class {
|
|
|
6532
6613
|
var LayoutGroup = class {
|
|
6533
6614
|
constructor(layoutGroupId) {
|
|
6534
6615
|
this.layoutGroupId = layoutGroupId;
|
|
6535
|
-
|
|
6616
|
+
// key = VerticalPos
|
|
6617
|
+
__publicField(this, "layoutObject", asMulti2(new IndexArray3()));
|
|
6536
6618
|
__publicField(this, "rowAlign");
|
|
6537
|
-
__publicField(this, "
|
|
6538
|
-
this
|
|
6539
|
-
|
|
6540
|
-
this.rowAlign =
|
|
6541
|
-
this.
|
|
6619
|
+
__publicField(this, "reserveSpace");
|
|
6620
|
+
__publicField(this, "padding");
|
|
6621
|
+
var _a, _b, _c, _d;
|
|
6622
|
+
this.rowAlign = ((_a = LayoutGroupIdAttrs.get(layoutGroupId)) == null ? void 0 : _a.rowAlign) === true;
|
|
6623
|
+
this.reserveSpace = ((_b = LayoutGroupIdAttrs.get(layoutGroupId)) == null ? void 0 : _b.reserveSpace) === true;
|
|
6624
|
+
this.padding = (_d = (_c = LayoutGroupIdAttrs.get(layoutGroupId)) == null ? void 0 : _c.padding) != null ? _d : 0;
|
|
6542
6625
|
}
|
|
6543
6626
|
getLayoutObjects(verticalPos) {
|
|
6544
|
-
return this.
|
|
6627
|
+
return this.layoutObject.getAll(verticalPos);
|
|
6545
6628
|
}
|
|
6546
6629
|
add(layoutObj) {
|
|
6547
|
-
this.
|
|
6630
|
+
this.layoutObject.add(layoutObj.verticalPos, layoutObj);
|
|
6548
6631
|
}
|
|
6549
6632
|
remove(layoutObj) {
|
|
6550
|
-
this.
|
|
6551
|
-
let i = layoutObjects.indexOf(layoutObj);
|
|
6552
|
-
if (i >= 0) {
|
|
6553
|
-
layoutObjects.splice(i, 1);
|
|
6554
|
-
}
|
|
6555
|
-
});
|
|
6633
|
+
this.layoutObject.remove(layoutObj.verticalPos, layoutObj);
|
|
6556
6634
|
}
|
|
6557
|
-
|
|
6558
|
-
this.
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6635
|
+
layout(ctx) {
|
|
6636
|
+
for (const w of this.layoutObject.values()) {
|
|
6637
|
+
w.resetPositionResolved();
|
|
6638
|
+
w.musicObj.layout(ctx);
|
|
6639
|
+
}
|
|
6640
|
+
}
|
|
6641
|
+
getPadding(ctx) {
|
|
6642
|
+
return this.padding * ctx.unitSize;
|
|
6564
6643
|
}
|
|
6565
6644
|
};
|
|
6566
6645
|
|
|
@@ -6570,7 +6649,7 @@ var ObjNotationLine5 = class extends MusicObject {
|
|
|
6570
6649
|
super(row);
|
|
6571
6650
|
this.row = row;
|
|
6572
6651
|
__publicField(this, "objects", []);
|
|
6573
|
-
__publicField(this, "layoutGroups",
|
|
6652
|
+
__publicField(this, "layoutGroups", new UniMap7());
|
|
6574
6653
|
}
|
|
6575
6654
|
addObject(o) {
|
|
6576
6655
|
this.objects.push(o);
|
|
@@ -6579,41 +6658,36 @@ var ObjNotationLine5 = class extends MusicObject {
|
|
|
6579
6658
|
this.objects.length = 0;
|
|
6580
6659
|
}
|
|
6581
6660
|
getLayoutGroup(lauoutGroupId) {
|
|
6582
|
-
|
|
6583
|
-
if (!layoutGroup) {
|
|
6584
|
-
layoutGroup = this.layoutGroups[lauoutGroupId] = new LayoutGroup(lauoutGroupId);
|
|
6585
|
-
}
|
|
6586
|
-
return layoutGroup;
|
|
6661
|
+
return this.layoutGroups.getOrCreate(lauoutGroupId, () => new LayoutGroup(lauoutGroupId));
|
|
6587
6662
|
}
|
|
6588
6663
|
resetLayoutGroups(ctx) {
|
|
6589
|
-
this.layoutGroups.forEach((layoutGroup) =>
|
|
6590
|
-
if (layoutGroup) {
|
|
6591
|
-
layoutGroup.clearPositionAndLayout(ctx);
|
|
6592
|
-
}
|
|
6593
|
-
});
|
|
6664
|
+
this.layoutGroups.forEach((layoutGroup) => layoutGroup.layout(ctx));
|
|
6594
6665
|
}
|
|
6595
6666
|
layoutLayoutGroups(ctx) {
|
|
6596
|
-
|
|
6667
|
+
for (const groupId of Utils10.Enum.getEnumValues(LayoutGroupId)) {
|
|
6668
|
+
const layoutGroup = this.getLayoutGroup(groupId);
|
|
6597
6669
|
if (layoutGroup) {
|
|
6598
6670
|
this.layoutLayoutGroup(ctx, layoutGroup, 0 /* Above */);
|
|
6599
6671
|
this.layoutLayoutGroup(ctx, layoutGroup, 1 /* Below */);
|
|
6600
6672
|
}
|
|
6601
|
-
}
|
|
6673
|
+
}
|
|
6602
6674
|
}
|
|
6603
6675
|
setObjectY(layoutObj, y) {
|
|
6604
6676
|
if (y === void 0) {
|
|
6605
6677
|
return;
|
|
6606
6678
|
}
|
|
6607
|
-
layoutObj.offset(0, y - layoutObj.getRect().
|
|
6679
|
+
layoutObj.offset(0, y - layoutObj.getRect().anchorY);
|
|
6608
6680
|
layoutObj.setPositionResolved();
|
|
6609
6681
|
}
|
|
6610
|
-
alignObjectsY(ctx,
|
|
6611
|
-
layoutObjArr =
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6682
|
+
alignObjectsY(ctx, layoutObjects, verticalPos) {
|
|
6683
|
+
const layoutObjArr = layoutObjects.filter((obj) => !obj.isPositionResolved() && obj.verticalPos === verticalPos);
|
|
6684
|
+
if (layoutObjArr.length === 0)
|
|
6685
|
+
return;
|
|
6686
|
+
const vdir = verticalPos === 1 /* Below */ ? 1 : -1;
|
|
6687
|
+
let yArr = layoutObjArr.map((layoutObj) => {
|
|
6688
|
+
return layoutObj.resolveClosestToStaffY(ctx) + layoutObj.layoutGroup.getPadding(ctx) * vdir;
|
|
6616
6689
|
});
|
|
6690
|
+
const rowY = verticalPos === 1 /* Below */ ? Math.max(...yArr) : Math.min(...yArr);
|
|
6617
6691
|
layoutObjArr.forEach((layoutObj) => this.setObjectY(layoutObj, rowY));
|
|
6618
6692
|
}
|
|
6619
6693
|
layoutLayoutGroup(ctx, layoutGroup, verticalPos) {
|
|
@@ -6623,20 +6697,20 @@ var ObjNotationLine5 = class extends MusicObject {
|
|
|
6623
6697
|
if (musicObj instanceof ObjEnding || musicObj instanceof ObjExtensionLine || musicObj instanceof ObjTabRhythm) {
|
|
6624
6698
|
musicObj.layoutFitToMeasure(ctx);
|
|
6625
6699
|
} else {
|
|
6626
|
-
musicObj.offset(anchor.getRect().
|
|
6700
|
+
musicObj.offset(anchor.getRect().anchorX - musicObj.getRect().anchorX, 0);
|
|
6627
6701
|
}
|
|
6628
6702
|
});
|
|
6629
6703
|
if (layoutGroup.rowAlign) {
|
|
6630
|
-
this.alignObjectsY(ctx, rowLayoutObjs);
|
|
6704
|
+
this.alignObjectsY(ctx, rowLayoutObjs, verticalPos);
|
|
6631
6705
|
} else {
|
|
6632
6706
|
rowLayoutObjs.forEach((layoutObj) => {
|
|
6633
6707
|
let link = layoutObj.musicObj.getLink();
|
|
6634
6708
|
if (link && link.getHead() === layoutObj.musicObj) {
|
|
6635
6709
|
let objectParts = [link.getHead(), ...link.getTails()];
|
|
6636
6710
|
let layoutObjs = rowLayoutObjs.filter((layoutObj2) => objectParts.some((o) => o === layoutObj2.musicObj));
|
|
6637
|
-
this.alignObjectsY(ctx, layoutObjs);
|
|
6711
|
+
this.alignObjectsY(ctx, layoutObjs, verticalPos);
|
|
6638
6712
|
} else {
|
|
6639
|
-
this.alignObjectsY(ctx, [layoutObj]);
|
|
6713
|
+
this.alignObjectsY(ctx, [layoutObj], verticalPos);
|
|
6640
6714
|
}
|
|
6641
6715
|
});
|
|
6642
6716
|
}
|
|
@@ -6743,7 +6817,7 @@ var ObjStaff = class extends ObjNotationLine5 {
|
|
|
6743
6817
|
return diatonicId % 2 !== this.middleLineDiatonicId % 2;
|
|
6744
6818
|
}
|
|
6745
6819
|
containsVoiceId(voiceId) {
|
|
6746
|
-
return
|
|
6820
|
+
return Guard9.isUndefined(this.staffConfig.voiceId) || Utils10.Arr.toArray(this.staffConfig.voiceId).includes(voiceId);
|
|
6747
6821
|
}
|
|
6748
6822
|
calcTop() {
|
|
6749
6823
|
let top = this.topLineY;
|
|
@@ -6773,7 +6847,7 @@ var ObjStaff = class extends ObjNotationLine5 {
|
|
|
6773
6847
|
let h = unitSize * DocumentSettings.StaffHeight;
|
|
6774
6848
|
this.topLineY = -h / 2;
|
|
6775
6849
|
this.bottomLineY = h / 2;
|
|
6776
|
-
this.rect = new
|
|
6850
|
+
this.rect = new AnchoredRect22(0, 0, this.topLineY, this.bottomLineY);
|
|
6777
6851
|
}
|
|
6778
6852
|
layoutWidth(ctx) {
|
|
6779
6853
|
this.rect.left = this.row.getRect().left;
|
|
@@ -6805,7 +6879,7 @@ var ObjTab = class extends ObjNotationLine5 {
|
|
|
6805
6879
|
__publicField(this, "tuningName");
|
|
6806
6880
|
__publicField(this, "tuningStrings");
|
|
6807
6881
|
__publicField(this, "mi");
|
|
6808
|
-
if (
|
|
6882
|
+
if (Guard9.isArray(tabConfig.tuning)) {
|
|
6809
6883
|
this.tuningName = void 0;
|
|
6810
6884
|
this.tuningStrings = tabConfig.tuning.map((noteName) => Note8.getNote(noteName)).reverse();
|
|
6811
6885
|
} else if (typeof tabConfig.tuning === "string") {
|
|
@@ -6856,7 +6930,7 @@ var ObjTab = class extends ObjNotationLine5 {
|
|
|
6856
6930
|
return this.bottom;
|
|
6857
6931
|
}
|
|
6858
6932
|
containsVoiceId(voiceId) {
|
|
6859
|
-
return
|
|
6933
|
+
return Guard9.isUndefined(this.tabConfig.voiceId) || Utils10.Arr.toArray(this.tabConfig.voiceId).includes(voiceId);
|
|
6860
6934
|
}
|
|
6861
6935
|
containsDiatonicId(diatonicId) {
|
|
6862
6936
|
return true;
|
|
@@ -6879,7 +6953,7 @@ var ObjTab = class extends ObjNotationLine5 {
|
|
|
6879
6953
|
let h = unitSize * DocumentSettings.TabHeight;
|
|
6880
6954
|
this.top = -h / 2;
|
|
6881
6955
|
this.bottom = h / 2;
|
|
6882
|
-
this.rect = new
|
|
6956
|
+
this.rect = new AnchoredRect22(0, 0, this.top, this.bottom);
|
|
6883
6957
|
}
|
|
6884
6958
|
layoutWidth(ctx) {
|
|
6885
6959
|
this.rect.left = this.row.getRect().left;
|
|
@@ -6903,7 +6977,7 @@ var ObjTab = class extends ObjNotationLine5 {
|
|
|
6903
6977
|
|
|
6904
6978
|
// src/score/engine/obj-score-row.ts
|
|
6905
6979
|
import { MusicError as MusicError16, MusicErrorType as MusicErrorType16 } from "@tspro/web-music-score/core";
|
|
6906
|
-
import { Utils as
|
|
6980
|
+
import { AnchoredRect as AnchoredRect23, Guard as Guard10, Utils as Utils11 } from "@tspro/ts-utils-lib";
|
|
6907
6981
|
var ObjScoreRow = class extends MusicObject {
|
|
6908
6982
|
constructor(doc, prevRow, scoreConfig) {
|
|
6909
6983
|
super(doc);
|
|
@@ -6935,7 +7009,7 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
6935
7009
|
}
|
|
6936
7010
|
this.instrumentLineGroups = lineGroups;
|
|
6937
7011
|
this.instrumentNames = this.instrumentLineGroups.map((lines) => {
|
|
6938
|
-
return lines.length > 0 &&
|
|
7012
|
+
return lines.length > 0 && Guard10.isNonEmptyString(lines[0].getConfig().instrument) ? new ObjText(this, String(lines[0].getConfig().instrument), 0, 0.5) : void 0;
|
|
6939
7013
|
});
|
|
6940
7014
|
if (this.prevRow) {
|
|
6941
7015
|
this.prevRow.nextRow = this;
|
|
@@ -6965,7 +7039,7 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
6965
7039
|
}
|
|
6966
7040
|
findMatchingLine(line) {
|
|
6967
7041
|
return line.row === this ? line : this.notationLines.find(
|
|
6968
|
-
(curLine) =>
|
|
7042
|
+
(curLine) => Utils11.Obj.deepEqual(line.row.scoreConfig, curLine.row.scoreConfig) && line.id === curLine.id || Guard10.isNonEmptyString(line.getConfig().name) && line.getConfig().name === curLine.getConfig().name && line.getConfig().type === curLine.getConfig().type
|
|
6969
7043
|
);
|
|
6970
7044
|
}
|
|
6971
7045
|
getStaves() {
|
|
@@ -7041,7 +7115,7 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7041
7115
|
let r = this.getRect();
|
|
7042
7116
|
let firstMeasure = this.getFirstMeasure();
|
|
7043
7117
|
let left = firstMeasure ? firstMeasure.getColumnsContentRect().left : r.left;
|
|
7044
|
-
return new
|
|
7118
|
+
return new AnchoredRect23(left, (left + r.right) / 2, r.right, r.top, r.anchorY, r.bottom);
|
|
7045
7119
|
}
|
|
7046
7120
|
getDiatonicIdAt(y) {
|
|
7047
7121
|
for (let i = 0; i < this.notationLines.length; i++) {
|
|
@@ -7091,7 +7165,7 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7091
7165
|
return "up" /* Up */;
|
|
7092
7166
|
}
|
|
7093
7167
|
let diatonicIds = noteGroupDiatonicIds.length > 0 ? noteGroupDiatonicIds : restDiatonicIds;
|
|
7094
|
-
let avgDiatonicId = Math.floor(
|
|
7168
|
+
let avgDiatonicId = Math.floor(Utils11.Math.avg(...diatonicIds));
|
|
7095
7169
|
let staves = this.getStaves().filter((staff) => staff.containsVoiceId(voiceId) && staff.containsDiatonicId(avgDiatonicId));
|
|
7096
7170
|
return staves.length > 0 ? avgDiatonicId >= staves[0].middleLineDiatonicId ? "down" /* Down */ : "up" /* Up */ : "up" /* Up */;
|
|
7097
7171
|
}
|
|
@@ -7126,21 +7200,21 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7126
7200
|
if (!this.needLayout) {
|
|
7127
7201
|
return;
|
|
7128
7202
|
}
|
|
7129
|
-
this.rect = new
|
|
7203
|
+
this.rect = new AnchoredRect23(0, right, 0, 0);
|
|
7130
7204
|
this.notationLines.forEach((line) => line.layoutWidth(ctx));
|
|
7131
7205
|
let targetColumnsAreaWidth = right - left;
|
|
7132
7206
|
let minColumnsAreaWidth = 0;
|
|
7133
7207
|
this.measures.forEach((m) => {
|
|
7134
|
-
targetColumnsAreaWidth -= m.
|
|
7135
|
-
minColumnsAreaWidth += m.
|
|
7208
|
+
targetColumnsAreaWidth -= m.getTotalSolidWidth() + m.getPostMeasureBreakWidth();
|
|
7209
|
+
minColumnsAreaWidth += m.getMinColumnsWidth();
|
|
7136
7210
|
});
|
|
7137
7211
|
let columnsAreaScale = targetColumnsAreaWidth / minColumnsAreaWidth;
|
|
7138
|
-
let x = this.doc.
|
|
7212
|
+
let x = this.doc.getInstrumentGroupRegions(ctx).braceRight;
|
|
7139
7213
|
this.measures.forEach((m) => {
|
|
7140
|
-
let newMeasureWidth = m.
|
|
7214
|
+
let newMeasureWidth = m.getTotalSolidWidth() + m.getMinColumnsWidth() * columnsAreaScale;
|
|
7141
7215
|
m.layoutWidth(ctx, newMeasureWidth);
|
|
7142
7216
|
let r = m.getRect();
|
|
7143
|
-
m.offset(x - r.left, -r.
|
|
7217
|
+
m.offset(x - r.left, -r.anchorY);
|
|
7144
7218
|
x += r.width;
|
|
7145
7219
|
x += m.getPostMeasureBreakWidth();
|
|
7146
7220
|
});
|
|
@@ -7154,7 +7228,7 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7154
7228
|
let right = this.measures.length > 0 ? this.measures[this.measures.length - 1].getRect().right : left;
|
|
7155
7229
|
let top = this.measures.length > 0 ? Math.min(...this.measures.map((m) => m.getRect().top)) : 0;
|
|
7156
7230
|
let bottom = this.measures.length > 0 ? Math.max(...this.measures.map((m) => m.getRect().bottom)) : 0;
|
|
7157
|
-
this.rect = new
|
|
7231
|
+
this.rect = new AnchoredRect23(left, right, top, bottom);
|
|
7158
7232
|
}
|
|
7159
7233
|
alignStemsToBeams() {
|
|
7160
7234
|
this.measures.forEach((m) => m.alignStemsToBeams());
|
|
@@ -7189,7 +7263,7 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7189
7263
|
if (obj && grp.length > 0) {
|
|
7190
7264
|
obj.offset(
|
|
7191
7265
|
-obj.getRect().left,
|
|
7192
|
-
-obj.getRect().
|
|
7266
|
+
-obj.getRect().anchorY + (grp[0].getRect().top + grp[grp.length - 1].getRect().bottom) / 2
|
|
7193
7267
|
);
|
|
7194
7268
|
}
|
|
7195
7269
|
});
|
|
@@ -7228,11 +7302,11 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7228
7302
|
}
|
|
7229
7303
|
this.measures.forEach((m) => m.draw(ctx));
|
|
7230
7304
|
this.notationLines.forEach((m) => m.draw(ctx));
|
|
7231
|
-
let grpSize = this.doc.
|
|
7305
|
+
let grpSize = this.doc.getInstrumentGroupRegions(ctx);
|
|
7232
7306
|
this.instrumentNames.forEach((obj, i) => {
|
|
7233
7307
|
let grp = this.instrumentLineGroups[i];
|
|
7234
7308
|
if (grp.length > 1) {
|
|
7235
|
-
let r = new
|
|
7309
|
+
let r = new AnchoredRect23(
|
|
7236
7310
|
grpSize.braceLeft,
|
|
7237
7311
|
grpSize.braceRight,
|
|
7238
7312
|
grp[0].getTopLineY(),
|
|
@@ -7249,6 +7323,7 @@ var ObjScoreRow = class extends MusicObject {
|
|
|
7249
7323
|
};
|
|
7250
7324
|
|
|
7251
7325
|
// src/score/engine/obj-header.ts
|
|
7326
|
+
import { AnchoredRect as AnchoredRect24 } from "@tspro/ts-utils-lib";
|
|
7252
7327
|
var ObjHeader = class extends MusicObject {
|
|
7253
7328
|
constructor(doc, title, composer, arranger) {
|
|
7254
7329
|
super(doc);
|
|
@@ -7293,7 +7368,7 @@ var ObjHeader = class extends MusicObject {
|
|
|
7293
7368
|
}
|
|
7294
7369
|
layoutWidth(ctx, left, right) {
|
|
7295
7370
|
let top = 0;
|
|
7296
|
-
this.rect = new
|
|
7371
|
+
this.rect = new AnchoredRect24(left, right, 0, 0);
|
|
7297
7372
|
if (this.titleText) {
|
|
7298
7373
|
this.titleText.layout(ctx);
|
|
7299
7374
|
this.titleText.offset((left + right) / 2, top);
|
|
@@ -7339,8 +7414,25 @@ var ObjHeader = class extends MusicObject {
|
|
|
7339
7414
|
};
|
|
7340
7415
|
|
|
7341
7416
|
// src/score/engine/obj-document.ts
|
|
7342
|
-
import {
|
|
7417
|
+
import { AnchoredRect as AnchoredRect25, Guard as Guard11, UniMap as UniMap8 } from "@tspro/ts-utils-lib";
|
|
7343
7418
|
import { MusicError as MusicError17, MusicErrorType as MusicErrorType17 } from "@tspro/web-music-score/core";
|
|
7419
|
+
var InstrumentGroupRegions = class {
|
|
7420
|
+
constructor() {
|
|
7421
|
+
__publicField(this, "nameLeft", 0);
|
|
7422
|
+
__publicField(this, "nameRight", 0);
|
|
7423
|
+
__publicField(this, "braceLeft", 0);
|
|
7424
|
+
__publicField(this, "braceRight", 0);
|
|
7425
|
+
}
|
|
7426
|
+
get left() {
|
|
7427
|
+
return this.nameLeft;
|
|
7428
|
+
}
|
|
7429
|
+
get right() {
|
|
7430
|
+
return this.braceRight;
|
|
7431
|
+
}
|
|
7432
|
+
get width() {
|
|
7433
|
+
return this.right - this.left;
|
|
7434
|
+
}
|
|
7435
|
+
};
|
|
7344
7436
|
var ObjDocument = class extends MusicObject {
|
|
7345
7437
|
constructor() {
|
|
7346
7438
|
super(void 0);
|
|
@@ -7353,7 +7445,8 @@ var ObjDocument = class extends MusicObject {
|
|
|
7353
7445
|
__publicField(this, "header");
|
|
7354
7446
|
__publicField(this, "newRowRequested", false);
|
|
7355
7447
|
__publicField(this, "allConnectiveProps", []);
|
|
7356
|
-
__publicField(this, "staffGroups",
|
|
7448
|
+
__publicField(this, "staffGroups", new UniMap8());
|
|
7449
|
+
__publicField(this, "instrumentGroupRegions", new InstrumentGroupRegions());
|
|
7357
7450
|
__publicField(this, "mi");
|
|
7358
7451
|
this.mi = new MDocument2(this);
|
|
7359
7452
|
}
|
|
@@ -7361,7 +7454,7 @@ var ObjDocument = class extends MusicObject {
|
|
|
7361
7454
|
return this.mi;
|
|
7362
7455
|
}
|
|
7363
7456
|
setScoreConfiguration(config) {
|
|
7364
|
-
if (
|
|
7457
|
+
if (Guard11.isEnumValue(config, StaffPreset)) {
|
|
7365
7458
|
switch (config) {
|
|
7366
7459
|
default:
|
|
7367
7460
|
case "treble" /* Treble */:
|
|
@@ -7389,7 +7482,7 @@ var ObjDocument = class extends MusicObject {
|
|
|
7389
7482
|
];
|
|
7390
7483
|
break;
|
|
7391
7484
|
}
|
|
7392
|
-
} else if (
|
|
7485
|
+
} else if (Guard11.isArray(config)) {
|
|
7393
7486
|
this.curScoreConfig = config;
|
|
7394
7487
|
} else {
|
|
7395
7488
|
this.curScoreConfig = [config];
|
|
@@ -7515,7 +7608,7 @@ var ObjDocument = class extends MusicObject {
|
|
|
7515
7608
|
lastRow = this.addNewRow(lastRow);
|
|
7516
7609
|
this.newRowRequested = false;
|
|
7517
7610
|
}
|
|
7518
|
-
let measure = new
|
|
7611
|
+
let measure = new ObjMeasure(lastRow, measureOptions);
|
|
7519
7612
|
this.measures.push(measure);
|
|
7520
7613
|
lastRow.addMeasure(measure);
|
|
7521
7614
|
this.requestLayout();
|
|
@@ -7550,17 +7643,16 @@ var ObjDocument = class extends MusicObject {
|
|
|
7550
7643
|
this.ctx.updateCursorRect(cursorRect);
|
|
7551
7644
|
}
|
|
7552
7645
|
}
|
|
7553
|
-
|
|
7646
|
+
getInstrumentGroupRegions(ctx) {
|
|
7554
7647
|
let nameWidth = Math.max(0, ...this.rows.map((row) => row.getInstrumentNameWidth(ctx)));
|
|
7555
7648
|
let hasName = nameWidth > 0;
|
|
7556
7649
|
let padding = hasName ? ctx.unitSize : 0;
|
|
7557
7650
|
let braceWidth = hasName ? ctx.unitSize * 5 : 0;
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
};
|
|
7651
|
+
this.instrumentGroupRegions.nameLeft = 0;
|
|
7652
|
+
this.instrumentGroupRegions.nameRight = nameWidth;
|
|
7653
|
+
this.instrumentGroupRegions.braceLeft = nameWidth + padding;
|
|
7654
|
+
this.instrumentGroupRegions.braceRight = nameWidth + padding + braceWidth + padding;
|
|
7655
|
+
return this.instrumentGroupRegions;
|
|
7564
7656
|
}
|
|
7565
7657
|
requestLayout() {
|
|
7566
7658
|
this.needLayout = true;
|
|
@@ -7590,18 +7682,18 @@ var ObjDocument = class extends MusicObject {
|
|
|
7590
7682
|
this.allConnectiveProps.forEach((props) => props.createConnectives());
|
|
7591
7683
|
this.rows.forEach((row) => row.resetLayoutGroups(ctx));
|
|
7592
7684
|
this.rows.forEach((row) => row.layout(ctx));
|
|
7593
|
-
let
|
|
7594
|
-
let
|
|
7685
|
+
let rowLeft = this.getInstrumentGroupRegions(ctx).right;
|
|
7686
|
+
let rowRight = rowLeft + Math.max(
|
|
7595
7687
|
DocumentSettings.DocumentMinWidth * unitSize,
|
|
7596
|
-
...this.rows.map((row) =>
|
|
7688
|
+
...this.rows.map((row) => row.getMinWidth())
|
|
7597
7689
|
);
|
|
7598
|
-
this.rows.forEach((row) => row.layoutWidth(ctx,
|
|
7690
|
+
this.rows.forEach((row) => row.layoutWidth(ctx, rowLeft, rowRight));
|
|
7599
7691
|
this.rows.forEach((row) => row.layoutLayoutGroups(ctx));
|
|
7600
7692
|
this.rows.forEach((row) => row.layoutSetNotationLines(ctx));
|
|
7601
7693
|
this.rows.forEach((row) => row.layoutPadding(ctx));
|
|
7602
|
-
this.rect = new
|
|
7694
|
+
this.rect = new AnchoredRect25();
|
|
7603
7695
|
if (this.header) {
|
|
7604
|
-
this.header.layoutWidth(ctx,
|
|
7696
|
+
this.header.layoutWidth(ctx, rowLeft, rowRight);
|
|
7605
7697
|
this.rect.expandInPlace(this.header.getRect());
|
|
7606
7698
|
}
|
|
7607
7699
|
this.rows.forEach((row) => {
|
|
@@ -7661,126 +7753,106 @@ var ObjDocument = class extends MusicObject {
|
|
|
7661
7753
|
};
|
|
7662
7754
|
|
|
7663
7755
|
// src/score/pub/document-builder.ts
|
|
7664
|
-
import { BeamGrouping, KeySignature as KeySignature3, Note as Note10, NoteLength as NoteLength8, RhythmProps as RhythmProps6, Scale as Scale2, ScaleType, SymbolSet as SymbolSet2, TimeSignature as TimeSignature2, TimeSignatures, TuningNameList
|
|
7756
|
+
import { BeamGrouping, isNoteLength, isTupletRatio, KeySignature as KeySignature3, Note as Note10, NoteLength as NoteLength8, RhythmProps as RhythmProps6, Scale as Scale2, ScaleType, SymbolSet as SymbolSet2, TimeSignature as TimeSignature2, TimeSignatures, TuningNameList } from "@tspro/web-music-score/theory";
|
|
7665
7757
|
import { MusicError as MusicError18, MusicErrorType as MusicErrorType18 } from "@tspro/web-music-score/core";
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
}
|
|
7758
|
+
var assertingFunction = "";
|
|
7759
|
+
function setAssertFunction(fnName, ...fnArgs) {
|
|
7760
|
+
let argsStr = fnArgs.map((arg) => JSON.stringify(arg)).join(", ");
|
|
7761
|
+
assertingFunction = `DocumentBuilder.${fnName}(${argsStr})`;
|
|
7670
7762
|
}
|
|
7671
|
-
function
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
}
|
|
7675
|
-
let p = Note10.parseNote(note);
|
|
7676
|
-
return p !== void 0 && p.octave !== void 0;
|
|
7677
|
-
}
|
|
7678
|
-
}
|
|
7679
|
-
function isVoiceId(value) {
|
|
7680
|
-
return Utils16.Is.isNumber(value) && getVoiceIds().indexOf(value) >= 0;
|
|
7681
|
-
}
|
|
7682
|
-
function isStringNumber(value) {
|
|
7683
|
-
return Utils16.Is.isNumber(value) && getStringNumbers().indexOf(value) >= 0;
|
|
7763
|
+
function assertArg(...conditions) {
|
|
7764
|
+
conditions.forEach((condition) => {
|
|
7765
|
+
if (!condition) throw new MusicError18(MusicErrorType18.Score, assertingFunction);
|
|
7766
|
+
});
|
|
7684
7767
|
}
|
|
7685
|
-
function
|
|
7686
|
-
|
|
7768
|
+
function assertArgMsg(condition, msg) {
|
|
7769
|
+
if (!condition) throw new MusicError18(MusicErrorType18.Score, msg);
|
|
7687
7770
|
}
|
|
7688
7771
|
function assertBaseConfig(baseConfig) {
|
|
7689
7772
|
var _a;
|
|
7690
|
-
assertArg(
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
|
|
7773
|
+
assertArg(
|
|
7774
|
+
Guard12.isObject(baseConfig),
|
|
7775
|
+
Guard12.isStringOrUndefined(baseConfig.name),
|
|
7776
|
+
Guard12.isUndefined(baseConfig.voiceId) || isVoiceId(baseConfig.voiceId) || Guard12.isArray(baseConfig.voiceId) && baseConfig.voiceId.every((voiceId) => isVoiceId(voiceId))
|
|
7777
|
+
);
|
|
7778
|
+
if (!Guard12.isUndefined(baseConfig.voiceIds)) {
|
|
7779
|
+
assertArg(isVoiceId(baseConfig.voiceIds) || Guard12.isArray(baseConfig.voiceIds) && baseConfig.voiceIds.every((voiceId) => isVoiceId(voiceId)));
|
|
7695
7780
|
console.warn(`Staff/tab config property 'voiceIds' is deprecated, use 'voiceId' instead.`);
|
|
7696
|
-
let arr =
|
|
7697
|
-
|
|
7781
|
+
let arr = Utils12.Arr.toArray((_a = baseConfig.voiceId) != null ? _a : []);
|
|
7782
|
+
Utils12.Arr.toArray(baseConfig.voiceIds).forEach((voiceId) => arr.push(voiceId));
|
|
7698
7783
|
baseConfig.voiceId = arr;
|
|
7699
7784
|
}
|
|
7700
|
-
if (
|
|
7701
|
-
baseConfig.voiceId =
|
|
7785
|
+
if (Guard12.isArray(baseConfig.voiceId)) {
|
|
7786
|
+
baseConfig.voiceId = Utils12.Arr.removeDuplicates(baseConfig.voiceId);
|
|
7702
7787
|
}
|
|
7703
|
-
assertArg(
|
|
7788
|
+
assertArg(Guard12.isStringOrUndefined(baseConfig.instrument));
|
|
7704
7789
|
}
|
|
7705
7790
|
function assertStaffConfig(staffConfig) {
|
|
7706
7791
|
assertBaseConfig(staffConfig);
|
|
7707
|
-
assertArg(
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7792
|
+
assertArg(
|
|
7793
|
+
Guard12.isObject(staffConfig),
|
|
7794
|
+
Guard12.isStrictEqual(staffConfig.type, "staff"),
|
|
7795
|
+
Guard12.isEnumValue(staffConfig.clef, Clef),
|
|
7796
|
+
Guard12.isBooleanOrUndefined(staffConfig.isOctaveDown),
|
|
7797
|
+
Guard12.isUndefined(staffConfig.minNote) || Note10.isNote(staffConfig.minNote),
|
|
7798
|
+
Guard12.isUndefined(staffConfig.maxNote) || Note10.isNote(staffConfig.maxNote),
|
|
7799
|
+
Guard12.isStringOrUndefined(staffConfig.grandId),
|
|
7800
|
+
Guard12.isBooleanOrUndefined(staffConfig.isGrand)
|
|
7801
|
+
);
|
|
7802
|
+
if (!Guard12.isUndefined(staffConfig.isGrand))
|
|
7716
7803
|
console.warn(`Staff config property 'isGrand' is deprecated, use 'grandId' instead.`);
|
|
7717
|
-
}
|
|
7718
7804
|
}
|
|
7719
7805
|
function assertTabConfig(tabConfig) {
|
|
7720
7806
|
assertBaseConfig(tabConfig);
|
|
7721
|
-
assertArg(
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
assertArg(tabConfig.tuning.length === getStringNumbers().length && tabConfig.tuning.every((s) => isNote(s)), "tabConfig.tuning", tabConfig.tuning);
|
|
7727
|
-
}
|
|
7807
|
+
assertArg(
|
|
7808
|
+
Guard12.isObject(tabConfig),
|
|
7809
|
+
Guard12.isStrictEqual(tabConfig.type, "tab"),
|
|
7810
|
+
Guard12.isUndefined(tabConfig.tuning) || Guard12.isString(tabConfig.tuning) && Guard12.isIncluded(tabConfig.tuning, TuningNameList) || Guard12.isArray(tabConfig.tuning) && Guard12.isStrictEqual(tabConfig.tuning.length, getStringNumbers().length && tabConfig.tuning.every((s) => Note10.isNote(s)))
|
|
7811
|
+
);
|
|
7728
7812
|
}
|
|
7729
7813
|
function assertNoteOptions(noteOptions) {
|
|
7730
|
-
assertArg(
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7814
|
+
assertArg(
|
|
7815
|
+
Guard12.isObject(noteOptions),
|
|
7816
|
+
Guard12.isBooleanOrUndefined(noteOptions.dotted) || Guard12.isIntegerGte(noteOptions.dotted, 0),
|
|
7817
|
+
Guard12.isEnumValueOrUndefined(noteOptions.stem, Stem),
|
|
7818
|
+
Guard12.isStringOrUndefined(noteOptions.color),
|
|
7819
|
+
Guard12.isBooleanOrUndefined(noteOptions.arpeggio) || Guard12.isEnumValue(noteOptions.arpeggio, Arpeggio),
|
|
7820
|
+
Guard12.isBooleanOrUndefined(noteOptions.staccato),
|
|
7821
|
+
Guard12.isBooleanOrUndefined(noteOptions.diamond),
|
|
7822
|
+
Guard12.isBooleanOrUndefined(noteOptions.triplet),
|
|
7823
|
+
Guard12.isUndefined(noteOptions.string) || isStringNumber(noteOptions.string) || Guard12.isEmptyArray(noteOptions.string) || Guard12.isNonEmptyArray(noteOptions.string) && noteOptions.string.every((string) => isStringNumber(string))
|
|
7824
|
+
);
|
|
7825
|
+
assertArgMsg(Guard12.isUndefined(noteOptions.tieSpan), `NoteOptions.tieSpan was removed. Use addConnective("tie", tieSpan)`);
|
|
7826
|
+
assertArgMsg(Guard12.isUndefined(noteOptions.slurSpan), `NoteOptions.slurSpan was removed. Use addConnective("slur", slurSpan)`);
|
|
7741
7827
|
}
|
|
7742
7828
|
function assertRestOptions(restOptions) {
|
|
7743
|
-
assertArg(
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7829
|
+
assertArg(
|
|
7830
|
+
Guard12.isObject(restOptions),
|
|
7831
|
+
Guard12.isBooleanOrUndefined(restOptions.dotted) || Guard12.isIntegerGte(restOptions.dotted, 0),
|
|
7832
|
+
Guard12.isStringOrUndefined(restOptions.staffPos) || Guard12.isInteger(restOptions.staffPos) || restOptions.staffPos instanceof Note10,
|
|
7833
|
+
Guard12.isStringOrUndefined(restOptions.color),
|
|
7834
|
+
Guard12.isBooleanOrUndefined(restOptions.hide),
|
|
7835
|
+
Guard12.isBooleanOrUndefined(restOptions.triplet)
|
|
7836
|
+
);
|
|
7749
7837
|
}
|
|
7750
7838
|
function assertLyricsOptions(lyricsOptions) {
|
|
7751
|
-
assertArg(
|
|
7752
|
-
|
|
7753
|
-
|
|
7839
|
+
assertArg(
|
|
7840
|
+
Guard12.isObject(lyricsOptions),
|
|
7841
|
+
Guard12.isEnumValueOrUndefined(lyricsOptions.align, LyricsAlign),
|
|
7842
|
+
Guard12.isEnumValueOrUndefined(lyricsOptions.hyphen, LyricsHyphen)
|
|
7843
|
+
);
|
|
7754
7844
|
}
|
|
7755
7845
|
function assertMeasureOptions(measureOptions) {
|
|
7756
|
-
assertArg(
|
|
7757
|
-
|
|
7846
|
+
assertArg(
|
|
7847
|
+
Guard12.isObject(measureOptions),
|
|
7848
|
+
Guard12.isBooleanOrUndefined(measureOptions.showNumber)
|
|
7849
|
+
);
|
|
7758
7850
|
}
|
|
7759
7851
|
function assertStaffTabOrGRoups(staffTabOrGroups) {
|
|
7760
7852
|
assertArg(
|
|
7761
|
-
|
|
7762
|
-
(staffTabOrGroup) => Utils16.Is.isString(staffTabOrGroup) || Utils16.Is.isIntegerGte(staffTabOrGroup, 0)
|
|
7763
|
-
),
|
|
7764
|
-
"staffTabOrGroup",
|
|
7765
|
-
staffTabOrGroups
|
|
7853
|
+
Guard12.isStringOrUndefined(staffTabOrGroups) || Guard12.isIntegerGte(staffTabOrGroups, 0) || Guard12.isNonEmptyArray(staffTabOrGroups) && staffTabOrGroups.every((staffTabOrGroup) => Guard12.isString(staffTabOrGroup) || Guard12.isIntegerGte(staffTabOrGroup, 0))
|
|
7766
7854
|
);
|
|
7767
7855
|
}
|
|
7768
|
-
function isNoteLength(noteLen) {
|
|
7769
|
-
try {
|
|
7770
|
-
validateNoteLength3(noteLen);
|
|
7771
|
-
return true;
|
|
7772
|
-
} catch (e) {
|
|
7773
|
-
return false;
|
|
7774
|
-
}
|
|
7775
|
-
}
|
|
7776
|
-
function isTupletRatio(tupletRatio) {
|
|
7777
|
-
try {
|
|
7778
|
-
validateTupletRatio(tupletRatio);
|
|
7779
|
-
return true;
|
|
7780
|
-
} catch (e) {
|
|
7781
|
-
return false;
|
|
7782
|
-
}
|
|
7783
|
-
}
|
|
7784
7856
|
var _DocumentBuilder = class _DocumentBuilder {
|
|
7785
7857
|
/**
|
|
7786
7858
|
* Create new document builder instance.
|
|
@@ -7791,27 +7863,28 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
7791
7863
|
this.doc = new ObjDocument();
|
|
7792
7864
|
}
|
|
7793
7865
|
setScoreConfiguration(config) {
|
|
7794
|
-
|
|
7866
|
+
setAssertFunction("setScoreConfiguration", config);
|
|
7867
|
+
if (Guard12.isEnumValue(config, StaffPreset)) {
|
|
7795
7868
|
this.doc.setScoreConfiguration(config);
|
|
7796
|
-
} else if (
|
|
7869
|
+
} else if (Guard12.isObject(config) && config.type === "staff") {
|
|
7797
7870
|
assertStaffConfig(config);
|
|
7798
7871
|
this.doc.setScoreConfiguration(config);
|
|
7799
|
-
} else if (
|
|
7872
|
+
} else if (Guard12.isObject(config) && config.type === "tab") {
|
|
7800
7873
|
assertTabConfig(config);
|
|
7801
7874
|
this.doc.setScoreConfiguration(config);
|
|
7802
|
-
} else if (
|
|
7875
|
+
} else if (Guard12.isNonEmptyArray(config)) {
|
|
7803
7876
|
config.forEach((c) => {
|
|
7804
|
-
if (
|
|
7877
|
+
if (Guard12.isObject(c) && c.type === "staff") {
|
|
7805
7878
|
assertStaffConfig(c);
|
|
7806
|
-
} else if (
|
|
7879
|
+
} else if (Guard12.isObject(c) && c.type === "tab") {
|
|
7807
7880
|
assertTabConfig(c);
|
|
7808
7881
|
} else {
|
|
7809
|
-
assertArg(false
|
|
7882
|
+
assertArg(false);
|
|
7810
7883
|
}
|
|
7811
7884
|
});
|
|
7812
7885
|
this.doc.setScoreConfiguration(config);
|
|
7813
7886
|
} else {
|
|
7814
|
-
assertArg(false
|
|
7887
|
+
assertArg(false);
|
|
7815
7888
|
}
|
|
7816
7889
|
return this;
|
|
7817
7890
|
}
|
|
@@ -7834,9 +7907,12 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
7834
7907
|
* @returns - This document builder instance.
|
|
7835
7908
|
*/
|
|
7836
7909
|
setHeader(title, composer, arranger) {
|
|
7837
|
-
|
|
7838
|
-
assertArg(
|
|
7839
|
-
|
|
7910
|
+
setAssertFunction("setHeader", title, composer, arranger);
|
|
7911
|
+
assertArg(
|
|
7912
|
+
Guard12.isStringOrUndefined(title),
|
|
7913
|
+
Guard12.isStringOrUndefined(composer),
|
|
7914
|
+
Guard12.isStringOrUndefined(arranger)
|
|
7915
|
+
);
|
|
7840
7916
|
this.doc.setHeader(title, composer, arranger);
|
|
7841
7917
|
return this;
|
|
7842
7918
|
}
|
|
@@ -7846,7 +7922,8 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
7846
7922
|
* @returns - This document builder instance.
|
|
7847
7923
|
*/
|
|
7848
7924
|
setMeasuresPerRow(measuresPerRow) {
|
|
7849
|
-
|
|
7925
|
+
setAssertFunction("setMeasuresPerRow", measuresPerRow);
|
|
7926
|
+
assertArg(Guard12.isIntegerGte(measuresPerRow, 1) || Guard12.isPosInfinity(measuresPerRow));
|
|
7850
7927
|
this.doc.setMeasuresPerRow(measuresPerRow);
|
|
7851
7928
|
return this;
|
|
7852
7929
|
}
|
|
@@ -7856,36 +7933,37 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
7856
7933
|
* @returns - This document builder instance.
|
|
7857
7934
|
*/
|
|
7858
7935
|
addMeasure(measureOptions) {
|
|
7936
|
+
setAssertFunction("addMeasure", measureOptions);
|
|
7859
7937
|
measureOptions != null ? measureOptions : measureOptions = {};
|
|
7860
7938
|
assertMeasureOptions(measureOptions);
|
|
7861
7939
|
this.doc.addMeasure(measureOptions);
|
|
7862
7940
|
return this;
|
|
7863
7941
|
}
|
|
7864
7942
|
setKeySignature(...args) {
|
|
7865
|
-
|
|
7943
|
+
setAssertFunction("setKeySignature", ...args);
|
|
7944
|
+
assertArg(args[0] instanceof Scale2 || args[0] instanceof KeySignature3 || Guard12.isNonEmptyString(args[0]) && Guard12.isEnumValueOrUndefined(args[1], ScaleType));
|
|
7866
7945
|
this.getMeasure().setKeySignature(...args);
|
|
7867
7946
|
return this;
|
|
7868
7947
|
}
|
|
7869
7948
|
setTimeSignature(...args) {
|
|
7949
|
+
setAssertFunction("setTimeSignature", ...args);
|
|
7870
7950
|
if (args[0] instanceof TimeSignature2) {
|
|
7871
7951
|
this.getMeasure().setTimeSignature(args[0]);
|
|
7872
|
-
} else if (
|
|
7952
|
+
} else if (Guard12.isEnumValue(args[0], TimeSignatures) && Guard12.isEnumValueOrUndefined(args[1], BeamGrouping)) {
|
|
7873
7953
|
this.getMeasure().setTimeSignature(new TimeSignature2(args[0], args[1]));
|
|
7874
|
-
} else if (
|
|
7954
|
+
} else if (Guard12.isIntegerGte(args[0], 1) && Guard12.isIntegerGte(args[1], 1) && Guard12.isEnumValueOrUndefined(args[2], BeamGrouping)) {
|
|
7875
7955
|
this.getMeasure().setTimeSignature(new TimeSignature2(args[0], args[1], args[2]));
|
|
7876
7956
|
} else {
|
|
7877
|
-
assertArg(false
|
|
7957
|
+
assertArg(false);
|
|
7878
7958
|
}
|
|
7879
7959
|
return this;
|
|
7880
7960
|
}
|
|
7881
7961
|
setTempo(beatsPerMinute, beatLength, dotted) {
|
|
7882
|
-
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
assertArg(Utils16.Is.isBooleanOrUndefined(dotted) || Utils16.Is.isIntegerGte(dotted, 0), "dotted", dotted);
|
|
7888
|
-
}
|
|
7962
|
+
setAssertFunction("setTempo", beatsPerMinute, beatLength, dotted);
|
|
7963
|
+
assertArg(
|
|
7964
|
+
Guard12.isIntegerGte(beatsPerMinute, 1),
|
|
7965
|
+
Guard12.isUndefined(beatLength) && Guard12.isUndefined(dotted) || isNoteLength(beatLength) && (Guard12.isBooleanOrUndefined(dotted) || Guard12.isIntegerGte(dotted, 0))
|
|
7966
|
+
);
|
|
7889
7967
|
this.getMeasure().setTempo(beatsPerMinute, beatLength, dotted);
|
|
7890
7968
|
return this;
|
|
7891
7969
|
}
|
|
@@ -7898,19 +7976,18 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
7898
7976
|
* @returns - This document builder instance.
|
|
7899
7977
|
*/
|
|
7900
7978
|
addNote(voiceId, note, noteLength, noteOptions) {
|
|
7901
|
-
|
|
7979
|
+
setAssertFunction("addNote", voiceId, note, noteLength, noteOptions);
|
|
7902
7980
|
assertArg(
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7981
|
+
isVoiceId(voiceId),
|
|
7982
|
+
note instanceof Note10 || Guard12.isNonEmptyString(note) || Guard12.isArray(note) && note.every((note2) => note2 instanceof Note10 || Guard12.isNonEmptyString(note2)),
|
|
7983
|
+
isNoteLength(noteLength)
|
|
7906
7984
|
);
|
|
7907
|
-
assertArg(Utils16.Is.isEnumValue(noteLength, NoteLength8) || isNoteLength(noteLength), "noteLength", noteLength);
|
|
7908
7985
|
noteOptions != null ? noteOptions : noteOptions = {};
|
|
7909
7986
|
assertNoteOptions(noteOptions);
|
|
7910
|
-
if (
|
|
7987
|
+
if (Guard12.isArray(note)) {
|
|
7911
7988
|
let string = noteOptions.string;
|
|
7912
7989
|
note.forEach((note2, noteId) => {
|
|
7913
|
-
noteOptions.string =
|
|
7990
|
+
noteOptions.string = Guard12.isArray(string) ? string[noteId] : string;
|
|
7914
7991
|
this.getMeasure().addNoteGroup(voiceId, [note2], noteLength, noteOptions);
|
|
7915
7992
|
});
|
|
7916
7993
|
} else {
|
|
@@ -7927,9 +8004,12 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
7927
8004
|
* @returns - This document builder instance.
|
|
7928
8005
|
*/
|
|
7929
8006
|
addChord(voiceId, notes, noteLength, noteOptions) {
|
|
7930
|
-
|
|
7931
|
-
assertArg(
|
|
7932
|
-
|
|
8007
|
+
setAssertFunction("addChord", voiceId, notes, noteLength, noteOptions);
|
|
8008
|
+
assertArg(
|
|
8009
|
+
isVoiceId(voiceId),
|
|
8010
|
+
Guard12.isNonEmptyArray(notes) && notes.every((note) => note instanceof Note10 || Guard12.isNonEmptyString(note)),
|
|
8011
|
+
isNoteLength(noteLength)
|
|
8012
|
+
);
|
|
7933
8013
|
noteOptions != null ? noteOptions : noteOptions = {};
|
|
7934
8014
|
assertNoteOptions(noteOptions);
|
|
7935
8015
|
this.getMeasure().addNoteGroup(voiceId, notes, noteLength, noteOptions);
|
|
@@ -7943,8 +8023,11 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
7943
8023
|
* @returns - This document builder instance.
|
|
7944
8024
|
*/
|
|
7945
8025
|
addRest(voiceId, restLength, restOptions) {
|
|
7946
|
-
|
|
7947
|
-
assertArg(
|
|
8026
|
+
setAssertFunction("addRest", voiceId, restLength, restOptions);
|
|
8027
|
+
assertArg(
|
|
8028
|
+
isVoiceId(voiceId),
|
|
8029
|
+
isNoteLength(restLength)
|
|
8030
|
+
);
|
|
7948
8031
|
restOptions != null ? restOptions : restOptions = {};
|
|
7949
8032
|
assertRestOptions(restOptions);
|
|
7950
8033
|
this.getMeasure().addRest(voiceId, restLength, restOptions);
|
|
@@ -7966,25 +8049,27 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
7966
8049
|
* @returns - This document builder instance.
|
|
7967
8050
|
*/
|
|
7968
8051
|
addTuplet(voiceId, tupletRatio, tupletBuilder) {
|
|
7969
|
-
|
|
7970
|
-
assertArg(
|
|
7971
|
-
|
|
8052
|
+
setAssertFunction("addTuplet", voiceId, tupletRatio);
|
|
8053
|
+
assertArg(
|
|
8054
|
+
isVoiceId(voiceId),
|
|
8055
|
+
Guard12.isFunction(tupletBuilder),
|
|
8056
|
+
isTupletRatio(tupletRatio) && Guard12.isBooleanOrUndefined(tupletRatio.showRatio)
|
|
8057
|
+
);
|
|
7972
8058
|
let tupletSymbols = [];
|
|
7973
8059
|
const helper = {
|
|
7974
8060
|
addNote: (note, noteLength, noteOptions) => {
|
|
8061
|
+
setAssertFunction("addTuplet => addNote", note, noteLength, noteOptions);
|
|
7975
8062
|
assertArg(
|
|
7976
|
-
note instanceof Note10 ||
|
|
7977
|
-
|
|
7978
|
-
note
|
|
8063
|
+
note instanceof Note10 || Guard12.isNonEmptyString(note) || Guard12.isArray(note) && note.every((note2) => note2 instanceof Note10 || Guard12.isNonEmptyString(note2)),
|
|
8064
|
+
isNoteLength(noteLength)
|
|
7979
8065
|
);
|
|
7980
|
-
assertArg(Utils16.Is.isEnumValue(noteLength, NoteLength8) || isNoteLength(noteLength), "noteLength", noteLength);
|
|
7981
8066
|
noteOptions != null ? noteOptions : noteOptions = {};
|
|
7982
8067
|
delete noteOptions.triplet;
|
|
7983
8068
|
assertNoteOptions(noteOptions);
|
|
7984
|
-
if (
|
|
8069
|
+
if (Guard12.isArray(note)) {
|
|
7985
8070
|
let string = noteOptions.string;
|
|
7986
8071
|
note.forEach((note2, noteId) => {
|
|
7987
|
-
noteOptions.string =
|
|
8072
|
+
noteOptions.string = Guard12.isArray(string) ? string[noteId] : string;
|
|
7988
8073
|
let s = this.getMeasure().addNoteGroup(voiceId, [note2], noteLength, noteOptions, tupletRatio);
|
|
7989
8074
|
tupletSymbols.push(s);
|
|
7990
8075
|
});
|
|
@@ -7995,8 +8080,11 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
7995
8080
|
return helper;
|
|
7996
8081
|
},
|
|
7997
8082
|
addChord: (notes, noteLength, noteOptions) => {
|
|
7998
|
-
|
|
7999
|
-
assertArg(
|
|
8083
|
+
setAssertFunction("addTuplet => addChord", notes, noteLength, noteOptions);
|
|
8084
|
+
assertArg(
|
|
8085
|
+
Guard12.isNonEmptyArray(notes) && notes.every((note) => note instanceof Note10 || Guard12.isNonEmptyString(note)),
|
|
8086
|
+
isNoteLength(noteLength)
|
|
8087
|
+
);
|
|
8000
8088
|
noteOptions != null ? noteOptions : noteOptions = {};
|
|
8001
8089
|
delete noteOptions.triplet;
|
|
8002
8090
|
assertNoteOptions(noteOptions);
|
|
@@ -8005,7 +8093,8 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8005
8093
|
return helper;
|
|
8006
8094
|
},
|
|
8007
8095
|
addRest: (restLength, restOptions) => {
|
|
8008
|
-
|
|
8096
|
+
setAssertFunction("addTuplet => addRest", restLength, restOptions);
|
|
8097
|
+
assertArg(isNoteLength(restLength));
|
|
8009
8098
|
restOptions != null ? restOptions : restOptions = {};
|
|
8010
8099
|
delete restOptions.triplet;
|
|
8011
8100
|
assertRestOptions(restOptions);
|
|
@@ -8021,9 +8110,11 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8021
8110
|
addLyricsInternal(staffTabOrGroups, verse, lyricsLength, lyricsText, lyricsOptions) {
|
|
8022
8111
|
var _a;
|
|
8023
8112
|
assertStaffTabOrGRoups(staffTabOrGroups);
|
|
8024
|
-
assertArg(
|
|
8025
|
-
|
|
8026
|
-
|
|
8113
|
+
assertArg(
|
|
8114
|
+
isVerseNumber(verse),
|
|
8115
|
+
Guard12.isEnumValue(lyricsLength, NoteLength8),
|
|
8116
|
+
Guard12.isString(lyricsText) || Guard12.isArray(lyricsText) && lyricsText.every((text) => Guard12.isString(text))
|
|
8117
|
+
);
|
|
8027
8118
|
lyricsOptions != null ? lyricsOptions : lyricsOptions = {};
|
|
8028
8119
|
assertLyricsOptions(lyricsOptions);
|
|
8029
8120
|
if (lyricsOptions.align !== void 0) {
|
|
@@ -8031,7 +8122,7 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8031
8122
|
} else {
|
|
8032
8123
|
(_a = lyricsOptions.align) != null ? _a : lyricsOptions.align = this.currentLyricsAlign;
|
|
8033
8124
|
}
|
|
8034
|
-
if (
|
|
8125
|
+
if (Guard12.isArray(lyricsText)) {
|
|
8035
8126
|
lyricsText.forEach((text) => this.getMeasure().addLyrics(staffTabOrGroups, verse, lyricsLength, text, lyricsOptions));
|
|
8036
8127
|
} else {
|
|
8037
8128
|
this.getMeasure().addLyrics(staffTabOrGroups, verse, lyricsLength, lyricsText, lyricsOptions);
|
|
@@ -8047,6 +8138,7 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8047
8138
|
* @returns - This document builder instance.
|
|
8048
8139
|
*/
|
|
8049
8140
|
addLyrics(verse, lyricsLength, lyricsText, lyricsOptions) {
|
|
8141
|
+
setAssertFunction("addLyrics", verse, lyricsLength, lyricsText, lyricsOptions);
|
|
8050
8142
|
return this.addLyricsInternal(void 0, verse, lyricsLength, lyricsText != null ? lyricsText : "", lyricsOptions);
|
|
8051
8143
|
}
|
|
8052
8144
|
/**
|
|
@@ -8059,11 +8151,12 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8059
8151
|
* @returns - This document builder instance.
|
|
8060
8152
|
*/
|
|
8061
8153
|
addLyricsTo(staffTabOrGroups, verse, lyricsLength, lyricsText, lyricsOptions) {
|
|
8154
|
+
setAssertFunction("addLyricsTo", verse, lyricsLength, lyricsText, lyricsOptions);
|
|
8062
8155
|
return this.addLyricsInternal(staffTabOrGroups, verse, lyricsLength, lyricsText != null ? lyricsText : "", lyricsOptions);
|
|
8063
8156
|
}
|
|
8064
8157
|
addFermataInternal(staffTabOrGroups, fermata) {
|
|
8065
8158
|
assertStaffTabOrGRoups(staffTabOrGroups);
|
|
8066
|
-
assertArg(
|
|
8159
|
+
assertArg(Guard12.isEnumValue(fermata, Fermata));
|
|
8067
8160
|
this.getMeasure().addFermata(staffTabOrGroups, fermata);
|
|
8068
8161
|
return this;
|
|
8069
8162
|
}
|
|
@@ -8073,6 +8166,7 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8073
8166
|
* @returns - This document builder instance.
|
|
8074
8167
|
*/
|
|
8075
8168
|
addFermata(fermata = "atNote" /* AtNote */) {
|
|
8169
|
+
setAssertFunction("addFermata", fermata);
|
|
8076
8170
|
return this.addFermataInternal(void 0, fermata);
|
|
8077
8171
|
}
|
|
8078
8172
|
/**
|
|
@@ -8082,23 +8176,23 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8082
8176
|
* @returns - This document builder instance.
|
|
8083
8177
|
*/
|
|
8084
8178
|
addFermataTo(staffTabOrGroups, fermata = "atNote" /* AtNote */) {
|
|
8179
|
+
setAssertFunction("addFermataTo", staffTabOrGroups, fermata);
|
|
8085
8180
|
return this.addFermataInternal(staffTabOrGroups, fermata);
|
|
8086
8181
|
}
|
|
8087
8182
|
addNavigationInternal(staffTabOrGroups, navigation, ...args) {
|
|
8088
8183
|
assertStaffTabOrGRoups(staffTabOrGroups);
|
|
8089
|
-
assertArg(
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
} else if (navigation === "ending" /* Ending */ && args.length > 0) {
|
|
8093
|
-
assertArg(args.every((passage) => Utils16.Is.isIntegerGte(passage, 1)), "passages", args);
|
|
8094
|
-
}
|
|
8184
|
+
assertArg(
|
|
8185
|
+
Guard12.isStrictEqual(navigation, "endRepeat" /* EndRepeat */) && Guard12.isStrictEqual(args.length, 1) || Guard12.isStrictEqual(navigation, "ending" /* Ending */) && Guard12.isIntegerGte(args.length, 1) && args.every((passage) => Guard12.isIntegerGte(passage, 1)) || Guard12.isEnumValue(navigation, Navigation) && Guard12.isEmptyArray(args)
|
|
8186
|
+
);
|
|
8095
8187
|
this.getMeasure().addNavigation(staffTabOrGroups, navigation, ...args);
|
|
8096
8188
|
return this;
|
|
8097
8189
|
}
|
|
8098
8190
|
addNavigation(navigation, ...args) {
|
|
8191
|
+
setAssertFunction("addNavigation", navigation, ...args);
|
|
8099
8192
|
return this.addNavigationInternal(void 0, navigation, ...args);
|
|
8100
8193
|
}
|
|
8101
8194
|
addNavigationTo(staffTabOrGroups, navigation, ...args) {
|
|
8195
|
+
setAssertFunction("addNavigationTo", staffTabOrGroups, navigation, ...args);
|
|
8102
8196
|
return this.addNavigationInternal(staffTabOrGroups, navigation, ...args);
|
|
8103
8197
|
}
|
|
8104
8198
|
addAnnotationInternal(staffTabOrGroups, annotation, text) {
|
|
@@ -8107,12 +8201,15 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8107
8201
|
throw new MusicError18(MusicErrorType18.Score, `Annotation text "${text}" is not known annotation.`);
|
|
8108
8202
|
}
|
|
8109
8203
|
assertStaffTabOrGRoups(staffTabOrGroups);
|
|
8110
|
-
assertArg(
|
|
8111
|
-
|
|
8204
|
+
assertArg(
|
|
8205
|
+
Guard12.isEnumValue(annotation, Annotation),
|
|
8206
|
+
Guard12.isNonEmptyString(text)
|
|
8207
|
+
);
|
|
8112
8208
|
this.getMeasure().addAnnotation(staffTabOrGroups, annotation, text);
|
|
8113
8209
|
return this;
|
|
8114
8210
|
}
|
|
8115
8211
|
addAnnotation(...args) {
|
|
8212
|
+
setAssertFunction("addAnnotation", ...args);
|
|
8116
8213
|
if (args.length === 1) {
|
|
8117
8214
|
return this.addAnnotationInternal(void 0, void 0, args[0]);
|
|
8118
8215
|
} else {
|
|
@@ -8120,6 +8217,7 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8120
8217
|
}
|
|
8121
8218
|
}
|
|
8122
8219
|
addAnnotationTo(staffTabOrGroups, ...args) {
|
|
8220
|
+
setAssertFunction("addAnnotationTo", staffTabOrGroups, ...args);
|
|
8123
8221
|
if (args.length === 1) {
|
|
8124
8222
|
return this.addAnnotationInternal(staffTabOrGroups, void 0, args[0]);
|
|
8125
8223
|
} else {
|
|
@@ -8128,8 +8226,10 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8128
8226
|
}
|
|
8129
8227
|
addLabelInternal(staffTabOrGroups, label, text) {
|
|
8130
8228
|
assertStaffTabOrGRoups(staffTabOrGroups);
|
|
8131
|
-
assertArg(
|
|
8132
|
-
|
|
8229
|
+
assertArg(
|
|
8230
|
+
Guard12.isEnumValue(label, Label),
|
|
8231
|
+
Guard12.isNonEmptyString(text)
|
|
8232
|
+
);
|
|
8133
8233
|
this.getMeasure().addLabel(staffTabOrGroups, label, text);
|
|
8134
8234
|
return this;
|
|
8135
8235
|
}
|
|
@@ -8140,6 +8240,7 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8140
8240
|
* @returns - This document builder instance.
|
|
8141
8241
|
*/
|
|
8142
8242
|
addLabel(label, text) {
|
|
8243
|
+
setAssertFunction("addLabel", label, text);
|
|
8143
8244
|
return this.addLabelInternal(void 0, label, text);
|
|
8144
8245
|
}
|
|
8145
8246
|
/**
|
|
@@ -8150,24 +8251,26 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8150
8251
|
* @returns - This document builder instance.
|
|
8151
8252
|
*/
|
|
8152
8253
|
addLabelTo(staffTabOrGroups, label, text) {
|
|
8254
|
+
setAssertFunction("addLabelTo", staffTabOrGroups, label, text);
|
|
8153
8255
|
return this.addLabelInternal(staffTabOrGroups, label, text);
|
|
8154
8256
|
}
|
|
8155
8257
|
addConnective(connective, ...args) {
|
|
8156
|
-
|
|
8258
|
+
setAssertFunction("addConnective", connective, ...args);
|
|
8259
|
+
assertArg(Guard12.isEnumValue(connective, Connective));
|
|
8157
8260
|
if (connective === "tie" /* Tie */) {
|
|
8158
|
-
assertArg(
|
|
8159
|
-
assertArg(
|
|
8261
|
+
assertArg(Guard12.isIntegerOrUndefined(args[0]) || Guard12.isEnumValue(args[0], TieType));
|
|
8262
|
+
assertArg(Guard12.isEnumValueOrUndefined(args[1], NoteAnchor));
|
|
8160
8263
|
let tieSpan = args[0];
|
|
8161
8264
|
let noteAnchor = args[1];
|
|
8162
8265
|
this.getMeasure().addConnective(connective, tieSpan, noteAnchor);
|
|
8163
8266
|
} else if (connective === "slur" /* Slur */) {
|
|
8164
|
-
assertArg(
|
|
8165
|
-
assertArg(
|
|
8267
|
+
assertArg(Guard12.isIntegerOrUndefined(args[0]));
|
|
8268
|
+
assertArg(Guard12.isEnumValueOrUndefined(args[1], NoteAnchor));
|
|
8166
8269
|
let slurSpan = args[0];
|
|
8167
8270
|
let noteAnchor = args[1];
|
|
8168
8271
|
this.getMeasure().addConnective(connective, slurSpan, noteAnchor);
|
|
8169
8272
|
} else if (connective === "slide" /* Slide */) {
|
|
8170
|
-
assertArg(
|
|
8273
|
+
assertArg(Guard12.isEnumValueOrUndefined(args[0], NoteAnchor));
|
|
8171
8274
|
let noteAnchor = args[0];
|
|
8172
8275
|
this.getMeasure().addConnective(connective, noteAnchor);
|
|
8173
8276
|
}
|
|
@@ -8186,26 +8289,31 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8186
8289
|
* @returns - This document builder instance.
|
|
8187
8290
|
*/
|
|
8188
8291
|
addExtension(extensionBuilder) {
|
|
8189
|
-
|
|
8292
|
+
setAssertFunction("addExtension");
|
|
8293
|
+
assertArgMsg(Guard12.isFunctionOrUndefined(extensionBuilder), "addExtension() has new usage, e.g. addExtension(ext => ext.measures(2)).");
|
|
8190
8294
|
let ticks = 0;
|
|
8191
8295
|
let visible = true;
|
|
8192
8296
|
const helper = {
|
|
8193
8297
|
notes: (noteLength, noteCount) => {
|
|
8194
|
-
|
|
8195
|
-
assertArg(
|
|
8298
|
+
setAssertFunction("addExtension.notes", noteLength, noteCount);
|
|
8299
|
+
assertArg(isNoteLength(noteLength));
|
|
8300
|
+
assertArg(Guard12.isUndefined(noteCount) || Guard12.isNumber(noteCount) && noteCount >= 0);
|
|
8196
8301
|
ticks += RhythmProps6.get(noteLength).ticks * (noteCount != null ? noteCount : 1);
|
|
8197
8302
|
return helper;
|
|
8198
8303
|
},
|
|
8199
8304
|
measures: (measureCount) => {
|
|
8200
|
-
|
|
8305
|
+
setAssertFunction("addExtension.measures", measureCount);
|
|
8306
|
+
assertArg(Guard12.isNumber(measureCount) && measureCount >= 1);
|
|
8201
8307
|
ticks += this.getMeasure().getMeasureTicks() * measureCount;
|
|
8202
8308
|
return helper;
|
|
8203
8309
|
},
|
|
8204
8310
|
infinity: () => {
|
|
8311
|
+
setAssertFunction("addExtension.infinity");
|
|
8205
8312
|
ticks = Infinity;
|
|
8206
8313
|
return helper;
|
|
8207
8314
|
},
|
|
8208
8315
|
hide: () => {
|
|
8316
|
+
setAssertFunction("addExtension.hide");
|
|
8209
8317
|
visible = false;
|
|
8210
8318
|
return helper;
|
|
8211
8319
|
}
|
|
@@ -8226,13 +8334,12 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8226
8334
|
* @returns - This document builder instance.
|
|
8227
8335
|
*/
|
|
8228
8336
|
addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition = "auto" /* Auto */) {
|
|
8229
|
-
|
|
8337
|
+
setAssertFunction("addStaffGroup", groupName, staffsTabsAndGroups, verticalPosition);
|
|
8230
8338
|
assertArg(
|
|
8231
|
-
|
|
8232
|
-
|
|
8233
|
-
|
|
8339
|
+
Guard12.isNonEmptyString(groupName),
|
|
8340
|
+
Guard12.isNonEmptyString(staffsTabsAndGroups) || Guard12.isIntegerGte(staffsTabsAndGroups, 0) || Guard12.isNonEmptyArray(staffsTabsAndGroups) && staffsTabsAndGroups.every((line) => Guard12.isNonEmptyString(line) || Guard12.isIntegerGte(line, 0)),
|
|
8341
|
+
Guard12.isEnumValue(verticalPosition, VerticalPosition)
|
|
8234
8342
|
);
|
|
8235
|
-
assertArg(Utils16.Is.isEnumValue(verticalPosition, VerticalPosition), "verticalPosition", verticalPosition);
|
|
8236
8343
|
this.doc.addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition);
|
|
8237
8344
|
return this;
|
|
8238
8345
|
}
|
|
@@ -8241,6 +8348,7 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8241
8348
|
* @returns - This document builder instance.
|
|
8242
8349
|
*/
|
|
8243
8350
|
endSong() {
|
|
8351
|
+
setAssertFunction("endSong");
|
|
8244
8352
|
this.getMeasure().endSong();
|
|
8245
8353
|
return this;
|
|
8246
8354
|
}
|
|
@@ -8249,6 +8357,7 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8249
8357
|
* @returns - This document builder instance.
|
|
8250
8358
|
*/
|
|
8251
8359
|
endSection() {
|
|
8360
|
+
setAssertFunction("endSection");
|
|
8252
8361
|
this.getMeasure().endSection();
|
|
8253
8362
|
return this;
|
|
8254
8363
|
}
|
|
@@ -8258,6 +8367,7 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8258
8367
|
*/
|
|
8259
8368
|
endRow() {
|
|
8260
8369
|
var _a;
|
|
8370
|
+
setAssertFunction("endRow");
|
|
8261
8371
|
(_a = this.doc.getLastMeasure()) == null ? void 0 : _a.endRow();
|
|
8262
8372
|
return this;
|
|
8263
8373
|
}
|
|
@@ -8267,7 +8377,8 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8267
8377
|
* @returns - This document builder instance.
|
|
8268
8378
|
*/
|
|
8269
8379
|
completeRests(voiceId) {
|
|
8270
|
-
|
|
8380
|
+
setAssertFunction("completeRests", voiceId);
|
|
8381
|
+
assertArg(Guard12.isUndefined(voiceId) || isVoiceId(voiceId) || Guard12.isArray(voiceId) && voiceId.every((id) => isVoiceId(id)));
|
|
8271
8382
|
this.getMeasure().completeRests(voiceId);
|
|
8272
8383
|
return this;
|
|
8273
8384
|
}
|
|
@@ -8279,8 +8390,11 @@ var _DocumentBuilder = class _DocumentBuilder {
|
|
|
8279
8390
|
* @returns - This document builder instance.
|
|
8280
8391
|
*/
|
|
8281
8392
|
addScaleArpeggio(scale, bottomNote, numOctaves) {
|
|
8282
|
-
|
|
8283
|
-
assertArg(
|
|
8393
|
+
setAssertFunction("addScaleArpeggio", scale, bottomNote, numOctaves);
|
|
8394
|
+
assertArg(
|
|
8395
|
+
Guard12.isNonEmptyString(bottomNote),
|
|
8396
|
+
Guard12.isIntegerGte(numOctaves, 1)
|
|
8397
|
+
);
|
|
8284
8398
|
let ts = this.getMeasure().getTimeSignature();
|
|
8285
8399
|
let notes = scale.getScaleNotes(bottomNote, numOctaves);
|
|
8286
8400
|
for (let i = 0; i < notes.length; i++) {
|
|
@@ -8366,19 +8480,16 @@ var ScoreObjectEvent = class extends ScoreEvent {
|
|
|
8366
8480
|
|
|
8367
8481
|
// src/score/pub/music-interface.ts
|
|
8368
8482
|
import * as Audio2 from "@tspro/web-music-score/audio";
|
|
8369
|
-
import { Utils as
|
|
8483
|
+
import { Guard as Guard14, UniMap as UniMap9, ValueSet as ValueSet2, Utils as Utils13 } from "@tspro/ts-utils-lib";
|
|
8370
8484
|
|
|
8371
8485
|
// src/score/pub/music-objects.ts
|
|
8372
|
-
import {
|
|
8486
|
+
import { Guard as Guard13 } from "@tspro/ts-utils-lib";
|
|
8373
8487
|
import { MusicError as MusicError20, MusicErrorType as MusicErrorType20 } from "@tspro/web-music-score/core";
|
|
8374
8488
|
function assertArg2(condition, argName, argValue) {
|
|
8375
8489
|
if (!condition) {
|
|
8376
8490
|
throw new MusicError20(MusicErrorType20.Score, `Invalid arg: ${argName} = ${argValue}`);
|
|
8377
8491
|
}
|
|
8378
8492
|
}
|
|
8379
|
-
function isVoiceId2(value) {
|
|
8380
|
-
return Utils17.Is.isNumber(value) && getVoiceIds().indexOf(value) >= 0;
|
|
8381
|
-
}
|
|
8382
8493
|
function getNotationLine(line) {
|
|
8383
8494
|
if (line instanceof ObjStaff || line instanceof ObjTab) {
|
|
8384
8495
|
return line.getMusicInterface();
|
|
@@ -8386,7 +8497,7 @@ function getNotationLine(line) {
|
|
|
8386
8497
|
throw new MusicError20(MusicErrorType20.Score, `Notation line not staff nor tab.`);
|
|
8387
8498
|
}
|
|
8388
8499
|
}
|
|
8389
|
-
var
|
|
8500
|
+
var MusicInterface5 = class {
|
|
8390
8501
|
/**
|
|
8391
8502
|
* Create new music interface object.
|
|
8392
8503
|
* @param name - OBject name.
|
|
@@ -8403,7 +8514,7 @@ var MusicInterface6 = class {
|
|
|
8403
8514
|
return (_a = this.getMusicObject().getParent()) == null ? void 0 : _a.getMusicInterface();
|
|
8404
8515
|
}
|
|
8405
8516
|
};
|
|
8406
|
-
var _MAccidental = class _MAccidental extends
|
|
8517
|
+
var _MAccidental = class _MAccidental extends MusicInterface5 {
|
|
8407
8518
|
/** @internal */
|
|
8408
8519
|
constructor(obj) {
|
|
8409
8520
|
super(_MAccidental.Name);
|
|
@@ -8424,7 +8535,7 @@ var _MAccidental = class _MAccidental extends MusicInterface6 {
|
|
|
8424
8535
|
/** Object name. */
|
|
8425
8536
|
__publicField(_MAccidental, "Name", "Accidental");
|
|
8426
8537
|
var MAccidental = _MAccidental;
|
|
8427
|
-
var _MConnective = class _MConnective extends
|
|
8538
|
+
var _MConnective = class _MConnective extends MusicInterface5 {
|
|
8428
8539
|
/** @internal */
|
|
8429
8540
|
constructor(obj) {
|
|
8430
8541
|
super(_MConnective.Name);
|
|
@@ -8438,7 +8549,7 @@ var _MConnective = class _MConnective extends MusicInterface6 {
|
|
|
8438
8549
|
/** Object name. */
|
|
8439
8550
|
__publicField(_MConnective, "Name", "Connective");
|
|
8440
8551
|
var MConnective = _MConnective;
|
|
8441
|
-
var _MArpeggio = class _MArpeggio extends
|
|
8552
|
+
var _MArpeggio = class _MArpeggio extends MusicInterface5 {
|
|
8442
8553
|
/** @internal */
|
|
8443
8554
|
constructor(obj) {
|
|
8444
8555
|
super(_MArpeggio.Name);
|
|
@@ -8466,7 +8577,7 @@ var _MArpeggio = class _MArpeggio extends MusicInterface6 {
|
|
|
8466
8577
|
/** Object name. */
|
|
8467
8578
|
__publicField(_MArpeggio, "Name", "Arpeggio");
|
|
8468
8579
|
var MArpeggio = _MArpeggio;
|
|
8469
|
-
var _MBeamGroup = class _MBeamGroup extends
|
|
8580
|
+
var _MBeamGroup = class _MBeamGroup extends MusicInterface5 {
|
|
8470
8581
|
/** @internal */
|
|
8471
8582
|
constructor(obj) {
|
|
8472
8583
|
super(_MBeamGroup.Name);
|
|
@@ -8480,7 +8591,7 @@ var _MBeamGroup = class _MBeamGroup extends MusicInterface6 {
|
|
|
8480
8591
|
/** OBject name. */
|
|
8481
8592
|
__publicField(_MBeamGroup, "Name", "BeamGroup");
|
|
8482
8593
|
var MBeamGroup = _MBeamGroup;
|
|
8483
|
-
var _MStaffBeamGroup = class _MStaffBeamGroup extends
|
|
8594
|
+
var _MStaffBeamGroup = class _MStaffBeamGroup extends MusicInterface5 {
|
|
8484
8595
|
/** @internal */
|
|
8485
8596
|
constructor(obj) {
|
|
8486
8597
|
super(_MStaffBeamGroup.Name);
|
|
@@ -8501,7 +8612,7 @@ var _MStaffBeamGroup = class _MStaffBeamGroup extends MusicInterface6 {
|
|
|
8501
8612
|
/** Object name. */
|
|
8502
8613
|
__publicField(_MStaffBeamGroup, "Name", "StaffBeamGroup");
|
|
8503
8614
|
var MStaffBeamGroup = _MStaffBeamGroup;
|
|
8504
|
-
var _MDocument = class _MDocument extends
|
|
8615
|
+
var _MDocument = class _MDocument extends MusicInterface5 {
|
|
8505
8616
|
/** @internal */
|
|
8506
8617
|
constructor(obj) {
|
|
8507
8618
|
super(_MDocument.Name);
|
|
@@ -8553,14 +8664,14 @@ var _MDocument = class _MDocument extends MusicInterface6 {
|
|
|
8553
8664
|
* @returns - Player instance.
|
|
8554
8665
|
*/
|
|
8555
8666
|
play(playStateChangeListener) {
|
|
8556
|
-
assertArg2(
|
|
8667
|
+
assertArg2(Guard13.isFunctionOrUndefined(playStateChangeListener), "playStateChangeListener", playStateChangeListener);
|
|
8557
8668
|
return new MPlayer(this, playStateChangeListener).play();
|
|
8558
8669
|
}
|
|
8559
8670
|
};
|
|
8560
8671
|
/** Object name. */
|
|
8561
8672
|
__publicField(_MDocument, "Name", "Document");
|
|
8562
8673
|
var MDocument2 = _MDocument;
|
|
8563
|
-
var _MEnding = class _MEnding extends
|
|
8674
|
+
var _MEnding = class _MEnding extends MusicInterface5 {
|
|
8564
8675
|
/** @internal */
|
|
8565
8676
|
constructor(obj) {
|
|
8566
8677
|
super(_MEnding.Name);
|
|
@@ -8583,14 +8694,14 @@ var _MEnding = class _MEnding extends MusicInterface6 {
|
|
|
8583
8694
|
* @returns - Boolean whether this ending has asked passage number.
|
|
8584
8695
|
*/
|
|
8585
8696
|
hasPassage(passage) {
|
|
8586
|
-
assertArg2(
|
|
8697
|
+
assertArg2(Guard13.isIntegerGte(passage, 1), "passage", passage);
|
|
8587
8698
|
return this.obj.hasPassage(passage);
|
|
8588
8699
|
}
|
|
8589
8700
|
};
|
|
8590
8701
|
/** Object name. */
|
|
8591
8702
|
__publicField(_MEnding, "Name", "Ending");
|
|
8592
8703
|
var MEnding = _MEnding;
|
|
8593
|
-
var _MFermata = class _MFermata extends
|
|
8704
|
+
var _MFermata = class _MFermata extends MusicInterface5 {
|
|
8594
8705
|
/** @internal */
|
|
8595
8706
|
constructor(obj) {
|
|
8596
8707
|
super(_MFermata.Name);
|
|
@@ -8604,7 +8715,7 @@ var _MFermata = class _MFermata extends MusicInterface6 {
|
|
|
8604
8715
|
/** OBject name. */
|
|
8605
8716
|
__publicField(_MFermata, "Name", "Fermata");
|
|
8606
8717
|
var MFermata = _MFermata;
|
|
8607
|
-
var _MHeader = class _MHeader extends
|
|
8718
|
+
var _MHeader = class _MHeader extends MusicInterface5 {
|
|
8608
8719
|
/** @internal */
|
|
8609
8720
|
constructor(obj) {
|
|
8610
8721
|
super(_MHeader.Name);
|
|
@@ -8639,7 +8750,7 @@ var _MHeader = class _MHeader extends MusicInterface6 {
|
|
|
8639
8750
|
/** OBject name. */
|
|
8640
8751
|
__publicField(_MHeader, "Name", "Header");
|
|
8641
8752
|
var MHeader = _MHeader;
|
|
8642
|
-
var _MImage = class _MImage extends
|
|
8753
|
+
var _MImage = class _MImage extends MusicInterface5 {
|
|
8643
8754
|
/** @internal */
|
|
8644
8755
|
constructor(obj) {
|
|
8645
8756
|
super(_MImage.Name);
|
|
@@ -8653,7 +8764,7 @@ var _MImage = class _MImage extends MusicInterface6 {
|
|
|
8653
8764
|
/** Object name. */
|
|
8654
8765
|
__publicField(_MImage, "Name", "Image");
|
|
8655
8766
|
var MImage = _MImage;
|
|
8656
|
-
var _MMeasure = class _MMeasure extends
|
|
8767
|
+
var _MMeasure = class _MMeasure extends MusicInterface5 {
|
|
8657
8768
|
/** @internal */
|
|
8658
8769
|
constructor(obj) {
|
|
8659
8770
|
super(_MMeasure.Name);
|
|
@@ -8688,7 +8799,7 @@ var _MMeasure = class _MMeasure extends MusicInterface6 {
|
|
|
8688
8799
|
/** OBject name. */
|
|
8689
8800
|
__publicField(_MMeasure, "Name", "Measure");
|
|
8690
8801
|
var MMeasure = _MMeasure;
|
|
8691
|
-
var _MBarLineRight = class _MBarLineRight extends
|
|
8802
|
+
var _MBarLineRight = class _MBarLineRight extends MusicInterface5 {
|
|
8692
8803
|
/** @internal */
|
|
8693
8804
|
constructor(obj) {
|
|
8694
8805
|
super(_MBarLineRight.Name);
|
|
@@ -8702,7 +8813,7 @@ var _MBarLineRight = class _MBarLineRight extends MusicInterface6 {
|
|
|
8702
8813
|
/** OBject name. */
|
|
8703
8814
|
__publicField(_MBarLineRight, "Name", "BarLineRight");
|
|
8704
8815
|
var MBarLineRight = _MBarLineRight;
|
|
8705
|
-
var _MBarLineLeft = class _MBarLineLeft extends
|
|
8816
|
+
var _MBarLineLeft = class _MBarLineLeft extends MusicInterface5 {
|
|
8706
8817
|
/** @internal */
|
|
8707
8818
|
constructor(obj) {
|
|
8708
8819
|
super(_MBarLineLeft.Name);
|
|
@@ -8716,7 +8827,7 @@ var _MBarLineLeft = class _MBarLineLeft extends MusicInterface6 {
|
|
|
8716
8827
|
/** Object name. */
|
|
8717
8828
|
__publicField(_MBarLineLeft, "Name", "BarLineLeft");
|
|
8718
8829
|
var MBarLineLeft = _MBarLineLeft;
|
|
8719
|
-
var _MStaffTabBarLine = class _MStaffTabBarLine extends
|
|
8830
|
+
var _MStaffTabBarLine = class _MStaffTabBarLine extends MusicInterface5 {
|
|
8720
8831
|
/** @internal */
|
|
8721
8832
|
constructor(obj) {
|
|
8722
8833
|
super(_MStaffTabBarLine.Name);
|
|
@@ -8749,7 +8860,7 @@ var _MStaffTabBarLine = class _MStaffTabBarLine extends MusicInterface6 {
|
|
|
8749
8860
|
/** Object name. */
|
|
8750
8861
|
__publicField(_MStaffTabBarLine, "Name", "StaffTabBarLine");
|
|
8751
8862
|
var MStaffTabBarLine = _MStaffTabBarLine;
|
|
8752
|
-
var _MNoteGroup = class _MNoteGroup extends
|
|
8863
|
+
var _MNoteGroup = class _MNoteGroup extends MusicInterface5 {
|
|
8753
8864
|
/** @internal */
|
|
8754
8865
|
constructor(obj) {
|
|
8755
8866
|
super(_MNoteGroup.Name);
|
|
@@ -8791,7 +8902,7 @@ var _MNoteGroup = class _MNoteGroup extends MusicInterface6 {
|
|
|
8791
8902
|
/** Object name. */
|
|
8792
8903
|
__publicField(_MNoteGroup, "Name", "NoteGroup");
|
|
8793
8904
|
var MNoteGroup = _MNoteGroup;
|
|
8794
|
-
var _MStaffNoteGroup = class _MStaffNoteGroup extends
|
|
8905
|
+
var _MStaffNoteGroup = class _MStaffNoteGroup extends MusicInterface5 {
|
|
8795
8906
|
/** @internal */
|
|
8796
8907
|
constructor(obj) {
|
|
8797
8908
|
super(_MStaffNoteGroup.Name);
|
|
@@ -8833,7 +8944,7 @@ var _MStaffNoteGroup = class _MStaffNoteGroup extends MusicInterface6 {
|
|
|
8833
8944
|
/** Object name. */
|
|
8834
8945
|
__publicField(_MStaffNoteGroup, "Name", "StaffNoteGroup");
|
|
8835
8946
|
var MStaffNoteGroup = _MStaffNoteGroup;
|
|
8836
|
-
var _MTabNoteGroup = class _MTabNoteGroup extends
|
|
8947
|
+
var _MTabNoteGroup = class _MTabNoteGroup extends MusicInterface5 {
|
|
8837
8948
|
/** @internal */
|
|
8838
8949
|
constructor(obj) {
|
|
8839
8950
|
super(_MTabNoteGroup.Name);
|
|
@@ -8875,7 +8986,7 @@ var _MTabNoteGroup = class _MTabNoteGroup extends MusicInterface6 {
|
|
|
8875
8986
|
/** OBject name. */
|
|
8876
8987
|
__publicField(_MTabNoteGroup, "Name", "TabNoteGroup");
|
|
8877
8988
|
var MTabNoteGroup = _MTabNoteGroup;
|
|
8878
|
-
var _MRest = class _MRest extends
|
|
8989
|
+
var _MRest = class _MRest extends MusicInterface5 {
|
|
8879
8990
|
/** @internal */
|
|
8880
8991
|
constructor(obj) {
|
|
8881
8992
|
super(_MRest.Name);
|
|
@@ -8910,7 +9021,7 @@ var _MRest = class _MRest extends MusicInterface6 {
|
|
|
8910
9021
|
/** OBject name. */
|
|
8911
9022
|
__publicField(_MRest, "Name", "Rest");
|
|
8912
9023
|
var MRest = _MRest;
|
|
8913
|
-
var _MStaffRest = class _MStaffRest extends
|
|
9024
|
+
var _MStaffRest = class _MStaffRest extends MusicInterface5 {
|
|
8914
9025
|
/** @internal */
|
|
8915
9026
|
constructor(obj) {
|
|
8916
9027
|
super(_MStaffRest.Name);
|
|
@@ -8952,7 +9063,7 @@ var _MStaffRest = class _MStaffRest extends MusicInterface6 {
|
|
|
8952
9063
|
/** Object name. */
|
|
8953
9064
|
__publicField(_MStaffRest, "Name", "StaffRest");
|
|
8954
9065
|
var MStaffRest = _MStaffRest;
|
|
8955
|
-
var _MRhythmColumn = class _MRhythmColumn extends
|
|
9066
|
+
var _MRhythmColumn = class _MRhythmColumn extends MusicInterface5 {
|
|
8956
9067
|
/** @internal */
|
|
8957
9068
|
constructor(obj) {
|
|
8958
9069
|
super(_MRhythmColumn.Name);
|
|
@@ -8969,7 +9080,7 @@ var _MRhythmColumn = class _MRhythmColumn extends MusicInterface6 {
|
|
|
8969
9080
|
*/
|
|
8970
9081
|
getRhythmSymbol(voiceId) {
|
|
8971
9082
|
var _a;
|
|
8972
|
-
assertArg2(
|
|
9083
|
+
assertArg2(isVoiceId(voiceId), "voiceId", voiceId);
|
|
8973
9084
|
return (_a = this.obj.getVoiceSymbol(voiceId)) == null ? void 0 : _a.getMusicInterface();
|
|
8974
9085
|
}
|
|
8975
9086
|
/**
|
|
@@ -8980,7 +9091,7 @@ var _MRhythmColumn = class _MRhythmColumn extends MusicInterface6 {
|
|
|
8980
9091
|
*/
|
|
8981
9092
|
getVoiceSymbol(voiceId) {
|
|
8982
9093
|
var _a;
|
|
8983
|
-
assertArg2(
|
|
9094
|
+
assertArg2(isVoiceId(voiceId), "voiceId", voiceId);
|
|
8984
9095
|
return (_a = this.obj.getVoiceSymbol(voiceId)) == null ? void 0 : _a.getMusicInterface();
|
|
8985
9096
|
}
|
|
8986
9097
|
/**
|
|
@@ -8994,7 +9105,7 @@ var _MRhythmColumn = class _MRhythmColumn extends MusicInterface6 {
|
|
|
8994
9105
|
/** OBject name. */
|
|
8995
9106
|
__publicField(_MRhythmColumn, "Name", "RhythmColumn");
|
|
8996
9107
|
var MRhythmColumn = _MRhythmColumn;
|
|
8997
|
-
var _MScoreRow = class _MScoreRow extends
|
|
9108
|
+
var _MScoreRow = class _MScoreRow extends MusicInterface5 {
|
|
8998
9109
|
/** @internal */
|
|
8999
9110
|
constructor(obj) {
|
|
9000
9111
|
super(_MScoreRow.Name);
|
|
@@ -9029,7 +9140,7 @@ var _MScoreRow = class _MScoreRow extends MusicInterface6 {
|
|
|
9029
9140
|
/** Object name. */
|
|
9030
9141
|
__publicField(_MScoreRow, "Name", "ScoreRow");
|
|
9031
9142
|
var MScoreRow = _MScoreRow;
|
|
9032
|
-
var _MStaff = class _MStaff extends
|
|
9143
|
+
var _MStaff = class _MStaff extends MusicInterface5 {
|
|
9033
9144
|
/** @internal */
|
|
9034
9145
|
constructor(obj) {
|
|
9035
9146
|
super(_MStaff.Name);
|
|
@@ -9064,7 +9175,7 @@ var _MStaff = class _MStaff extends MusicInterface6 {
|
|
|
9064
9175
|
/** Object name. */
|
|
9065
9176
|
__publicField(_MStaff, "Name", "Staff");
|
|
9066
9177
|
var MStaff = _MStaff;
|
|
9067
|
-
var _MTab = class _MTab extends
|
|
9178
|
+
var _MTab = class _MTab extends MusicInterface5 {
|
|
9068
9179
|
/** @internal */
|
|
9069
9180
|
constructor(obj) {
|
|
9070
9181
|
super(_MTab.Name);
|
|
@@ -9099,7 +9210,7 @@ var _MTab = class _MTab extends MusicInterface6 {
|
|
|
9099
9210
|
/** Object name. */
|
|
9100
9211
|
__publicField(_MTab, "Name", "Tab");
|
|
9101
9212
|
var MTab = _MTab;
|
|
9102
|
-
var _MStaffSignature = class _MStaffSignature extends
|
|
9213
|
+
var _MStaffSignature = class _MStaffSignature extends MusicInterface5 {
|
|
9103
9214
|
/** @internal */
|
|
9104
9215
|
constructor(obj) {
|
|
9105
9216
|
super(_MStaffSignature.Name);
|
|
@@ -9120,7 +9231,7 @@ var _MStaffSignature = class _MStaffSignature extends MusicInterface6 {
|
|
|
9120
9231
|
/** Object name. */
|
|
9121
9232
|
__publicField(_MStaffSignature, "Name", "StaffSignature");
|
|
9122
9233
|
var MStaffSignature = _MStaffSignature;
|
|
9123
|
-
var _MTabSignature = class _MTabSignature extends
|
|
9234
|
+
var _MTabSignature = class _MTabSignature extends MusicInterface5 {
|
|
9124
9235
|
/** @internal */
|
|
9125
9236
|
constructor(obj) {
|
|
9126
9237
|
super(_MTabSignature.Name);
|
|
@@ -9141,7 +9252,7 @@ var _MTabSignature = class _MTabSignature extends MusicInterface6 {
|
|
|
9141
9252
|
/** Object name. */
|
|
9142
9253
|
__publicField(_MTabSignature, "Name", "TabSignature");
|
|
9143
9254
|
var MTabSignature = _MTabSignature;
|
|
9144
|
-
var _MTabRhythm = class _MTabRhythm extends
|
|
9255
|
+
var _MTabRhythm = class _MTabRhythm extends MusicInterface5 {
|
|
9145
9256
|
/** @internal */
|
|
9146
9257
|
constructor(obj) {
|
|
9147
9258
|
super(_MTabRhythm.Name);
|
|
@@ -9169,7 +9280,7 @@ var _MTabRhythm = class _MTabRhythm extends MusicInterface6 {
|
|
|
9169
9280
|
/** Object name. */
|
|
9170
9281
|
__publicField(_MTabRhythm, "Name", "TabRhythm");
|
|
9171
9282
|
var MTabRhythm = _MTabRhythm;
|
|
9172
|
-
var _MSpecialText = class _MSpecialText extends
|
|
9283
|
+
var _MSpecialText = class _MSpecialText extends MusicInterface5 {
|
|
9173
9284
|
/** @internal */
|
|
9174
9285
|
constructor(obj) {
|
|
9175
9286
|
super(_MSpecialText.Name);
|
|
@@ -9190,7 +9301,7 @@ var _MSpecialText = class _MSpecialText extends MusicInterface6 {
|
|
|
9190
9301
|
/** Object name. */
|
|
9191
9302
|
__publicField(_MSpecialText, "Name", "SpecialText");
|
|
9192
9303
|
var MSpecialText = _MSpecialText;
|
|
9193
|
-
var _MText = class _MText extends
|
|
9304
|
+
var _MText = class _MText extends MusicInterface5 {
|
|
9194
9305
|
/** @internal */
|
|
9195
9306
|
constructor(obj) {
|
|
9196
9307
|
super(_MText.Name);
|
|
@@ -9211,7 +9322,7 @@ var _MText = class _MText extends MusicInterface6 {
|
|
|
9211
9322
|
/** Object name. */
|
|
9212
9323
|
__publicField(_MText, "Name", "Text");
|
|
9213
9324
|
var MText = _MText;
|
|
9214
|
-
var _MLyrics = class _MLyrics extends
|
|
9325
|
+
var _MLyrics = class _MLyrics extends MusicInterface5 {
|
|
9215
9326
|
/** @internal */
|
|
9216
9327
|
constructor(obj) {
|
|
9217
9328
|
super(_MLyrics.Name);
|
|
@@ -9232,7 +9343,7 @@ var _MLyrics = class _MLyrics extends MusicInterface6 {
|
|
|
9232
9343
|
/** Object name. */
|
|
9233
9344
|
__publicField(_MLyrics, "Name", "Lyrics");
|
|
9234
9345
|
var MLyrics = _MLyrics;
|
|
9235
|
-
var _MExtensionLine = class _MExtensionLine extends
|
|
9346
|
+
var _MExtensionLine = class _MExtensionLine extends MusicInterface5 {
|
|
9236
9347
|
/** @internal */
|
|
9237
9348
|
constructor(obj) {
|
|
9238
9349
|
super(_MExtensionLine.Name);
|
|
@@ -9270,10 +9381,12 @@ var _MPlayer = class _MPlayer {
|
|
|
9270
9381
|
constructor(doc, playStateChangeListener) {
|
|
9271
9382
|
__publicField(this, "player");
|
|
9272
9383
|
assertArg3(doc instanceof MDocument2, "doc", doc);
|
|
9273
|
-
assertArg3(
|
|
9384
|
+
assertArg3(Guard14.isFunctionOrUndefined(playStateChangeListener), "playStateChangeListener", playStateChangeListener);
|
|
9274
9385
|
this.player = new Player();
|
|
9275
9386
|
this.player.setDocument(doc.getMusicObject());
|
|
9276
|
-
this.player.setCursorPositionChangeListener((cursorRect) =>
|
|
9387
|
+
this.player.setCursorPositionChangeListener((cursorRect) => {
|
|
9388
|
+
doc.getMusicObject().updateCursorRect(cursorRect);
|
|
9389
|
+
});
|
|
9277
9390
|
if (playStateChangeListener) {
|
|
9278
9391
|
this.player.setPlayStateChnageListener(playStateChangeListener);
|
|
9279
9392
|
}
|
|
@@ -9312,7 +9425,7 @@ var _MPlayer = class _MPlayer {
|
|
|
9312
9425
|
return this;
|
|
9313
9426
|
}
|
|
9314
9427
|
};
|
|
9315
|
-
__publicField(_MPlayer, "currentlyPlaying",
|
|
9428
|
+
__publicField(_MPlayer, "currentlyPlaying", new ValueSet2());
|
|
9316
9429
|
var MPlayer = _MPlayer;
|
|
9317
9430
|
var MRenderContext2 = class {
|
|
9318
9431
|
/**
|
|
@@ -9328,7 +9441,7 @@ var MRenderContext2 = class {
|
|
|
9328
9441
|
* @returns - This render context instance.
|
|
9329
9442
|
*/
|
|
9330
9443
|
setDocument(doc) {
|
|
9331
|
-
assertArg3(
|
|
9444
|
+
assertArg3(Guard14.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
|
|
9332
9445
|
this.ctx.setDocument(doc);
|
|
9333
9446
|
return this;
|
|
9334
9447
|
}
|
|
@@ -9338,7 +9451,7 @@ var MRenderContext2 = class {
|
|
|
9338
9451
|
* @returns - This render context instance.
|
|
9339
9452
|
*/
|
|
9340
9453
|
setCanvas(canvas) {
|
|
9341
|
-
canvas = require_t(
|
|
9454
|
+
canvas = require_t(Utils13.Dom.getCanvas(canvas), typeof canvas === "string" ? "Cannot set render canvas because invalid canvas id: " + canvas : "Cannot set render canvas because given canvas is undefined.");
|
|
9342
9455
|
this.ctx.setCanvas(canvas);
|
|
9343
9456
|
return this;
|
|
9344
9457
|
}
|
|
@@ -9347,7 +9460,7 @@ var MRenderContext2 = class {
|
|
|
9347
9460
|
* @param scoreEventListener - Score event listener.
|
|
9348
9461
|
*/
|
|
9349
9462
|
setScoreEventListener(scoreEventListener) {
|
|
9350
|
-
assertArg3(
|
|
9463
|
+
assertArg3(Guard14.isFunctionOrUndefined(scoreEventListener), "scoreEventListener", scoreEventListener);
|
|
9351
9464
|
this.ctx.setScoreEventListener(scoreEventListener);
|
|
9352
9465
|
}
|
|
9353
9466
|
/**
|
|
@@ -9422,7 +9535,7 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
9422
9535
|
* @returns
|
|
9423
9536
|
*/
|
|
9424
9537
|
setDocument(doc) {
|
|
9425
|
-
assertArg3(
|
|
9538
|
+
assertArg3(Guard14.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
|
|
9426
9539
|
this.onStop();
|
|
9427
9540
|
if (doc) {
|
|
9428
9541
|
this.player = new MPlayer(doc, (playState) => {
|
|
@@ -9466,9 +9579,9 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
9466
9579
|
* @returns - This playback buttons class instance.
|
|
9467
9580
|
*/
|
|
9468
9581
|
setPlayButton(btn, btnLabel) {
|
|
9469
|
-
assertArg3(
|
|
9582
|
+
assertArg3(Guard14.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
|
|
9470
9583
|
_MPlaybackButtons.removeOnClickListeners(this.playButton, this.onPlay);
|
|
9471
|
-
this.playButton = require_t(
|
|
9584
|
+
this.playButton = require_t(Utils13.Dom.getButton(btn), "Play button required!");
|
|
9472
9585
|
this.playLabel = btnLabel != null ? btnLabel : "Play";
|
|
9473
9586
|
_MPlaybackButtons.removeOnClickListeners(this.playButton, "all");
|
|
9474
9587
|
_MPlaybackButtons.addOnClickListener(this.playButton, this.onPlay);
|
|
@@ -9482,9 +9595,9 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
9482
9595
|
* @returns - This playback buttons class instance.
|
|
9483
9596
|
*/
|
|
9484
9597
|
setStopButton(btn, btnLabel) {
|
|
9485
|
-
assertArg3(
|
|
9598
|
+
assertArg3(Guard14.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
|
|
9486
9599
|
_MPlaybackButtons.removeOnClickListeners(this.stopButton, this.onStop);
|
|
9487
|
-
this.stopButton = require_t(
|
|
9600
|
+
this.stopButton = require_t(Utils13.Dom.getButton(btn), "Stop button required!");
|
|
9488
9601
|
this.stopLabel = btnLabel != null ? btnLabel : "Stop";
|
|
9489
9602
|
_MPlaybackButtons.removeOnClickListeners(this.stopButton, "all");
|
|
9490
9603
|
_MPlaybackButtons.addOnClickListener(this.stopButton, this.onStop);
|
|
@@ -9499,10 +9612,10 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
9499
9612
|
* @returns - This playback buttons class instance.
|
|
9500
9613
|
*/
|
|
9501
9614
|
setPlayStopButton(btn, playLabel, stopLabel) {
|
|
9502
|
-
assertArg3(
|
|
9503
|
-
assertArg3(
|
|
9615
|
+
assertArg3(Guard14.isStringOrUndefined(playLabel), "playLabel", playLabel);
|
|
9616
|
+
assertArg3(Guard14.isStringOrUndefined(stopLabel), "stopLabel", stopLabel);
|
|
9504
9617
|
_MPlaybackButtons.removeOnClickListeners(this.playStopButton, this.onPlayStop);
|
|
9505
|
-
this.playStopButton = require_t(
|
|
9618
|
+
this.playStopButton = require_t(Utils13.Dom.getButton(btn), "Play/stop button required!");
|
|
9506
9619
|
this.playLabel = playLabel != null ? playLabel : "Play";
|
|
9507
9620
|
this.stopLabel = stopLabel != null ? stopLabel : "Stop";
|
|
9508
9621
|
_MPlaybackButtons.removeOnClickListeners(this.playStopButton, "all");
|
|
@@ -9517,37 +9630,35 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
9517
9630
|
* @returns - This playback buttons class instance.
|
|
9518
9631
|
*/
|
|
9519
9632
|
setPauseButton(btn, btnLabel) {
|
|
9520
|
-
assertArg3(
|
|
9633
|
+
assertArg3(Guard14.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
|
|
9521
9634
|
_MPlaybackButtons.removeOnClickListeners(this.pauseButton, this.onPause);
|
|
9522
|
-
this.pauseButton = require_t(
|
|
9635
|
+
this.pauseButton = require_t(Utils13.Dom.getButton(btn), "Pause button required!");
|
|
9523
9636
|
this.pauseLabel = btnLabel != null ? btnLabel : "Pause";
|
|
9524
9637
|
_MPlaybackButtons.removeOnClickListeners(this.pauseButton, "all");
|
|
9525
9638
|
_MPlaybackButtons.addOnClickListener(this.pauseButton, this.onPause);
|
|
9526
9639
|
this.updateButtons();
|
|
9527
9640
|
return this;
|
|
9528
9641
|
}
|
|
9529
|
-
static removeOnClickListeners(btn,
|
|
9530
|
-
if (btn)
|
|
9531
|
-
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
|
|
9541
|
-
}
|
|
9642
|
+
static removeOnClickListeners(btn, onClickListener) {
|
|
9643
|
+
if (!btn) return;
|
|
9644
|
+
let curListeners = this.savedOnClickListeners.getOrDefault(btn, []);
|
|
9645
|
+
curListeners = curListeners.filter((listener) => {
|
|
9646
|
+
if (onClickListener === listener || onClickListener === "all") {
|
|
9647
|
+
btn.removeEventListener("click", listener);
|
|
9648
|
+
return false;
|
|
9649
|
+
} else {
|
|
9650
|
+
return true;
|
|
9651
|
+
}
|
|
9652
|
+
});
|
|
9653
|
+
this.savedOnClickListeners.set(btn, curListeners);
|
|
9542
9654
|
}
|
|
9543
|
-
static addOnClickListener(btn,
|
|
9544
|
-
assertArg3(
|
|
9545
|
-
btn.addEventListener("click",
|
|
9546
|
-
|
|
9547
|
-
this.savedOnClickListeners.set(btn, [...clickListeners, onClick]);
|
|
9655
|
+
static addOnClickListener(btn, onClickListener) {
|
|
9656
|
+
assertArg3(Guard14.isFunction(onClickListener), "onClick", onClickListener);
|
|
9657
|
+
btn.addEventListener("click", onClickListener);
|
|
9658
|
+
this.savedOnClickListeners.getOrCreate(btn, []).push(onClickListener);
|
|
9548
9659
|
}
|
|
9549
9660
|
};
|
|
9550
|
-
__publicField(_MPlaybackButtons, "savedOnClickListeners",
|
|
9661
|
+
__publicField(_MPlaybackButtons, "savedOnClickListeners", new UniMap9());
|
|
9551
9662
|
var MPlaybackButtons = _MPlaybackButtons;
|
|
9552
9663
|
|
|
9553
9664
|
// src/score/index.ts
|
|
@@ -9599,7 +9710,7 @@ export {
|
|
|
9599
9710
|
MTabRhythm,
|
|
9600
9711
|
MTabSignature,
|
|
9601
9712
|
MText,
|
|
9602
|
-
|
|
9713
|
+
MusicInterface5 as MusicInterface,
|
|
9603
9714
|
Navigation,
|
|
9604
9715
|
NoteAnchor,
|
|
9605
9716
|
PlayState,
|
|
@@ -9613,6 +9724,12 @@ export {
|
|
|
9613
9724
|
VerticalPosition,
|
|
9614
9725
|
getStringNumbers,
|
|
9615
9726
|
getVerseNumbers,
|
|
9616
|
-
getVoiceIds
|
|
9727
|
+
getVoiceIds,
|
|
9728
|
+
isStringNumber,
|
|
9729
|
+
isVerseNumber,
|
|
9730
|
+
isVoiceId,
|
|
9731
|
+
validateStringNumber,
|
|
9732
|
+
validateVerseNumber,
|
|
9733
|
+
validateVoiceId
|
|
9617
9734
|
};
|
|
9618
9735
|
//# sourceMappingURL=index.mjs.map
|