@tspro/web-music-score 4.0.1 → 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 +7 -0
- package/README.md +17 -8
- package/dist/audio/index.js +1 -1
- package/dist/audio/index.mjs +2 -2
- package/dist/audio-cg/index.js +1 -1
- package/dist/audio-cg/index.mjs +2 -2
- package/dist/{chunk-YFPLOHP2.mjs → chunk-MHNTJ6FU.mjs} +2 -2
- package/dist/core/index.js +2 -2
- package/dist/core/index.mjs +3 -3
- package/dist/iife/index.global.js +11 -11
- package/dist/{music-objects-DJQ4d2OA.d.mts → music-objects-DIaqNPjs.d.mts} +68 -62
- package/dist/{music-objects-Dc3kR-XF.d.ts → music-objects-xJJNlFwK.d.ts} +68 -62
- package/dist/pieces/index.d.mts +2 -2
- package/dist/pieces/index.d.ts +2 -2
- package/dist/pieces/index.js +2 -2
- package/dist/pieces/index.mjs +3 -3
- package/dist/react-ui/index.d.mts +3 -3
- package/dist/react-ui/index.d.ts +3 -3
- package/dist/react-ui/index.js +1 -1
- package/dist/react-ui/index.mjs +2 -2
- package/dist/{scale-B2Icbetz.d.ts → scale-DQNA-YLD.d.ts} +1 -1
- package/dist/{scale-BbDJTbrG.d.mts → scale-bnD0WnMV.d.mts} +1 -1
- package/dist/score/index.d.mts +21 -6
- package/dist/score/index.d.ts +21 -6
- package/dist/score/index.js +137 -103
- package/dist/score/index.mjs +140 -106
- package/dist/{tempo-Dt8aHpol.d.ts → tempo-Bp1UzsrZ.d.ts} +40 -10
- package/dist/{tempo-CtUhvJbr.d.mts → tempo-S85Q7uJA.d.mts} +40 -10
- package/dist/theory/index.d.mts +3 -3
- package/dist/theory/index.d.ts +3 -3
- package/dist/theory/index.js +67 -20
- package/dist/theory/index.mjs +66 -21
- package/package.json +3 -2
package/dist/score/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* WebMusicScore v4.0
|
|
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
|
}
|
|
@@ -896,7 +902,7 @@ import { Utils as Utils11 } from "@tspro/ts-utils-lib";
|
|
|
896
902
|
// src/score/engine/obj-measure.ts
|
|
897
903
|
import { Utils as Utils10 } from "@tspro/ts-utils-lib";
|
|
898
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";
|
|
899
|
-
import { getDefaultTempo,
|
|
905
|
+
import { getDefaultTempo, getDefaultTimeSignature } from "@tspro/web-music-score/theory";
|
|
900
906
|
|
|
901
907
|
// src/score/engine/acc-state.ts
|
|
902
908
|
import { Note } from "@tspro/web-music-score/theory";
|
|
@@ -1279,9 +1285,9 @@ var ObjSignature = class extends MusicObject {
|
|
|
1279
1285
|
if (showTimeSignature) {
|
|
1280
1286
|
let timeSignature = this.measure.getTimeSignature();
|
|
1281
1287
|
let beatCount = timeSignature.beatCount.toString();
|
|
1282
|
-
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);
|
|
1283
1289
|
let beatSize = timeSignature.beatSize.toString();
|
|
1284
|
-
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);
|
|
1285
1291
|
} else {
|
|
1286
1292
|
this.beatCountText = this.beatSizeText = void 0;
|
|
1287
1293
|
}
|
|
@@ -1371,6 +1377,7 @@ var ObjSignature = class extends MusicObject {
|
|
|
1371
1377
|
return [this];
|
|
1372
1378
|
}
|
|
1373
1379
|
layout(renderer) {
|
|
1380
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1374
1381
|
let { unitSize } = renderer;
|
|
1375
1382
|
let { staff } = this;
|
|
1376
1383
|
let paddingX = unitSize;
|
|
@@ -1415,15 +1422,16 @@ var ObjSignature = class extends MusicObject {
|
|
|
1415
1422
|
});
|
|
1416
1423
|
}
|
|
1417
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);
|
|
1418
1428
|
if (this.beatCountText) {
|
|
1419
|
-
this.beatCountText.
|
|
1420
|
-
this.beatCountText.offset(x + paddingX, staff.getDiatonicIdY(staff.middleLineDiatonicId + 2));
|
|
1429
|
+
this.beatCountText.offset(x + tsWidth / 2 + paddingX, staff.getDiatonicIdY(staff.middleLineDiatonicId + 2));
|
|
1421
1430
|
this.rect.expandInPlace(this.beatCountText.getRect());
|
|
1422
1431
|
right = Math.max(right, this.rect.right);
|
|
1423
1432
|
}
|
|
1424
1433
|
if (this.beatSizeText) {
|
|
1425
|
-
this.beatSizeText.
|
|
1426
|
-
this.beatSizeText.offset(x + paddingX, staff.getDiatonicIdY(staff.bottomLineDiatonicId + 2));
|
|
1434
|
+
this.beatSizeText.offset(x + tsWidth / 2 + paddingX, staff.getDiatonicIdY(staff.bottomLineDiatonicId + 2));
|
|
1427
1435
|
this.rect.expandInPlace(this.beatSizeText.getRect());
|
|
1428
1436
|
right = Math.max(right, this.rect.right);
|
|
1429
1437
|
}
|
|
@@ -2812,11 +2820,10 @@ var ObjNoteGroup = class _ObjNoteGroup extends MusicObject {
|
|
|
2812
2820
|
}
|
|
2813
2821
|
setStemTipY(staff, stemTipY) {
|
|
2814
2822
|
let obj = this.staffObjects.find((obj2) => obj2.staff === staff);
|
|
2815
|
-
if (
|
|
2816
|
-
|
|
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();
|
|
2817
2826
|
}
|
|
2818
|
-
obj.stemTip.top = obj.stemTip.centerY = obj.stemTip.bottom = stemTipY;
|
|
2819
|
-
this.requestRectUpdate();
|
|
2820
2827
|
}
|
|
2821
2828
|
offset(dx, dy) {
|
|
2822
2829
|
this.staffObjects.forEach((obj) => obj.offset(dx, 0));
|
|
@@ -5025,7 +5032,7 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5025
5032
|
setTimeSignature(timeSignature) {
|
|
5026
5033
|
var _a;
|
|
5027
5034
|
(_a = this.getPrevMeasure()) == null ? void 0 : _a.endSection();
|
|
5028
|
-
this.alterTimeSignature = timeSignature
|
|
5035
|
+
this.alterTimeSignature = timeSignature;
|
|
5029
5036
|
this.updateTimeSignature();
|
|
5030
5037
|
}
|
|
5031
5038
|
updateTimeSignature() {
|
|
@@ -5555,52 +5562,77 @@ var _ObjMeasure = class _ObjMeasure extends MusicObject {
|
|
|
5555
5562
|
return false;
|
|
5556
5563
|
}
|
|
5557
5564
|
});
|
|
5565
|
+
let ts = this.getTimeSignature();
|
|
5566
|
+
if (!this.needBeamsUpdate || ts.beamGroupSizes.length === 0) {
|
|
5567
|
+
return;
|
|
5568
|
+
}
|
|
5558
5569
|
getVoiceIds().forEach((voiceId) => {
|
|
5559
|
-
let symbols = this.getVoiceSymbols(voiceId);
|
|
5560
|
-
if (symbols.length
|
|
5561
|
-
|
|
5562
|
-
}
|
|
5563
|
-
if (!DebugSettings.DisableBeams) {
|
|
5564
|
-
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;
|
|
5565
5573
|
let groupStartTicks = 0;
|
|
5566
|
-
let
|
|
5567
|
-
|
|
5568
|
-
let
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
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
|
+
}
|
|
5581
5590
|
}
|
|
5582
|
-
|
|
5591
|
+
_ObjMeasure.setupBeamGroup(groupSymbols, beamGroupSize);
|
|
5592
|
+
symbolsStartTicks += groupSymbolsLength;
|
|
5593
|
+
groupStartTicks += groupLength;
|
|
5594
|
+
}
|
|
5583
5595
|
}
|
|
5584
5596
|
});
|
|
5585
5597
|
this.needBeamsUpdate = false;
|
|
5586
5598
|
this.requestLayout();
|
|
5587
5599
|
}
|
|
5588
|
-
static setupBeamGroup(groupSymbols) {
|
|
5600
|
+
static setupBeamGroup(groupSymbols, mainBeamGroupSizeArr) {
|
|
5601
|
+
if (mainBeamGroupSizeArr.length === 0) {
|
|
5602
|
+
return false;
|
|
5603
|
+
}
|
|
5589
5604
|
let groupNotes = groupSymbols.map((s) => {
|
|
5590
5605
|
var _a;
|
|
5591
5606
|
return s instanceof ObjNoteGroup && ((_a = s.getBeamGroup()) == null ? void 0 : _a.isTuplet()) !== true ? s : void 0;
|
|
5592
5607
|
});
|
|
5593
5608
|
ObjNoteGroup.setBeamCounts(groupNotes);
|
|
5594
|
-
let
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
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;
|
|
5604
5636
|
}
|
|
5605
5637
|
getBarLineLeft() {
|
|
5606
5638
|
return this.barLineLeft;
|
|
@@ -6949,7 +6981,7 @@ var ObjDocument = class extends MusicObject {
|
|
|
6949
6981
|
};
|
|
6950
6982
|
|
|
6951
6983
|
// src/score/pub/document-builder.ts
|
|
6952
|
-
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";
|
|
6953
6985
|
import { MusicError as MusicError17, MusicErrorType as MusicErrorType17 } from "@tspro/web-music-score/core";
|
|
6954
6986
|
function assertArg(condition, argName, argValue) {
|
|
6955
6987
|
if (!condition) {
|
|
@@ -7117,14 +7149,16 @@ var DocumentBuilder = class {
|
|
|
7117
7149
|
this.getMeasure().setKeySignature(...args);
|
|
7118
7150
|
return this;
|
|
7119
7151
|
}
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
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
|
+
}
|
|
7128
7162
|
return this;
|
|
7129
7163
|
}
|
|
7130
7164
|
setTempo(beatsPerMinute, beatLength, dotted) {
|
|
@@ -289,8 +289,38 @@ declare class RhythmProps {
|
|
|
289
289
|
static equals(a: RhythmProps, b: RhythmProps): boolean;
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
/** Time signature
|
|
293
|
-
|
|
292
|
+
/** Time signature enum. */
|
|
293
|
+
declare enum TimeSignatures {
|
|
294
|
+
/** 2/4 time signature. */
|
|
295
|
+
_2_4 = "2/4",
|
|
296
|
+
/** 3/4 time signature. */
|
|
297
|
+
_3_4 = "3/4",
|
|
298
|
+
/** 4/4 time signature. */
|
|
299
|
+
_4_4 = "4/4",
|
|
300
|
+
/** 5/8 time signature. */
|
|
301
|
+
_5_8 = "5/8",
|
|
302
|
+
/** 6/8 time signature. */
|
|
303
|
+
_6_8 = "6/8",
|
|
304
|
+
/** 7/8 time signature. */
|
|
305
|
+
_7_8 = "7/8",
|
|
306
|
+
/** 9/8 time signature. */
|
|
307
|
+
_9_8 = "9/8",
|
|
308
|
+
/** 12/8 time signature. */
|
|
309
|
+
_12_8 = "12/8"
|
|
310
|
+
}
|
|
311
|
+
/** @deprecated - Use TimeSignatures enum values or just it's string values. */
|
|
312
|
+
type TimeSignatureString = `${TimeSignatures}`;
|
|
313
|
+
/** Beam grouping enum. */
|
|
314
|
+
declare enum BeamGrouping {
|
|
315
|
+
/** 2-3 beam grouping for 5/8 time signature. */
|
|
316
|
+
_2_3 = "2-3",
|
|
317
|
+
/** 3-2 beam grouping for 5/8 time signature. */
|
|
318
|
+
_3_2 = "3-2",
|
|
319
|
+
/** 2-2-3 beam grouping for 7/8 time signature. */
|
|
320
|
+
_2_2_3 = "2-2-3",
|
|
321
|
+
/** 3-2-2 beam grouping for 7/8 time signature. */
|
|
322
|
+
_3_2_2 = "3-2-2"
|
|
323
|
+
}
|
|
294
324
|
/** Time signature class. */
|
|
295
325
|
declare class TimeSignature {
|
|
296
326
|
/** Number of beats in measure, upper value (e.g. "3" in "3/4"). */
|
|
@@ -301,21 +331,21 @@ declare class TimeSignature {
|
|
|
301
331
|
readonly beatLength: NoteLength;
|
|
302
332
|
/** Number of ticks in measure. */
|
|
303
333
|
readonly measureTicks: number;
|
|
304
|
-
/**
|
|
305
|
-
readonly
|
|
306
|
-
/** Length of one beam group. */
|
|
307
|
-
readonly beamGroupLength: number;
|
|
334
|
+
/** Beam groups (e.g. [[2], [2]] or [[2, 2], [2, 2]] (first try as [[4], [4]])). */
|
|
335
|
+
readonly beamGroupSizes: number[][];
|
|
308
336
|
/**
|
|
309
337
|
* Create new time signature instance.
|
|
310
|
-
* @param
|
|
338
|
+
* @param timeSignature - For example "4/4".
|
|
339
|
+
* @param beamGrouping - Beam grouping (e.g. "3-2" for time signature "5/8").
|
|
311
340
|
*/
|
|
312
|
-
constructor(
|
|
341
|
+
constructor(timeSignature: TimeSignatures | `${TimeSignatures}`, beamGrouping?: BeamGrouping | `${BeamGrouping}`);
|
|
313
342
|
/**
|
|
314
343
|
* Create new time signature instance.
|
|
315
344
|
* @param beatCount - Measure beat count.
|
|
316
345
|
* @param beatSize - Size value: whole-note=1, half-note=2, quarter-note=4, etc.
|
|
346
|
+
* @param beamGrouping - Beam grouping (e.g. "3-2" for time signature "5/8").
|
|
317
347
|
*/
|
|
318
|
-
constructor(beatCount: number, beatSize: number);
|
|
348
|
+
constructor(beatCount: number, beatSize: number, beamGrouping?: BeamGrouping | `${BeamGrouping}`);
|
|
319
349
|
/**
|
|
320
350
|
* Test whether this time signature has given beat count and size.
|
|
321
351
|
* @param beatCount - Beat count.
|
|
@@ -366,4 +396,4 @@ declare function getTempoString(tempo: Tempo): string;
|
|
|
366
396
|
*/
|
|
367
397
|
declare function alterTempoSpeed(tempo: Tempo, speed: number): Tempo;
|
|
368
398
|
|
|
369
|
-
export { AccidentalType as A, KeySignature as K, Mode as M, NoteLength as N, RhythmProps as R, type TimeSignatureString as
|
|
399
|
+
export { AccidentalType as A, BeamGrouping as B, KeySignature as K, Mode as M, NoteLength as N, RhythmProps as R, TimeSignatures as T, type TimeSignatureString as a, TimeSignature as b, getDefaultTimeSignature as c, type Tempo as d, getDefaultTempo as e, getTempoString as f, getDefaultKeySignature as g, alterTempoSpeed as h, type NoteLengthStr as i, NoteLengthProps as j, type TupletRatio as k, validateTupletRatio as l, Tuplet as m, validateNoteLength as v };
|
|
@@ -289,8 +289,38 @@ declare class RhythmProps {
|
|
|
289
289
|
static equals(a: RhythmProps, b: RhythmProps): boolean;
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
/** Time signature
|
|
293
|
-
|
|
292
|
+
/** Time signature enum. */
|
|
293
|
+
declare enum TimeSignatures {
|
|
294
|
+
/** 2/4 time signature. */
|
|
295
|
+
_2_4 = "2/4",
|
|
296
|
+
/** 3/4 time signature. */
|
|
297
|
+
_3_4 = "3/4",
|
|
298
|
+
/** 4/4 time signature. */
|
|
299
|
+
_4_4 = "4/4",
|
|
300
|
+
/** 5/8 time signature. */
|
|
301
|
+
_5_8 = "5/8",
|
|
302
|
+
/** 6/8 time signature. */
|
|
303
|
+
_6_8 = "6/8",
|
|
304
|
+
/** 7/8 time signature. */
|
|
305
|
+
_7_8 = "7/8",
|
|
306
|
+
/** 9/8 time signature. */
|
|
307
|
+
_9_8 = "9/8",
|
|
308
|
+
/** 12/8 time signature. */
|
|
309
|
+
_12_8 = "12/8"
|
|
310
|
+
}
|
|
311
|
+
/** @deprecated - Use TimeSignatures enum values or just it's string values. */
|
|
312
|
+
type TimeSignatureString = `${TimeSignatures}`;
|
|
313
|
+
/** Beam grouping enum. */
|
|
314
|
+
declare enum BeamGrouping {
|
|
315
|
+
/** 2-3 beam grouping for 5/8 time signature. */
|
|
316
|
+
_2_3 = "2-3",
|
|
317
|
+
/** 3-2 beam grouping for 5/8 time signature. */
|
|
318
|
+
_3_2 = "3-2",
|
|
319
|
+
/** 2-2-3 beam grouping for 7/8 time signature. */
|
|
320
|
+
_2_2_3 = "2-2-3",
|
|
321
|
+
/** 3-2-2 beam grouping for 7/8 time signature. */
|
|
322
|
+
_3_2_2 = "3-2-2"
|
|
323
|
+
}
|
|
294
324
|
/** Time signature class. */
|
|
295
325
|
declare class TimeSignature {
|
|
296
326
|
/** Number of beats in measure, upper value (e.g. "3" in "3/4"). */
|
|
@@ -301,21 +331,21 @@ declare class TimeSignature {
|
|
|
301
331
|
readonly beatLength: NoteLength;
|
|
302
332
|
/** Number of ticks in measure. */
|
|
303
333
|
readonly measureTicks: number;
|
|
304
|
-
/**
|
|
305
|
-
readonly
|
|
306
|
-
/** Length of one beam group. */
|
|
307
|
-
readonly beamGroupLength: number;
|
|
334
|
+
/** Beam groups (e.g. [[2], [2]] or [[2, 2], [2, 2]] (first try as [[4], [4]])). */
|
|
335
|
+
readonly beamGroupSizes: number[][];
|
|
308
336
|
/**
|
|
309
337
|
* Create new time signature instance.
|
|
310
|
-
* @param
|
|
338
|
+
* @param timeSignature - For example "4/4".
|
|
339
|
+
* @param beamGrouping - Beam grouping (e.g. "3-2" for time signature "5/8").
|
|
311
340
|
*/
|
|
312
|
-
constructor(
|
|
341
|
+
constructor(timeSignature: TimeSignatures | `${TimeSignatures}`, beamGrouping?: BeamGrouping | `${BeamGrouping}`);
|
|
313
342
|
/**
|
|
314
343
|
* Create new time signature instance.
|
|
315
344
|
* @param beatCount - Measure beat count.
|
|
316
345
|
* @param beatSize - Size value: whole-note=1, half-note=2, quarter-note=4, etc.
|
|
346
|
+
* @param beamGrouping - Beam grouping (e.g. "3-2" for time signature "5/8").
|
|
317
347
|
*/
|
|
318
|
-
constructor(beatCount: number, beatSize: number);
|
|
348
|
+
constructor(beatCount: number, beatSize: number, beamGrouping?: BeamGrouping | `${BeamGrouping}`);
|
|
319
349
|
/**
|
|
320
350
|
* Test whether this time signature has given beat count and size.
|
|
321
351
|
* @param beatCount - Beat count.
|
|
@@ -366,4 +396,4 @@ declare function getTempoString(tempo: Tempo): string;
|
|
|
366
396
|
*/
|
|
367
397
|
declare function alterTempoSpeed(tempo: Tempo, speed: number): Tempo;
|
|
368
398
|
|
|
369
|
-
export { AccidentalType as A, KeySignature as K, Mode as M, NoteLength as N, RhythmProps as R, type TimeSignatureString as
|
|
399
|
+
export { AccidentalType as A, BeamGrouping as B, KeySignature as K, Mode as M, NoteLength as N, RhythmProps as R, TimeSignatures as T, type TimeSignatureString as a, TimeSignature as b, getDefaultTimeSignature as c, type Tempo as d, getDefaultTempo as e, getTempoString as f, getDefaultKeySignature as g, alterTempoSpeed as h, type NoteLengthStr as i, NoteLengthProps as j, type TupletRatio as k, validateTupletRatio as l, Tuplet as m, validateNoteLength as v };
|
package/dist/theory/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { N as Note } from '../note-eA2xPPiG.mjs';
|
|
2
2
|
export { A as Accidental, d as DefaultGuitarNoteLabel, D as DefaultPitchNotation, G as GuitarNoteLabel, e as GuitarNoteLabelList, a as NoteLetter, P as ParsedNote, b as PitchNotation, c as PitchNotationList, S as SymbolSet, g as getPitchNotationName, f as validateGuitarNoteLabel, v as validatePitchNotation } from '../note-eA2xPPiG.mjs';
|
|
3
|
-
import { D as Degree } from '../scale-
|
|
4
|
-
export { b as Interval, I as IntervalDirection, a as IntervalQuality, c as Scale, d as ScaleFactory, S as ScaleType, i as getDefaultScale, h as getScale, e as getScaleFactory, g as getScaleFactoryList, v as validateIntervalQuality, f as validateScaleType } from '../scale-
|
|
3
|
+
import { D as Degree } from '../scale-bnD0WnMV.mjs';
|
|
4
|
+
export { b as Interval, I as IntervalDirection, a as IntervalQuality, c as Scale, d as ScaleFactory, S as ScaleType, i as getDefaultScale, h as getScale, e as getScaleFactory, g as getScaleFactoryList, v as validateIntervalQuality, f as validateScaleType } from '../scale-bnD0WnMV.mjs';
|
|
5
5
|
export { D as DefaultHandedness, a as DefaultTuningName, H as Handedness, T as TuningNameList, g as getTuningStrings, v as validateHandedness, b as validateTuningName } from '../guitar-DdexKdN6.mjs';
|
|
6
|
-
export { A as AccidentalType, K as KeySignature, M as Mode, N as NoteLength,
|
|
6
|
+
export { A as AccidentalType, B as BeamGrouping, K as KeySignature, M as Mode, N as NoteLength, j as NoteLengthProps, i as NoteLengthStr, R as RhythmProps, d as Tempo, b as TimeSignature, a as TimeSignatureString, T as TimeSignatures, m as Tuplet, k as TupletRatio, h as alterTempoSpeed, g as getDefaultKeySignature, e as getDefaultTempo, c as getDefaultTimeSignature, f as getTempoString, v as validateNoteLength, l as validateTupletRatio } from '../tempo-S85Q7uJA.mjs';
|
|
7
7
|
|
|
8
8
|
/** Chord info type. */
|
|
9
9
|
type ChordInfo = {
|