@tspro/web-music-score 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +18 -9
- package/dist/audio/index.d.mts +40 -1
- package/dist/audio/index.d.ts +40 -1
- package/dist/audio/index.js +1 -1
- package/dist/audio/index.mjs +2 -2
- package/dist/audio-cg/index.d.mts +3 -0
- package/dist/audio-cg/index.d.ts +3 -0
- package/dist/audio-cg/index.js +1 -1
- package/dist/audio-cg/index.mjs +2 -2
- package/dist/{chunk-D643HZHM.mjs → chunk-MHNTJ6FU.mjs} +2 -2
- package/dist/core/index.d.mts +12 -0
- package/dist/core/index.d.ts +12 -0
- package/dist/core/index.js +3 -2
- package/dist/core/index.mjs +4 -3
- package/dist/guitar-CaZJDA05.d.ts +35 -0
- package/dist/guitar-DdexKdN6.d.mts +35 -0
- package/dist/iife/index.global.js +11 -11
- package/dist/{interface-XoKiryoV.d.mts → music-objects-DIaqNPjs.d.mts} +616 -114
- package/dist/{interface-7k8qGG44.d.ts → music-objects-xJJNlFwK.d.ts} +616 -114
- package/dist/note-eA2xPPiG.d.mts +294 -0
- package/dist/note-eA2xPPiG.d.ts +294 -0
- package/dist/pieces/index.d.mts +22 -3
- package/dist/pieces/index.d.ts +22 -3
- package/dist/pieces/index.js +5 -2
- package/dist/pieces/index.mjs +6 -3
- package/dist/react-ui/index.d.mts +166 -17
- package/dist/react-ui/index.d.ts +166 -17
- package/dist/react-ui/index.js +78 -1
- package/dist/react-ui/index.mjs +79 -2
- package/dist/scale-DQNA-YLD.d.ts +230 -0
- package/dist/scale-bnD0WnMV.d.mts +230 -0
- package/dist/score/index.d.mts +315 -47
- package/dist/score/index.d.ts +315 -47
- package/dist/score/index.js +684 -173
- package/dist/score/index.mjs +683 -174
- package/dist/tempo-Bp1UzsrZ.d.ts +399 -0
- package/dist/tempo-S85Q7uJA.d.mts +399 -0
- package/dist/theory/index.d.mts +29 -13
- package/dist/theory/index.d.ts +29 -13
- package/dist/theory/index.js +433 -42
- package/dist/theory/index.mjs +432 -43
- package/package.json +3 -2
- package/dist/guitar-DggbM2UL.d.mts +0 -17
- package/dist/guitar-cNmE-EvH.d.ts +0 -17
- package/dist/note-BFa43I86.d.mts +0 -85
- package/dist/note-CcVdUFqS.d.ts +0 -85
- package/dist/scale-C2pCNxdE.d.mts +0 -75
- package/dist/scale-CvPbJvfN.d.ts +0 -75
- package/dist/tempo-BAYoZ_Li.d.mts +0 -187
- package/dist/tempo-r2sb6Ku2.d.ts +0 -187
package/dist/score/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* WebMusicScore v4.
|
|
1
|
+
/* WebMusicScore v4.1.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
|
|
2
2
|
import {
|
|
3
3
|
__publicField
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-MHNTJ6FU.mjs";
|
|
5
5
|
|
|
6
6
|
// src/score/pub/div-rect.ts
|
|
7
7
|
import { Utils } from "@tspro/ts-utils-lib";
|
|
@@ -38,11 +38,11 @@ var DivRect = class _DivRect {
|
|
|
38
38
|
/**
|
|
39
39
|
* Create rect from basic left, top, width and height arguments.
|
|
40
40
|
*
|
|
41
|
-
* @param left -
|
|
42
|
-
* @param top -
|
|
43
|
-
* @param width -
|
|
44
|
-
* @param height -
|
|
45
|
-
* @returns
|
|
41
|
+
* @param left - Left coordinate.
|
|
42
|
+
* @param top - Top coordinate.
|
|
43
|
+
* @param width - With.
|
|
44
|
+
* @param height - Height.
|
|
45
|
+
* @returns - DivRect.
|
|
46
46
|
*/
|
|
47
47
|
static create(left, top, width, height) {
|
|
48
48
|
return new _DivRect(left, left + width, top, top + height);
|
|
@@ -52,9 +52,9 @@ var DivRect = class _DivRect {
|
|
|
52
52
|
*
|
|
53
53
|
* @param centerX - Center x-coordinate.
|
|
54
54
|
* @param centerY - Center y-coordinate.
|
|
55
|
-
* @param width -
|
|
56
|
-
* @param height -
|
|
57
|
-
* @returns
|
|
55
|
+
* @param width - Width.
|
|
56
|
+
* @param height - Height.
|
|
57
|
+
* @returns - DivRect.
|
|
58
58
|
*/
|
|
59
59
|
static createCentered(centerX, centerY, width, height) {
|
|
60
60
|
return new _DivRect(centerX - width / 2, centerX + width / 2, centerY - height / 2, centerY + height / 2);
|
|
@@ -66,43 +66,43 @@ var DivRect = class _DivRect {
|
|
|
66
66
|
* @param rightw - Right section width.
|
|
67
67
|
* @param toph - Top section height.
|
|
68
68
|
* @param bottomh - Bottomsection height.
|
|
69
|
-
* @returns
|
|
69
|
+
* @returns - DivRect.
|
|
70
70
|
*/
|
|
71
71
|
static createSections(leftw, rightw, toph, bottomh) {
|
|
72
72
|
return new _DivRect(-leftw, 0, rightw, -toph, 0, bottomh);
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
|
-
* Width.
|
|
75
|
+
* Width getter.
|
|
76
76
|
*/
|
|
77
77
|
get width() {
|
|
78
78
|
return this.right - this.left;
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
|
-
* Height.
|
|
81
|
+
* Height getter.
|
|
82
82
|
*/
|
|
83
83
|
get height() {
|
|
84
84
|
return this.bottom - this.top;
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
|
-
* Left section width.
|
|
87
|
+
* Left section width getter.
|
|
88
88
|
*/
|
|
89
89
|
get leftw() {
|
|
90
90
|
return this.centerX - this.left;
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
|
-
* Right section width.
|
|
93
|
+
* Right section width getter.
|
|
94
94
|
*/
|
|
95
95
|
get rightw() {
|
|
96
96
|
return this.right - this.centerX;
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
|
-
* Top section height.
|
|
99
|
+
* Top section height getter.
|
|
100
100
|
*/
|
|
101
101
|
get toph() {
|
|
102
102
|
return this.centerY - this.top;
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
|
-
* Bottom section height.
|
|
105
|
+
* Bottom section height getter.
|
|
106
106
|
*/
|
|
107
107
|
get bottomh() {
|
|
108
108
|
return this.bottom - this.centerY;
|
|
@@ -110,9 +110,9 @@ var DivRect = class _DivRect {
|
|
|
110
110
|
/**
|
|
111
111
|
* Does this Rect contain given (x, y)-point?
|
|
112
112
|
*
|
|
113
|
-
* @param x -
|
|
114
|
-
* @param y -
|
|
115
|
-
* @returns
|
|
113
|
+
* @param x - X-coordinate.
|
|
114
|
+
* @param y - Y-coordinate.
|
|
115
|
+
* @returns - True/false.
|
|
116
116
|
*/
|
|
117
117
|
contains(x, y) {
|
|
118
118
|
return x >= this.left && x <= this.right && y >= this.top && y <= this.bottom;
|
|
@@ -120,9 +120,9 @@ var DivRect = class _DivRect {
|
|
|
120
120
|
/**
|
|
121
121
|
* Do a and b rects overlap?
|
|
122
122
|
*
|
|
123
|
-
* @param a -
|
|
124
|
-
* @param b -
|
|
125
|
-
* @returns
|
|
123
|
+
* @param a - DivRect a.
|
|
124
|
+
* @param b - DivRect b.
|
|
125
|
+
* @returns - True/false.
|
|
126
126
|
*/
|
|
127
127
|
static overlap(a, b) {
|
|
128
128
|
return a.right > b.left && a.left < b.right && a.bottom > b.top && a.top < b.bottom;
|
|
@@ -130,17 +130,18 @@ var DivRect = class _DivRect {
|
|
|
130
130
|
/**
|
|
131
131
|
* Do horizontal measures of a and b rects overlap?
|
|
132
132
|
*
|
|
133
|
-
* @param a -
|
|
134
|
-
* @param b -
|
|
135
|
-
* @returns
|
|
133
|
+
* @param a - DivRect a.
|
|
134
|
+
* @param b - DivRect b.
|
|
135
|
+
* @returns - True/false.
|
|
136
136
|
*/
|
|
137
137
|
static overlapX(a, b) {
|
|
138
138
|
return a.right > b.left && a.left < b.right;
|
|
139
139
|
}
|
|
140
140
|
/**
|
|
141
141
|
* Check if this Rect equals with given Rect.
|
|
142
|
-
* @param
|
|
143
|
-
* @
|
|
142
|
+
* @param a - DivRect a.
|
|
143
|
+
* @param b - DivRect b.
|
|
144
|
+
* @returns - True/false.
|
|
144
145
|
*/
|
|
145
146
|
static equals(a, b) {
|
|
146
147
|
if (a == null && b == null) {
|
|
@@ -152,10 +153,11 @@ var DivRect = class _DivRect {
|
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
155
|
/**
|
|
155
|
-
* Check if frame
|
|
156
|
+
* Check if frame of this Rect equals with given Rect, ignoring center x- and center y-coordinates.
|
|
156
157
|
*
|
|
157
|
-
* @param
|
|
158
|
-
* @
|
|
158
|
+
* @param a - DivRect a.
|
|
159
|
+
* @param b - DivRect b.
|
|
160
|
+
* @returns - True/false.
|
|
159
161
|
*/
|
|
160
162
|
static equalsFrame(a, b) {
|
|
161
163
|
if (a == null && b == null) {
|
|
@@ -169,7 +171,7 @@ var DivRect = class _DivRect {
|
|
|
169
171
|
/**
|
|
170
172
|
* Created duplicate of this Rect.
|
|
171
173
|
*
|
|
172
|
-
* @returns
|
|
174
|
+
* @returns - Duplicate.
|
|
173
175
|
*/
|
|
174
176
|
copy() {
|
|
175
177
|
return new _DivRect(this.left, this.centerX, this.right, this.top, this.centerY, this.bottom);
|
|
@@ -177,9 +179,9 @@ var DivRect = class _DivRect {
|
|
|
177
179
|
/**
|
|
178
180
|
* Move this rect by (dx, dy). Modifies this Rect.
|
|
179
181
|
*
|
|
180
|
-
* @param dx -
|
|
181
|
-
* @param dy -
|
|
182
|
-
* @returns
|
|
182
|
+
* @param dx - Offset amount in x-direction.
|
|
183
|
+
* @param dy - Offset amount in y-direction.
|
|
184
|
+
* @returns - This DivRect instance.
|
|
183
185
|
*/
|
|
184
186
|
offsetInPlace(dx, dy) {
|
|
185
187
|
this.left += dx;
|
|
@@ -193,9 +195,9 @@ var DivRect = class _DivRect {
|
|
|
193
195
|
/**
|
|
194
196
|
* Move this rect by (dx, dy). Immutable, returns modified copy.
|
|
195
197
|
*
|
|
196
|
-
* @param dx -
|
|
197
|
-
* @param dy -
|
|
198
|
-
* @returns
|
|
198
|
+
* @param dx - Offset amount in x-direction.
|
|
199
|
+
* @param dy - Offset amount in y-direction.
|
|
200
|
+
* @returns - DivRect copy with applied offset.
|
|
199
201
|
*/
|
|
200
202
|
offsetCopy(dx, dy) {
|
|
201
203
|
return this.copy().offsetInPlace(dx, dy);
|
|
@@ -203,8 +205,8 @@ var DivRect = class _DivRect {
|
|
|
203
205
|
/**
|
|
204
206
|
* Expand this Rect by given Rect. Modifies this Rect.
|
|
205
207
|
*
|
|
206
|
-
* @param rect -
|
|
207
|
-
* @returns
|
|
208
|
+
* @param rect - DivRect to expand this instance with.
|
|
209
|
+
* @returns - This DivRect instance.
|
|
208
210
|
*/
|
|
209
211
|
expandInPlace(rect) {
|
|
210
212
|
this.left = Math.min(this.left, rect.left);
|
|
@@ -216,8 +218,8 @@ var DivRect = class _DivRect {
|
|
|
216
218
|
/**
|
|
217
219
|
* Expand this Rect by given Rect. Immutable, returns modified copy.
|
|
218
220
|
*
|
|
219
|
-
* @param rect -
|
|
220
|
-
* @returns
|
|
221
|
+
* @param rect - DivRect to expand this instance with.
|
|
222
|
+
* @returns - Expanded copy of this DivRect.
|
|
221
223
|
*/
|
|
222
224
|
expandCopy(rect) {
|
|
223
225
|
return this.copy().expandInPlace(rect);
|
|
@@ -225,8 +227,8 @@ var DivRect = class _DivRect {
|
|
|
225
227
|
/**
|
|
226
228
|
* Clip this Rect by given Rect. Mmodifies this Rect.
|
|
227
229
|
*
|
|
228
|
-
* @param clipRect -
|
|
229
|
-
* @returns
|
|
230
|
+
* @param clipRect - DivRect to clip this instance with.
|
|
231
|
+
* @returns - This DivRect instance.
|
|
230
232
|
*/
|
|
231
233
|
clipInPlace(clipRect) {
|
|
232
234
|
this.left = Math.max(this.left, clipRect.left);
|
|
@@ -240,8 +242,8 @@ var DivRect = class _DivRect {
|
|
|
240
242
|
/**
|
|
241
243
|
* Clip this Rect by given Rect. Immutable, return modified copy.
|
|
242
244
|
*
|
|
243
|
-
* @param clipRect -
|
|
244
|
-
* @returns
|
|
245
|
+
* @param clipRect - DivRecto to clip this instance with.
|
|
246
|
+
* @returns - Clipped DivRect copy.
|
|
245
247
|
*/
|
|
246
248
|
clipCopy(clipRect) {
|
|
247
249
|
return this.copy().clipInPlace(clipRect);
|
|
@@ -249,9 +251,9 @@ var DivRect = class _DivRect {
|
|
|
249
251
|
/**
|
|
250
252
|
* Scale Rect. Anchor pos is (centerX, centerY). Modifies this Rect.
|
|
251
253
|
*
|
|
252
|
-
* @param scaleX -
|
|
253
|
-
* @param scaleY -
|
|
254
|
-
* @returns
|
|
254
|
+
* @param scaleX - Scale x-amount.
|
|
255
|
+
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
256
|
+
* @returns This DivRect instance.
|
|
255
257
|
*/
|
|
256
258
|
scaleInPlace(scaleX, scaleY) {
|
|
257
259
|
scaleY = scaleY != null ? scaleY : scaleX;
|
|
@@ -264,13 +266,17 @@ var DivRect = class _DivRect {
|
|
|
264
266
|
/**
|
|
265
267
|
* Scale Rect. Anchor pos is (centerX, centerY). Immutable, returns modified copy.
|
|
266
268
|
*
|
|
267
|
-
* @param scaleX -
|
|
268
|
-
* @param scaleY -
|
|
269
|
-
* @returns
|
|
269
|
+
* @param scaleX - Scale x-amount.
|
|
270
|
+
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
271
|
+
* @returns Scaled copy of this DivRect.
|
|
270
272
|
*/
|
|
271
273
|
scaleCopy(scaleX, scaleY) {
|
|
272
274
|
return this.copy().scaleInPlace(scaleX, scaleY);
|
|
273
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* Get this DivRect instance.
|
|
278
|
+
* @returns - This DivRect instance.
|
|
279
|
+
*/
|
|
274
280
|
getRect() {
|
|
275
281
|
return this;
|
|
276
282
|
}
|
|
@@ -361,6 +367,27 @@ var Annotation = /* @__PURE__ */ ((Annotation2) => {
|
|
|
361
367
|
Annotation2["Tempo"] = "tempo";
|
|
362
368
|
return Annotation2;
|
|
363
369
|
})(Annotation || {});
|
|
370
|
+
var DynamicsAnnotation = /* @__PURE__ */ ((DynamicsAnnotation2) => {
|
|
371
|
+
DynamicsAnnotation2["cresc"] = "cresc.";
|
|
372
|
+
DynamicsAnnotation2["decresc"] = "decresc.";
|
|
373
|
+
DynamicsAnnotation2["dim"] = "dim.";
|
|
374
|
+
DynamicsAnnotation2["ppp"] = "ppp";
|
|
375
|
+
DynamicsAnnotation2["pp"] = "pp";
|
|
376
|
+
DynamicsAnnotation2["p"] = "p";
|
|
377
|
+
DynamicsAnnotation2["mp"] = "mp";
|
|
378
|
+
DynamicsAnnotation2["m"] = "m";
|
|
379
|
+
DynamicsAnnotation2["mf"] = "mf";
|
|
380
|
+
DynamicsAnnotation2["f"] = "f";
|
|
381
|
+
DynamicsAnnotation2["ff"] = "ff";
|
|
382
|
+
DynamicsAnnotation2["fff"] = "fff";
|
|
383
|
+
return DynamicsAnnotation2;
|
|
384
|
+
})(DynamicsAnnotation || {});
|
|
385
|
+
var TempoAnnotation = /* @__PURE__ */ ((TempoAnnotation2) => {
|
|
386
|
+
TempoAnnotation2["accel"] = "accel.";
|
|
387
|
+
TempoAnnotation2["rit"] = "rit.";
|
|
388
|
+
TempoAnnotation2["a_tempo"] = "a tempo";
|
|
389
|
+
return TempoAnnotation2;
|
|
390
|
+
})(TempoAnnotation || {});
|
|
364
391
|
var Label = /* @__PURE__ */ ((Label2) => {
|
|
365
392
|
Label2["Note"] = "note";
|
|
366
393
|
Label2["Chord"] = "chord";
|
|
@@ -875,7 +902,7 @@ import { Utils as Utils11 } from "@tspro/ts-utils-lib";
|
|
|
875
902
|
// src/score/engine/obj-measure.ts
|
|
876
903
|
import { Utils as Utils10 } from "@tspro/ts-utils-lib";
|
|
877
904
|
import { getScale, Scale, validateScaleType, Note as Note7, RhythmProps as RhythmProps4, KeySignature as KeySignature2, getDefaultKeySignature, PitchNotation, SymbolSet, validateNoteLength, NoteLengthProps as NoteLengthProps4 } from "@tspro/web-music-score/theory";
|
|
878
|
-
import { getDefaultTempo,
|
|
905
|
+
import { getDefaultTempo, getDefaultTimeSignature } from "@tspro/web-music-score/theory";
|
|
879
906
|
|
|
880
907
|
// src/score/engine/acc-state.ts
|
|
881
908
|
import { Note } from "@tspro/web-music-score/theory";
|
|
@@ -1258,9 +1285,9 @@ var ObjSignature = class extends MusicObject {
|
|
|
1258
1285
|
if (showTimeSignature) {
|
|
1259
1286
|
let timeSignature = this.measure.getTimeSignature();
|
|
1260
1287
|
let beatCount = timeSignature.beatCount.toString();
|
|
1261
|
-
this.beatCountText = new ObjText(this, { text: beatCount, scale: 1.4 }, 0, 0.5);
|
|
1288
|
+
this.beatCountText = new ObjText(this, { text: beatCount, scale: 1.4 }, 0.5, 0.5);
|
|
1262
1289
|
let beatSize = timeSignature.beatSize.toString();
|
|
1263
|
-
this.beatSizeText = new ObjText(this, { text: beatSize, scale: 1.4 }, 0, 0.5);
|
|
1290
|
+
this.beatSizeText = new ObjText(this, { text: beatSize, scale: 1.4 }, 0.5, 0.5);
|
|
1264
1291
|
} else {
|
|
1265
1292
|
this.beatCountText = this.beatSizeText = void 0;
|
|
1266
1293
|
}
|
|
@@ -1350,6 +1377,7 @@ var ObjSignature = class extends MusicObject {
|
|
|
1350
1377
|
return [this];
|
|
1351
1378
|
}
|
|
1352
1379
|
layout(renderer) {
|
|
1380
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1353
1381
|
let { unitSize } = renderer;
|
|
1354
1382
|
let { staff } = this;
|
|
1355
1383
|
let paddingX = unitSize;
|
|
@@ -1394,15 +1422,16 @@ var ObjSignature = class extends MusicObject {
|
|
|
1394
1422
|
});
|
|
1395
1423
|
}
|
|
1396
1424
|
let right = x;
|
|
1425
|
+
(_a = this.beatCountText) == null ? void 0 : _a.layout(renderer);
|
|
1426
|
+
(_b = this.beatSizeText) == null ? void 0 : _b.layout(renderer);
|
|
1427
|
+
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);
|
|
1397
1428
|
if (this.beatCountText) {
|
|
1398
|
-
this.beatCountText.
|
|
1399
|
-
this.beatCountText.offset(x + paddingX, staff.getDiatonicIdY(staff.middleLineDiatonicId + 2));
|
|
1429
|
+
this.beatCountText.offset(x + tsWidth / 2 + paddingX, staff.getDiatonicIdY(staff.middleLineDiatonicId + 2));
|
|
1400
1430
|
this.rect.expandInPlace(this.beatCountText.getRect());
|
|
1401
1431
|
right = Math.max(right, this.rect.right);
|
|
1402
1432
|
}
|
|
1403
1433
|
if (this.beatSizeText) {
|
|
1404
|
-
this.beatSizeText.
|
|
1405
|
-
this.beatSizeText.offset(x + paddingX, staff.getDiatonicIdY(staff.bottomLineDiatonicId + 2));
|
|
1434
|
+
this.beatSizeText.offset(x + tsWidth / 2 + paddingX, staff.getDiatonicIdY(staff.bottomLineDiatonicId + 2));
|
|
1406
1435
|
this.rect.expandInPlace(this.beatSizeText.getRect());
|
|
1407
1436
|
right = Math.max(right, this.rect.right);
|
|
1408
1437
|
}
|
|
@@ -2791,11 +2820,10 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2791
2820
|
}
|
|
2792
2821
|
setStemTipY(staff, stemTipY) {
|
|
2793
2822
|
let obj = this.staffObjects.find((obj2) => obj2.staff === staff);
|
|
2794
|
-
if (
|
|
2795
|
-
|
|
2823
|
+
if (this.hasBeamCount() && (obj == null ? void 0 : obj.stemTip) && stemTipY !== obj.stemTip.centerY) {
|
|
2824
|
+
obj.stemTip.top = obj.stemTip.centerY = obj.stemTip.bottom = stemTipY;
|
|
2825
|
+
this.requestRectUpdate();
|
|
2796
2826
|
}
|
|
2797
|
-
obj.stemTip.top = obj.stemTip.centerY = obj.stemTip.bottom = stemTipY;
|
|
2798
|
-
this.requestRectUpdate();
|
|
2799
2827
|
}
|
|
2800
2828
|
offset(dx, dy) {
|
|
2801
2829
|
this.staffObjects.forEach((obj) => obj.offset(dx, 0));
|
|
@@ -3324,6 +3352,9 @@ var ObjRhythmColumn = class extends MusicObject {
|
|
|
3324
3352
|
}
|
|
3325
3353
|
};
|
|
3326
3354
|
|
|
3355
|
+
// src/score/engine/extension.ts
|
|
3356
|
+
import { MusicError as MusicError9, MusicErrorType as MusicErrorType9 } from "@tspro/web-music-score/core";
|
|
3357
|
+
|
|
3327
3358
|
// src/score/engine/element-data.ts
|
|
3328
3359
|
import { Utils as Utils5 } from "@tspro/ts-utils-lib";
|
|
3329
3360
|
|
|
@@ -3446,29 +3477,8 @@ function getNavigationString(navigation) {
|
|
|
3446
3477
|
return navigation[0].toUpperCase() + navigation.substring(1);
|
|
3447
3478
|
}
|
|
3448
3479
|
}
|
|
3449
|
-
var DynamicsAnnotations = /* @__PURE__ */ ((DynamicsAnnotations2) => {
|
|
3450
|
-
DynamicsAnnotations2["cresc"] = "cresc.";
|
|
3451
|
-
DynamicsAnnotations2["decresc"] = "decresc.";
|
|
3452
|
-
DynamicsAnnotations2["dim"] = "dim.";
|
|
3453
|
-
DynamicsAnnotations2["ppp"] = "ppp";
|
|
3454
|
-
DynamicsAnnotations2["pp"] = "pp";
|
|
3455
|
-
DynamicsAnnotations2["p"] = "p";
|
|
3456
|
-
DynamicsAnnotations2["mp"] = "mp";
|
|
3457
|
-
DynamicsAnnotations2["m"] = "m";
|
|
3458
|
-
DynamicsAnnotations2["mf"] = "mf";
|
|
3459
|
-
DynamicsAnnotations2["f"] = "f";
|
|
3460
|
-
DynamicsAnnotations2["ff"] = "ff";
|
|
3461
|
-
DynamicsAnnotations2["fff"] = "fff";
|
|
3462
|
-
return DynamicsAnnotations2;
|
|
3463
|
-
})(DynamicsAnnotations || {});
|
|
3464
|
-
var TempoAnnotations = /* @__PURE__ */ ((TempoAnnotations2) => {
|
|
3465
|
-
TempoAnnotations2["accel"] = "accel.";
|
|
3466
|
-
TempoAnnotations2["rit"] = "rit.";
|
|
3467
|
-
TempoAnnotations2["a_tempo"] = "a tempo";
|
|
3468
|
-
return TempoAnnotations2;
|
|
3469
|
-
})(TempoAnnotations || {});
|
|
3470
3480
|
function isDynamicsText(text) {
|
|
3471
|
-
return Utils5.Is.isEnumValue(text,
|
|
3481
|
+
return Utils5.Is.isEnumValue(text, DynamicsAnnotation);
|
|
3472
3482
|
}
|
|
3473
3483
|
function getDynamicsVolume(text) {
|
|
3474
3484
|
if (/^(p+|f+|m|mp|mf)$/.test(text)) {
|
|
@@ -3479,12 +3489,12 @@ function getDynamicsVolume(text) {
|
|
|
3479
3489
|
}
|
|
3480
3490
|
}
|
|
3481
3491
|
function isTempoText(text) {
|
|
3482
|
-
return Utils5.Is.isEnumValue(text,
|
|
3492
|
+
return Utils5.Is.isEnumValue(text, TempoAnnotation);
|
|
3483
3493
|
}
|
|
3484
3494
|
function getAnnotation(text) {
|
|
3485
|
-
if (Utils5.Is.isEnumValue(text,
|
|
3495
|
+
if (Utils5.Is.isEnumValue(text, DynamicsAnnotation)) {
|
|
3486
3496
|
return "dynamics" /* Dynamics */;
|
|
3487
|
-
} else if (Utils5.Is.isEnumValue(text,
|
|
3497
|
+
} else if (Utils5.Is.isEnumValue(text, TempoAnnotation)) {
|
|
3488
3498
|
return "tempo" /* Tempo */;
|
|
3489
3499
|
} else {
|
|
3490
3500
|
return void 0;
|
|
@@ -3492,7 +3502,6 @@ function getAnnotation(text) {
|
|
|
3492
3502
|
}
|
|
3493
3503
|
|
|
3494
3504
|
// src/score/engine/extension.ts
|
|
3495
|
-
import { MusicError as MusicError9, MusicErrorType as MusicErrorType9 } from "@tspro/web-music-score/core";
|
|
3496
3505
|
function getTextAnchorY(linePos) {
|
|
3497
3506
|
switch (linePos) {
|
|
3498
3507
|
case "bottom":
|
|
@@ -5023,7 +5032,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5023
5032
|
setTimeSignature(timeSignature) {
|
|
5024
5033
|
var _a;
|
|
5025
5034
|
(_a = this.getPrevMeasure()) == null ? void 0 : _a.endSection();
|
|
5026
|
-
this.alterTimeSignature = timeSignature
|
|
5035
|
+
this.alterTimeSignature = timeSignature;
|
|
5027
5036
|
this.updateTimeSignature();
|
|
5028
5037
|
}
|
|
5029
5038
|
updateTimeSignature() {
|
|
@@ -5553,52 +5562,77 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5553
5562
|
return false;
|
|
5554
5563
|
}
|
|
5555
5564
|
});
|
|
5565
|
+
let ts = this.getTimeSignature();
|
|
5566
|
+
if (!this.needBeamsUpdate || ts.beamGroupSizes.length === 0) {
|
|
5567
|
+
return;
|
|
5568
|
+
}
|
|
5556
5569
|
getVoiceIds().forEach((voiceId) => {
|
|
5557
|
-
let symbols = this.getVoiceSymbols(voiceId);
|
|
5558
|
-
if (symbols.length
|
|
5559
|
-
|
|
5560
|
-
}
|
|
5561
|
-
if (!DebugSettings.DisableBeams) {
|
|
5562
|
-
let groupSymbols = [];
|
|
5570
|
+
let symbols = this.getVoiceSymbols(voiceId).slice();
|
|
5571
|
+
if (symbols.length >= 2) {
|
|
5572
|
+
let symbolsStartTicks = this.isUpBeat() ? Math.max(0, this.getMeasureTicks() - this.getConsumedTicks()) : 0;
|
|
5563
5573
|
let groupStartTicks = 0;
|
|
5564
|
-
let
|
|
5565
|
-
|
|
5566
|
-
let
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5574
|
+
for (let groupId = 0; groupId < ts.beamGroupSizes.length; groupId++) {
|
|
5575
|
+
let beamGroupSize = ts.beamGroupSizes[groupId];
|
|
5576
|
+
let groupSizeSum = 0;
|
|
5577
|
+
beamGroupSize.forEach((s) => groupSizeSum += s);
|
|
5578
|
+
let groupLength = groupSizeSum * NoteLengthProps4.get("8n").ticks;
|
|
5579
|
+
let groupSymbols = [];
|
|
5580
|
+
let groupSymbolsLength = 0;
|
|
5581
|
+
while (symbols.length > 0 && groupSymbolsLength < groupLength) {
|
|
5582
|
+
let symbol = symbols[0];
|
|
5583
|
+
if (symbol.col.positionTicks >= groupStartTicks) {
|
|
5584
|
+
groupSymbols.push(symbol);
|
|
5585
|
+
groupSymbolsLength += symbol.rhythmProps.ticks;
|
|
5586
|
+
symbols.shift();
|
|
5587
|
+
} else {
|
|
5588
|
+
break;
|
|
5589
|
+
}
|
|
5579
5590
|
}
|
|
5580
|
-
|
|
5591
|
+
_ObjMeasure.setupBeamGroup(groupSymbols, beamGroupSize);
|
|
5592
|
+
symbolsStartTicks += groupSymbolsLength;
|
|
5593
|
+
groupStartTicks += groupLength;
|
|
5594
|
+
}
|
|
5581
5595
|
}
|
|
5582
5596
|
});
|
|
5583
5597
|
this.needBeamsUpdate = false;
|
|
5584
5598
|
this.requestLayout();
|
|
5585
5599
|
}
|
|
5586
|
-
static setupBeamGroup(groupSymbols) {
|
|
5600
|
+
static setupBeamGroup(groupSymbols, mainBeamGroupSizeArr) {
|
|
5601
|
+
if (mainBeamGroupSizeArr.length === 0) {
|
|
5602
|
+
return false;
|
|
5603
|
+
}
|
|
5587
5604
|
let groupNotes = groupSymbols.map((s) => {
|
|
5588
5605
|
var _a;
|
|
5589
5606
|
return s instanceof ObjNoteGroup && ((_a = s.getBeamGroup()) == null ? void 0 : _a.isTuplet()) !== true ? s : void 0;
|
|
5590
5607
|
});
|
|
5591
5608
|
ObjNoteGroup.setBeamCounts(groupNotes);
|
|
5592
|
-
let
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5609
|
+
let beamGroupSizeArrList = [mainBeamGroupSizeArr];
|
|
5610
|
+
if (mainBeamGroupSizeArr.length > 1) {
|
|
5611
|
+
let sum = 0;
|
|
5612
|
+
mainBeamGroupSizeArr.forEach((s) => sum += s);
|
|
5613
|
+
beamGroupSizeArrList.unshift([sum]);
|
|
5614
|
+
}
|
|
5615
|
+
let beamsCreated = false;
|
|
5616
|
+
while (beamGroupSizeArrList.length > 0 && !beamsCreated) {
|
|
5617
|
+
let beamGroupSizeArr = beamGroupSizeArrList.shift();
|
|
5618
|
+
let groupSymbolsCopy = groupSymbols.slice();
|
|
5619
|
+
beamGroupSizeArr.forEach((beamGroupSize) => {
|
|
5620
|
+
var _a;
|
|
5621
|
+
let beamGroupLength = beamGroupSize * NoteLengthProps4.get("8n").ticks;
|
|
5622
|
+
let beamNotesLength = 0;
|
|
5623
|
+
let beamNotes = [];
|
|
5624
|
+
while (beamNotesLength < beamGroupLength && groupSymbolsCopy.length > 0) {
|
|
5625
|
+
let symbol = groupSymbolsCopy.shift();
|
|
5626
|
+
beamNotesLength += symbol.rhythmProps.ticks;
|
|
5627
|
+
beamNotes.push(symbol instanceof ObjNoteGroup && ((_a = symbol.getBeamGroup()) == null ? void 0 : _a.isTuplet()) !== true ? symbol : void 0);
|
|
5628
|
+
}
|
|
5629
|
+
if (beamNotesLength === beamGroupLength && beamNotes.every((n) => n !== void 0) && (beamNotes.every((n) => n.rhythmProps.flagCount === 1) || beamGroupSizeArrList.length === 0)) {
|
|
5630
|
+
ObjBeamGroup.createBeam(beamNotes);
|
|
5631
|
+
beamsCreated = true;
|
|
5632
|
+
}
|
|
5633
|
+
});
|
|
5634
|
+
}
|
|
5635
|
+
return beamsCreated;
|
|
5602
5636
|
}
|
|
5603
5637
|
getBarLineLeft() {
|
|
5604
5638
|
return this.barLineLeft;
|
|
@@ -6947,7 +6981,7 @@ var ObjDocument = class extends MusicObject {
|
|
|
6947
6981
|
};
|
|
6948
6982
|
|
|
6949
6983
|
// src/score/pub/document-builder.ts
|
|
6950
|
-
import { KeySignature as KeySignature3, Note as Note10, NoteLength as NoteLength7, RhythmProps as RhythmProps5, Scale as Scale2, ScaleType, SymbolSet as SymbolSet2, TimeSignature as TimeSignature2, TuningNameList, validateNoteLength as validateNoteLength2, validateTupletRatio } from "@tspro/web-music-score/theory";
|
|
6984
|
+
import { BeamGrouping, KeySignature as KeySignature3, Note as Note10, NoteLength as NoteLength7, RhythmProps as RhythmProps5, Scale as Scale2, ScaleType, SymbolSet as SymbolSet2, TimeSignature as TimeSignature2, TimeSignatures, TuningNameList, validateNoteLength as validateNoteLength2, validateTupletRatio } from "@tspro/web-music-score/theory";
|
|
6951
6985
|
import { MusicError as MusicError17, MusicErrorType as MusicErrorType17 } from "@tspro/web-music-score/core";
|
|
6952
6986
|
function assertArg(condition, argName, argValue) {
|
|
6953
6987
|
if (!condition) {
|
|
@@ -7035,6 +7069,9 @@ function isTupletRatio(tupletRatio) {
|
|
|
7035
7069
|
}
|
|
7036
7070
|
}
|
|
7037
7071
|
var DocumentBuilder = class {
|
|
7072
|
+
/**
|
|
7073
|
+
* Create new document builder instance.
|
|
7074
|
+
*/
|
|
7038
7075
|
constructor() {
|
|
7039
7076
|
__publicField(this, "doc");
|
|
7040
7077
|
this.doc = new ObjDocument();
|
|
@@ -7068,9 +7105,20 @@ var DocumentBuilder = class {
|
|
|
7068
7105
|
var _a;
|
|
7069
7106
|
return (_a = this.doc.getLastMeasure()) != null ? _a : this.doc.addMeasure();
|
|
7070
7107
|
}
|
|
7108
|
+
/**
|
|
7109
|
+
* Get music document after finished building.
|
|
7110
|
+
* @returns - Music document.
|
|
7111
|
+
*/
|
|
7071
7112
|
getDocument() {
|
|
7072
7113
|
return this.doc.getMusicInterface();
|
|
7073
7114
|
}
|
|
7115
|
+
/**
|
|
7116
|
+
* Set header texts.
|
|
7117
|
+
* @param title - Title of this docmument/musical piece.
|
|
7118
|
+
* @param composer - Composer of this document/musical piece.
|
|
7119
|
+
* @param arranger - Arranger of this document/musical piece.
|
|
7120
|
+
* @returns - This document builder instance.
|
|
7121
|
+
*/
|
|
7074
7122
|
setHeader(title, composer, arranger) {
|
|
7075
7123
|
assertArg(Utils13.Is.isStringOrUndefined(title), "title", title);
|
|
7076
7124
|
assertArg(Utils13.Is.isStringOrUndefined(composer), "composer", composer);
|
|
@@ -7078,11 +7126,20 @@ var DocumentBuilder = class {
|
|
|
7078
7126
|
this.doc.setHeader(title, composer, arranger);
|
|
7079
7127
|
return this;
|
|
7080
7128
|
}
|
|
7129
|
+
/**
|
|
7130
|
+
* Automatically limit number of measures per score row.
|
|
7131
|
+
* @param measuresPerRow - Number of measures per row. Must be integer >=1 or Infinity.
|
|
7132
|
+
* @returns - This document builder instance.
|
|
7133
|
+
*/
|
|
7081
7134
|
setMeasuresPerRow(measuresPerRow) {
|
|
7082
7135
|
assertArg(Utils13.Is.isIntegerGte(measuresPerRow, 1) || Utils13.Is.isPosInfinity(measuresPerRow), "measuresPerRow", measuresPerRow);
|
|
7083
7136
|
this.doc.setMeasuresPerRow(measuresPerRow);
|
|
7084
7137
|
return this;
|
|
7085
7138
|
}
|
|
7139
|
+
/**
|
|
7140
|
+
* Add new measure.
|
|
7141
|
+
* @returns - This document builder instance.
|
|
7142
|
+
*/
|
|
7086
7143
|
addMeasure() {
|
|
7087
7144
|
this.doc.addMeasure();
|
|
7088
7145
|
return this;
|
|
@@ -7092,9 +7149,16 @@ var DocumentBuilder = class {
|
|
|
7092
7149
|
this.getMeasure().setKeySignature(...args);
|
|
7093
7150
|
return this;
|
|
7094
7151
|
}
|
|
7095
|
-
setTimeSignature(
|
|
7096
|
-
|
|
7097
|
-
|
|
7152
|
+
setTimeSignature(...args) {
|
|
7153
|
+
if (args[0] instanceof TimeSignature2) {
|
|
7154
|
+
this.getMeasure().setTimeSignature(args[0]);
|
|
7155
|
+
} else if (Utils13.Is.isEnumValue(args[0], TimeSignatures) && Utils13.Is.isEnumValueOrUndefined(args[1], BeamGrouping)) {
|
|
7156
|
+
this.getMeasure().setTimeSignature(new TimeSignature2(args[0], args[1]));
|
|
7157
|
+
} else if (Utils13.Is.isIntegerGte(args[0], 1) && Utils13.Is.isIntegerGte(args[1], 1) && Utils13.Is.isEnumValueOrUndefined(args[2], BeamGrouping)) {
|
|
7158
|
+
this.getMeasure().setTimeSignature(new TimeSignature2(args[0], args[1], args[2]));
|
|
7159
|
+
} else {
|
|
7160
|
+
assertArg(false, "timeSignature args", args);
|
|
7161
|
+
}
|
|
7098
7162
|
return this;
|
|
7099
7163
|
}
|
|
7100
7164
|
setTempo(beatsPerMinute, beatLength, dotted) {
|
|
@@ -7108,6 +7172,14 @@ var DocumentBuilder = class {
|
|
|
7108
7172
|
this.getMeasure().setTempo(beatsPerMinute, beatLength, dotted);
|
|
7109
7173
|
return this;
|
|
7110
7174
|
}
|
|
7175
|
+
/**
|
|
7176
|
+
* Add note o current measure.
|
|
7177
|
+
* @param voiceId - Voice id to add note to.
|
|
7178
|
+
* @param note - Note instance of Note or string (e.g. "D4").
|
|
7179
|
+
* @param noteLength - Note length (e.g. "4n").
|
|
7180
|
+
* @param options - Note options.
|
|
7181
|
+
* @returns - This document builder instance.
|
|
7182
|
+
*/
|
|
7111
7183
|
addNote(voiceId, note, noteLength, options) {
|
|
7112
7184
|
assertArg(isVoiceId(voiceId), "voiceId", voiceId);
|
|
7113
7185
|
assertArg(note instanceof Note10 || Utils13.Is.isNonEmptyString(note), "note", note);
|
|
@@ -7118,6 +7190,13 @@ var DocumentBuilder = class {
|
|
|
7118
7190
|
this.getMeasure().addNoteGroup(voiceId, [note], noteLength, options);
|
|
7119
7191
|
return this;
|
|
7120
7192
|
}
|
|
7193
|
+
/**
|
|
7194
|
+
* @param voiceId - Voice id to add chord to.
|
|
7195
|
+
* @param notes - Array of notes, each instance of Note or string (e.g. "D4").
|
|
7196
|
+
* @param noteLength - Note length (e.g. "4n").
|
|
7197
|
+
* @param options - Note options.
|
|
7198
|
+
* @returns - This document builder instance.
|
|
7199
|
+
*/
|
|
7121
7200
|
addChord(voiceId, notes, noteLength, options) {
|
|
7122
7201
|
assertArg(isVoiceId(voiceId), "voiceId", voiceId);
|
|
7123
7202
|
assertArg(Utils13.Is.isNonEmptyArray(notes) && notes.every((note) => note instanceof Note10 || Utils13.Is.isNonEmptyString(note)), "notes", notes);
|
|
@@ -7128,6 +7207,13 @@ var DocumentBuilder = class {
|
|
|
7128
7207
|
this.getMeasure().addNoteGroup(voiceId, notes, noteLength, options);
|
|
7129
7208
|
return this;
|
|
7130
7209
|
}
|
|
7210
|
+
/**
|
|
7211
|
+
*
|
|
7212
|
+
* @param voiceId - Voice id to add rest to.
|
|
7213
|
+
* @param restLength - Rest length (e.g. "4n").
|
|
7214
|
+
* @param options - Rest options.
|
|
7215
|
+
* @returns - This document builder instance.
|
|
7216
|
+
*/
|
|
7131
7217
|
addRest(voiceId, restLength, options) {
|
|
7132
7218
|
assertArg(isVoiceId(voiceId), "voiceId", voiceId);
|
|
7133
7219
|
assertArg(Utils13.Is.isEnumValue(restLength, NoteLength7) || isNoteLength(restLength), "restLength", restLength);
|
|
@@ -7147,10 +7233,10 @@ var DocumentBuilder = class {
|
|
|
7147
7233
|
* });
|
|
7148
7234
|
* </pre>
|
|
7149
7235
|
*
|
|
7150
|
-
* @param voiceId
|
|
7236
|
+
* @param voiceId - Voice id to add tuplet to.
|
|
7151
7237
|
* @param tupletRatio - You can also use Theory.Tuplet presets (e.g. Theory.Tuplet.Triplet).
|
|
7152
|
-
* @param tupletBuilder
|
|
7153
|
-
* @returns
|
|
7238
|
+
* @param tupletBuilder - Tuplet builder function to build tuplet.
|
|
7239
|
+
* @returns - This document builder instance.
|
|
7154
7240
|
*/
|
|
7155
7241
|
addTuplet(voiceId, tupletRatio, tupletBuilder) {
|
|
7156
7242
|
assertArg(isVoiceId(voiceId), "voiceId", voiceId);
|
|
@@ -7201,10 +7287,20 @@ var DocumentBuilder = class {
|
|
|
7201
7287
|
this.getMeasure().addFermata(staffTabOrGroups, fermata);
|
|
7202
7288
|
return this;
|
|
7203
7289
|
}
|
|
7290
|
+
/**
|
|
7291
|
+
* Add fermata to current measure.
|
|
7292
|
+
* @param fermata - Fermata type (e.g. "atNote" or Fermata.AtrNote).
|
|
7293
|
+
* @returns - This document builder instance.
|
|
7294
|
+
*/
|
|
7204
7295
|
addFermata(fermata = "atNote" /* AtNote */) {
|
|
7205
7296
|
return this.addFermataInternal(void 0, fermata);
|
|
7206
7297
|
}
|
|
7207
|
-
/**
|
|
7298
|
+
/**
|
|
7299
|
+
* Add Fermata to current measure to given staff/tab/group.
|
|
7300
|
+
* @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name.
|
|
7301
|
+
* @param fermata - Fermata type (e.g. "atNote" or Fermata.AtrNote).
|
|
7302
|
+
* @returns - This document builder instance.
|
|
7303
|
+
*/
|
|
7208
7304
|
addFermataTo(staffTabOrGroups, fermata = "atNote" /* AtNote */) {
|
|
7209
7305
|
return this.addFermataInternal(staffTabOrGroups, fermata);
|
|
7210
7306
|
}
|
|
@@ -7257,10 +7353,22 @@ var DocumentBuilder = class {
|
|
|
7257
7353
|
this.getMeasure().addLabel(staffTabOrGroups, label, text);
|
|
7258
7354
|
return this;
|
|
7259
7355
|
}
|
|
7356
|
+
/**
|
|
7357
|
+
* Add label text to column of last added note/chord/rest in current measure.
|
|
7358
|
+
* @param label - Label type (e.g. "chord" or Label.Chord).
|
|
7359
|
+
* @param text - label text (e.g. "Am").
|
|
7360
|
+
* @returns - This document builder instance.
|
|
7361
|
+
*/
|
|
7260
7362
|
addLabel(label, text) {
|
|
7261
7363
|
return this.addLabelInternal(void 0, label, text);
|
|
7262
7364
|
}
|
|
7263
|
-
/**
|
|
7365
|
+
/**
|
|
7366
|
+
* Add label text to column of last added note/chord/rest in current measure to given staff/tab/group.
|
|
7367
|
+
* @param staffTabOrGroups - staff/tab index (0=top), staff/tab name, or staff group name.
|
|
7368
|
+
* @param label - Label type (e.g. "chord" or Label.Chord).
|
|
7369
|
+
* @param text - label text (e.g. "Am").
|
|
7370
|
+
* @returns - This document builder instance.
|
|
7371
|
+
*/
|
|
7264
7372
|
addLabelTo(staffTabOrGroups, label, text) {
|
|
7265
7373
|
return this.addLabelInternal(staffTabOrGroups, label, text);
|
|
7266
7374
|
}
|
|
@@ -7286,16 +7394,16 @@ var DocumentBuilder = class {
|
|
|
7286
7394
|
return this;
|
|
7287
7395
|
}
|
|
7288
7396
|
/**
|
|
7289
|
-
*
|
|
7397
|
+
* Add extension line to previously added annotation or label element.
|
|
7290
7398
|
* <pre>
|
|
7399
|
+
* // Example
|
|
7291
7400
|
* addExtension(ext => ext.notes("1n", 2)) // length is 2 whole notes
|
|
7292
7401
|
* addExtension(ext => ext.measures(3).hide()) // length is 3 measures, hidden
|
|
7293
7402
|
* addExtension(ext => ext.measures(1).notes("8n")) // length is 1 measure + 1 eigth note
|
|
7294
7403
|
* addExtension(ext => ext.infinity()) // length is as long as possible
|
|
7295
7404
|
* </pre>
|
|
7296
|
-
* @param
|
|
7297
|
-
* @
|
|
7298
|
-
* @returns
|
|
7405
|
+
* @param extensionBuilder - Extension builder function used to build exstension.
|
|
7406
|
+
* @returns - This document builder instance.
|
|
7299
7407
|
*/
|
|
7300
7408
|
addExtension(extensionBuilder) {
|
|
7301
7409
|
assertArg(Utils13.Is.isFunctionOrUndefined(extensionBuilder), "addExtension() has new usage, for e.g. addExtension(ext => ext.measures(2)). Please refer to README or API Reference.", extensionBuilder);
|
|
@@ -7331,11 +7439,11 @@ var DocumentBuilder = class {
|
|
|
7331
7439
|
return this;
|
|
7332
7440
|
}
|
|
7333
7441
|
/**
|
|
7334
|
-
*
|
|
7442
|
+
* Add staff group.
|
|
7335
7443
|
* @param groupName - Name of staff group.
|
|
7336
7444
|
* @param staffsTabsAndGroups - staff/tab index (0=top), staff/tab name, or staff group name. Single value or array.
|
|
7337
7445
|
* @param verticalPosition - Vertical position, are elements added above, below or both.
|
|
7338
|
-
* @returns
|
|
7446
|
+
* @returns - This document builder instance.
|
|
7339
7447
|
*/
|
|
7340
7448
|
addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition = "auto" /* Auto */) {
|
|
7341
7449
|
assertArg(Utils13.Is.isNonEmptyString(groupName), "groupName", groupName);
|
|
@@ -7348,24 +7456,48 @@ var DocumentBuilder = class {
|
|
|
7348
7456
|
this.doc.addStaffGroup(groupName, staffsTabsAndGroups, verticalPosition);
|
|
7349
7457
|
return this;
|
|
7350
7458
|
}
|
|
7459
|
+
/**
|
|
7460
|
+
* Add song end. Adds certain bar line at the end of measure.
|
|
7461
|
+
* @returns - This document builder instance.
|
|
7462
|
+
*/
|
|
7351
7463
|
endSong() {
|
|
7352
7464
|
this.getMeasure().endSong();
|
|
7353
7465
|
return this;
|
|
7354
7466
|
}
|
|
7467
|
+
/**
|
|
7468
|
+
* Add section end. Adds certain bar line at the end of measure.
|
|
7469
|
+
* @returns - This document builder instance.
|
|
7470
|
+
*/
|
|
7355
7471
|
endSection() {
|
|
7356
7472
|
this.getMeasure().endSection();
|
|
7357
7473
|
return this;
|
|
7358
7474
|
}
|
|
7475
|
+
/**
|
|
7476
|
+
* End current score row. Next measure will start new row.
|
|
7477
|
+
* @returns - This document builder instance.
|
|
7478
|
+
*/
|
|
7359
7479
|
endRow() {
|
|
7360
7480
|
var _a;
|
|
7361
7481
|
(_a = this.doc.getLastMeasure()) == null ? void 0 : _a.endRow();
|
|
7362
7482
|
return this;
|
|
7363
7483
|
}
|
|
7484
|
+
/**
|
|
7485
|
+
* Add rests to fill current measure.
|
|
7486
|
+
* @param voiceId - Voice id to add rests to. Single value, array or all if omitted.
|
|
7487
|
+
* @returns - This document builder instance.
|
|
7488
|
+
*/
|
|
7364
7489
|
completeRests(voiceId) {
|
|
7365
7490
|
assertArg(Utils13.Is.isUndefined(voiceId) || isVoiceId(voiceId) || Utils13.Is.isArray(voiceId) && voiceId.every((id) => isVoiceId(id)), "voiceId", voiceId);
|
|
7366
7491
|
this.getMeasure().completeRests(voiceId);
|
|
7367
7492
|
return this;
|
|
7368
7493
|
}
|
|
7494
|
+
/**
|
|
7495
|
+
* Add notes of given scale in ascending order.
|
|
7496
|
+
* @param scale - Scale.
|
|
7497
|
+
* @param bottomNote - Scale starts from note >= bottom note.
|
|
7498
|
+
* @param numOctaves - Number of octaves to add.
|
|
7499
|
+
* @returns - This document builder instance.
|
|
7500
|
+
*/
|
|
7369
7501
|
addScaleArpeggio(scale, bottomNote, numOctaves) {
|
|
7370
7502
|
assertArg(Utils13.Is.isNonEmptyString(bottomNote), "bottomNote", bottomNote);
|
|
7371
7503
|
assertArg(Utils13.Is.isIntegerGte(numOctaves, 1), "numOctaves", numOctaves);
|
|
@@ -7386,11 +7518,22 @@ var DocumentBuilder = class {
|
|
|
7386
7518
|
// src/score/pub/event.ts
|
|
7387
7519
|
import { MusicError as MusicError18, MusicErrorType as MusicErrorType18 } from "@tspro/web-music-score/core";
|
|
7388
7520
|
var ScoreEvent = class {
|
|
7521
|
+
/**
|
|
7522
|
+
* Create new score event instance.
|
|
7523
|
+
* @param type - Score event type.
|
|
7524
|
+
*/
|
|
7389
7525
|
constructor(type) {
|
|
7390
7526
|
this.type = type;
|
|
7391
7527
|
}
|
|
7392
7528
|
};
|
|
7393
7529
|
var ScoreStaffPosEvent = class extends ScoreEvent {
|
|
7530
|
+
/**
|
|
7531
|
+
* Create new score staff position event.
|
|
7532
|
+
* @param type - Score event type.
|
|
7533
|
+
* @param renderer - Renderer.
|
|
7534
|
+
* @param scoreRow - Score row.
|
|
7535
|
+
* @param diatonicId - Diatonic id that was clicked/entered/left.
|
|
7536
|
+
*/
|
|
7394
7537
|
constructor(type, renderer, scoreRow, diatonicId) {
|
|
7395
7538
|
super(type);
|
|
7396
7539
|
this.renderer = renderer;
|
|
@@ -7399,6 +7542,12 @@ var ScoreStaffPosEvent = class extends ScoreEvent {
|
|
|
7399
7542
|
}
|
|
7400
7543
|
};
|
|
7401
7544
|
var ScoreObjectEvent = class extends ScoreEvent {
|
|
7545
|
+
/**
|
|
7546
|
+
* Create new score object event.
|
|
7547
|
+
* @param type - Score event type.
|
|
7548
|
+
* @param renderer - Renderer.
|
|
7549
|
+
* @param objects - Array of objects, last object in this array is the top object that was clicked/entered/left, previous objects are it's parent objects.
|
|
7550
|
+
*/
|
|
7402
7551
|
constructor(type, renderer, objects) {
|
|
7403
7552
|
super(type);
|
|
7404
7553
|
this.renderer = renderer;
|
|
@@ -7407,16 +7556,25 @@ var ScoreObjectEvent = class extends ScoreEvent {
|
|
|
7407
7556
|
throw new MusicError18(MusicErrorType18.Score, "Empty array in score object event!");
|
|
7408
7557
|
}
|
|
7409
7558
|
}
|
|
7559
|
+
/** Top object getter. */
|
|
7410
7560
|
get topObject() {
|
|
7411
7561
|
return this.objects[this.objects.length - 1];
|
|
7412
7562
|
}
|
|
7563
|
+
/**
|
|
7564
|
+
* Find object.
|
|
7565
|
+
* @param fn - Compare function.
|
|
7566
|
+
* @returns - First object that matched compare function, or undefined if no match.
|
|
7567
|
+
*/
|
|
7413
7568
|
findObject(fn) {
|
|
7414
7569
|
return this.objects.find((obj) => fn(obj));
|
|
7415
7570
|
}
|
|
7416
7571
|
};
|
|
7417
7572
|
|
|
7418
|
-
// src/score/pub/interface.ts
|
|
7573
|
+
// src/score/pub/music-interface.ts
|
|
7419
7574
|
import * as Audio2 from "@tspro/web-music-score/audio";
|
|
7575
|
+
import { Utils as Utils15 } from "@tspro/ts-utils-lib";
|
|
7576
|
+
|
|
7577
|
+
// src/score/pub/music-objects.ts
|
|
7420
7578
|
import { Utils as Utils14 } from "@tspro/ts-utils-lib";
|
|
7421
7579
|
import { MusicError as MusicError19, MusicErrorType as MusicErrorType19 } from "@tspro/web-music-score/core";
|
|
7422
7580
|
function assertArg2(condition, argName, argValue) {
|
|
@@ -7424,13 +7582,6 @@ function assertArg2(condition, argName, argValue) {
|
|
|
7424
7582
|
throw new MusicError19(MusicErrorType19.Score, `Invalid arg: ${argName} = ${argValue}`);
|
|
7425
7583
|
}
|
|
7426
7584
|
}
|
|
7427
|
-
function require_t(t, message) {
|
|
7428
|
-
if (t === void 0 || t === null) {
|
|
7429
|
-
throw new TypeError(message);
|
|
7430
|
-
} else {
|
|
7431
|
-
return t;
|
|
7432
|
-
}
|
|
7433
|
-
}
|
|
7434
7585
|
function isVoiceId2(value) {
|
|
7435
7586
|
return Utils14.Is.isNumber(value) && getVoiceIds().indexOf(value) >= 0;
|
|
7436
7587
|
}
|
|
@@ -7442,9 +7593,17 @@ function getNotationLine(line) {
|
|
|
7442
7593
|
}
|
|
7443
7594
|
}
|
|
7444
7595
|
var MusicInterface6 = class {
|
|
7596
|
+
/**
|
|
7597
|
+
* Create new music interface object.
|
|
7598
|
+
* @param name - OBject name.
|
|
7599
|
+
*/
|
|
7445
7600
|
constructor(name) {
|
|
7446
7601
|
this.name = name;
|
|
7447
7602
|
}
|
|
7603
|
+
/**
|
|
7604
|
+
* Get parent object.
|
|
7605
|
+
* @returns - Parent object or undefined.
|
|
7606
|
+
*/
|
|
7448
7607
|
getParent() {
|
|
7449
7608
|
var _a;
|
|
7450
7609
|
return (_a = this.getMusicObject().getParent()) == null ? void 0 : _a.getMusicInterface();
|
|
@@ -7460,10 +7619,15 @@ var _MAccidental = class _MAccidental extends MusicInterface6 {
|
|
|
7460
7619
|
getMusicObject() {
|
|
7461
7620
|
return this.obj;
|
|
7462
7621
|
}
|
|
7622
|
+
/**
|
|
7623
|
+
* Get accidental.
|
|
7624
|
+
* @returns - Accidental (e.g. 1 = #).
|
|
7625
|
+
*/
|
|
7463
7626
|
getAccidental() {
|
|
7464
7627
|
return this.obj.accidental;
|
|
7465
7628
|
}
|
|
7466
7629
|
};
|
|
7630
|
+
/** Object name. */
|
|
7467
7631
|
__publicField(_MAccidental, "Name", "Accidental");
|
|
7468
7632
|
var MAccidental = _MAccidental;
|
|
7469
7633
|
var _MConnective = class _MConnective extends MusicInterface6 {
|
|
@@ -7477,6 +7641,7 @@ var _MConnective = class _MConnective extends MusicInterface6 {
|
|
|
7477
7641
|
return this.obj;
|
|
7478
7642
|
}
|
|
7479
7643
|
};
|
|
7644
|
+
/** Object name. */
|
|
7480
7645
|
__publicField(_MConnective, "Name", "Connective");
|
|
7481
7646
|
var MConnective = _MConnective;
|
|
7482
7647
|
var _MArpeggio = class _MArpeggio extends MusicInterface6 {
|
|
@@ -7489,13 +7654,22 @@ var _MArpeggio = class _MArpeggio extends MusicInterface6 {
|
|
|
7489
7654
|
getMusicObject() {
|
|
7490
7655
|
return this.obj;
|
|
7491
7656
|
}
|
|
7657
|
+
/**
|
|
7658
|
+
* Get rhythm column this arpeggio is in.
|
|
7659
|
+
* @returns - Rhythm column.
|
|
7660
|
+
*/
|
|
7492
7661
|
getRhythmColumn() {
|
|
7493
7662
|
return this.obj.col.getMusicInterface();
|
|
7494
7663
|
}
|
|
7664
|
+
/**
|
|
7665
|
+
* Get notation line this arpeggio is in.
|
|
7666
|
+
* @returns - Staff or tab object.
|
|
7667
|
+
*/
|
|
7495
7668
|
getNotationLine() {
|
|
7496
7669
|
return getNotationLine(this.obj.line);
|
|
7497
7670
|
}
|
|
7498
7671
|
};
|
|
7672
|
+
/** Object name. */
|
|
7499
7673
|
__publicField(_MArpeggio, "Name", "Arpeggio");
|
|
7500
7674
|
var MArpeggio = _MArpeggio;
|
|
7501
7675
|
var _MBeamGroup = class _MBeamGroup extends MusicInterface6 {
|
|
@@ -7509,6 +7683,7 @@ var _MBeamGroup = class _MBeamGroup extends MusicInterface6 {
|
|
|
7509
7683
|
return this.obj;
|
|
7510
7684
|
}
|
|
7511
7685
|
};
|
|
7686
|
+
/** OBject name. */
|
|
7512
7687
|
__publicField(_MBeamGroup, "Name", "BeamGroup");
|
|
7513
7688
|
var MBeamGroup = _MBeamGroup;
|
|
7514
7689
|
var _MStaffBeamGroup = class _MStaffBeamGroup extends MusicInterface6 {
|
|
@@ -7521,10 +7696,15 @@ var _MStaffBeamGroup = class _MStaffBeamGroup extends MusicInterface6 {
|
|
|
7521
7696
|
getMusicObject() {
|
|
7522
7697
|
return this.obj;
|
|
7523
7698
|
}
|
|
7699
|
+
/**
|
|
7700
|
+
* Get staff this beam group is in.
|
|
7701
|
+
* @returns - Staff object.
|
|
7702
|
+
*/
|
|
7524
7703
|
getStaff() {
|
|
7525
7704
|
return this.obj.staff.getMusicInterface();
|
|
7526
7705
|
}
|
|
7527
7706
|
};
|
|
7707
|
+
/** Object name. */
|
|
7528
7708
|
__publicField(_MStaffBeamGroup, "Name", "StaffBeamGroup");
|
|
7529
7709
|
var MStaffBeamGroup = _MStaffBeamGroup;
|
|
7530
7710
|
var _MDocument = class _MDocument extends MusicInterface6 {
|
|
@@ -7537,27 +7717,53 @@ var _MDocument = class _MDocument extends MusicInterface6 {
|
|
|
7537
7717
|
getMusicObject() {
|
|
7538
7718
|
return this.obj;
|
|
7539
7719
|
}
|
|
7720
|
+
/**
|
|
7721
|
+
* Get title.
|
|
7722
|
+
* @returns - Title string or undefined.
|
|
7723
|
+
*/
|
|
7540
7724
|
getTitle() {
|
|
7541
7725
|
return this.obj.getTitle();
|
|
7542
7726
|
}
|
|
7727
|
+
/**
|
|
7728
|
+
* Get composer.
|
|
7729
|
+
* @returns - Composer string or undefined.
|
|
7730
|
+
*/
|
|
7543
7731
|
getComposer() {
|
|
7544
7732
|
return this.obj.getComposer();
|
|
7545
7733
|
3;
|
|
7546
7734
|
}
|
|
7735
|
+
/**
|
|
7736
|
+
* Get arranger.
|
|
7737
|
+
* @returns - Arranger string or undefined.
|
|
7738
|
+
*/
|
|
7547
7739
|
getArranger() {
|
|
7548
7740
|
return this.obj.getArranger();
|
|
7549
7741
|
}
|
|
7742
|
+
/**
|
|
7743
|
+
* Get score rows.
|
|
7744
|
+
* @returns - Array or score rows.
|
|
7745
|
+
*/
|
|
7550
7746
|
getRows() {
|
|
7551
7747
|
return this.obj.getRows().map((r) => r.getMusicInterface());
|
|
7552
7748
|
}
|
|
7749
|
+
/**
|
|
7750
|
+
* Get measures.
|
|
7751
|
+
* @returns - Array of measures.
|
|
7752
|
+
*/
|
|
7553
7753
|
getMeasures() {
|
|
7554
7754
|
return this.obj.getMeasures().map((m) => m.getMusicInterface());
|
|
7555
7755
|
}
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7756
|
+
/**
|
|
7757
|
+
* Play this document.
|
|
7758
|
+
* @param playStateChangeListener - Play state change listener function or undefined.
|
|
7759
|
+
* @returns - Player instance.
|
|
7760
|
+
*/
|
|
7761
|
+
play(playStateChangeListener) {
|
|
7762
|
+
assertArg2(Utils14.Is.isFunctionOrUndefined(playStateChangeListener), "playStateChangeListener", playStateChangeListener);
|
|
7763
|
+
return new MPlayer(this, playStateChangeListener).play();
|
|
7559
7764
|
}
|
|
7560
7765
|
};
|
|
7766
|
+
/** Object name. */
|
|
7561
7767
|
__publicField(_MDocument, "Name", "Document");
|
|
7562
7768
|
var MDocument2 = _MDocument;
|
|
7563
7769
|
var _MEnding = class _MEnding extends MusicInterface6 {
|
|
@@ -7570,14 +7776,24 @@ var _MEnding = class _MEnding extends MusicInterface6 {
|
|
|
7570
7776
|
getMusicObject() {
|
|
7571
7777
|
return this.obj;
|
|
7572
7778
|
}
|
|
7779
|
+
/**
|
|
7780
|
+
* Get passages.
|
|
7781
|
+
* @returns - Array of passage numbers, e.g. passage number 1 means that this ending is played on first pass.
|
|
7782
|
+
*/
|
|
7573
7783
|
getPassages() {
|
|
7574
7784
|
return this.obj.passages;
|
|
7575
7785
|
}
|
|
7786
|
+
/**
|
|
7787
|
+
* Has passage number?
|
|
7788
|
+
* @param passage - Passage number to find out.
|
|
7789
|
+
* @returns - Boolean whether this ending has asked passage number.
|
|
7790
|
+
*/
|
|
7576
7791
|
hasPassage(passage) {
|
|
7577
7792
|
assertArg2(Utils14.Is.isIntegerGte(passage, 1), "passage", passage);
|
|
7578
7793
|
return this.obj.hasPassage(passage);
|
|
7579
7794
|
}
|
|
7580
7795
|
};
|
|
7796
|
+
/** Object name. */
|
|
7581
7797
|
__publicField(_MEnding, "Name", "Ending");
|
|
7582
7798
|
var MEnding = _MEnding;
|
|
7583
7799
|
var _MFermata = class _MFermata extends MusicInterface6 {
|
|
@@ -7591,6 +7807,7 @@ var _MFermata = class _MFermata extends MusicInterface6 {
|
|
|
7591
7807
|
return this.obj;
|
|
7592
7808
|
}
|
|
7593
7809
|
};
|
|
7810
|
+
/** OBject name. */
|
|
7594
7811
|
__publicField(_MFermata, "Name", "Fermata");
|
|
7595
7812
|
var MFermata = _MFermata;
|
|
7596
7813
|
var _MHeader = class _MHeader extends MusicInterface6 {
|
|
@@ -7603,16 +7820,29 @@ var _MHeader = class _MHeader extends MusicInterface6 {
|
|
|
7603
7820
|
getMusicObject() {
|
|
7604
7821
|
return this.obj;
|
|
7605
7822
|
}
|
|
7823
|
+
/**
|
|
7824
|
+
* Get title.
|
|
7825
|
+
* @returns - Title string or undefined.
|
|
7826
|
+
*/
|
|
7606
7827
|
getTitle() {
|
|
7607
7828
|
return this.obj.title;
|
|
7608
7829
|
}
|
|
7830
|
+
/**
|
|
7831
|
+
* Get composer.
|
|
7832
|
+
* @returns - Composer string or undefined.
|
|
7833
|
+
*/
|
|
7609
7834
|
getComposer() {
|
|
7610
7835
|
return this.obj.composer;
|
|
7611
7836
|
}
|
|
7837
|
+
/**
|
|
7838
|
+
* Get arranger.
|
|
7839
|
+
* @returns - Arranger string or undefined.
|
|
7840
|
+
*/
|
|
7612
7841
|
getArranger() {
|
|
7613
7842
|
return this.obj.arranger;
|
|
7614
7843
|
}
|
|
7615
7844
|
};
|
|
7845
|
+
/** OBject name. */
|
|
7616
7846
|
__publicField(_MHeader, "Name", "Header");
|
|
7617
7847
|
var MHeader = _MHeader;
|
|
7618
7848
|
var _MImage = class _MImage extends MusicInterface6 {
|
|
@@ -7626,6 +7856,7 @@ var _MImage = class _MImage extends MusicInterface6 {
|
|
|
7626
7856
|
return this.obj;
|
|
7627
7857
|
}
|
|
7628
7858
|
};
|
|
7859
|
+
/** Object name. */
|
|
7629
7860
|
__publicField(_MImage, "Name", "Image");
|
|
7630
7861
|
var MImage = _MImage;
|
|
7631
7862
|
var _MMeasure = class _MMeasure extends MusicInterface6 {
|
|
@@ -7638,16 +7869,29 @@ var _MMeasure = class _MMeasure extends MusicInterface6 {
|
|
|
7638
7869
|
getMusicObject() {
|
|
7639
7870
|
return this.obj;
|
|
7640
7871
|
}
|
|
7872
|
+
/**
|
|
7873
|
+
* Get measure number.
|
|
7874
|
+
* @returns - Measure number starting from 1, or 0 if upbeat.
|
|
7875
|
+
*/
|
|
7641
7876
|
getMeasureNumber() {
|
|
7642
7877
|
return this.obj.getMeasureNumber();
|
|
7643
7878
|
}
|
|
7879
|
+
/**
|
|
7880
|
+
* Get rhythm columns.
|
|
7881
|
+
* @returns - Array of rhythm columns.
|
|
7882
|
+
*/
|
|
7644
7883
|
getRhythmColumns() {
|
|
7645
7884
|
return this.obj.getColumns().map((col) => col.getMusicInterface());
|
|
7646
7885
|
}
|
|
7886
|
+
/**
|
|
7887
|
+
* Get score row that this measure is in.
|
|
7888
|
+
* @returns - Score row.
|
|
7889
|
+
*/
|
|
7647
7890
|
getRow() {
|
|
7648
7891
|
return this.obj.row.getMusicInterface();
|
|
7649
7892
|
}
|
|
7650
7893
|
};
|
|
7894
|
+
/** OBject name. */
|
|
7651
7895
|
__publicField(_MMeasure, "Name", "Measure");
|
|
7652
7896
|
var MMeasure = _MMeasure;
|
|
7653
7897
|
var _MBarLineRight = class _MBarLineRight extends MusicInterface6 {
|
|
@@ -7661,6 +7905,7 @@ var _MBarLineRight = class _MBarLineRight extends MusicInterface6 {
|
|
|
7661
7905
|
return this.obj;
|
|
7662
7906
|
}
|
|
7663
7907
|
};
|
|
7908
|
+
/** OBject name. */
|
|
7664
7909
|
__publicField(_MBarLineRight, "Name", "BarLineRight");
|
|
7665
7910
|
var MBarLineRight = _MBarLineRight;
|
|
7666
7911
|
var _MBarLineLeft = class _MBarLineLeft extends MusicInterface6 {
|
|
@@ -7674,6 +7919,7 @@ var _MBarLineLeft = class _MBarLineLeft extends MusicInterface6 {
|
|
|
7674
7919
|
return this.obj;
|
|
7675
7920
|
}
|
|
7676
7921
|
};
|
|
7922
|
+
/** Object name. */
|
|
7677
7923
|
__publicField(_MBarLineLeft, "Name", "BarLineLeft");
|
|
7678
7924
|
var MBarLineLeft = _MBarLineLeft;
|
|
7679
7925
|
var _MStaffTabBarLine = class _MStaffTabBarLine extends MusicInterface6 {
|
|
@@ -7686,6 +7932,10 @@ var _MStaffTabBarLine = class _MStaffTabBarLine extends MusicInterface6 {
|
|
|
7686
7932
|
getMusicObject() {
|
|
7687
7933
|
return this.obj;
|
|
7688
7934
|
}
|
|
7935
|
+
/**
|
|
7936
|
+
* Get parent bar line object.
|
|
7937
|
+
* @returns - Parent bar line object.
|
|
7938
|
+
*/
|
|
7689
7939
|
getBarLine() {
|
|
7690
7940
|
let barLine = this.obj.barLine;
|
|
7691
7941
|
if (barLine instanceof ObjBarLineLeft || barLine instanceof ObjBarLineRight) {
|
|
@@ -7694,10 +7944,15 @@ var _MStaffTabBarLine = class _MStaffTabBarLine extends MusicInterface6 {
|
|
|
7694
7944
|
throw new MusicError19(MusicErrorType19.Score, `Bar line not let nor right.`);
|
|
7695
7945
|
}
|
|
7696
7946
|
}
|
|
7947
|
+
/**
|
|
7948
|
+
* Get staff or tab this bar lien object is in.
|
|
7949
|
+
* @returns - Staff or tab.
|
|
7950
|
+
*/
|
|
7697
7951
|
getNotationLine() {
|
|
7698
7952
|
return getNotationLine(this.obj.line);
|
|
7699
7953
|
}
|
|
7700
7954
|
};
|
|
7955
|
+
/** Object name. */
|
|
7701
7956
|
__publicField(_MStaffTabBarLine, "Name", "StaffTabBarLine");
|
|
7702
7957
|
var MStaffTabBarLine = _MStaffTabBarLine;
|
|
7703
7958
|
var _MNoteGroup = class _MNoteGroup extends MusicInterface6 {
|
|
@@ -7710,19 +7965,36 @@ var _MNoteGroup = class _MNoteGroup extends MusicInterface6 {
|
|
|
7710
7965
|
getMusicObject() {
|
|
7711
7966
|
return this.obj;
|
|
7712
7967
|
}
|
|
7968
|
+
/**
|
|
7969
|
+
* Get notes of this note group.
|
|
7970
|
+
* @returns - Array of Note instances.
|
|
7971
|
+
*/
|
|
7713
7972
|
getNotes() {
|
|
7714
7973
|
return this.obj.notes;
|
|
7715
7974
|
}
|
|
7975
|
+
/**
|
|
7976
|
+
* Get rhythm props of this note group.
|
|
7977
|
+
* @returns - Rhythm props.
|
|
7978
|
+
*/
|
|
7716
7979
|
getRhythmProps() {
|
|
7717
7980
|
return this.obj.rhythmProps;
|
|
7718
7981
|
}
|
|
7982
|
+
/**
|
|
7983
|
+
* Get rhythm column this note group is in.
|
|
7984
|
+
* @returns - Rhythm column.
|
|
7985
|
+
*/
|
|
7719
7986
|
getRhythmColumn() {
|
|
7720
7987
|
return this.obj.col.getMusicInterface();
|
|
7721
7988
|
}
|
|
7989
|
+
/**
|
|
7990
|
+
* Get the measure this note group is in.
|
|
7991
|
+
* @returns - Measure.
|
|
7992
|
+
*/
|
|
7722
7993
|
getMeasure() {
|
|
7723
7994
|
return this.obj.measure.getMusicInterface();
|
|
7724
7995
|
}
|
|
7725
7996
|
};
|
|
7997
|
+
/** Object name. */
|
|
7726
7998
|
__publicField(_MNoteGroup, "Name", "NoteGroup");
|
|
7727
7999
|
var MNoteGroup = _MNoteGroup;
|
|
7728
8000
|
var _MStaffNoteGroup = class _MStaffNoteGroup extends MusicInterface6 {
|
|
@@ -7735,19 +8007,36 @@ var _MStaffNoteGroup = class _MStaffNoteGroup extends MusicInterface6 {
|
|
|
7735
8007
|
getMusicObject() {
|
|
7736
8008
|
return this.obj;
|
|
7737
8009
|
}
|
|
8010
|
+
/**
|
|
8011
|
+
* Get parent note group.
|
|
8012
|
+
* @returns - Parent note group.
|
|
8013
|
+
*/
|
|
7738
8014
|
getNoteGroup() {
|
|
7739
8015
|
return this.obj.noteGroup.getMusicInterface();
|
|
7740
8016
|
}
|
|
8017
|
+
/**
|
|
8018
|
+
* Get rhythm column this note group is in.
|
|
8019
|
+
* @returns - Rhythm column.
|
|
8020
|
+
*/
|
|
7741
8021
|
getRhythmColumn() {
|
|
7742
8022
|
return this.getNoteGroup().getRhythmColumn();
|
|
7743
8023
|
}
|
|
8024
|
+
/**
|
|
8025
|
+
* Get the measure this note group is in.
|
|
8026
|
+
* @returns - Measure.
|
|
8027
|
+
*/
|
|
7744
8028
|
getMeasure() {
|
|
7745
8029
|
return this.getNoteGroup().getMeasure();
|
|
7746
8030
|
}
|
|
8031
|
+
/**
|
|
8032
|
+
* Get staff notation line this note group is in.
|
|
8033
|
+
* @returns - Staff object.
|
|
8034
|
+
*/
|
|
7747
8035
|
getStaff() {
|
|
7748
8036
|
return this.obj.staff.getMusicInterface();
|
|
7749
8037
|
}
|
|
7750
8038
|
};
|
|
8039
|
+
/** Object name. */
|
|
7751
8040
|
__publicField(_MStaffNoteGroup, "Name", "StaffNoteGroup");
|
|
7752
8041
|
var MStaffNoteGroup = _MStaffNoteGroup;
|
|
7753
8042
|
var _MTabNoteGroup = class _MTabNoteGroup extends MusicInterface6 {
|
|
@@ -7760,19 +8049,36 @@ var _MTabNoteGroup = class _MTabNoteGroup extends MusicInterface6 {
|
|
|
7760
8049
|
getMusicObject() {
|
|
7761
8050
|
return this.obj;
|
|
7762
8051
|
}
|
|
8052
|
+
/**
|
|
8053
|
+
* Get parent note group.
|
|
8054
|
+
* @returns - Parent note group.
|
|
8055
|
+
*/
|
|
7763
8056
|
getNoteGroup() {
|
|
7764
8057
|
return this.obj.noteGroup.getMusicInterface();
|
|
7765
8058
|
}
|
|
8059
|
+
/**
|
|
8060
|
+
* Get rhythm column this note group is in.
|
|
8061
|
+
* @returns - Rhythm column.
|
|
8062
|
+
*/
|
|
7766
8063
|
getRhythmColumn() {
|
|
7767
8064
|
return this.getNoteGroup().getRhythmColumn();
|
|
7768
8065
|
}
|
|
8066
|
+
/**
|
|
8067
|
+
* Get the measure this note group is in.
|
|
8068
|
+
* @returns - Measure.
|
|
8069
|
+
*/
|
|
7769
8070
|
getMeasure() {
|
|
7770
8071
|
return this.getNoteGroup().getMeasure();
|
|
7771
8072
|
}
|
|
8073
|
+
/**
|
|
8074
|
+
* Get guitar tab this note group is in.
|
|
8075
|
+
* @returns - Tab object.
|
|
8076
|
+
*/
|
|
7772
8077
|
getTab() {
|
|
7773
8078
|
return this.obj.tab.getMusicInterface();
|
|
7774
8079
|
}
|
|
7775
8080
|
};
|
|
8081
|
+
/** OBject name. */
|
|
7776
8082
|
__publicField(_MTabNoteGroup, "Name", "TabNoteGroup");
|
|
7777
8083
|
var MTabNoteGroup = _MTabNoteGroup;
|
|
7778
8084
|
var _MRest = class _MRest extends MusicInterface6 {
|
|
@@ -7785,16 +8091,29 @@ var _MRest = class _MRest extends MusicInterface6 {
|
|
|
7785
8091
|
getMusicObject() {
|
|
7786
8092
|
return this.obj;
|
|
7787
8093
|
}
|
|
8094
|
+
/**
|
|
8095
|
+
* Get rhythm props of this rest.
|
|
8096
|
+
* @returns - Rhythm props.
|
|
8097
|
+
*/
|
|
7788
8098
|
getRhythmProps() {
|
|
7789
8099
|
return this.obj.rhythmProps;
|
|
7790
8100
|
}
|
|
8101
|
+
/**
|
|
8102
|
+
* Get rhythm column this rest is in.
|
|
8103
|
+
* @returns - Rhythm column.
|
|
8104
|
+
*/
|
|
7791
8105
|
getRhythmColumn() {
|
|
7792
8106
|
return this.obj.col.getMusicInterface();
|
|
7793
8107
|
}
|
|
8108
|
+
/**
|
|
8109
|
+
* Get the measure this rest is in.
|
|
8110
|
+
* @returns - Measure.
|
|
8111
|
+
*/
|
|
7794
8112
|
getMeasure() {
|
|
7795
8113
|
return this.obj.measure.getMusicInterface();
|
|
7796
8114
|
}
|
|
7797
8115
|
};
|
|
8116
|
+
/** OBject name. */
|
|
7798
8117
|
__publicField(_MRest, "Name", "Rest");
|
|
7799
8118
|
var MRest = _MRest;
|
|
7800
8119
|
var _MStaffRest = class _MStaffRest extends MusicInterface6 {
|
|
@@ -7807,19 +8126,36 @@ var _MStaffRest = class _MStaffRest extends MusicInterface6 {
|
|
|
7807
8126
|
getMusicObject() {
|
|
7808
8127
|
return this.obj;
|
|
7809
8128
|
}
|
|
8129
|
+
/**
|
|
8130
|
+
* Get parent rest object.
|
|
8131
|
+
* @returns - Parent rest object.
|
|
8132
|
+
*/
|
|
7810
8133
|
getRest() {
|
|
7811
8134
|
return this.obj.rest.getMusicInterface();
|
|
7812
8135
|
}
|
|
8136
|
+
/**
|
|
8137
|
+
* Get rhythm column this rest is in.
|
|
8138
|
+
* @returns - Rhythm column.
|
|
8139
|
+
*/
|
|
7813
8140
|
getRhythmColumn() {
|
|
7814
8141
|
return this.getRest().getRhythmColumn();
|
|
7815
8142
|
}
|
|
8143
|
+
/**
|
|
8144
|
+
* Get the measure this rest is in.
|
|
8145
|
+
* @returns - Measure.
|
|
8146
|
+
*/
|
|
7816
8147
|
getMeasure() {
|
|
7817
8148
|
return this.getRest().getMeasure();
|
|
7818
8149
|
}
|
|
8150
|
+
/**
|
|
8151
|
+
* Get staff notation line this rest is in.
|
|
8152
|
+
* @returns - Staff object.
|
|
8153
|
+
*/
|
|
7819
8154
|
getStaff() {
|
|
7820
8155
|
return this.obj.staff.getMusicInterface();
|
|
7821
8156
|
}
|
|
7822
8157
|
};
|
|
8158
|
+
/** Object name. */
|
|
7823
8159
|
__publicField(_MStaffRest, "Name", "StaffRest");
|
|
7824
8160
|
var MStaffRest = _MStaffRest;
|
|
7825
8161
|
var _MRhythmColumn = class _MRhythmColumn extends MusicInterface6 {
|
|
@@ -7832,19 +8168,36 @@ var _MRhythmColumn = class _MRhythmColumn extends MusicInterface6 {
|
|
|
7832
8168
|
getMusicObject() {
|
|
7833
8169
|
return this.obj;
|
|
7834
8170
|
}
|
|
8171
|
+
/**
|
|
8172
|
+
* Get symbol (note group or rest) of this column for given voice id.
|
|
8173
|
+
* @param voiceId - Voice id.
|
|
8174
|
+
* @returns - Note group, rest or undefined.
|
|
8175
|
+
*/
|
|
7835
8176
|
getRhythmSymbol(voiceId) {
|
|
7836
8177
|
var _a;
|
|
7837
8178
|
assertArg2(isVoiceId2(voiceId), "voiceId", voiceId);
|
|
7838
8179
|
return (_a = this.obj.getVoiceSymbol(voiceId)) == null ? void 0 : _a.getMusicInterface();
|
|
7839
8180
|
}
|
|
8181
|
+
/**
|
|
8182
|
+
* Get symbol (note group or rest) of this column for given voice id.
|
|
8183
|
+
* @deprecated - Use getRhythmSymbol(voiceId) instead.
|
|
8184
|
+
* @param voiceId - Voice id.
|
|
8185
|
+
* @returns - Note group, rest or undefined.
|
|
8186
|
+
*/
|
|
8187
|
+
getVoiceSymbol(voiceId) {
|
|
8188
|
+
var _a;
|
|
8189
|
+
assertArg2(isVoiceId2(voiceId), "voiceId", voiceId);
|
|
8190
|
+
return (_a = this.obj.getVoiceSymbol(voiceId)) == null ? void 0 : _a.getMusicInterface();
|
|
8191
|
+
}
|
|
8192
|
+
/**
|
|
8193
|
+
* Get the measure this rhythm column is in.
|
|
8194
|
+
* @returns - Measure.
|
|
8195
|
+
*/
|
|
7840
8196
|
getMeasure() {
|
|
7841
8197
|
return this.obj.measure.getMusicInterface();
|
|
7842
8198
|
}
|
|
7843
|
-
getVoiceSymbol(voiceId) {
|
|
7844
|
-
let s = this.obj.getVoiceSymbol(voiceId);
|
|
7845
|
-
return s instanceof ObjNoteGroup || s instanceof ObjRest ? s.getMusicInterface() : void 0;
|
|
7846
|
-
}
|
|
7847
8199
|
};
|
|
8200
|
+
/** OBject name. */
|
|
7848
8201
|
__publicField(_MRhythmColumn, "Name", "RhythmColumn");
|
|
7849
8202
|
var MRhythmColumn = _MRhythmColumn;
|
|
7850
8203
|
var _MScoreRow = class _MScoreRow extends MusicInterface6 {
|
|
@@ -7857,16 +8210,29 @@ var _MScoreRow = class _MScoreRow extends MusicInterface6 {
|
|
|
7857
8210
|
getMusicObject() {
|
|
7858
8211
|
return this.obj;
|
|
7859
8212
|
}
|
|
8213
|
+
/**
|
|
8214
|
+
* Parent music document.
|
|
8215
|
+
* @returns - Parent music document.
|
|
8216
|
+
*/
|
|
7860
8217
|
getDocument() {
|
|
7861
8218
|
return this.obj.doc.getMusicInterface();
|
|
7862
8219
|
}
|
|
8220
|
+
/**
|
|
8221
|
+
* Get measures of this score row.
|
|
8222
|
+
* @returns - Array of measures.
|
|
8223
|
+
*/
|
|
7863
8224
|
getMeasures() {
|
|
7864
8225
|
return this.obj.getMeasures().map((m) => m.getMusicInterface());
|
|
7865
8226
|
}
|
|
8227
|
+
/**
|
|
8228
|
+
* Get notation lines (staves and tabs) of this score row.
|
|
8229
|
+
* @returns - Array of staves and tabs.
|
|
8230
|
+
*/
|
|
7866
8231
|
getNotationLines() {
|
|
7867
8232
|
return this.obj.getNotationLines().map((line) => getNotationLine(line));
|
|
7868
8233
|
}
|
|
7869
8234
|
};
|
|
8235
|
+
/** Object name. */
|
|
7870
8236
|
__publicField(_MScoreRow, "Name", "ScoreRow");
|
|
7871
8237
|
var MScoreRow = _MScoreRow;
|
|
7872
8238
|
var _MStaff = class _MStaff extends MusicInterface6 {
|
|
@@ -7879,16 +8245,29 @@ var _MStaff = class _MStaff extends MusicInterface6 {
|
|
|
7879
8245
|
getMusicObject() {
|
|
7880
8246
|
return this.obj;
|
|
7881
8247
|
}
|
|
8248
|
+
/**
|
|
8249
|
+
* Get index of this staff in score row.
|
|
8250
|
+
* @returns - Index (0=top notation line).
|
|
8251
|
+
*/
|
|
7882
8252
|
getId() {
|
|
7883
8253
|
return this.obj.id;
|
|
7884
8254
|
}
|
|
8255
|
+
/**
|
|
8256
|
+
* Get name of this staff.
|
|
8257
|
+
* @returns - Staff name.
|
|
8258
|
+
*/
|
|
7885
8259
|
getName() {
|
|
7886
8260
|
return this.obj.name.length > 0 ? this.obj.name : void 0;
|
|
7887
8261
|
}
|
|
8262
|
+
/**
|
|
8263
|
+
* Get the score row this staff is in.
|
|
8264
|
+
* @returns - Score row.
|
|
8265
|
+
*/
|
|
7888
8266
|
getRow() {
|
|
7889
8267
|
return this.obj.row.getMusicInterface();
|
|
7890
8268
|
}
|
|
7891
8269
|
};
|
|
8270
|
+
/** Object name. */
|
|
7892
8271
|
__publicField(_MStaff, "Name", "Staff");
|
|
7893
8272
|
var MStaff = _MStaff;
|
|
7894
8273
|
var _MTab = class _MTab extends MusicInterface6 {
|
|
@@ -7901,16 +8280,29 @@ var _MTab = class _MTab extends MusicInterface6 {
|
|
|
7901
8280
|
getMusicObject() {
|
|
7902
8281
|
return this.obj;
|
|
7903
8282
|
}
|
|
8283
|
+
/**
|
|
8284
|
+
* Get index of this guitar tab in score row.
|
|
8285
|
+
* @returns - Index (0=top notation line).
|
|
8286
|
+
*/
|
|
7904
8287
|
getId() {
|
|
7905
8288
|
return this.obj.id;
|
|
7906
8289
|
}
|
|
8290
|
+
/**
|
|
8291
|
+
* Get name of this guitar tab.
|
|
8292
|
+
* @returns - Staff name.
|
|
8293
|
+
*/
|
|
7907
8294
|
getName() {
|
|
7908
8295
|
return this.obj.name.length > 0 ? this.obj.name : void 0;
|
|
7909
8296
|
}
|
|
8297
|
+
/**
|
|
8298
|
+
* Get the score row this guitar tab is in.
|
|
8299
|
+
* @returns - Score row.
|
|
8300
|
+
*/
|
|
7910
8301
|
getRow() {
|
|
7911
8302
|
return this.obj.row.getMusicInterface();
|
|
7912
8303
|
}
|
|
7913
8304
|
};
|
|
8305
|
+
/** Object name. */
|
|
7914
8306
|
__publicField(_MTab, "Name", "Tab");
|
|
7915
8307
|
var MTab = _MTab;
|
|
7916
8308
|
var _MSignature = class _MSignature extends MusicInterface6 {
|
|
@@ -7923,10 +8315,15 @@ var _MSignature = class _MSignature extends MusicInterface6 {
|
|
|
7923
8315
|
getMusicObject() {
|
|
7924
8316
|
return this.obj;
|
|
7925
8317
|
}
|
|
8318
|
+
/**
|
|
8319
|
+
* Get staff notation line this signature is in.
|
|
8320
|
+
* @returns - Staff object.
|
|
8321
|
+
*/
|
|
7926
8322
|
getStaff() {
|
|
7927
8323
|
return this.obj.staff.getMusicInterface();
|
|
7928
8324
|
}
|
|
7929
8325
|
};
|
|
8326
|
+
/** Object name. */
|
|
7930
8327
|
__publicField(_MSignature, "Name", "Signature");
|
|
7931
8328
|
var MSignature = _MSignature;
|
|
7932
8329
|
var _MSpecialText = class _MSpecialText extends MusicInterface6 {
|
|
@@ -7939,10 +8336,15 @@ var _MSpecialText = class _MSpecialText extends MusicInterface6 {
|
|
|
7939
8336
|
getMusicObject() {
|
|
7940
8337
|
return this.obj;
|
|
7941
8338
|
}
|
|
8339
|
+
/**
|
|
8340
|
+
* Get text content.
|
|
8341
|
+
* @returns - Text content.
|
|
8342
|
+
*/
|
|
7942
8343
|
getText() {
|
|
7943
8344
|
return this.obj.getText();
|
|
7944
8345
|
}
|
|
7945
8346
|
};
|
|
8347
|
+
/** Object name. */
|
|
7946
8348
|
__publicField(_MSpecialText, "Name", "SpecialText");
|
|
7947
8349
|
var MSpecialText = _MSpecialText;
|
|
7948
8350
|
var _MText = class _MText extends MusicInterface6 {
|
|
@@ -7955,10 +8357,15 @@ var _MText = class _MText extends MusicInterface6 {
|
|
|
7955
8357
|
getMusicObject() {
|
|
7956
8358
|
return this.obj;
|
|
7957
8359
|
}
|
|
8360
|
+
/**
|
|
8361
|
+
* Get text content.
|
|
8362
|
+
* @returns - Text content.
|
|
8363
|
+
*/
|
|
7958
8364
|
getText() {
|
|
7959
8365
|
return this.obj.getText();
|
|
7960
8366
|
}
|
|
7961
8367
|
};
|
|
8368
|
+
/** Object name. */
|
|
7962
8369
|
__publicField(_MText, "Name", "Text");
|
|
7963
8370
|
var MText = _MText;
|
|
7964
8371
|
var _MExtensionLine = class _MExtensionLine extends MusicInterface6 {
|
|
@@ -7972,33 +8379,69 @@ var _MExtensionLine = class _MExtensionLine extends MusicInterface6 {
|
|
|
7972
8379
|
return this.obj;
|
|
7973
8380
|
}
|
|
7974
8381
|
};
|
|
8382
|
+
/** OBject name. */
|
|
7975
8383
|
__publicField(_MExtensionLine, "Name", "ExtensionLine");
|
|
7976
8384
|
var MExtensionLine = _MExtensionLine;
|
|
8385
|
+
|
|
8386
|
+
// src/score/pub/music-interface.ts
|
|
8387
|
+
import { MusicError as MusicError20, MusicErrorType as MusicErrorType20 } from "@tspro/web-music-score/core";
|
|
8388
|
+
function assertArg3(condition, argName, argValue) {
|
|
8389
|
+
if (!condition) {
|
|
8390
|
+
throw new MusicError20(MusicErrorType20.Score, `Invalid arg: ${argName} = ${argValue}`);
|
|
8391
|
+
}
|
|
8392
|
+
}
|
|
8393
|
+
function require_t(t, message) {
|
|
8394
|
+
if (t === void 0 || t === null) {
|
|
8395
|
+
throw new TypeError(message);
|
|
8396
|
+
} else {
|
|
8397
|
+
return t;
|
|
8398
|
+
}
|
|
8399
|
+
}
|
|
7977
8400
|
var _MPlayer = class _MPlayer {
|
|
7978
|
-
|
|
8401
|
+
/**
|
|
8402
|
+
* Create new music player.
|
|
8403
|
+
* @param doc - Music document to play.
|
|
8404
|
+
* @param playStateChangeListener - Play state change listener.
|
|
8405
|
+
*/
|
|
8406
|
+
constructor(doc, playStateChangeListener) {
|
|
7979
8407
|
__publicField(this, "player");
|
|
7980
|
-
|
|
7981
|
-
|
|
8408
|
+
assertArg3(doc instanceof MDocument2, "doc", doc);
|
|
8409
|
+
assertArg3(Utils15.Is.isFunctionOrUndefined(playStateChangeListener), "playStateChangeListener", playStateChangeListener);
|
|
7982
8410
|
this.player = new Player();
|
|
7983
8411
|
this.player.setDocument(doc.getMusicObject());
|
|
7984
8412
|
this.player.setCursorPositionChangeListener((cursorRect) => doc.getMusicObject().updateCursorRect(cursorRect));
|
|
7985
|
-
if (
|
|
7986
|
-
this.player.setPlayStateChnageListener(
|
|
8413
|
+
if (playStateChangeListener) {
|
|
8414
|
+
this.player.setPlayStateChnageListener(playStateChangeListener);
|
|
7987
8415
|
}
|
|
7988
8416
|
}
|
|
8417
|
+
/**
|
|
8418
|
+
* Stop all playing.
|
|
8419
|
+
*/
|
|
7989
8420
|
static stopAll() {
|
|
7990
8421
|
this.currentlyPlaying.forEach((p) => p.stop());
|
|
7991
8422
|
Audio2.stop();
|
|
7992
8423
|
}
|
|
8424
|
+
/**
|
|
8425
|
+
* Playe attached document.
|
|
8426
|
+
* @returns - This player instance.
|
|
8427
|
+
*/
|
|
7993
8428
|
play() {
|
|
7994
8429
|
_MPlayer.currentlyPlaying.add(this);
|
|
7995
8430
|
this.player.play();
|
|
7996
8431
|
return this;
|
|
7997
8432
|
}
|
|
8433
|
+
/**
|
|
8434
|
+
* Pause playback of attached document.
|
|
8435
|
+
* @returns - This player instance.
|
|
8436
|
+
*/
|
|
7998
8437
|
pause() {
|
|
7999
8438
|
this.player.pause();
|
|
8000
8439
|
return this;
|
|
8001
8440
|
}
|
|
8441
|
+
/**
|
|
8442
|
+
* Stop playback of attached document.
|
|
8443
|
+
* @returns - This player instance.
|
|
8444
|
+
*/
|
|
8002
8445
|
stop() {
|
|
8003
8446
|
this.player.stop();
|
|
8004
8447
|
_MPlayer.currentlyPlaying.delete(this);
|
|
@@ -8008,33 +8451,61 @@ var _MPlayer = class _MPlayer {
|
|
|
8008
8451
|
__publicField(_MPlayer, "currentlyPlaying", /* @__PURE__ */ new Set());
|
|
8009
8452
|
var MPlayer = _MPlayer;
|
|
8010
8453
|
var MRenderer2 = class {
|
|
8454
|
+
/**
|
|
8455
|
+
* Create new renderer instance.
|
|
8456
|
+
*/
|
|
8011
8457
|
constructor() {
|
|
8012
8458
|
__publicField(this, "renderer");
|
|
8013
8459
|
this.renderer = new Renderer(this);
|
|
8014
8460
|
}
|
|
8461
|
+
/**
|
|
8462
|
+
* Attach music document to this renderer.
|
|
8463
|
+
* @param doc - Music document.
|
|
8464
|
+
* @returns - This renderer instance.
|
|
8465
|
+
*/
|
|
8015
8466
|
setDocument(doc) {
|
|
8016
|
-
|
|
8467
|
+
assertArg3(Utils15.Is.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
|
|
8017
8468
|
this.renderer.setDocument(doc);
|
|
8018
8469
|
return this;
|
|
8019
8470
|
}
|
|
8471
|
+
/**
|
|
8472
|
+
* Set target canvas html element for this renderer.
|
|
8473
|
+
* @param canvas - HTML canvas element or element id.
|
|
8474
|
+
* @returns - This renderer instance.
|
|
8475
|
+
*/
|
|
8020
8476
|
setCanvas(canvas) {
|
|
8021
|
-
canvas = require_t(
|
|
8477
|
+
canvas = require_t(Utils15.Dom.getCanvas(canvas), typeof canvas === "string" ? "Cannot set renderer canvas because invalid canvas id: " + canvas : "Cannot set renderer canvas because given canvas is undefined.");
|
|
8022
8478
|
this.renderer.setCanvas(canvas);
|
|
8023
8479
|
return this;
|
|
8024
8480
|
}
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8481
|
+
/**
|
|
8482
|
+
* Set score event listener.
|
|
8483
|
+
* @param scoreEventListener - Score event listener.
|
|
8484
|
+
*/
|
|
8485
|
+
setScoreEventListener(scoreEventListener) {
|
|
8486
|
+
assertArg3(Utils15.Is.isFunctionOrUndefined(scoreEventListener), "scoreEventListener", scoreEventListener);
|
|
8487
|
+
this.renderer.setScoreEventListener(scoreEventListener);
|
|
8028
8488
|
}
|
|
8489
|
+
/**
|
|
8490
|
+
* Draw given music object hilighted.
|
|
8491
|
+
* @param obj - Music object or undefined to remove hilighting.
|
|
8492
|
+
*/
|
|
8029
8493
|
hilightObject(obj) {
|
|
8030
8494
|
this.renderer.hilightObject(obj == null ? void 0 : obj.getMusicObject());
|
|
8031
8495
|
}
|
|
8496
|
+
/**
|
|
8497
|
+
* Draw given staff position hilighted.
|
|
8498
|
+
* @param staffPos - Staff position (score row and diatonic id) or undefined to remove hilighting.
|
|
8499
|
+
*/
|
|
8032
8500
|
hilightStaffPos(staffPos) {
|
|
8033
8501
|
this.renderer.hilightStaffPos(staffPos ? {
|
|
8034
8502
|
scoreRow: staffPos.scoreRow.getMusicObject(),
|
|
8035
8503
|
diatonicId: staffPos.diatonicId
|
|
8036
8504
|
} : void 0);
|
|
8037
8505
|
}
|
|
8506
|
+
/**
|
|
8507
|
+
* Draw contents of attached music document to attached canvas.
|
|
8508
|
+
*/
|
|
8038
8509
|
draw() {
|
|
8039
8510
|
try {
|
|
8040
8511
|
this.renderer.draw();
|
|
@@ -8045,6 +8516,9 @@ var MRenderer2 = class {
|
|
|
8045
8516
|
}
|
|
8046
8517
|
};
|
|
8047
8518
|
var _MPlaybackButtons = class _MPlaybackButtons {
|
|
8519
|
+
/**
|
|
8520
|
+
* Create new playback buttons helper class instance.
|
|
8521
|
+
*/
|
|
8048
8522
|
constructor() {
|
|
8049
8523
|
__publicField(this, "playButton");
|
|
8050
8524
|
__publicField(this, "stopButton");
|
|
@@ -8077,8 +8551,13 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
8077
8551
|
};
|
|
8078
8552
|
this.updateButtons();
|
|
8079
8553
|
}
|
|
8554
|
+
/**
|
|
8555
|
+
* Attach music document whose playcak will be controlled by this playback buttons helper class instance.
|
|
8556
|
+
* @param doc - Music document.
|
|
8557
|
+
* @returns
|
|
8558
|
+
*/
|
|
8080
8559
|
setDocument(doc) {
|
|
8081
|
-
|
|
8560
|
+
assertArg3(Utils15.Is.isUndefined(doc) || doc instanceof MDocument2, "doc", doc);
|
|
8082
8561
|
this.onStop();
|
|
8083
8562
|
if (doc) {
|
|
8084
8563
|
this.player = new MPlayer(doc, (playState) => {
|
|
@@ -8091,6 +8570,9 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
8091
8570
|
this.updateButtons();
|
|
8092
8571
|
return this;
|
|
8093
8572
|
}
|
|
8573
|
+
/**
|
|
8574
|
+
* Detach attached music document.
|
|
8575
|
+
*/
|
|
8094
8576
|
detachDocument() {
|
|
8095
8577
|
this.setDocument(void 0);
|
|
8096
8578
|
}
|
|
@@ -8112,31 +8594,50 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
8112
8594
|
this.pauseButton.innerText = this.pauseLabel;
|
|
8113
8595
|
}
|
|
8114
8596
|
}
|
|
8597
|
+
/**
|
|
8598
|
+
* Set play button.
|
|
8599
|
+
* @param btn - HTML button element or element id.
|
|
8600
|
+
* @param btnLabel - Custom button label (e.g. "Play").
|
|
8601
|
+
* @returns - This playback buttons class instance.
|
|
8602
|
+
*/
|
|
8115
8603
|
setPlayButton(btn, btnLabel) {
|
|
8116
|
-
|
|
8604
|
+
assertArg3(Utils15.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
|
|
8117
8605
|
_MPlaybackButtons.removeOnClickListeners(this.playButton, this.onPlay);
|
|
8118
|
-
this.playButton = require_t(
|
|
8606
|
+
this.playButton = require_t(Utils15.Dom.getButton(btn), "Play button required!");
|
|
8119
8607
|
this.playLabel = btnLabel != null ? btnLabel : "Play";
|
|
8120
8608
|
_MPlaybackButtons.removeOnClickListeners(this.playButton, "all");
|
|
8121
8609
|
_MPlaybackButtons.addOnClickListener(this.playButton, this.onPlay);
|
|
8122
8610
|
this.updateButtons();
|
|
8123
8611
|
return this;
|
|
8124
8612
|
}
|
|
8613
|
+
/**
|
|
8614
|
+
* Set stop button.
|
|
8615
|
+
* @param btn - HTML button element or element id.
|
|
8616
|
+
* @param btnLabel - Custom button label (e.g. "Stop").
|
|
8617
|
+
* @returns - This playback buttons class instance.
|
|
8618
|
+
*/
|
|
8125
8619
|
setStopButton(btn, btnLabel) {
|
|
8126
|
-
|
|
8620
|
+
assertArg3(Utils15.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
|
|
8127
8621
|
_MPlaybackButtons.removeOnClickListeners(this.stopButton, this.onStop);
|
|
8128
|
-
this.stopButton = require_t(
|
|
8622
|
+
this.stopButton = require_t(Utils15.Dom.getButton(btn), "Stop button required!");
|
|
8129
8623
|
this.stopLabel = btnLabel != null ? btnLabel : "Stop";
|
|
8130
8624
|
_MPlaybackButtons.removeOnClickListeners(this.stopButton, "all");
|
|
8131
8625
|
_MPlaybackButtons.addOnClickListener(this.stopButton, this.onStop);
|
|
8132
8626
|
this.updateButtons();
|
|
8133
8627
|
return this;
|
|
8134
8628
|
}
|
|
8629
|
+
/**
|
|
8630
|
+
* Set play/stop button.
|
|
8631
|
+
* @param btn - HTML button element or element id.
|
|
8632
|
+
* @param playLabel - Custom button label for play action (e.g. "Play").
|
|
8633
|
+
* @param stopLabel - Custom button label for stop action (e.g. "Stop").
|
|
8634
|
+
* @returns - This playback buttons class instance.
|
|
8635
|
+
*/
|
|
8135
8636
|
setPlayStopButton(btn, playLabel, stopLabel) {
|
|
8136
|
-
|
|
8137
|
-
|
|
8637
|
+
assertArg3(Utils15.Is.isStringOrUndefined(playLabel), "playLabel", playLabel);
|
|
8638
|
+
assertArg3(Utils15.Is.isStringOrUndefined(stopLabel), "stopLabel", stopLabel);
|
|
8138
8639
|
_MPlaybackButtons.removeOnClickListeners(this.playStopButton, this.onPlayStop);
|
|
8139
|
-
this.playStopButton = require_t(
|
|
8640
|
+
this.playStopButton = require_t(Utils15.Dom.getButton(btn), "Play/stop button required!");
|
|
8140
8641
|
this.playLabel = playLabel != null ? playLabel : "Play";
|
|
8141
8642
|
this.stopLabel = stopLabel != null ? stopLabel : "Stop";
|
|
8142
8643
|
_MPlaybackButtons.removeOnClickListeners(this.playStopButton, "all");
|
|
@@ -8144,10 +8645,16 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
8144
8645
|
this.updateButtons();
|
|
8145
8646
|
return this;
|
|
8146
8647
|
}
|
|
8648
|
+
/**
|
|
8649
|
+
* Set pause button.
|
|
8650
|
+
* @param btn - HTML button element or element id.
|
|
8651
|
+
* @param btnLabel - Custom button label (e.g. "Pause").
|
|
8652
|
+
* @returns - This playback buttons class instance.
|
|
8653
|
+
*/
|
|
8147
8654
|
setPauseButton(btn, btnLabel) {
|
|
8148
|
-
|
|
8655
|
+
assertArg3(Utils15.Is.isStringOrUndefined(btnLabel), "btnLabel", btnLabel);
|
|
8149
8656
|
_MPlaybackButtons.removeOnClickListeners(this.pauseButton, this.onPause);
|
|
8150
|
-
this.pauseButton = require_t(
|
|
8657
|
+
this.pauseButton = require_t(Utils15.Dom.getButton(btn), "Pause button required!");
|
|
8151
8658
|
this.pauseLabel = btnLabel != null ? btnLabel : "Pause";
|
|
8152
8659
|
_MPlaybackButtons.removeOnClickListeners(this.pauseButton, "all");
|
|
8153
8660
|
_MPlaybackButtons.addOnClickListener(this.pauseButton, this.onPause);
|
|
@@ -8169,7 +8676,7 @@ var _MPlaybackButtons = class _MPlaybackButtons {
|
|
|
8169
8676
|
}
|
|
8170
8677
|
}
|
|
8171
8678
|
static addOnClickListener(btn, onClick) {
|
|
8172
|
-
|
|
8679
|
+
assertArg3(Utils15.Is.isFunction(onClick), "onClick", onClick);
|
|
8173
8680
|
btn.addEventListener("click", onClick);
|
|
8174
8681
|
let clickListeners = this.savedOnClickListeners.get(btn) || [];
|
|
8175
8682
|
this.savedOnClickListeners.set(btn, [...clickListeners, onClick]);
|
|
@@ -8188,6 +8695,7 @@ export {
|
|
|
8188
8695
|
Connective,
|
|
8189
8696
|
DivRect,
|
|
8190
8697
|
DocumentBuilder,
|
|
8698
|
+
DynamicsAnnotation,
|
|
8191
8699
|
Fermata,
|
|
8192
8700
|
Label,
|
|
8193
8701
|
MAccidental,
|
|
@@ -8229,6 +8737,7 @@ export {
|
|
|
8229
8737
|
ScoreStaffPosEvent,
|
|
8230
8738
|
StaffPreset,
|
|
8231
8739
|
Stem,
|
|
8740
|
+
TempoAnnotation,
|
|
8232
8741
|
TieType,
|
|
8233
8742
|
VerticalPosition,
|
|
8234
8743
|
getStringNumbers,
|