@libraz/libcantus 1.2.0 → 1.4.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/NOTICE +63 -0
- package/README.md +7 -1
- package/README_ja.md +17 -11
- package/dist/analyze/index.cjs +31 -7
- package/dist/analyze/index.cjs.map +1 -1
- package/dist/analyze/index.d.cts +161 -13
- package/dist/analyze/index.d.ts +161 -13
- package/dist/analyze/index.js +37 -13
- package/dist/{chunk-NB25P3EH.js → chunk-2G5MCGYU.js} +33 -11
- package/dist/chunk-2G5MCGYU.js.map +1 -0
- package/dist/{chunk-NM7UAMC3.cjs → chunk-3FDBMIPR.cjs} +64 -64
- package/dist/chunk-3FDBMIPR.cjs.map +1 -0
- package/dist/{chunk-HPVSH7SF.cjs → chunk-3MDOEFIQ.cjs} +618 -954
- package/dist/chunk-3MDOEFIQ.cjs.map +1 -0
- package/dist/{chunk-FBH75DAY.js → chunk-5MWRBYAT.js} +560 -159
- package/dist/chunk-5MWRBYAT.js.map +1 -0
- package/dist/{chunk-J7FHVZII.cjs → chunk-6TTBEON3.cjs} +3074 -740
- package/dist/chunk-6TTBEON3.cjs.map +1 -0
- package/dist/{chunk-UMWZ4ZET.js → chunk-7NQ6AL3H.js} +4 -4
- package/dist/chunk-7NQ6AL3H.js.map +1 -0
- package/dist/{chunk-HWHGOVO6.cjs → chunk-E3QO3UET.cjs} +31 -23
- package/dist/chunk-E3QO3UET.cjs.map +1 -0
- package/dist/{chunk-H2KJHBW4.js → chunk-FJFULJZE.js} +2375 -191
- package/dist/chunk-FJFULJZE.js.map +1 -0
- package/dist/{chunk-Q6LFSAKV.js → chunk-FK3DGAIZ.js} +2657 -323
- package/dist/chunk-FK3DGAIZ.js.map +1 -0
- package/dist/chunk-GEDTJHAC.cjs.map +1 -1
- package/dist/{chunk-RFIBF2RR.js → chunk-H7FVMBUC.js} +138 -65
- package/dist/chunk-H7FVMBUC.js.map +1 -0
- package/dist/{chunk-DSMJRXCZ.cjs → chunk-HYSVSFNI.cjs} +931 -530
- package/dist/chunk-HYSVSFNI.cjs.map +1 -0
- package/dist/{chunk-35NBV2FT.cjs → chunk-KMYGRFZ6.cjs} +47 -24
- package/dist/chunk-KMYGRFZ6.cjs.map +1 -0
- package/dist/chunk-LQZQDBCD.cjs +5513 -0
- package/dist/chunk-LQZQDBCD.cjs.map +1 -0
- package/dist/{chunk-PM4XJE2Y.cjs → chunk-P3CPXAJ5.cjs} +76 -54
- package/dist/chunk-P3CPXAJ5.cjs.map +1 -0
- package/dist/{chunk-S5BKZZGM.cjs → chunk-S3QELJUE.cjs} +72 -56
- package/dist/chunk-S3QELJUE.cjs.map +1 -0
- package/dist/{chunk-PUKJP2Z5.js → chunk-TXFWSU5D.js} +31 -8
- package/dist/chunk-TXFWSU5D.js.map +1 -0
- package/dist/{chunk-76ZBTRG2.cjs → chunk-U4EQTDGN.cjs} +258 -218
- package/dist/chunk-U4EQTDGN.cjs.map +1 -0
- package/dist/chunk-UGLFDG7L.cjs.map +1 -1
- package/dist/{chunk-HYJJ2V2I.js → chunk-UTE5A36R.js} +483 -819
- package/dist/chunk-UTE5A36R.js.map +1 -0
- package/dist/{chunk-NFJ4P6ZZ.js → chunk-UZKQISRF.js} +17 -9
- package/dist/chunk-UZKQISRF.js.map +1 -0
- package/dist/{chunk-7KG3RTYS.js → chunk-VL5NXVCN.js} +281 -155
- package/dist/chunk-VL5NXVCN.js.map +1 -0
- package/dist/{chunk-CGBADIO5.cjs → chunk-WOMCXN2W.cjs} +328 -202
- package/dist/chunk-WOMCXN2W.cjs.map +1 -0
- package/dist/{chunk-3R3QVKY5.cjs → chunk-YDGMWH43.cjs} +397 -324
- package/dist/chunk-YDGMWH43.cjs.map +1 -0
- package/dist/{chunk-AGOVW7U6.js → chunk-YYVXRV3V.js} +72 -56
- package/dist/chunk-YYVXRV3V.js.map +1 -0
- package/dist/{chunk-M5RYMAFI.js → chunk-ZLNSH4UL.js} +71 -31
- package/dist/chunk-ZLNSH4UL.js.map +1 -0
- package/dist/{coerce-DRERzdve.d.cts → coerce-CUhHc3Tu.d.ts} +16 -8
- package/dist/{coerce-DP0vYu-x.d.ts → coerce-Ytt2Eiq9.d.cts} +16 -8
- package/dist/core/index.cjs +5 -5
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +9 -8
- package/dist/core/index.d.ts +9 -8
- package/dist/core/index.js +4 -4
- package/dist/generate/index.cjs +20 -8
- package/dist/generate/index.cjs.map +1 -1
- package/dist/generate/index.d.cts +105 -17
- package/dist/generate/index.d.ts +105 -17
- package/dist/generate/index.js +19 -7
- package/dist/{index-CL4b4gUQ.d.ts → index-5VJgKz_Q.d.cts} +6 -2
- package/dist/{index-B9QLziDe.d.cts → index-BLuDesVG.d.ts} +20 -13
- package/dist/{index-BHIUyjhZ.d.ts → index-BV6APVa6.d.cts} +20 -13
- package/dist/{index-BMweUlm5.d.cts → index-Bf0Sv8a9.d.ts} +6 -2
- package/dist/{index-Dw2DP7vm.d.ts → index-BkT21EMv.d.cts} +3 -2
- package/dist/{index-BL5N2Oyz.d.cts → index-C7KCaTRz.d.ts} +3 -2
- package/dist/{index-Cy15oTvh.d.ts → index-C9MYbuKS.d.cts} +7 -3
- package/dist/{index-Cy15oTvh.d.cts → index-C9MYbuKS.d.ts} +7 -3
- package/dist/{index-BNSM-DSk.d.cts → index-DVInzCDS.d.cts} +533 -28
- package/dist/{index-9eoQs2C1.d.ts → index-Dg-SAfhz.d.ts} +6 -4
- package/dist/{index-BJgP97N1.d.ts → index-jgeug9EA.d.ts} +533 -28
- package/dist/{index-cHvbYgJI.d.cts → index-pQihL4z7.d.cts} +6 -4
- package/dist/index.cjs +49 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.js +55 -19
- package/dist/{masks-Cc7-MzzY.d.ts → masks-BnzXnBj0.d.cts} +3 -2
- package/dist/{masks-pADfTOiD.d.cts → masks-tycmkrgs.d.ts} +3 -2
- package/dist/model/index.cjs +12 -12
- package/dist/model/index.cjs.map +1 -1
- package/dist/model/index.d.cts +259 -48
- package/dist/model/index.d.ts +259 -48
- package/dist/model/index.js +11 -11
- package/dist/{positional-DJgs6ltD.d.ts → positional-CscpxtlE.d.cts} +3 -2
- package/dist/{positional-DMZer-FM.d.cts → positional-DLnfUgqG.d.ts} +3 -2
- package/dist/{index-BRMbPkHE.d.ts → profile-B4WqcM4H.d.ts} +85 -610
- package/dist/{index-DGCNKAUr.d.cts → profile-BJd1XkPB.d.cts} +85 -610
- package/dist/theory/index.cjs +5 -5
- package/dist/theory/index.cjs.map +1 -1
- package/dist/theory/index.d.cts +18 -14
- package/dist/theory/index.d.ts +18 -14
- package/dist/theory/index.js +4 -4
- package/dist/{index-CJBBiAmU.d.ts → types-7mGFwvMm.d.ts} +1210 -31
- package/dist/{index-BBWNZS0f.d.cts → types-_ofpb2be.d.cts} +1210 -31
- package/package.json +13 -13
- package/dist/chunk-35NBV2FT.cjs.map +0 -1
- package/dist/chunk-3R3QVKY5.cjs.map +0 -1
- package/dist/chunk-76ZBTRG2.cjs.map +0 -1
- package/dist/chunk-7KG3RTYS.js.map +0 -1
- package/dist/chunk-AGOVW7U6.js.map +0 -1
- package/dist/chunk-CGBADIO5.cjs.map +0 -1
- package/dist/chunk-DSMJRXCZ.cjs.map +0 -1
- package/dist/chunk-FBH75DAY.js.map +0 -1
- package/dist/chunk-H2KJHBW4.js.map +0 -1
- package/dist/chunk-HPVSH7SF.cjs.map +0 -1
- package/dist/chunk-HWHGOVO6.cjs.map +0 -1
- package/dist/chunk-HYJJ2V2I.js.map +0 -1
- package/dist/chunk-J7FHVZII.cjs.map +0 -1
- package/dist/chunk-M5RYMAFI.js.map +0 -1
- package/dist/chunk-NB25P3EH.js.map +0 -1
- package/dist/chunk-NFJ4P6ZZ.js.map +0 -1
- package/dist/chunk-NM7UAMC3.cjs.map +0 -1
- package/dist/chunk-PM4XJE2Y.cjs.map +0 -1
- package/dist/chunk-PUKJP2Z5.js.map +0 -1
- package/dist/chunk-Q6LFSAKV.js.map +0 -1
- package/dist/chunk-RFIBF2RR.js.map +0 -1
- package/dist/chunk-S5BKZZGM.cjs.map +0 -1
- package/dist/chunk-SGLEQVJH.cjs +0 -3329
- package/dist/chunk-SGLEQVJH.cjs.map +0 -1
- package/dist/chunk-UMWZ4ZET.js.map +0 -1
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var _chunkHPVSH7SFcjs = require('./chunk-HPVSH7SF.cjs');
|
|
18
17
|
|
|
19
18
|
|
|
19
|
+
var _chunk3MDOEFIQcjs = require('./chunk-3MDOEFIQ.cjs');
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
@@ -38,9 +38,9 @@ var _chunkHPVSH7SFcjs = require('./chunk-HPVSH7SF.cjs');
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
var _chunkNM7UAMC3cjs = require('./chunk-NM7UAMC3.cjs');
|
|
42
41
|
|
|
43
42
|
|
|
43
|
+
var _chunk3FDBMIPRcjs = require('./chunk-3FDBMIPR.cjs');
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
@@ -69,13 +69,13 @@ var _chunkNM7UAMC3cjs = require('./chunk-NM7UAMC3.cjs');
|
|
|
69
69
|
|
|
70
70
|
|
|
71
71
|
|
|
72
|
-
var _chunkJ7FHVZIIcjs = require('./chunk-J7FHVZII.cjs');
|
|
73
72
|
|
|
74
73
|
|
|
75
74
|
|
|
76
75
|
|
|
77
76
|
|
|
78
77
|
|
|
78
|
+
var _chunk6TTBEON3cjs = require('./chunk-6TTBEON3.cjs');
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
|
|
@@ -97,7 +97,6 @@ var _chunkJ7FHVZIIcjs = require('./chunk-J7FHVZII.cjs');
|
|
|
97
97
|
|
|
98
98
|
|
|
99
99
|
|
|
100
|
-
var _chunkSGLEQVJHcjs = require('./chunk-SGLEQVJH.cjs');
|
|
101
100
|
|
|
102
101
|
|
|
103
102
|
|
|
@@ -110,12 +109,11 @@ var _chunkSGLEQVJHcjs = require('./chunk-SGLEQVJH.cjs');
|
|
|
110
109
|
|
|
111
110
|
|
|
112
111
|
|
|
113
|
-
var _chunkCGBADIO5cjs = require('./chunk-CGBADIO5.cjs');
|
|
114
112
|
|
|
115
113
|
|
|
116
|
-
var _chunk35NBV2FTcjs = require('./chunk-35NBV2FT.cjs');
|
|
117
114
|
|
|
118
115
|
|
|
116
|
+
var _chunkLQZQDBCDcjs = require('./chunk-LQZQDBCD.cjs');
|
|
119
117
|
|
|
120
118
|
|
|
121
119
|
|
|
@@ -128,14 +126,14 @@ var _chunk35NBV2FTcjs = require('./chunk-35NBV2FT.cjs');
|
|
|
128
126
|
|
|
129
127
|
|
|
130
128
|
|
|
131
|
-
var
|
|
129
|
+
var _chunkWOMCXN2Wcjs = require('./chunk-WOMCXN2W.cjs');
|
|
132
130
|
|
|
133
131
|
|
|
132
|
+
var _chunkKMYGRFZ6cjs = require('./chunk-KMYGRFZ6.cjs');
|
|
134
133
|
|
|
135
134
|
|
|
136
135
|
|
|
137
136
|
|
|
138
|
-
var _chunkPM4XJE2Ycjs = require('./chunk-PM4XJE2Y.cjs');
|
|
139
137
|
|
|
140
138
|
|
|
141
139
|
|
|
@@ -146,12 +144,14 @@ var _chunkPM4XJE2Ycjs = require('./chunk-PM4XJE2Y.cjs');
|
|
|
146
144
|
|
|
147
145
|
|
|
148
146
|
|
|
147
|
+
var _chunkU4EQTDGNcjs = require('./chunk-U4EQTDGN.cjs');
|
|
149
148
|
|
|
150
149
|
|
|
151
150
|
|
|
152
151
|
|
|
153
152
|
|
|
154
153
|
|
|
154
|
+
var _chunkP3CPXAJ5cjs = require('./chunk-P3CPXAJ5.cjs');
|
|
155
155
|
|
|
156
156
|
|
|
157
157
|
|
|
@@ -191,7 +191,6 @@ var _chunkPM4XJE2Ycjs = require('./chunk-PM4XJE2Y.cjs');
|
|
|
191
191
|
|
|
192
192
|
|
|
193
193
|
|
|
194
|
-
var _chunk3R3QVKY5cjs = require('./chunk-3R3QVKY5.cjs');
|
|
195
194
|
|
|
196
195
|
|
|
197
196
|
|
|
@@ -209,6 +208,7 @@ var _chunk3R3QVKY5cjs = require('./chunk-3R3QVKY5.cjs');
|
|
|
209
208
|
|
|
210
209
|
|
|
211
210
|
|
|
211
|
+
var _chunkYDGMWH43cjs = require('./chunk-YDGMWH43.cjs');
|
|
212
212
|
|
|
213
213
|
|
|
214
214
|
|
|
@@ -235,7 +235,26 @@ var _chunk3R3QVKY5cjs = require('./chunk-3R3QVKY5.cjs');
|
|
|
235
235
|
|
|
236
236
|
|
|
237
237
|
|
|
238
|
-
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
var _chunkS3QELJUEcjs = require('./chunk-S3QELJUE.cjs');
|
|
239
258
|
|
|
240
259
|
// src/model/interval.ts
|
|
241
260
|
var INVERSION_SUM = 9;
|
|
@@ -244,6 +263,14 @@ function simpleDegree(numberValue) {
|
|
|
244
263
|
const reduced = (numberValue - 1) % 7 + 1;
|
|
245
264
|
return reduced === 1 && numberValue > 1 ? OCTAVE_DEGREES : reduced;
|
|
246
265
|
}
|
|
266
|
+
function checkedDirection(descending) {
|
|
267
|
+
if (typeof descending !== "boolean") {
|
|
268
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
269
|
+
`interval.descending must be a boolean; received ${_chunkS3QELJUEcjs.describeRejected.call(void 0, descending)}`
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
return descending;
|
|
273
|
+
}
|
|
247
274
|
function invertQuality(quality) {
|
|
248
275
|
if (quality === "P") {
|
|
249
276
|
return "P";
|
|
@@ -275,6 +302,12 @@ var Interval = class _Interval {
|
|
|
275
302
|
* @returns The interval from `a` to `b`.
|
|
276
303
|
*/
|
|
277
304
|
static between(a, b) {
|
|
305
|
+
if (typeof a !== "object" || a === null || typeof a.intervalTo !== "function") {
|
|
306
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(`interval a must be a Note; received ${_chunkS3QELJUEcjs.describeRejected.call(void 0, a)}`);
|
|
307
|
+
}
|
|
308
|
+
if (typeof b !== "object" || b === null || typeof b.data !== "object" || b.data === null) {
|
|
309
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(`interval b must be a Note; received ${_chunkS3QELJUEcjs.describeRejected.call(void 0, b)}`);
|
|
310
|
+
}
|
|
278
311
|
return a.intervalTo(b);
|
|
279
312
|
}
|
|
280
313
|
/**
|
|
@@ -304,8 +337,13 @@ var Interval = class _Interval {
|
|
|
304
337
|
* @throws If the number, quality, and span do not describe the same interval.
|
|
305
338
|
*/
|
|
306
339
|
static fromData(data) {
|
|
307
|
-
const checked =
|
|
308
|
-
return new _Interval(
|
|
340
|
+
const checked = _chunkS3QELJUEcjs.toSpelledInterval.call(void 0, data);
|
|
341
|
+
return new _Interval(
|
|
342
|
+
checked.number,
|
|
343
|
+
checked.quality,
|
|
344
|
+
checked.semitones,
|
|
345
|
+
checkedDirection(checked.descending)
|
|
346
|
+
);
|
|
309
347
|
}
|
|
310
348
|
/**
|
|
311
349
|
* Rebuild an interval from its {@link Interval.toJSON} output.
|
|
@@ -328,7 +366,7 @@ var Interval = class _Interval {
|
|
|
328
366
|
* interval field read on every keystroke.
|
|
329
367
|
*/
|
|
330
368
|
static parse(name) {
|
|
331
|
-
return
|
|
369
|
+
return _chunkS3QELJUEcjs.unwrapParse.call(void 0, _Interval.tryParse(name));
|
|
332
370
|
}
|
|
333
371
|
/**
|
|
334
372
|
* Parse an interval name, reporting failure instead of throwing it.
|
|
@@ -347,7 +385,7 @@ var Interval = class _Interval {
|
|
|
347
385
|
* ```
|
|
348
386
|
*/
|
|
349
387
|
static tryParse(name) {
|
|
350
|
-
const parsed =
|
|
388
|
+
const parsed = _chunkS3QELJUEcjs.tryParseInterval.call(void 0, name);
|
|
351
389
|
return parsed.ok ? { ok: true, value: _Interval.fromData(parsed.value) } : parsed;
|
|
352
390
|
}
|
|
353
391
|
/** Diatonic size: 1 = unison, 2 = second, ... 8 = octave, and beyond. */
|
|
@@ -403,7 +441,7 @@ var Interval = class _Interval {
|
|
|
403
441
|
invert() {
|
|
404
442
|
const numberValue = INVERSION_SUM - simpleDegree(this.#number);
|
|
405
443
|
const quality = invertQuality(this.#quality);
|
|
406
|
-
return _Interval.of(numberValue, quality,
|
|
444
|
+
return _Interval.of(numberValue, quality, _chunkS3QELJUEcjs.intervalSemitones.call(void 0, numberValue, quality));
|
|
407
445
|
}
|
|
408
446
|
/**
|
|
409
447
|
* The same interval taken in the opposite direction.
|
|
@@ -430,12 +468,15 @@ var Interval = class _Interval {
|
|
|
430
468
|
/**
|
|
431
469
|
* Whether the interval is consonant.
|
|
432
470
|
*
|
|
471
|
+
* The spelling decides, not the span: a diminished fourth is a dissonance
|
|
472
|
+
* though it sounds like a major third.
|
|
473
|
+
*
|
|
433
474
|
* @param twoVoice When true, the perfect fourth counts as a dissonance,
|
|
434
475
|
* matching two-voice counterpoint.
|
|
435
476
|
* @returns True if the interval is consonant in that context.
|
|
436
477
|
*/
|
|
437
478
|
isConsonant(twoVoice = true) {
|
|
438
|
-
return
|
|
479
|
+
return _chunkYDGMWH43cjs.classifySpelledInterval.call(void 0, this.toJSON(), twoVoice) !== 2 /* Dissonance */;
|
|
439
480
|
}
|
|
440
481
|
/**
|
|
441
482
|
* Whether another interval is spelled identically.
|
|
@@ -482,7 +523,6 @@ var Interval = class _Interval {
|
|
|
482
523
|
};
|
|
483
524
|
|
|
484
525
|
// src/model/shared.ts
|
|
485
|
-
var STATED_KEY_CONFIDENCE = 1;
|
|
486
526
|
function describeShape(value) {
|
|
487
527
|
if (value === null) {
|
|
488
528
|
return "null";
|
|
@@ -491,13 +531,13 @@ function describeShape(value) {
|
|
|
491
531
|
}
|
|
492
532
|
function assertDataObject(value, name) {
|
|
493
533
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
494
|
-
throw new (0,
|
|
534
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(`${name} must be an object; received ${describeShape(value)}`);
|
|
495
535
|
}
|
|
496
536
|
return value;
|
|
497
537
|
}
|
|
498
538
|
function assertDataArray(value, name) {
|
|
499
539
|
if (!Array.isArray(value)) {
|
|
500
|
-
throw new (0,
|
|
540
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(`${name} must be an array; received ${describeShape(value)}`);
|
|
501
541
|
}
|
|
502
542
|
return value;
|
|
503
543
|
}
|
|
@@ -509,14 +549,14 @@ function assertDataObjects(value, name) {
|
|
|
509
549
|
return items;
|
|
510
550
|
}
|
|
511
551
|
function assertNoteEventArray(notes, name, options) {
|
|
512
|
-
return
|
|
552
|
+
return _chunkS3QELJUEcjs.assertNoteEvents.call(void 0, assertDataArray(notes, name), name, options);
|
|
513
553
|
}
|
|
514
554
|
function assertKeyArgument(value, name) {
|
|
515
555
|
if (value === void 0 || typeof value === "string" || isKeyShaped(value)) {
|
|
516
556
|
return;
|
|
517
557
|
}
|
|
518
558
|
const received = value === null ? "null" : typeof value === "object" ? "an object" : `a ${typeof value}`;
|
|
519
|
-
throw new (0,
|
|
559
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
520
560
|
`${name} must be a Key; received ${received}. A method that also takes options takes them after the key, not in its place`
|
|
521
561
|
);
|
|
522
562
|
}
|
|
@@ -554,7 +594,7 @@ function copyNoteEvent(note) {
|
|
|
554
594
|
}
|
|
555
595
|
function copyTimeSignature(ts, name) {
|
|
556
596
|
assertDataObject(ts, _nullishCoalesce(name, () => ( "time signature")));
|
|
557
|
-
|
|
597
|
+
_chunkS3QELJUEcjs.assertTimeSignature.call(void 0, ts, name);
|
|
558
598
|
const copy = { numerator: ts.numerator, denominator: ts.denominator };
|
|
559
599
|
if (ts.grouping !== void 0) {
|
|
560
600
|
copy.grouping = [...ts.grouping];
|
|
@@ -567,19 +607,19 @@ function copyPlain(value, name) {
|
|
|
567
607
|
}
|
|
568
608
|
function copyPlainAt(value, name, seen, depth) {
|
|
569
609
|
if (typeof value === "number") {
|
|
570
|
-
return
|
|
610
|
+
return _chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, value, name);
|
|
571
611
|
}
|
|
572
612
|
if (typeof value === "function" || typeof value === "symbol" || typeof value === "bigint") {
|
|
573
|
-
throw new (0,
|
|
613
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(`${name} must be plain data; received ${typeof value}`);
|
|
574
614
|
}
|
|
575
615
|
if (typeof value !== "object" || value === null) {
|
|
576
616
|
return value;
|
|
577
617
|
}
|
|
578
618
|
if (seen.has(value)) {
|
|
579
|
-
throw new (0,
|
|
619
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(`${name} must be plain data; received a value referring to itself`);
|
|
580
620
|
}
|
|
581
621
|
if (depth >= MAX_PLAIN_DEPTH) {
|
|
582
|
-
throw new (0,
|
|
622
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
583
623
|
`${name} must be plain data; received a value nested more than ${MAX_PLAIN_DEPTH} levels deep`
|
|
584
624
|
);
|
|
585
625
|
}
|
|
@@ -617,7 +657,7 @@ function samePlain(value, other) {
|
|
|
617
657
|
function copyNote(data) {
|
|
618
658
|
assertDataObject(data, "note data");
|
|
619
659
|
if (!Number.isInteger(data.letter) || data.letter < 0 || data.letter > 6) {
|
|
620
|
-
throw new (0,
|
|
660
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
621
661
|
`note letter must be an integer in [0, 6]; received ${data.letter}`
|
|
622
662
|
);
|
|
623
663
|
}
|
|
@@ -625,7 +665,7 @@ function copyNote(data) {
|
|
|
625
665
|
if (data.octave !== void 0) {
|
|
626
666
|
copy.octave = data.octave;
|
|
627
667
|
}
|
|
628
|
-
|
|
668
|
+
_chunkS3QELJUEcjs.noteToPitchClass.call(void 0, copy);
|
|
629
669
|
return copy;
|
|
630
670
|
}
|
|
631
671
|
var NATURAL_LETTER = /^[A-G]$/;
|
|
@@ -634,11 +674,11 @@ function letterNumberOf(letter) {
|
|
|
634
674
|
return letter;
|
|
635
675
|
}
|
|
636
676
|
if (!NATURAL_LETTER.test(letter)) {
|
|
637
|
-
throw new (0,
|
|
638
|
-
`Note.of takes a letter number 0..6 or a bare letter name 'C'..'B'; received ${
|
|
677
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
678
|
+
`Note.of takes a letter number 0..6 or a bare letter name 'C'..'B'; received ${_chunkS3QELJUEcjs.describeRejected.call(void 0, letter)}. Use Note.parse(${_chunkS3QELJUEcjs.describeRejected.call(void 0, letter)}) to read a note name with an accidental or an octave.`
|
|
639
679
|
);
|
|
640
680
|
}
|
|
641
|
-
return
|
|
681
|
+
return _chunkS3QELJUEcjs.unwrapParse.call(void 0, _chunkS3QELJUEcjs.tryParseNote.call(void 0, letter)).letter;
|
|
642
682
|
}
|
|
643
683
|
var DIMINISHED_SECOND = {
|
|
644
684
|
number: 2,
|
|
@@ -651,7 +691,7 @@ var DESCENDING_DIMINISHED_SECOND = {
|
|
|
651
691
|
descending: true
|
|
652
692
|
};
|
|
653
693
|
function soundingOrder(note) {
|
|
654
|
-
return note.octave === void 0 ?
|
|
694
|
+
return note.octave === void 0 ? _chunkS3QELJUEcjs.noteToPitchClass.call(void 0, note) : _chunkS3QELJUEcjs.noteToMidi.call(void 0, note);
|
|
655
695
|
}
|
|
656
696
|
var Note = class _Note {
|
|
657
697
|
#data;
|
|
@@ -715,7 +755,7 @@ var Note = class _Note {
|
|
|
715
755
|
* ```
|
|
716
756
|
*/
|
|
717
757
|
static parse(text, opts) {
|
|
718
|
-
return
|
|
758
|
+
return _chunkS3QELJUEcjs.unwrapParse.call(void 0, _Note.tryParse(text, opts));
|
|
719
759
|
}
|
|
720
760
|
/**
|
|
721
761
|
* Parse a note name, reporting failure instead of throwing it.
|
|
@@ -736,7 +776,7 @@ var Note = class _Note {
|
|
|
736
776
|
* ```
|
|
737
777
|
*/
|
|
738
778
|
static tryParse(name, opts) {
|
|
739
|
-
const parsed =
|
|
779
|
+
const parsed = _chunkS3QELJUEcjs.tryParseNote.call(void 0, name, opts);
|
|
740
780
|
return parsed.ok ? { ok: true, value: new _Note(parsed.value) } : parsed;
|
|
741
781
|
}
|
|
742
782
|
/**
|
|
@@ -747,7 +787,7 @@ var Note = class _Note {
|
|
|
747
787
|
* @returns The spelled note, with octave.
|
|
748
788
|
*/
|
|
749
789
|
static fromMidi(midi, spelling = "sharp") {
|
|
750
|
-
return new _Note(
|
|
790
|
+
return new _Note(_chunkS3QELJUEcjs.midiToNote.call(void 0, midi, spelling));
|
|
751
791
|
}
|
|
752
792
|
/**
|
|
753
793
|
* Wrap an existing plain note object.
|
|
@@ -764,7 +804,7 @@ var Note = class _Note {
|
|
|
764
804
|
* `'Bb'`. Use {@link Note.format} to write it in another notation system.
|
|
765
805
|
*/
|
|
766
806
|
get name() {
|
|
767
|
-
return
|
|
807
|
+
return _chunkS3QELJUEcjs.formatNote.call(void 0, this.#data);
|
|
768
808
|
}
|
|
769
809
|
/**
|
|
770
810
|
* The note name written in a notation system.
|
|
@@ -783,11 +823,11 @@ var Note = class _Note {
|
|
|
783
823
|
* ```
|
|
784
824
|
*/
|
|
785
825
|
format(opts) {
|
|
786
|
-
return
|
|
826
|
+
return _chunkS3QELJUEcjs.formatNote.call(void 0, this.#data, opts);
|
|
787
827
|
}
|
|
788
828
|
/** The pitch class (0..11), ignoring octave. */
|
|
789
829
|
get pitchClass() {
|
|
790
|
-
return
|
|
830
|
+
return _chunkS3QELJUEcjs.noteToPitchClass.call(void 0, this.#data);
|
|
791
831
|
}
|
|
792
832
|
/**
|
|
793
833
|
* The MIDI number (middle C = C4 = 60).
|
|
@@ -796,9 +836,9 @@ var Note = class _Note {
|
|
|
796
836
|
*/
|
|
797
837
|
get midi() {
|
|
798
838
|
if (this.#data.octave === void 0) {
|
|
799
|
-
throw new (0,
|
|
839
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(`note ${this.name} has no octave, so it has no MIDI number`);
|
|
800
840
|
}
|
|
801
|
-
return
|
|
841
|
+
return _chunkS3QELJUEcjs.noteToMidi.call(void 0, this.#data);
|
|
802
842
|
}
|
|
803
843
|
/** The diatonic letter number: 0..6 for C..B. */
|
|
804
844
|
get letter() {
|
|
@@ -840,7 +880,7 @@ var Note = class _Note {
|
|
|
840
880
|
* ```
|
|
841
881
|
*/
|
|
842
882
|
frequency(tuning) {
|
|
843
|
-
return
|
|
883
|
+
return _chunk3FDBMIPRcjs.frequencyOf.call(void 0, this.midi, tuning);
|
|
844
884
|
}
|
|
845
885
|
/**
|
|
846
886
|
* Transpose by a signed number of semitones, keeping the spelling.
|
|
@@ -866,7 +906,7 @@ var Note = class _Note {
|
|
|
866
906
|
if (semitones === 0 && _optionalChain([opts, 'optionalAccess', _ => _.spelling]) === void 0) {
|
|
867
907
|
return new _Note(this.#data);
|
|
868
908
|
}
|
|
869
|
-
return new _Note(
|
|
909
|
+
return new _Note(_chunkS3QELJUEcjs.transposeNote.call(void 0, this.#data, semitones, opts));
|
|
870
910
|
}
|
|
871
911
|
/**
|
|
872
912
|
* The spelled interval from this note to another.
|
|
@@ -875,7 +915,7 @@ var Note = class _Note {
|
|
|
875
915
|
* @returns The interval, which {@link Interval.toJSON} unwraps to plain data.
|
|
876
916
|
*/
|
|
877
917
|
intervalTo(other) {
|
|
878
|
-
return Interval.fromData(
|
|
918
|
+
return Interval.fromData(_chunkS3QELJUEcjs.spelledInterval.call(void 0, this.#data, other.data));
|
|
879
919
|
}
|
|
880
920
|
/**
|
|
881
921
|
* Transpose by a spelled interval, keeping the spelling the interval names.
|
|
@@ -896,7 +936,7 @@ var Note = class _Note {
|
|
|
896
936
|
* ```
|
|
897
937
|
*/
|
|
898
938
|
transposeBy(interval) {
|
|
899
|
-
return new _Note(
|
|
939
|
+
return new _Note(_chunkS3QELJUEcjs.transposeByInterval.call(void 0, this.#data, _chunkS3QELJUEcjs.toSpelledInterval.call(void 0, interval)));
|
|
900
940
|
}
|
|
901
941
|
/**
|
|
902
942
|
* The same spelled note in another octave.
|
|
@@ -945,7 +985,7 @@ var Note = class _Note {
|
|
|
945
985
|
* ```
|
|
946
986
|
*/
|
|
947
987
|
forInstrument(instrument) {
|
|
948
|
-
return new _Note(
|
|
988
|
+
return new _Note(_chunkU4EQTDGNcjs.toWrittenPitch.call(void 0, this.#data, instrument));
|
|
949
989
|
}
|
|
950
990
|
/**
|
|
951
991
|
* The other ways this note can be spelled: the same sounding pitch written on
|
|
@@ -966,7 +1006,7 @@ var Note = class _Note {
|
|
|
966
1006
|
* ```
|
|
967
1007
|
*/
|
|
968
1008
|
enharmonic() {
|
|
969
|
-
return [DIMINISHED_SECOND, DESCENDING_DIMINISHED_SECOND].map((interval) =>
|
|
1009
|
+
return [DIMINISHED_SECOND, DESCENDING_DIMINISHED_SECOND].map((interval) => _chunkS3QELJUEcjs.transposeByInterval.call(void 0, this.#data, interval)).filter((note) => Math.abs(note.alter) <= _chunkS3QELJUEcjs.MAX_NAME_ACCIDENTALS).map((note) => new _Note(note));
|
|
970
1010
|
}
|
|
971
1011
|
/**
|
|
972
1012
|
* The scale degree this note occupies in a key, counted from 1 at the tonic.
|
|
@@ -987,7 +1027,7 @@ var Note = class _Note {
|
|
|
987
1027
|
* ```
|
|
988
1028
|
*/
|
|
989
1029
|
degreeIn(key) {
|
|
990
|
-
const degree =
|
|
1030
|
+
const degree = _chunkYDGMWH43cjs.pitchToScaleDegree.call(void 0, this.pitchClass, key);
|
|
991
1031
|
return degree === -1 ? null : degree;
|
|
992
1032
|
}
|
|
993
1033
|
/**
|
|
@@ -1065,11 +1105,27 @@ var Note = class _Note {
|
|
|
1065
1105
|
};
|
|
1066
1106
|
|
|
1067
1107
|
// src/model/timeline.ts
|
|
1108
|
+
var KEY_RELATIONS = [
|
|
1109
|
+
"same",
|
|
1110
|
+
"enharmonic",
|
|
1111
|
+
"relative",
|
|
1112
|
+
"parallel",
|
|
1113
|
+
"dominant",
|
|
1114
|
+
"subdominant",
|
|
1115
|
+
"relativeOfDominant",
|
|
1116
|
+
"relativeOfSubdominant"
|
|
1117
|
+
];
|
|
1118
|
+
function assertNumeral(numeral, name) {
|
|
1119
|
+
if (typeof numeral !== "string") {
|
|
1120
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(`${name} must be a string; received ${_chunkS3QELJUEcjs.describeRejected.call(void 0, numeral)}`);
|
|
1121
|
+
}
|
|
1122
|
+
return numeral;
|
|
1123
|
+
}
|
|
1068
1124
|
function copySegment(segment) {
|
|
1069
1125
|
assertDataObject(segment, "timeline segment");
|
|
1070
1126
|
return {
|
|
1071
|
-
startBeat:
|
|
1072
|
-
endBeat:
|
|
1127
|
+
startBeat: _chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, segment.startBeat, "timeline segment startBeat"),
|
|
1128
|
+
endBeat: _chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, segment.endBeat, "timeline segment endBeat"),
|
|
1073
1129
|
// The chord is checked by the same boundary every other chord crosses, so a
|
|
1074
1130
|
// root of 25 or an interval of NaN is refused or reduced here rather than
|
|
1075
1131
|
// surfacing wherever the number is finally used.
|
|
@@ -1079,22 +1135,22 @@ function copySegment(segment) {
|
|
|
1079
1135
|
function copyKeyRegion(region) {
|
|
1080
1136
|
assertDataObject(region, "key region");
|
|
1081
1137
|
const copy = {
|
|
1082
|
-
startBeat:
|
|
1083
|
-
endBeat:
|
|
1138
|
+
startBeat: _chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, region.startBeat, "key region startBeat"),
|
|
1139
|
+
endBeat: _chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, region.endBeat, "key region endBeat"),
|
|
1084
1140
|
// Read through the key itself, so a tonic that does not spell the region's
|
|
1085
1141
|
// own root is refused here rather than spelling later notes wrongly.
|
|
1086
1142
|
key: keyIdentity(toKey(region.key)),
|
|
1087
|
-
confidence:
|
|
1143
|
+
confidence: _chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, region.confidence, "key region confidence")
|
|
1088
1144
|
};
|
|
1089
1145
|
if (region.modulation !== void 0) {
|
|
1090
|
-
copy.modulation = region.modulation;
|
|
1146
|
+
copy.modulation = _chunkS3QELJUEcjs.assertOneOf.call(void 0, region.modulation, KEY_RELATIONS, "key region modulation");
|
|
1091
1147
|
}
|
|
1092
1148
|
if (region.pivot !== void 0) {
|
|
1093
1149
|
assertDataObject(region.pivot, "key region pivot");
|
|
1094
1150
|
copy.pivot = {
|
|
1095
1151
|
chord: new Chord(region.pivot.chord).toJSON(),
|
|
1096
|
-
romanFrom: region.pivot.romanFrom,
|
|
1097
|
-
romanTo: region.pivot.romanTo
|
|
1152
|
+
romanFrom: assertNumeral(region.pivot.romanFrom, "key region pivot romanFrom"),
|
|
1153
|
+
romanTo: assertNumeral(region.pivot.romanTo, "key region pivot romanTo")
|
|
1098
1154
|
};
|
|
1099
1155
|
}
|
|
1100
1156
|
return copy;
|
|
@@ -1105,14 +1161,18 @@ function copyConfidence(confidence, segments) {
|
|
|
1105
1161
|
}
|
|
1106
1162
|
assertDataArray(confidence, "timeline segmentConfidence");
|
|
1107
1163
|
if (confidence.length !== segments) {
|
|
1108
|
-
throw new (0,
|
|
1164
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
1109
1165
|
`timeline segmentConfidence must hold one value per segment; received ${confidence.length} for ${segments}`
|
|
1110
1166
|
);
|
|
1111
1167
|
}
|
|
1112
1168
|
return confidence.map(
|
|
1113
|
-
(value, index) =>
|
|
1169
|
+
(value, index) => _chunkS3QELJUEcjs.assertRange.call(void 0, value, 0, 1, `timeline segmentConfidence[${index}]`)
|
|
1114
1170
|
);
|
|
1115
1171
|
}
|
|
1172
|
+
function validateTimeline(segments, keys) {
|
|
1173
|
+
_chunkLQZQDBCDcjs.assertSpansInOrder.call(void 0, segments, "timeline segments");
|
|
1174
|
+
_chunkLQZQDBCDcjs.assertSpansInOrder.call(void 0, keys, "timeline keys");
|
|
1175
|
+
}
|
|
1116
1176
|
function clipSpan(span, fromBeat, toBeat) {
|
|
1117
1177
|
const startBeat = Math.max(span.startBeat, fromBeat);
|
|
1118
1178
|
const endBeat = Math.min(span.endBeat, toBeat);
|
|
@@ -1128,15 +1188,16 @@ var Timeline = class _Timeline {
|
|
|
1128
1188
|
*
|
|
1129
1189
|
* @param data The segments and the span they cover; copied, never retained.
|
|
1130
1190
|
* @throws If the span, a segment, or a key region carries a number it cannot
|
|
1131
|
-
* hold — a beat that is not finite, a mode mask that names no scale —
|
|
1132
|
-
* the
|
|
1191
|
+
* hold — a beat that is not finite, a mode mask that names no scale — if
|
|
1192
|
+
* the segments or the key regions are not disjoint, in beat order and of
|
|
1193
|
+
* positive length, or if the confidences do not run one per segment.
|
|
1133
1194
|
*/
|
|
1134
1195
|
constructor(data) {
|
|
1135
1196
|
assertDataObject(data, "timeline data");
|
|
1136
1197
|
this.#segments = Object.freeze(
|
|
1137
1198
|
assertDataArray(data.segments, "timeline segments").map(copySegment)
|
|
1138
1199
|
);
|
|
1139
|
-
this.#totalBeats =
|
|
1200
|
+
this.#totalBeats = _chunkS3QELJUEcjs.assertRange.call(void 0,
|
|
1140
1201
|
data.totalBeats,
|
|
1141
1202
|
0,
|
|
1142
1203
|
Number.MAX_SAFE_INTEGER,
|
|
@@ -1148,6 +1209,7 @@ var Timeline = class _Timeline {
|
|
|
1148
1209
|
this.#segmentConfidence = Object.freeze(
|
|
1149
1210
|
copyConfidence(data.segmentConfidence, this.#segments.length)
|
|
1150
1211
|
);
|
|
1212
|
+
validateTimeline(this.#segments, this.#keys);
|
|
1151
1213
|
}
|
|
1152
1214
|
/**
|
|
1153
1215
|
* Build a timeline from placed chords.
|
|
@@ -1155,24 +1217,18 @@ var Timeline = class _Timeline {
|
|
|
1155
1217
|
* @param spans The chords with their onsets, in any order.
|
|
1156
1218
|
* @param totalBeats Where the last chord stops sounding.
|
|
1157
1219
|
* @param key The key the chords are read in, when it is already known. It
|
|
1158
|
-
* becomes the one key region
|
|
1220
|
+
* becomes the one key region from the first chord to the end of the span;
|
|
1221
|
+
* without it, or without a chord for it to be in force over, the timeline
|
|
1159
1222
|
* carries no key, and the members that need one say so.
|
|
1160
1223
|
* @returns The timeline.
|
|
1161
1224
|
*/
|
|
1162
1225
|
static fromChords(spans, totalBeats, key) {
|
|
1163
|
-
const timeline =
|
|
1226
|
+
const timeline = _chunkLQZQDBCDcjs.chordTimelineFromChords.call(void 0, spans, totalBeats);
|
|
1164
1227
|
const data = { segments: timeline.segments, totalBeats };
|
|
1165
1228
|
if (key !== void 0) {
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
// so a chord placed in a pickup is covered by the key it sounds in.
|
|
1170
|
-
startBeat: _nullishCoalesce(_optionalChain([timeline, 'access', _2 => _2.segments, 'access', _3 => _3[0], 'optionalAccess', _4 => _4.startBeat]), () => ( 0)),
|
|
1171
|
-
endBeat: totalBeats,
|
|
1172
|
-
key: keyIdentity(toKey(key)),
|
|
1173
|
-
confidence: STATED_KEY_CONFIDENCE
|
|
1174
|
-
}
|
|
1175
|
-
];
|
|
1229
|
+
const stated = keyIdentity(toKey(key));
|
|
1230
|
+
const first = timeline.segments[0];
|
|
1231
|
+
data.keys = first === void 0 ? [] : _chunkLQZQDBCDcjs.statedKeyRegions.call(void 0, stated, first.startBeat, totalBeats);
|
|
1176
1232
|
}
|
|
1177
1233
|
return new _Timeline(data);
|
|
1178
1234
|
}
|
|
@@ -1184,8 +1240,8 @@ var Timeline = class _Timeline {
|
|
|
1184
1240
|
* @returns The inferred timeline, carrying the key regions the analysis found.
|
|
1185
1241
|
*/
|
|
1186
1242
|
static fromNotes(notes, opts) {
|
|
1187
|
-
const { timeline, keys, segmentConfidence } =
|
|
1188
|
-
const totalBeats = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
1243
|
+
const { timeline, keys, segmentConfidence } = _chunkLQZQDBCDcjs.chordTimelineFromNotes.call(void 0, notes, opts);
|
|
1244
|
+
const totalBeats = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _2 => _2.totalBeats]), () => ( spanEnd(timeline.segments, keys)));
|
|
1189
1245
|
return new _Timeline({ segments: timeline.segments, totalBeats, keys, segmentConfidence });
|
|
1190
1246
|
}
|
|
1191
1247
|
/**
|
|
@@ -1203,11 +1259,25 @@ var Timeline = class _Timeline {
|
|
|
1203
1259
|
* @throws If `beatsEach` is not a positive finite number of beats.
|
|
1204
1260
|
*/
|
|
1205
1261
|
static fromProgression(progression, beatsEach) {
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1262
|
+
const read = progression;
|
|
1263
|
+
if (typeof read !== "object" || read === null || !Array.isArray(read.chords)) {
|
|
1264
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
1265
|
+
`timeline progression must be a Progression; received ${_chunkS3QELJUEcjs.describeRejected.call(void 0, progression)}`
|
|
1266
|
+
);
|
|
1267
|
+
}
|
|
1268
|
+
_chunkS3QELJUEcjs.assertRange.call(void 0, beatsEach, Number.MIN_VALUE, Number.MAX_SAFE_INTEGER, "timeline beatsEach");
|
|
1269
|
+
const chords = read.chords;
|
|
1270
|
+
const spans = chords.map((chord, index) => {
|
|
1271
|
+
const data = _optionalChain([chord, 'optionalAccess', _3 => _3.data]);
|
|
1272
|
+
if (typeof data !== "object" || data === null) {
|
|
1273
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
1274
|
+
`timeline progression chords[${index}] must be a Chord; received ${_chunkS3QELJUEcjs.describeRejected.call(void 0, chord)}`
|
|
1275
|
+
);
|
|
1276
|
+
}
|
|
1277
|
+
return _chunkYDGMWH43cjs.spanFromChord.call(void 0, data, index * beatsEach);
|
|
1278
|
+
});
|
|
1209
1279
|
const totalBeats = chords.length * beatsEach;
|
|
1210
|
-
const key =
|
|
1280
|
+
const key = read.key;
|
|
1211
1281
|
return key === void 0 ? _Timeline.fromChords(spans, totalBeats) : _Timeline.fromChords(spans, totalBeats, key);
|
|
1212
1282
|
}
|
|
1213
1283
|
/** Rebuild a timeline from the plain data {@link Timeline.data} hands out. */
|
|
@@ -1231,7 +1301,7 @@ var Timeline = class _Timeline {
|
|
|
1231
1301
|
* @throws If `beat` is not finite.
|
|
1232
1302
|
*/
|
|
1233
1303
|
at(beat) {
|
|
1234
|
-
const chord =
|
|
1304
|
+
const chord = _chunkLQZQDBCDcjs.chordAtBeat.call(void 0, this.#segments, beat);
|
|
1235
1305
|
if (chord === null) {
|
|
1236
1306
|
return null;
|
|
1237
1307
|
}
|
|
@@ -1248,7 +1318,7 @@ var Timeline = class _Timeline {
|
|
|
1248
1318
|
}
|
|
1249
1319
|
/** The key held longest across the span, when the analysis found one. */
|
|
1250
1320
|
get key() {
|
|
1251
|
-
const prevailing =
|
|
1321
|
+
const prevailing = _chunkLQZQDBCDcjs.prevailingKeyOf.call(void 0, this.#keys);
|
|
1252
1322
|
return prevailing === null ? void 0 : toKey(prevailing);
|
|
1253
1323
|
}
|
|
1254
1324
|
/**
|
|
@@ -1320,7 +1390,7 @@ var Timeline = class _Timeline {
|
|
|
1320
1390
|
* @throws If the timeline carries no key region to read the chords against.
|
|
1321
1391
|
*/
|
|
1322
1392
|
reduce(opts) {
|
|
1323
|
-
return
|
|
1393
|
+
return _chunkLQZQDBCDcjs.reduceProgression.call(void 0, this.chordTimeline, this.#keyContext(), opts);
|
|
1324
1394
|
}
|
|
1325
1395
|
/**
|
|
1326
1396
|
* The cadences the harmony arrives at.
|
|
@@ -1333,7 +1403,7 @@ var Timeline = class _Timeline {
|
|
|
1333
1403
|
* @throws If the timeline carries no key region to read the chords against.
|
|
1334
1404
|
*/
|
|
1335
1405
|
cadences() {
|
|
1336
|
-
return
|
|
1406
|
+
return _chunkLQZQDBCDcjs.detectCadences.call(void 0, this.chordTimeline, this.#keyContext());
|
|
1337
1407
|
}
|
|
1338
1408
|
/**
|
|
1339
1409
|
* The keys the chords themselves imply, in time order.
|
|
@@ -1362,7 +1432,7 @@ var Timeline = class _Timeline {
|
|
|
1362
1432
|
* ```
|
|
1363
1433
|
*/
|
|
1364
1434
|
modulations(opts) {
|
|
1365
|
-
return
|
|
1435
|
+
return _chunkLQZQDBCDcjs.detectModulations.call(void 0, this.#copySegments(), {
|
|
1366
1436
|
totalBeats: this.#totalBeats,
|
|
1367
1437
|
...opts
|
|
1368
1438
|
}).map(copyKeyRegion);
|
|
@@ -1380,12 +1450,12 @@ var Timeline = class _Timeline {
|
|
|
1380
1450
|
*/
|
|
1381
1451
|
roman(key, opts) {
|
|
1382
1452
|
assertKeyArgument(key, "timeline key");
|
|
1383
|
-
const given = key === void 0 ? void 0 :
|
|
1453
|
+
const given = key === void 0 ? void 0 : _chunkYDGMWH43cjs.resolveKey.call(void 0, key);
|
|
1384
1454
|
const keyAt = given === void 0 ? this.#resolvedKeyAt() : () => given;
|
|
1385
1455
|
return this.#segments.map((segment) => ({
|
|
1386
1456
|
startBeat: segment.startBeat,
|
|
1387
1457
|
endBeat: segment.endBeat,
|
|
1388
|
-
roman:
|
|
1458
|
+
roman: _chunkLQZQDBCDcjs.chordToRoman.call(void 0, segment.chord, keyAt(segment.startBeat), opts)
|
|
1389
1459
|
}));
|
|
1390
1460
|
}
|
|
1391
1461
|
/**
|
|
@@ -1402,10 +1472,10 @@ var Timeline = class _Timeline {
|
|
|
1402
1472
|
* @throws If either beat is not finite, or `toBeat` precedes `fromBeat`.
|
|
1403
1473
|
*/
|
|
1404
1474
|
slice(fromBeat, toBeat) {
|
|
1405
|
-
|
|
1406
|
-
|
|
1475
|
+
_chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, fromBeat, "timeline slice fromBeat");
|
|
1476
|
+
_chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, toBeat, "timeline slice toBeat");
|
|
1407
1477
|
if (toBeat < fromBeat) {
|
|
1408
|
-
throw new (0,
|
|
1478
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
1409
1479
|
`timeline slice toBeat must not precede fromBeat; received [${fromBeat}, ${toBeat})`
|
|
1410
1480
|
);
|
|
1411
1481
|
}
|
|
@@ -1500,7 +1570,7 @@ var Timeline = class _Timeline {
|
|
|
1500
1570
|
/** The `{ at, segments }` shape the analysis functions take. */
|
|
1501
1571
|
get chordTimeline() {
|
|
1502
1572
|
const segments = this.#copySegments();
|
|
1503
|
-
return { at: (beat) =>
|
|
1573
|
+
return { at: (beat) => _chunkLQZQDBCDcjs.chordAtBeat.call(void 0, segments, beat), segments };
|
|
1504
1574
|
}
|
|
1505
1575
|
/** A fresh copy of the segments, which is what every reader is handed. */
|
|
1506
1576
|
#copySegments() {
|
|
@@ -1508,8 +1578,8 @@ var Timeline = class _Timeline {
|
|
|
1508
1578
|
}
|
|
1509
1579
|
/** The key in force at a beat, or undefined when the timeline knows none. */
|
|
1510
1580
|
#keyAt(beat) {
|
|
1511
|
-
const prevailing =
|
|
1512
|
-
return prevailing === null ? void 0 : toKey(
|
|
1581
|
+
const prevailing = _chunkLQZQDBCDcjs.prevailingKeyOf.call(void 0, this.#keys);
|
|
1582
|
+
return prevailing === null ? void 0 : toKey(_chunkLQZQDBCDcjs.keyLookup.call(void 0, this.#keys, prevailing)(beat));
|
|
1513
1583
|
}
|
|
1514
1584
|
/**
|
|
1515
1585
|
* The key every beat of the timeline is read against, spelling and all.
|
|
@@ -1522,13 +1592,13 @@ var Timeline = class _Timeline {
|
|
|
1522
1592
|
* would number it as the G# minor those read best as.
|
|
1523
1593
|
*/
|
|
1524
1594
|
#resolvedKeyAt() {
|
|
1525
|
-
const prevailing =
|
|
1595
|
+
const prevailing = _chunkLQZQDBCDcjs.prevailingKeyOf.call(void 0, this.#keys);
|
|
1526
1596
|
if (prevailing === null) {
|
|
1527
|
-
throw new (0,
|
|
1597
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
1528
1598
|
"timeline carries no key; build it from notes, or pass a key to Timeline.fromChords"
|
|
1529
1599
|
);
|
|
1530
1600
|
}
|
|
1531
|
-
return
|
|
1601
|
+
return _chunkLQZQDBCDcjs.keyLookup.call(void 0, this.#keys, prevailing);
|
|
1532
1602
|
}
|
|
1533
1603
|
/**
|
|
1534
1604
|
* The pitch classes of that key, for the readings that want them.
|
|
@@ -1540,7 +1610,7 @@ var Timeline = class _Timeline {
|
|
|
1540
1610
|
*/
|
|
1541
1611
|
#keyContext() {
|
|
1542
1612
|
const keyAt = this.#resolvedKeyAt();
|
|
1543
|
-
return (beat) =>
|
|
1613
|
+
return (beat) => _chunkYDGMWH43cjs.scaleOf.call(void 0, keyAt(beat));
|
|
1544
1614
|
}
|
|
1545
1615
|
/** Move every chord and every key region by the same step. */
|
|
1546
1616
|
#moved(moveChord, moveKey) {
|
|
@@ -1599,7 +1669,14 @@ var Progression = class _Progression {
|
|
|
1599
1669
|
*/
|
|
1600
1670
|
static #attachKey(chords, key) {
|
|
1601
1671
|
const given = assertDataObjects(chords, "progression chords");
|
|
1602
|
-
return
|
|
1672
|
+
return given.map((chord, index) => {
|
|
1673
|
+
if (typeof chord.toJSON !== "function") {
|
|
1674
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
1675
|
+
`progression chords[${index}] must be a Chord; received ${_chunkS3QELJUEcjs.describeRejected.call(void 0, chord)}`
|
|
1676
|
+
);
|
|
1677
|
+
}
|
|
1678
|
+
return new Chord(chord.toJSON(), _nullishCoalesce(key, () => ( chord.key)));
|
|
1679
|
+
});
|
|
1603
1680
|
}
|
|
1604
1681
|
/**
|
|
1605
1682
|
* Start from a chord sequence, matching the `of` factory on the other
|
|
@@ -1642,24 +1719,39 @@ var Progression = class _Progression {
|
|
|
1642
1719
|
*/
|
|
1643
1720
|
static fromSpans(spans, key) {
|
|
1644
1721
|
const chords = assertDataObjects(spans, "progression spans").map(
|
|
1645
|
-
(span) => Chord.fromData(
|
|
1722
|
+
(span) => Chord.fromData(_chunkYDGMWH43cjs.chordFromSpan.call(void 0, span))
|
|
1646
1723
|
);
|
|
1647
1724
|
return new _Progression(chords, key);
|
|
1648
1725
|
}
|
|
1649
1726
|
/**
|
|
1650
|
-
* Rebuild a progression from its {@link Progression.toJSON} output
|
|
1727
|
+
* Rebuild a progression from its {@link Progression.toJSON} output, with the
|
|
1728
|
+
* carried key or, without one, each chord's own key.
|
|
1651
1729
|
*
|
|
1652
|
-
* @param data The serialized chords and
|
|
1730
|
+
* @param data The serialized chords and keys.
|
|
1653
1731
|
* @returns The progression.
|
|
1732
|
+
* @throws If `chordKeys` does not hold one entry per chord.
|
|
1654
1733
|
*/
|
|
1655
1734
|
static fromJSON(data) {
|
|
1656
1735
|
assertDataObject(data, "progression data");
|
|
1657
1736
|
const key = data.key === void 0 ? void 0 : Key.fromJSON(data.key);
|
|
1658
|
-
const
|
|
1659
|
-
|
|
1660
|
-
)
|
|
1737
|
+
const given = assertDataArray(data.chords, "progression chords");
|
|
1738
|
+
const chordKeys = key === void 0 && data.chordKeys !== void 0 ? _Progression.#readChordKeys(data.chordKeys, given.length) : void 0;
|
|
1739
|
+
const chords = given.map((chord, index) => {
|
|
1740
|
+
const own = _optionalChain([chordKeys, 'optionalAccess', _4 => _4[index]]);
|
|
1741
|
+
return own === void 0 ? Chord.fromJSON(chord) : Chord.fromJSON(chord).withKey(own);
|
|
1742
|
+
});
|
|
1661
1743
|
return key === void 0 ? new _Progression(chords) : new _Progression(chords, key);
|
|
1662
1744
|
}
|
|
1745
|
+
/** Read the per-chord keys of {@link ProgressionData}, one entry per chord. */
|
|
1746
|
+
static #readChordKeys(value, count) {
|
|
1747
|
+
const entries = assertDataArray(value, "progression chord keys");
|
|
1748
|
+
if (entries.length !== count) {
|
|
1749
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
1750
|
+
`progression chord keys must hold one entry per chord (${count}); received ${entries.length}`
|
|
1751
|
+
);
|
|
1752
|
+
}
|
|
1753
|
+
return entries.map((entry) => entry === null ? void 0 : Key.fromJSON(entry));
|
|
1754
|
+
}
|
|
1663
1755
|
/**
|
|
1664
1756
|
* Wrap plain progression data, matching the `fromData` factory on the other
|
|
1665
1757
|
* classes.
|
|
@@ -1869,11 +1961,9 @@ var Progression = class _Progression {
|
|
|
1869
1961
|
* @throws If any chord admits no voicing within the given ranges.
|
|
1870
1962
|
*/
|
|
1871
1963
|
voice(opts) {
|
|
1872
|
-
const key = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
key === void 0 ? opts : { ...opts, key }
|
|
1876
|
-
);
|
|
1964
|
+
const key = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _5 => _5.key]), () => ( this.#key));
|
|
1965
|
+
const views = _optionalChain([opts, 'optionalAccess', _6 => _6.key]) === void 0 ? this.#chords.map((chord) => chord.data) : this.#viewsIn(toKey(opts.key));
|
|
1966
|
+
return _chunkU4EQTDGNcjs.voiceProgression.call(void 0, views, key === void 0 ? opts : { ...opts, key });
|
|
1877
1967
|
}
|
|
1878
1968
|
/**
|
|
1879
1969
|
* The Roman numeral of each chord in a key.
|
|
@@ -1934,12 +2024,13 @@ var Progression = class _Progression {
|
|
|
1934
2024
|
const resolved = this.#resolveKey(key);
|
|
1935
2025
|
const chords = this.#chords.map((chord) => chord.analyze(resolved, opts));
|
|
1936
2026
|
const { voicing, ...cadenceOpts } = _nullishCoalesce(opts, () => ( {}));
|
|
1937
|
-
const
|
|
1938
|
-
const
|
|
1939
|
-
const
|
|
1940
|
-
const
|
|
2027
|
+
const views = this.#viewsIn(resolved);
|
|
2028
|
+
const from = views[views.length - 2];
|
|
2029
|
+
const to = views[views.length - 1];
|
|
2030
|
+
const approach = views[views.length - 3];
|
|
2031
|
+
const cadence = from !== void 0 && to !== void 0 ? _chunkLQZQDBCDcjs.detectCadence.call(void 0, from, to, resolved, {
|
|
1941
2032
|
...cadenceOpts,
|
|
1942
|
-
...approach === void 0 ? {} : { approach
|
|
2033
|
+
...approach === void 0 ? {} : { approach },
|
|
1943
2034
|
...voicing === void 0 ? {} : { voicing: this.#closingVoicing(voicing) }
|
|
1944
2035
|
}) : null;
|
|
1945
2036
|
return { chords, cadence };
|
|
@@ -1957,7 +2048,7 @@ var Progression = class _Progression {
|
|
|
1957
2048
|
if (voicing.length === this.#chords.length || voicing.length === 2) {
|
|
1958
2049
|
return [_nullishCoalesce(voicing[voicing.length - 2], () => ( [])), _nullishCoalesce(voicing[voicing.length - 1], () => ( []))];
|
|
1959
2050
|
}
|
|
1960
|
-
throw new (0,
|
|
2051
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
1961
2052
|
`voicing must hold one voicing per chord (${this.#chords.length}) or the closing pair; received ${voicing.length}`
|
|
1962
2053
|
);
|
|
1963
2054
|
}
|
|
@@ -1967,7 +2058,7 @@ var Progression = class _Progression {
|
|
|
1967
2058
|
* @returns One scale choice per chord in this progression.
|
|
1968
2059
|
*/
|
|
1969
2060
|
scales() {
|
|
1970
|
-
return
|
|
2061
|
+
return _chunkP3CPXAJ5cjs.scalesForChanges.call(void 0, this.#chords.map((chord) => chord.data));
|
|
1971
2062
|
}
|
|
1972
2063
|
/**
|
|
1973
2064
|
* Classify the motion at every chord change, not only the closing one.
|
|
@@ -2004,18 +2095,19 @@ var Progression = class _Progression {
|
|
|
2004
2095
|
*/
|
|
2005
2096
|
cadences(key, opts) {
|
|
2006
2097
|
const resolved = this.#resolveKey(key);
|
|
2098
|
+
const views = this.#viewsIn(resolved);
|
|
2007
2099
|
const found = [];
|
|
2008
|
-
for (let index = 1; index <
|
|
2009
|
-
const from =
|
|
2010
|
-
const to =
|
|
2100
|
+
for (let index = 1; index < views.length; index += 1) {
|
|
2101
|
+
const from = views[index - 1];
|
|
2102
|
+
const to = views[index];
|
|
2011
2103
|
if (from === void 0 || to === void 0) {
|
|
2012
2104
|
continue;
|
|
2013
2105
|
}
|
|
2014
|
-
const approach = index >= 2 ?
|
|
2015
|
-
const pair = _optionalChain([opts, 'optionalAccess',
|
|
2106
|
+
const approach = index >= 2 ? views[index - 2] : _optionalChain([opts, 'optionalAccess', _7 => _7.approach]);
|
|
2107
|
+
const pair = _optionalChain([opts, 'optionalAccess', _8 => _8.voicing]);
|
|
2016
2108
|
found.push(
|
|
2017
|
-
|
|
2018
|
-
..._optionalChain([opts, 'optionalAccess',
|
|
2109
|
+
_chunkLQZQDBCDcjs.detectCadence.call(void 0, from, to, resolved, {
|
|
2110
|
+
..._optionalChain([opts, 'optionalAccess', _9 => _9.alternatives]) === void 0 ? {} : { alternatives: opts.alternatives },
|
|
2019
2111
|
...approach === void 0 ? {} : { approach },
|
|
2020
2112
|
...pair === void 0 ? {} : { voicing: [_nullishCoalesce(pair[index - 1], () => ( [])), _nullishCoalesce(pair[index], () => ( []))] }
|
|
2021
2113
|
})
|
|
@@ -2051,16 +2143,16 @@ var Progression = class _Progression {
|
|
|
2051
2143
|
const position = index < 0 ? this.#chords.length + index : index;
|
|
2052
2144
|
const target = this.#chords[position];
|
|
2053
2145
|
if (target === void 0) {
|
|
2054
|
-
throw new (0,
|
|
2146
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
2055
2147
|
`progression has no chord at index ${index}; it holds ${this.#chords.length}`
|
|
2056
2148
|
);
|
|
2057
2149
|
}
|
|
2058
2150
|
const key = this.#resolveKey();
|
|
2059
|
-
const chosen =
|
|
2151
|
+
const chosen = _chunk6TTBEON3cjs.substituteChord.call(void 0, target.data, key, opts).find(
|
|
2060
2152
|
(candidate) => candidate.type === type
|
|
2061
2153
|
);
|
|
2062
2154
|
if (chosen === void 0) {
|
|
2063
|
-
throw new (0,
|
|
2155
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
2064
2156
|
`no ${type} substitution for ${target.symbol()} in ${key.toString()}`
|
|
2065
2157
|
);
|
|
2066
2158
|
}
|
|
@@ -2102,7 +2194,7 @@ var Progression = class _Progression {
|
|
|
2102
2194
|
* ```
|
|
2103
2195
|
*/
|
|
2104
2196
|
transpose(semitones) {
|
|
2105
|
-
const key = _optionalChain([this, 'access',
|
|
2197
|
+
const key = _optionalChain([this, 'access', _10 => _10.#key, 'optionalAccess', _11 => _11.transpose, 'call', _12 => _12(semitones)]);
|
|
2106
2198
|
const chords = this.#chords.map((chord) => chord.transpose(semitones));
|
|
2107
2199
|
return new _Progression(chords, key);
|
|
2108
2200
|
}
|
|
@@ -2125,7 +2217,7 @@ var Progression = class _Progression {
|
|
|
2125
2217
|
* ```
|
|
2126
2218
|
*/
|
|
2127
2219
|
transposeBy(interval) {
|
|
2128
|
-
const key = _optionalChain([this, 'access',
|
|
2220
|
+
const key = _optionalChain([this, 'access', _13 => _13.#key, 'optionalAccess', _14 => _14.transposeBy, 'call', _15 => _15(interval)]);
|
|
2129
2221
|
const chords = this.#chords.map((chord) => chord.transposeBy(interval));
|
|
2130
2222
|
return new _Progression(chords, key);
|
|
2131
2223
|
}
|
|
@@ -2153,7 +2245,7 @@ var Progression = class _Progression {
|
|
|
2153
2245
|
transposeTo(target) {
|
|
2154
2246
|
const from = this.#key;
|
|
2155
2247
|
if (from === void 0) {
|
|
2156
|
-
throw new (0,
|
|
2248
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
2157
2249
|
"progression has no key context; attach one with withKey() before transposing to another key"
|
|
2158
2250
|
);
|
|
2159
2251
|
}
|
|
@@ -2175,16 +2267,26 @@ var Progression = class _Progression {
|
|
|
2175
2267
|
/**
|
|
2176
2268
|
* The plain progression data, for JSON serialization.
|
|
2177
2269
|
*
|
|
2178
|
-
* Private class fields do not serialize, so this preserves
|
|
2179
|
-
*
|
|
2270
|
+
* Private class fields do not serialize, so this preserves the chord data,
|
|
2271
|
+
* any carried key, and — for a progression with no key of its own — each
|
|
2272
|
+
* chord's own key in `JSON.stringify(progression)`.
|
|
2180
2273
|
*
|
|
2181
|
-
* @returns The chord data sequence
|
|
2274
|
+
* @returns The chord data sequence, the carried key, if any, and the
|
|
2275
|
+
* per-chord keys when they are what spells the chords.
|
|
2182
2276
|
*/
|
|
2183
2277
|
toJSON() {
|
|
2184
|
-
|
|
2278
|
+
const out = {
|
|
2185
2279
|
chords: this.#chords.map((chord) => chord.toJSON()),
|
|
2186
|
-
key: _optionalChain([this, 'access',
|
|
2280
|
+
key: _optionalChain([this, 'access', _16 => _16.#key, 'optionalAccess', _17 => _17.toJSON, 'call', _18 => _18()])
|
|
2187
2281
|
};
|
|
2282
|
+
if (this.#key === void 0 && this.#chords.some((chord) => chord.key !== void 0)) {
|
|
2283
|
+
out.chordKeys = this.#chords.map((chord) => _nullishCoalesce(_optionalChain([chord, 'access', _19 => _19.key, 'optionalAccess', _20 => _20.toJSON, 'call', _21 => _21()]), () => ( null)));
|
|
2284
|
+
}
|
|
2285
|
+
return out;
|
|
2286
|
+
}
|
|
2287
|
+
/** The members read in `key`: spellings the caller gave, the rest derived from it. */
|
|
2288
|
+
#viewsIn(key) {
|
|
2289
|
+
return this.#chords.map((chord) => chord.withKey(key).data);
|
|
2188
2290
|
}
|
|
2189
2291
|
/**
|
|
2190
2292
|
* Resolve the key for an analysis method: explicit first, then carried.
|
|
@@ -2196,7 +2298,7 @@ var Progression = class _Progression {
|
|
|
2196
2298
|
assertKeyArgument(key, "progression key");
|
|
2197
2299
|
const resolved = key === void 0 ? this.#key : toKey(key);
|
|
2198
2300
|
if (resolved === void 0) {
|
|
2199
|
-
throw new (0,
|
|
2301
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
2200
2302
|
"progression has no key context; pass a Key or attach one with withKey()"
|
|
2201
2303
|
);
|
|
2202
2304
|
}
|
|
@@ -2206,25 +2308,25 @@ var Progression = class _Progression {
|
|
|
2206
2308
|
|
|
2207
2309
|
// src/model/chord.ts
|
|
2208
2310
|
function hintMatches(hint, pc) {
|
|
2209
|
-
return hint !== void 0 && pc !== void 0 &&
|
|
2311
|
+
return hint !== void 0 && pc !== void 0 && _chunkS3QELJUEcjs.pitchClassOf.call(void 0, _chunkS3QELJUEcjs.noteToPitchClass.call(void 0, hint)) === _chunkS3QELJUEcjs.pitchClassOf.call(void 0, pc);
|
|
2210
2312
|
}
|
|
2211
2313
|
function transposeHintByInterval(hint, interval) {
|
|
2212
2314
|
if (hint === void 0) {
|
|
2213
2315
|
return void 0;
|
|
2214
2316
|
}
|
|
2215
|
-
const moved =
|
|
2317
|
+
const moved = _chunkS3QELJUEcjs.transposeByInterval.call(void 0, hint, interval);
|
|
2216
2318
|
return { letter: moved.letter, alter: moved.alter };
|
|
2217
2319
|
}
|
|
2218
2320
|
function transposeToneHintsByInterval(hints, interval) {
|
|
2219
2321
|
return _optionalChain([hints, 'optionalAccess', _22 => _22.map, 'call', _23 => _23((hint) => {
|
|
2220
|
-
const moved =
|
|
2322
|
+
const moved = _chunkS3QELJUEcjs.transposeByInterval.call(void 0, hint, interval);
|
|
2221
2323
|
return { letter: moved.letter, alter: moved.alter };
|
|
2222
2324
|
})]);
|
|
2223
2325
|
}
|
|
2224
2326
|
function copyChord(data) {
|
|
2225
2327
|
assertDataObject(data, "chord data");
|
|
2226
|
-
|
|
2227
|
-
const rootPc =
|
|
2328
|
+
_chunkYDGMWH43cjs.assertChordQuality.call(void 0, data.quality);
|
|
2329
|
+
const rootPc = _chunkS3QELJUEcjs.pitchClassOf.call(void 0, data.rootPc);
|
|
2228
2330
|
const copy = {
|
|
2229
2331
|
rootPc,
|
|
2230
2332
|
quality: data.quality,
|
|
@@ -2232,14 +2334,14 @@ function copyChord(data) {
|
|
|
2232
2334
|
// interval voices, spells and formats as a chord that looks real, and the
|
|
2233
2335
|
// failure surfaces wherever the number is finally used.
|
|
2234
2336
|
intervals: assertDataArray(data.intervals, "chord intervals").map(
|
|
2235
|
-
(interval, index) =>
|
|
2337
|
+
(interval, index) => _chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, interval, `chord intervals[${index}]`)
|
|
2236
2338
|
)
|
|
2237
2339
|
};
|
|
2238
|
-
const bassPc = data.bassPc === void 0 ? void 0 :
|
|
2340
|
+
const bassPc = data.bassPc === void 0 ? void 0 : _chunkS3QELJUEcjs.pitchClassOf.call(void 0, data.bassPc);
|
|
2239
2341
|
if (bassPc !== void 0 && bassPc !== rootPc) {
|
|
2240
2342
|
copy.bassPc = bassPc;
|
|
2241
2343
|
}
|
|
2242
|
-
const tones =
|
|
2344
|
+
const tones = _chunkYDGMWH43cjs.chordToneSpellings.call(void 0, data);
|
|
2243
2345
|
if (tones !== void 0) {
|
|
2244
2346
|
copy.toneSpellings = tones;
|
|
2245
2347
|
}
|
|
@@ -2258,8 +2360,8 @@ function deriveBassSpelling(chord, key) {
|
|
|
2258
2360
|
}
|
|
2259
2361
|
const root = chord.rootSpelling;
|
|
2260
2362
|
if (root !== void 0) {
|
|
2261
|
-
const index = chord.intervals.findIndex((i) =>
|
|
2262
|
-
const tone = index >= 0 ?
|
|
2363
|
+
const index = chord.intervals.findIndex((i) => _chunkS3QELJUEcjs.pitchClassOf.call(void 0, chord.rootPc + i) === bassPc);
|
|
2364
|
+
const tone = index >= 0 ? _chunkYDGMWH43cjs.spellChordFromRoot.call(void 0, chord, root)[index] : void 0;
|
|
2263
2365
|
if (tone !== void 0) {
|
|
2264
2366
|
return { letter: tone.letter, alter: tone.alter };
|
|
2265
2367
|
}
|
|
@@ -2267,7 +2369,7 @@ function deriveBassSpelling(chord, key) {
|
|
|
2267
2369
|
if (key === void 0) {
|
|
2268
2370
|
return void 0;
|
|
2269
2371
|
}
|
|
2270
|
-
const spelled =
|
|
2372
|
+
const spelled = _chunkYDGMWH43cjs.spellPitchClass.call(void 0, bassPc, key.tonic.data, key);
|
|
2271
2373
|
return { letter: spelled.letter, alter: spelled.alter };
|
|
2272
2374
|
}
|
|
2273
2375
|
var Chord = class _Chord {
|
|
@@ -2300,7 +2402,7 @@ var Chord = class _Chord {
|
|
|
2300
2402
|
#dataWithKey(key) {
|
|
2301
2403
|
const out = copyChord(this.#given);
|
|
2302
2404
|
if (out.rootSpelling === void 0 && key !== void 0) {
|
|
2303
|
-
out.rootSpelling =
|
|
2405
|
+
out.rootSpelling = _chunkYDGMWH43cjs.spellPitchClass.call(void 0, out.rootPc, key.tonic.data, key);
|
|
2304
2406
|
}
|
|
2305
2407
|
if (out.bassSpelling === void 0) {
|
|
2306
2408
|
const bass = deriveBassSpelling(out, key);
|
|
@@ -2323,7 +2425,7 @@ var Chord = class _Chord {
|
|
|
2323
2425
|
const bassNote = typeof bass === "string" ? Note.parse(bass) : void 0;
|
|
2324
2426
|
const bassPc = bassNote !== void 0 ? bassNote.pitchClass : bass;
|
|
2325
2427
|
const rootNote = typeof root === "string" ? Note.parse(root) : void 0;
|
|
2326
|
-
const data =
|
|
2428
|
+
const data = _chunkYDGMWH43cjs.makeChord.call(void 0,
|
|
2327
2429
|
rootNote !== void 0 ? rootNote.pitchClass : root,
|
|
2328
2430
|
quality,
|
|
2329
2431
|
bassPc
|
|
@@ -2389,7 +2491,7 @@ var Chord = class _Chord {
|
|
|
2389
2491
|
* ```
|
|
2390
2492
|
*/
|
|
2391
2493
|
static fromFiguredBass(bass, figures, key) {
|
|
2392
|
-
return new _Chord(
|
|
2494
|
+
return new _Chord(_chunkU4EQTDGNcjs.realizeFiguredBass.call(void 0, _chunkS3QELJUEcjs.toNoteData.call(void 0, bass), figures, key));
|
|
2393
2495
|
}
|
|
2394
2496
|
/**
|
|
2395
2497
|
* Parse a lead-sheet chord symbol (e.g. `'Cmaj7'`, `'F#m7b5'`, `'C/G'`).
|
|
@@ -2412,7 +2514,7 @@ var Chord = class _Chord {
|
|
|
2412
2514
|
* ```
|
|
2413
2515
|
*/
|
|
2414
2516
|
static parse(symbol, opts) {
|
|
2415
|
-
return
|
|
2517
|
+
return _chunkS3QELJUEcjs.unwrapParse.call(void 0, _Chord.tryParse(symbol, opts));
|
|
2416
2518
|
}
|
|
2417
2519
|
/**
|
|
2418
2520
|
* Parse a lead-sheet chord symbol, reporting failure instead of throwing it.
|
|
@@ -2435,7 +2537,7 @@ var Chord = class _Chord {
|
|
|
2435
2537
|
* ```
|
|
2436
2538
|
*/
|
|
2437
2539
|
static tryParse(symbol, opts) {
|
|
2438
|
-
const parsed =
|
|
2540
|
+
const parsed = _chunkYDGMWH43cjs.tryParseChordSymbol.call(void 0, symbol, opts);
|
|
2439
2541
|
return parsed.ok ? { ok: true, value: new _Chord(parsed.value) } : parsed;
|
|
2440
2542
|
}
|
|
2441
2543
|
/**
|
|
@@ -2446,8 +2548,8 @@ var Chord = class _Chord {
|
|
|
2446
2548
|
* @returns Ranked chord interpretations (may be empty).
|
|
2447
2549
|
*/
|
|
2448
2550
|
static detect(pitches, opts) {
|
|
2449
|
-
return
|
|
2450
|
-
(match) => new _Chord(
|
|
2551
|
+
return _chunkLQZQDBCDcjs.detectChord.call(void 0, pitches, opts).map(
|
|
2552
|
+
(match) => new _Chord(_chunkYDGMWH43cjs.makeChord.call(void 0, match.rootPc, match.quality, match.bassPc))
|
|
2451
2553
|
);
|
|
2452
2554
|
}
|
|
2453
2555
|
/**
|
|
@@ -2469,8 +2571,8 @@ var Chord = class _Chord {
|
|
|
2469
2571
|
* ```
|
|
2470
2572
|
*/
|
|
2471
2573
|
static detectMatches(pitches, opts) {
|
|
2472
|
-
return
|
|
2473
|
-
chord: new _Chord(
|
|
2574
|
+
return _chunkLQZQDBCDcjs.detectChord.call(void 0, pitches, opts).map((match) => ({
|
|
2575
|
+
chord: new _Chord(_chunkYDGMWH43cjs.makeChord.call(void 0, match.rootPc, match.quality, match.bassPc)),
|
|
2474
2576
|
match
|
|
2475
2577
|
}));
|
|
2476
2578
|
}
|
|
@@ -2482,7 +2584,7 @@ var Chord = class _Chord {
|
|
|
2482
2584
|
* @returns The top-ranked chord, or null when nothing matches.
|
|
2483
2585
|
*/
|
|
2484
2586
|
static detectBest(pitches, opts) {
|
|
2485
|
-
const best =
|
|
2587
|
+
const best = _chunkLQZQDBCDcjs.detectChordBest.call(void 0, pitches, opts);
|
|
2486
2588
|
return best === null ? null : new _Chord(best);
|
|
2487
2589
|
}
|
|
2488
2590
|
/** The root pitch class (0..11). */
|
|
@@ -2526,7 +2628,7 @@ var Chord = class _Chord {
|
|
|
2526
2628
|
* ```
|
|
2527
2629
|
*/
|
|
2528
2630
|
get spec() {
|
|
2529
|
-
return
|
|
2631
|
+
return _chunkYDGMWH43cjs.chordSpecOf.call(void 0, this.#data);
|
|
2530
2632
|
}
|
|
2531
2633
|
/** The carried key context, if any. */
|
|
2532
2634
|
get key() {
|
|
@@ -2564,7 +2666,7 @@ var Chord = class _Chord {
|
|
|
2564
2666
|
* ```
|
|
2565
2667
|
*/
|
|
2566
2668
|
pitchClasses(opts) {
|
|
2567
|
-
return
|
|
2669
|
+
return _chunkYDGMWH43cjs.chordPitchClasses.call(void 0, this.#data, opts);
|
|
2568
2670
|
}
|
|
2569
2671
|
/**
|
|
2570
2672
|
* Whether a pitch is one of the chord's tones, ignoring octave.
|
|
@@ -2582,7 +2684,7 @@ var Chord = class _Chord {
|
|
|
2582
2684
|
* ```
|
|
2583
2685
|
*/
|
|
2584
2686
|
contains(pitch) {
|
|
2585
|
-
return
|
|
2687
|
+
return _chunkYDGMWH43cjs.isChordMember.call(void 0, pitch, this.#data);
|
|
2586
2688
|
}
|
|
2587
2689
|
/**
|
|
2588
2690
|
* A pitch's harmonic role in the chord: root, third, fifth, sixth, or
|
|
@@ -2605,7 +2707,7 @@ var Chord = class _Chord {
|
|
|
2605
2707
|
* ```
|
|
2606
2708
|
*/
|
|
2607
2709
|
roleOf(pitch) {
|
|
2608
|
-
return
|
|
2710
|
+
return _chunkYDGMWH43cjs.chordToneRole.call(void 0, pitch, this.#data);
|
|
2609
2711
|
}
|
|
2610
2712
|
/**
|
|
2611
2713
|
* The chord's Roman numeral in a key.
|
|
@@ -2617,7 +2719,8 @@ var Chord = class _Chord {
|
|
|
2617
2719
|
* @throws If no key is given and none is carried.
|
|
2618
2720
|
*/
|
|
2619
2721
|
roman(key, opts) {
|
|
2620
|
-
|
|
2722
|
+
const resolved = this.#resolveKey(key);
|
|
2723
|
+
return _chunkLQZQDBCDcjs.chordToRoman.call(void 0, this.#dataWithKey(resolved), resolved, opts);
|
|
2621
2724
|
}
|
|
2622
2725
|
/**
|
|
2623
2726
|
* The chord's Roman numeral together with the reasoning behind it: the degree
|
|
@@ -2645,7 +2748,8 @@ var Chord = class _Chord {
|
|
|
2645
2748
|
* ```
|
|
2646
2749
|
*/
|
|
2647
2750
|
explain(key, opts) {
|
|
2648
|
-
|
|
2751
|
+
const resolved = this.#resolveKey(key);
|
|
2752
|
+
return _chunkLQZQDBCDcjs.explainRoman.call(void 0, this.#dataWithKey(resolved), resolved, opts);
|
|
2649
2753
|
}
|
|
2650
2754
|
/**
|
|
2651
2755
|
* The chord's harmonic function (tonic / subdominant / dominant) in a key.
|
|
@@ -2656,7 +2760,8 @@ var Chord = class _Chord {
|
|
|
2656
2760
|
* @throws If no key is given and none is carried.
|
|
2657
2761
|
*/
|
|
2658
2762
|
function(key) {
|
|
2659
|
-
|
|
2763
|
+
const resolved = this.#resolveKey(key);
|
|
2764
|
+
return _chunkLQZQDBCDcjs.functionOf.call(void 0, this.#dataWithKey(resolved), resolved);
|
|
2660
2765
|
}
|
|
2661
2766
|
/**
|
|
2662
2767
|
* Full functional analysis: function, borrowing, Roman numeral, and the
|
|
@@ -2676,7 +2781,8 @@ var Chord = class _Chord {
|
|
|
2676
2781
|
* ```
|
|
2677
2782
|
*/
|
|
2678
2783
|
analyze(key, opts) {
|
|
2679
|
-
|
|
2784
|
+
const resolved = this.#resolveKey(key);
|
|
2785
|
+
return _chunkLQZQDBCDcjs.analyzeChord.call(void 0, this.#dataWithKey(resolved), resolved, opts);
|
|
2680
2786
|
}
|
|
2681
2787
|
/**
|
|
2682
2788
|
* Whether the chord is borrowed from the parallel mode (modal interchange).
|
|
@@ -2687,7 +2793,8 @@ var Chord = class _Chord {
|
|
|
2687
2793
|
* @throws If no key is given and none is carried.
|
|
2688
2794
|
*/
|
|
2689
2795
|
isBorrowed(key) {
|
|
2690
|
-
|
|
2796
|
+
const resolved = this.#resolveKey(key);
|
|
2797
|
+
return _chunkLQZQDBCDcjs.isBorrowedChord.call(void 0, this.#dataWithKey(resolved), resolved);
|
|
2691
2798
|
}
|
|
2692
2799
|
/**
|
|
2693
2800
|
* The origin of a non-diatonic chord (parallel mode or Neapolitan), or null.
|
|
@@ -2698,7 +2805,8 @@ var Chord = class _Chord {
|
|
|
2698
2805
|
* @throws If no key is given and none is carried.
|
|
2699
2806
|
*/
|
|
2700
2807
|
borrowedSource(key) {
|
|
2701
|
-
|
|
2808
|
+
const resolved = this.#resolveKey(key);
|
|
2809
|
+
return _chunkLQZQDBCDcjs.borrowedSource.call(void 0, this.#dataWithKey(resolved), resolved);
|
|
2702
2810
|
}
|
|
2703
2811
|
/**
|
|
2704
2812
|
* The chord written as the figures a bass would carry under it: `6`, `64`,
|
|
@@ -2723,7 +2831,8 @@ var Chord = class _Chord {
|
|
|
2723
2831
|
* ```
|
|
2724
2832
|
*/
|
|
2725
2833
|
figuredBass(key) {
|
|
2726
|
-
|
|
2834
|
+
const resolved = this.#resolveKey(key);
|
|
2835
|
+
return _chunkU4EQTDGNcjs.figuredBassOf.call(void 0, this.#dataWithKey(resolved), resolved);
|
|
2727
2836
|
}
|
|
2728
2837
|
/**
|
|
2729
2838
|
* The chords that can stand in for this one in a key: its tritone substitute,
|
|
@@ -2750,7 +2859,8 @@ var Chord = class _Chord {
|
|
|
2750
2859
|
* ```
|
|
2751
2860
|
*/
|
|
2752
2861
|
substitutions(key, opts) {
|
|
2753
|
-
|
|
2862
|
+
const resolved = this.#resolveKey(key);
|
|
2863
|
+
return _chunk6TTBEON3cjs.substituteChord.call(void 0, this.#dataWithKey(resolved), resolved, opts);
|
|
2754
2864
|
}
|
|
2755
2865
|
/**
|
|
2756
2866
|
* The modal-interchange palette of the chord's key: the parallel mode's
|
|
@@ -2775,7 +2885,7 @@ var Chord = class _Chord {
|
|
|
2775
2885
|
* ```
|
|
2776
2886
|
*/
|
|
2777
2887
|
modalInterchange(key) {
|
|
2778
|
-
return
|
|
2888
|
+
return _chunk6TTBEON3cjs.modalInterchangePalette.call(void 0, this.#resolveKey(key));
|
|
2779
2889
|
}
|
|
2780
2890
|
/**
|
|
2781
2891
|
* The chord rendered as a lead-sheet symbol (e.g. `'Cmaj7'`, `'F#m7'`, `'C/G'`).
|
|
@@ -2790,7 +2900,7 @@ var Chord = class _Chord {
|
|
|
2790
2900
|
* ```
|
|
2791
2901
|
*/
|
|
2792
2902
|
symbol(opts) {
|
|
2793
|
-
return
|
|
2903
|
+
return _chunkYDGMWH43cjs.formatChordSymbol.call(void 0, this.#data, opts);
|
|
2794
2904
|
}
|
|
2795
2905
|
/**
|
|
2796
2906
|
* Realize the chord as one MIDI pitch per voice, ascending.
|
|
@@ -2804,7 +2914,8 @@ var Chord = class _Chord {
|
|
|
2804
2914
|
*/
|
|
2805
2915
|
voice(opts) {
|
|
2806
2916
|
const key = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _24 => _24.key]), () => ( this.#key));
|
|
2807
|
-
|
|
2917
|
+
const data = _optionalChain([opts, 'optionalAccess', _25 => _25.key]) === void 0 ? this.#data : this.#dataWithKey(toKey(opts.key));
|
|
2918
|
+
return _chunkU4EQTDGNcjs.voiceChord.call(void 0, data, key === void 0 ? opts : { ...opts, key });
|
|
2808
2919
|
}
|
|
2809
2920
|
/**
|
|
2810
2921
|
* Realize the chord as a single styled voicing (`close`, `drop2`, `drop3`,
|
|
@@ -2814,7 +2925,7 @@ var Chord = class _Chord {
|
|
|
2814
2925
|
* @returns MIDI pitches, ascending.
|
|
2815
2926
|
*/
|
|
2816
2927
|
styledVoicing(opts) {
|
|
2817
|
-
return
|
|
2928
|
+
return _chunkU4EQTDGNcjs.voiceChordStyled.call(void 0, this.#data, opts);
|
|
2818
2929
|
}
|
|
2819
2930
|
/**
|
|
2820
2931
|
* The negative-harmony mirror of the chord about the key's tonic–dominant
|
|
@@ -2827,7 +2938,7 @@ var Chord = class _Chord {
|
|
|
2827
2938
|
*/
|
|
2828
2939
|
negativeHarmony(key) {
|
|
2829
2940
|
const resolved = this.#resolveKey(key);
|
|
2830
|
-
return new _Chord(
|
|
2941
|
+
return new _Chord(_chunk6TTBEON3cjs.negativeHarmonyMirror.call(void 0, this.#dataWithKey(resolved), resolved), resolved);
|
|
2831
2942
|
}
|
|
2832
2943
|
/**
|
|
2833
2944
|
* The V7 that tonicizes this chord: a dominant seventh a perfect fifth above
|
|
@@ -2845,7 +2956,7 @@ var Chord = class _Chord {
|
|
|
2845
2956
|
* ```
|
|
2846
2957
|
*/
|
|
2847
2958
|
secondaryDominant() {
|
|
2848
|
-
return new _Chord(
|
|
2959
|
+
return new _Chord(_chunkLQZQDBCDcjs.secondaryDominantOf.call(void 0, this.#given), this.#key);
|
|
2849
2960
|
}
|
|
2850
2961
|
/**
|
|
2851
2962
|
* The n-th inversion: a copy whose bass is the chord tone `n` steps above the
|
|
@@ -2864,14 +2975,14 @@ var Chord = class _Chord {
|
|
|
2864
2975
|
const intervals = data.intervals;
|
|
2865
2976
|
const length = intervals.length;
|
|
2866
2977
|
if (length === 0) {
|
|
2867
|
-
throw new (0,
|
|
2978
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)("cannot invert a chord with no intervals");
|
|
2868
2979
|
}
|
|
2869
2980
|
const index = (n % length + length) % length;
|
|
2870
2981
|
delete data.bassSpelling;
|
|
2871
2982
|
if (index === 0) {
|
|
2872
2983
|
delete data.bassPc;
|
|
2873
2984
|
} else {
|
|
2874
|
-
data.bassPc =
|
|
2985
|
+
data.bassPc = _chunkS3QELJUEcjs.pitchClassOf.call(void 0, data.rootPc + (_nullishCoalesce(intervals[index], () => ( 0))));
|
|
2875
2986
|
}
|
|
2876
2987
|
return new _Chord(data, this.#key);
|
|
2877
2988
|
}
|
|
@@ -2892,8 +3003,8 @@ var Chord = class _Chord {
|
|
|
2892
3003
|
* ```
|
|
2893
3004
|
*/
|
|
2894
3005
|
transpose(semitones) {
|
|
2895
|
-
const moved =
|
|
2896
|
-
const { rootSpelling, bassSpelling, toneSpellings } =
|
|
3006
|
+
const moved = _chunkYDGMWH43cjs.transposeChord.call(void 0, this.#given, semitones);
|
|
3007
|
+
const { rootSpelling, bassSpelling, toneSpellings } = _chunkYDGMWH43cjs.transposeChordSpellings.call(void 0,
|
|
2897
3008
|
this.#given,
|
|
2898
3009
|
semitones
|
|
2899
3010
|
);
|
|
@@ -2906,7 +3017,7 @@ var Chord = class _Chord {
|
|
|
2906
3017
|
if (toneSpellings !== void 0) {
|
|
2907
3018
|
moved.toneSpellings = toneSpellings;
|
|
2908
3019
|
}
|
|
2909
|
-
return new _Chord(moved, _optionalChain([this, 'access',
|
|
3020
|
+
return new _Chord(moved, _optionalChain([this, 'access', _26 => _26.#key, 'optionalAccess', _27 => _27.transpose, 'call', _28 => _28(semitones)]));
|
|
2910
3021
|
}
|
|
2911
3022
|
/**
|
|
2912
3023
|
* Transpose the chord by a spelled interval.
|
|
@@ -2928,8 +3039,8 @@ var Chord = class _Chord {
|
|
|
2928
3039
|
* ```
|
|
2929
3040
|
*/
|
|
2930
3041
|
transposeBy(interval) {
|
|
2931
|
-
const spelled =
|
|
2932
|
-
const moved =
|
|
3042
|
+
const spelled = _chunkS3QELJUEcjs.toSpelledInterval.call(void 0, interval);
|
|
3043
|
+
const moved = _chunkYDGMWH43cjs.transposeChord.call(void 0, this.#given, spelled.semitones);
|
|
2933
3044
|
const rootSpelling = transposeHintByInterval(this.#given.rootSpelling, spelled);
|
|
2934
3045
|
const bassSpelling = transposeHintByInterval(this.#given.bassSpelling, spelled);
|
|
2935
3046
|
const toneSpellings = transposeToneHintsByInterval(this.#given.toneSpellings, spelled);
|
|
@@ -2942,7 +3053,7 @@ var Chord = class _Chord {
|
|
|
2942
3053
|
if (toneSpellings !== void 0) {
|
|
2943
3054
|
moved.toneSpellings = toneSpellings;
|
|
2944
3055
|
}
|
|
2945
|
-
return new _Chord(moved, _optionalChain([this, 'access',
|
|
3056
|
+
return new _Chord(moved, _optionalChain([this, 'access', _29 => _29.#key, 'optionalAccess', _30 => _30.transposeBy, 'call', _31 => _31(spelled)]));
|
|
2946
3057
|
}
|
|
2947
3058
|
/**
|
|
2948
3059
|
* The named scales that fit over this chord, best fit first, rooted on the
|
|
@@ -2955,7 +3066,7 @@ var Chord = class _Chord {
|
|
|
2955
3066
|
* @returns The matching scales.
|
|
2956
3067
|
*/
|
|
2957
3068
|
scales() {
|
|
2958
|
-
return
|
|
3069
|
+
return _chunkP3CPXAJ5cjs.chordScales.call(void 0, this.#data);
|
|
2959
3070
|
}
|
|
2960
3071
|
/**
|
|
2961
3072
|
* The scales that fit over this chord, each with the tones it does not state
|
|
@@ -2977,7 +3088,7 @@ var Chord = class _Chord {
|
|
|
2977
3088
|
* ```
|
|
2978
3089
|
*/
|
|
2979
3090
|
scaleReport(limit) {
|
|
2980
|
-
return
|
|
3091
|
+
return _chunkP3CPXAJ5cjs.chordScaleReport.call(void 0, this.#data, limit);
|
|
2981
3092
|
}
|
|
2982
3093
|
/**
|
|
2983
3094
|
* The available tensions (usable non-chord, non-avoid scale tones) of a
|
|
@@ -3002,7 +3113,7 @@ var Chord = class _Chord {
|
|
|
3002
3113
|
* ```
|
|
3003
3114
|
*/
|
|
3004
3115
|
tensions(scaleName, opts) {
|
|
3005
|
-
return
|
|
3116
|
+
return _chunkP3CPXAJ5cjs.availableTensions.call(void 0, this.#data, scaleName, opts);
|
|
3006
3117
|
}
|
|
3007
3118
|
/**
|
|
3008
3119
|
* The avoid notes (scale tones a semitone above a chord tone) of a scale
|
|
@@ -3026,7 +3137,7 @@ var Chord = class _Chord {
|
|
|
3026
3137
|
* ```
|
|
3027
3138
|
*/
|
|
3028
3139
|
avoidNotes(scaleName, opts) {
|
|
3029
|
-
return
|
|
3140
|
+
return _chunkP3CPXAJ5cjs.avoidNotes.call(void 0, this.#data, scaleName, opts);
|
|
3030
3141
|
}
|
|
3031
3142
|
/**
|
|
3032
3143
|
* Spell the chord tones with letter names, root first, in the key's spelling.
|
|
@@ -3057,17 +3168,17 @@ var Chord = class _Chord {
|
|
|
3057
3168
|
if (resolved === void 0) {
|
|
3058
3169
|
const root = data.rootSpelling;
|
|
3059
3170
|
if (root === void 0) {
|
|
3060
|
-
throw new (0,
|
|
3171
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
3061
3172
|
"chord has no key context and no root spelling; pass a Key, attach one with withKey(), or build the chord from a symbol"
|
|
3062
3173
|
);
|
|
3063
3174
|
}
|
|
3064
|
-
tones =
|
|
3175
|
+
tones = _chunkYDGMWH43cjs.spellChordFromRoot.call(void 0, data, root);
|
|
3065
3176
|
} else {
|
|
3066
|
-
tones =
|
|
3177
|
+
tones = _chunkYDGMWH43cjs.spellChord.call(void 0, data, resolved.tonic.data, resolved);
|
|
3067
3178
|
}
|
|
3068
3179
|
const bassPc = data.bassPc;
|
|
3069
3180
|
const bass = data.bassSpelling;
|
|
3070
|
-
if (bassPc !== void 0 && bass !== void 0 && !tones.some((tone) =>
|
|
3181
|
+
if (bassPc !== void 0 && bass !== void 0 && !tones.some((tone) => _chunkS3QELJUEcjs.pitchClassOf.call(void 0, _chunkS3QELJUEcjs.noteToPitchClass.call(void 0, tone)) === _chunkS3QELJUEcjs.pitchClassOf.call(void 0, bassPc))) {
|
|
3071
3182
|
tones = [...tones, { letter: bass.letter, alter: bass.alter }];
|
|
3072
3183
|
}
|
|
3073
3184
|
return tones.map((note) => new Note(note));
|
|
@@ -3101,7 +3212,7 @@ var Chord = class _Chord {
|
|
|
3101
3212
|
* ```
|
|
3102
3213
|
*/
|
|
3103
3214
|
span(startBeat) {
|
|
3104
|
-
return
|
|
3215
|
+
return _chunkYDGMWH43cjs.spanFromChord.call(void 0, this.#data, startBeat);
|
|
3105
3216
|
}
|
|
3106
3217
|
/**
|
|
3107
3218
|
* Whether another chord has the same root, quality, intervals, and bass.
|
|
@@ -3141,7 +3252,7 @@ var Chord = class _Chord {
|
|
|
3141
3252
|
assertKeyArgument(key, "chord key");
|
|
3142
3253
|
const resolved = key === void 0 ? this.#key : toKey(key);
|
|
3143
3254
|
if (resolved === void 0) {
|
|
3144
|
-
throw new (0,
|
|
3255
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
3145
3256
|
"chord has no key context; pass a Key or attach one with withKey()"
|
|
3146
3257
|
);
|
|
3147
3258
|
}
|
|
@@ -3151,11 +3262,11 @@ var Chord = class _Chord {
|
|
|
3151
3262
|
|
|
3152
3263
|
// src/model/key.ts
|
|
3153
3264
|
function detectedKeyMatch(match) {
|
|
3154
|
-
const key = { ...
|
|
3265
|
+
const key = { ..._chunkYDGMWH43cjs.resolveKey.call(void 0, match.key), variant: match.variant };
|
|
3155
3266
|
return { ...match, key: toKey(key) };
|
|
3156
3267
|
}
|
|
3157
3268
|
function scaleWord(mask, isMinor) {
|
|
3158
|
-
const name =
|
|
3269
|
+
const name = _chunkYDGMWH43cjs.scaleNameOfMask.call(void 0, mask);
|
|
3159
3270
|
if (name === void 0) {
|
|
3160
3271
|
return isMinor ? "minor" : "major";
|
|
3161
3272
|
}
|
|
@@ -3170,13 +3281,13 @@ function scaleWord(mask, isMinor) {
|
|
|
3170
3281
|
var HEPTATONIC_DEGREES = 7;
|
|
3171
3282
|
var REFERENCE_TONIC = { letter: 0, alter: 0 };
|
|
3172
3283
|
function bareInterval(from, to) {
|
|
3173
|
-
return
|
|
3284
|
+
return _chunkS3QELJUEcjs.spelledInterval.call(void 0,
|
|
3174
3285
|
{ letter: from.letter, alter: from.alter },
|
|
3175
3286
|
{ letter: to.letter, alter: to.alter }
|
|
3176
3287
|
);
|
|
3177
3288
|
}
|
|
3178
3289
|
function spelledTonicFor(scale) {
|
|
3179
|
-
return new Note(
|
|
3290
|
+
return new Note(_chunkYDGMWH43cjs.resolveKey.call(void 0, scale).tonic);
|
|
3180
3291
|
}
|
|
3181
3292
|
function isNoteInstance(value) {
|
|
3182
3293
|
if (value === null || typeof value !== "object") {
|
|
@@ -3207,28 +3318,29 @@ var Key = class _Key {
|
|
|
3207
3318
|
*/
|
|
3208
3319
|
constructor(scale, tonic, variant) {
|
|
3209
3320
|
assertDataObject(scale, "scale");
|
|
3210
|
-
|
|
3211
|
-
|
|
3321
|
+
_chunkS3QELJUEcjs.assertInteger.call(void 0, scale.rootPc, "scale.rootPc");
|
|
3322
|
+
_chunkS3QELJUEcjs.assertInteger.call(void 0, scale.modeMask12, "scale.modeMask12", 1, 4095);
|
|
3212
3323
|
if ((scale.modeMask12 & 1) === 0) {
|
|
3213
|
-
throw new (0,
|
|
3324
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)("scale.modeMask12 must include the tonic (bit 0)");
|
|
3214
3325
|
}
|
|
3215
3326
|
if (!isNoteInstance(tonic)) {
|
|
3216
|
-
throw new (0,
|
|
3327
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
3217
3328
|
`tonic must be the class API's Note; received ${describeTonic(tonic)}; wrap plain note data with Note.fromData, or omit the tonic to have one chosen`
|
|
3218
3329
|
);
|
|
3219
3330
|
}
|
|
3220
|
-
const
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3331
|
+
const note = tonic instanceof Note ? tonic : new Note(tonic.data);
|
|
3332
|
+
const rootPc = _chunkS3QELJUEcjs.pitchClassOf.call(void 0, scale.rootPc);
|
|
3333
|
+
if (note.pitchClass !== rootPc) {
|
|
3334
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
3335
|
+
`tonic ${note.name} does not match the scale root pitch class ${rootPc}; pass a tonic that spells the scale root, or omit it to have one chosen`
|
|
3224
3336
|
);
|
|
3225
3337
|
}
|
|
3226
3338
|
if (variant !== void 0) {
|
|
3227
|
-
|
|
3339
|
+
_chunkYDGMWH43cjs.assertKeyVariant.call(void 0, variant, scale.modeMask12);
|
|
3228
3340
|
}
|
|
3229
3341
|
this.#scale = { rootPc, modeMask12: scale.modeMask12 };
|
|
3230
|
-
this.#tonic =
|
|
3231
|
-
this.#variant = _nullishCoalesce(variant, () => (
|
|
3342
|
+
this.#tonic = note;
|
|
3343
|
+
this.#variant = _nullishCoalesce(variant, () => ( _chunkYDGMWH43cjs.variantOfMask.call(void 0, scale.modeMask12)));
|
|
3232
3344
|
}
|
|
3233
3345
|
/** Preserve detection metadata while replacing its plain key with this API's Key. */
|
|
3234
3346
|
static #fromMatch(match) {
|
|
@@ -3255,9 +3367,9 @@ var Key = class _Key {
|
|
|
3255
3367
|
static major(root) {
|
|
3256
3368
|
if (typeof root === "string") {
|
|
3257
3369
|
const tonic = Note.parse(root);
|
|
3258
|
-
return new _Key(
|
|
3370
|
+
return new _Key(_chunkYDGMWH43cjs.majorKey.call(void 0, tonic.pitchClass), tonic);
|
|
3259
3371
|
}
|
|
3260
|
-
const scale =
|
|
3372
|
+
const scale = _chunkYDGMWH43cjs.majorKey.call(void 0, root);
|
|
3261
3373
|
return new _Key(scale, spelledTonicFor(scale));
|
|
3262
3374
|
}
|
|
3263
3375
|
/**
|
|
@@ -3271,9 +3383,9 @@ var Key = class _Key {
|
|
|
3271
3383
|
static minor(root) {
|
|
3272
3384
|
if (typeof root === "string") {
|
|
3273
3385
|
const tonic = Note.parse(root);
|
|
3274
|
-
return new _Key(
|
|
3386
|
+
return new _Key(_chunkYDGMWH43cjs.minorKey.call(void 0, tonic.pitchClass), tonic);
|
|
3275
3387
|
}
|
|
3276
|
-
const scale =
|
|
3388
|
+
const scale = _chunkYDGMWH43cjs.minorKey.call(void 0, root);
|
|
3277
3389
|
return new _Key(scale, spelledTonicFor(scale));
|
|
3278
3390
|
}
|
|
3279
3391
|
/**
|
|
@@ -3289,9 +3401,9 @@ var Key = class _Key {
|
|
|
3289
3401
|
static named(name, root) {
|
|
3290
3402
|
if (typeof root === "string") {
|
|
3291
3403
|
const tonic = Note.parse(root);
|
|
3292
|
-
return new _Key(
|
|
3404
|
+
return new _Key(_chunkYDGMWH43cjs.scaleByName.call(void 0, name, tonic.pitchClass), tonic);
|
|
3293
3405
|
}
|
|
3294
|
-
const scale =
|
|
3406
|
+
const scale = _chunkYDGMWH43cjs.scaleByName.call(void 0, name, _chunkS3QELJUEcjs.pitchClassOf.call(void 0, root));
|
|
3295
3407
|
return new _Key(scale, spelledTonicFor(scale));
|
|
3296
3408
|
}
|
|
3297
3409
|
/**
|
|
@@ -3326,7 +3438,7 @@ var Key = class _Key {
|
|
|
3326
3438
|
* ```
|
|
3327
3439
|
*/
|
|
3328
3440
|
static parse(text, opts) {
|
|
3329
|
-
return
|
|
3441
|
+
return _chunkS3QELJUEcjs.unwrapParse.call(void 0, _Key.tryParse(text, opts));
|
|
3330
3442
|
}
|
|
3331
3443
|
/**
|
|
3332
3444
|
* Parse a key name, reporting failure instead of throwing it.
|
|
@@ -3348,7 +3460,7 @@ var Key = class _Key {
|
|
|
3348
3460
|
* ```
|
|
3349
3461
|
*/
|
|
3350
3462
|
static tryParse(text, opts) {
|
|
3351
|
-
const parsed =
|
|
3463
|
+
const parsed = _chunkYDGMWH43cjs.tryResolveKeyName.call(void 0, text, opts);
|
|
3352
3464
|
return parsed.ok ? {
|
|
3353
3465
|
ok: true,
|
|
3354
3466
|
value: new _Key(parsed.value.scale, new Note(parsed.value.tonic), parsed.value.variant)
|
|
@@ -3375,7 +3487,7 @@ var Key = class _Key {
|
|
|
3375
3487
|
* ```
|
|
3376
3488
|
*/
|
|
3377
3489
|
static fromFifths(fifths, mode = "major") {
|
|
3378
|
-
return _Key.#fromSpelled(
|
|
3490
|
+
return _Key.#fromSpelled(_chunkYDGMWH43cjs.keyFromFifths.call(void 0, fifths, mode));
|
|
3379
3491
|
}
|
|
3380
3492
|
/**
|
|
3381
3493
|
* Wrap an existing `KeyScale`, synthesizing a spelled tonic when none is
|
|
@@ -3398,7 +3510,7 @@ var Key = class _Key {
|
|
|
3398
3510
|
* @throws If the given tonic is not the scale's root pitch class.
|
|
3399
3511
|
*/
|
|
3400
3512
|
static of(key, tonic) {
|
|
3401
|
-
const resolved =
|
|
3513
|
+
const resolved = _chunkYDGMWH43cjs.resolveKey.call(void 0, key);
|
|
3402
3514
|
return new _Key(resolved.scale, _nullishCoalesce(tonic, () => ( new Note(resolved.tonic))), resolved.variant);
|
|
3403
3515
|
}
|
|
3404
3516
|
/**
|
|
@@ -3440,7 +3552,7 @@ var Key = class _Key {
|
|
|
3440
3552
|
* @returns Ranked key matches (may be empty).
|
|
3441
3553
|
*/
|
|
3442
3554
|
static detectMatches(pitches, opts) {
|
|
3443
|
-
return
|
|
3555
|
+
return _chunkLQZQDBCDcjs.detectKey.call(void 0, pitches, opts).map((match) => _Key.#fromMatch(match));
|
|
3444
3556
|
}
|
|
3445
3557
|
/**
|
|
3446
3558
|
* The single best key interpretation of a pitch set.
|
|
@@ -3455,7 +3567,7 @@ var Key = class _Key {
|
|
|
3455
3567
|
* ```
|
|
3456
3568
|
*/
|
|
3457
3569
|
static detectBest(pitches, opts) {
|
|
3458
|
-
const best =
|
|
3570
|
+
const best = _chunkLQZQDBCDcjs.detectKeyBest.call(void 0, pitches, opts);
|
|
3459
3571
|
return best === null ? null : _Key.#fromMatch(best).key;
|
|
3460
3572
|
}
|
|
3461
3573
|
/**
|
|
@@ -3485,7 +3597,7 @@ var Key = class _Key {
|
|
|
3485
3597
|
}
|
|
3486
3598
|
/** Whether the scale has a minor third and no major third. */
|
|
3487
3599
|
get isMinor() {
|
|
3488
|
-
return
|
|
3600
|
+
return _chunkLQZQDBCDcjs.isMinorKey.call(void 0, this.#scale);
|
|
3489
3601
|
}
|
|
3490
3602
|
/**
|
|
3491
3603
|
* The key signature as a signed count of sharps (positive) or flats
|
|
@@ -3503,7 +3615,7 @@ var Key = class _Key {
|
|
|
3503
3615
|
* ```
|
|
3504
3616
|
*/
|
|
3505
3617
|
get fifths() {
|
|
3506
|
-
return
|
|
3618
|
+
return _chunkYDGMWH43cjs.keySignatureFifths.call(void 0, this.#tonic.data, this.#scale);
|
|
3507
3619
|
}
|
|
3508
3620
|
/**
|
|
3509
3621
|
* The built-in scale this key's mode mask is, or undefined when no built-in
|
|
@@ -3527,13 +3639,13 @@ var Key = class _Key {
|
|
|
3527
3639
|
*/
|
|
3528
3640
|
get scaleName() {
|
|
3529
3641
|
const mask = this.#scale.modeMask12;
|
|
3530
|
-
return Object.keys(
|
|
3642
|
+
return Object.keys(_chunkYDGMWH43cjs.NAMED_SCALES).find((name) => _chunkYDGMWH43cjs.NAMED_SCALES[name] === mask);
|
|
3531
3643
|
}
|
|
3532
3644
|
/** A copy of the underlying plain key data. */
|
|
3533
3645
|
get data() {
|
|
3534
3646
|
return this.toJSON();
|
|
3535
3647
|
}
|
|
3536
|
-
/** The
|
|
3648
|
+
/** The scale form this key stands in: natural, harmonic or melodic, read from the mask unless named. */
|
|
3537
3649
|
get variant() {
|
|
3538
3650
|
return this.#variant;
|
|
3539
3651
|
}
|
|
@@ -3559,8 +3671,8 @@ var Key = class _Key {
|
|
|
3559
3671
|
* ```
|
|
3560
3672
|
*/
|
|
3561
3673
|
pitchClasses(opts) {
|
|
3562
|
-
const order = _optionalChain([opts, 'optionalAccess',
|
|
3563
|
-
return order === "ascending" ?
|
|
3674
|
+
const order = _optionalChain([opts, 'optionalAccess', _32 => _32.order]) === void 0 ? "degree" : _chunkS3QELJUEcjs.assertOneOf.call(void 0, opts.order, ["degree", "ascending"], "pitch-class order");
|
|
3675
|
+
return order === "ascending" ? _chunkYDGMWH43cjs.diatonicPitchClasses.call(void 0, this.#scale) : _chunkYDGMWH43cjs.scaleTonesInDegreeOrder.call(void 0, this.#scale);
|
|
3564
3676
|
}
|
|
3565
3677
|
/**
|
|
3566
3678
|
* The kind of pitch organisation this key's scale belongs to: the
|
|
@@ -3584,7 +3696,7 @@ var Key = class _Key {
|
|
|
3584
3696
|
* ```
|
|
3585
3697
|
*/
|
|
3586
3698
|
system() {
|
|
3587
|
-
return
|
|
3699
|
+
return _chunkYDGMWH43cjs.scaleSystemOf.call(void 0, this.#scale);
|
|
3588
3700
|
}
|
|
3589
3701
|
/**
|
|
3590
3702
|
* Whether functional (Roman-numeral) analysis describes this key.
|
|
@@ -3604,7 +3716,7 @@ var Key = class _Key {
|
|
|
3604
3716
|
* ```
|
|
3605
3717
|
*/
|
|
3606
3718
|
supportsFunctionalHarmony() {
|
|
3607
|
-
return
|
|
3719
|
+
return _chunkYDGMWH43cjs.supportsFunctionalHarmony.call(void 0, this.#scale);
|
|
3608
3720
|
}
|
|
3609
3721
|
/**
|
|
3610
3722
|
* The relative key: for a plain major or minor key, the same key signature
|
|
@@ -3628,7 +3740,7 @@ var Key = class _Key {
|
|
|
3628
3740
|
* ```
|
|
3629
3741
|
*/
|
|
3630
3742
|
relative() {
|
|
3631
|
-
return _Key.#fromSpelled(
|
|
3743
|
+
return _Key.#fromSpelled(_chunkYDGMWH43cjs.relativeKeyOf.call(void 0, this.#tonic.data, this.#scale));
|
|
3632
3744
|
}
|
|
3633
3745
|
/**
|
|
3634
3746
|
* The parallel key: the other mode on the same tonic, which keeps this key's
|
|
@@ -3642,7 +3754,7 @@ var Key = class _Key {
|
|
|
3642
3754
|
* ```
|
|
3643
3755
|
*/
|
|
3644
3756
|
parallel() {
|
|
3645
|
-
return _Key.#fromSpelled(
|
|
3757
|
+
return _Key.#fromSpelled(_chunkYDGMWH43cjs.parallelKeyOf.call(void 0, this.#tonic.data, this.#scale));
|
|
3646
3758
|
}
|
|
3647
3759
|
/**
|
|
3648
3760
|
* The dominant key: the key a fifth above, in the mode this key's third names.
|
|
@@ -3659,7 +3771,7 @@ var Key = class _Key {
|
|
|
3659
3771
|
* ```
|
|
3660
3772
|
*/
|
|
3661
3773
|
dominantKey() {
|
|
3662
|
-
return _Key.#fromSpelled(
|
|
3774
|
+
return _Key.#fromSpelled(_chunkYDGMWH43cjs.dominantKeyOf.call(void 0, this.#tonic.data, this.#scale));
|
|
3663
3775
|
}
|
|
3664
3776
|
/**
|
|
3665
3777
|
* The subdominant key: the key a fifth below, in the mode this key's third
|
|
@@ -3675,7 +3787,7 @@ var Key = class _Key {
|
|
|
3675
3787
|
* ```
|
|
3676
3788
|
*/
|
|
3677
3789
|
subdominantKey() {
|
|
3678
|
-
return _Key.#fromSpelled(
|
|
3790
|
+
return _Key.#fromSpelled(_chunkYDGMWH43cjs.subdominantKeyOf.call(void 0, this.#tonic.data, this.#scale));
|
|
3679
3791
|
}
|
|
3680
3792
|
/**
|
|
3681
3793
|
* The same sounding key written the other way round the circle of fifths.
|
|
@@ -3693,7 +3805,7 @@ var Key = class _Key {
|
|
|
3693
3805
|
* ```
|
|
3694
3806
|
*/
|
|
3695
3807
|
enharmonic() {
|
|
3696
|
-
const other =
|
|
3808
|
+
const other = _chunkYDGMWH43cjs.enharmonicKeyOf.call(void 0, this.#tonic.data, this.#scale);
|
|
3697
3809
|
return other === null ? null : _Key.#fromSpelled(other);
|
|
3698
3810
|
}
|
|
3699
3811
|
/**
|
|
@@ -3724,7 +3836,7 @@ var Key = class _Key {
|
|
|
3724
3836
|
* ```
|
|
3725
3837
|
*/
|
|
3726
3838
|
relatedKeys() {
|
|
3727
|
-
return
|
|
3839
|
+
return _chunkYDGMWH43cjs.relatedKeysOf.call(void 0, this.#tonic.data, this.#scale).map(({ relation, ...spelled }) => ({
|
|
3728
3840
|
relation,
|
|
3729
3841
|
key: _Key.#fromSpelled(spelled)
|
|
3730
3842
|
}));
|
|
@@ -3751,7 +3863,7 @@ var Key = class _Key {
|
|
|
3751
3863
|
* ```
|
|
3752
3864
|
*/
|
|
3753
3865
|
relationTo(other) {
|
|
3754
|
-
return
|
|
3866
|
+
return _chunkYDGMWH43cjs.keyRelationBetween.call(void 0, this.toJSON(), other.toJSON());
|
|
3755
3867
|
}
|
|
3756
3868
|
/**
|
|
3757
3869
|
* The chords a modulation from this key into another can pivot on.
|
|
@@ -3778,7 +3890,7 @@ var Key = class _Key {
|
|
|
3778
3890
|
*/
|
|
3779
3891
|
pivotsTo(other) {
|
|
3780
3892
|
assertKeyArgument(other, "key");
|
|
3781
|
-
return
|
|
3893
|
+
return _chunkLQZQDBCDcjs.pivotChords.call(void 0, this, _chunkYDGMWH43cjs.resolveKey.call(void 0, other)).map(({ chord, romanFrom, romanTo }) => ({
|
|
3782
3894
|
chord: new Chord(chord, this),
|
|
3783
3895
|
romanFrom,
|
|
3784
3896
|
romanTo
|
|
@@ -3800,7 +3912,7 @@ var Key = class _Key {
|
|
|
3800
3912
|
*/
|
|
3801
3913
|
degree(n) {
|
|
3802
3914
|
const notes = this.notes();
|
|
3803
|
-
|
|
3915
|
+
_chunkS3QELJUEcjs.assertInteger.call(void 0, n, "degree", 1, notes.length);
|
|
3804
3916
|
return _nullishCoalesce(notes[n - 1], () => ( this.#tonic));
|
|
3805
3917
|
}
|
|
3806
3918
|
/**
|
|
@@ -3851,12 +3963,12 @@ var Key = class _Key {
|
|
|
3851
3963
|
*/
|
|
3852
3964
|
keyHavingTonicAsDegree(n, mode) {
|
|
3853
3965
|
const resolved = _nullishCoalesce(mode, () => ( (this.isMinor ? "minor" : "major")));
|
|
3854
|
-
const reference =
|
|
3855
|
-
|
|
3966
|
+
const reference = _chunkYDGMWH43cjs.spellScale.call(void 0, REFERENCE_TONIC, resolved === "minor" ? _chunkYDGMWH43cjs.minorKey.call(void 0, 0) : _chunkYDGMWH43cjs.majorKey.call(void 0, 0));
|
|
3967
|
+
_chunkS3QELJUEcjs.assertInteger.call(void 0, n, "degree", 1, reference.length);
|
|
3856
3968
|
const first = reference[0];
|
|
3857
|
-
const step =
|
|
3969
|
+
const step = _chunkS3QELJUEcjs.spelledInterval.call(void 0, first, reference[n - 1]);
|
|
3858
3970
|
const tonic = new Note(
|
|
3859
|
-
|
|
3971
|
+
_chunkS3QELJUEcjs.transposeByInterval.call(void 0, this.#tonic.data, {
|
|
3860
3972
|
number: step.number,
|
|
3861
3973
|
quality: step.quality,
|
|
3862
3974
|
// Negating a zero span yields -0, which compares unequal to 0.
|
|
@@ -3876,7 +3988,7 @@ var Key = class _Key {
|
|
|
3876
3988
|
*/
|
|
3877
3989
|
static #modeOn(mode, tonic) {
|
|
3878
3990
|
const rootPc = tonic.pitchClass;
|
|
3879
|
-
return new _Key(mode === "minor" ?
|
|
3991
|
+
return new _Key(mode === "minor" ? _chunkYDGMWH43cjs.minorKey.call(void 0, rootPc) : _chunkYDGMWH43cjs.majorKey.call(void 0, rootPc), tonic).#asWritten();
|
|
3880
3992
|
}
|
|
3881
3993
|
/**
|
|
3882
3994
|
* The mode a scale degree implies, read off its diatonic triad. Scales that
|
|
@@ -3887,7 +3999,7 @@ var Key = class _Key {
|
|
|
3887
3999
|
if (this.pitchClasses().length !== HEPTATONIC_DEGREES) {
|
|
3888
4000
|
return this.isMinor ? "minor" : "major";
|
|
3889
4001
|
}
|
|
3890
|
-
const { quality } =
|
|
4002
|
+
const { quality } = _chunkYDGMWH43cjs.diatonicTriad.call(void 0, n, this);
|
|
3891
4003
|
return quality === "min" || quality === "dim" ? "minor" : "major";
|
|
3892
4004
|
}
|
|
3893
4005
|
/**
|
|
@@ -3896,7 +4008,7 @@ var Key = class _Key {
|
|
|
3896
4008
|
*
|
|
3897
4009
|
* Unlike {@link Key.transpose}, which picks a letter from the semitone count,
|
|
3898
4010
|
* the interval's diatonic number decides the tonic's letter: G# minor down an
|
|
3899
|
-
* augmented fourth is D minor, while down a diminished fifth it is
|
|
4011
|
+
* augmented fourth is D minor, while down a diminished fifth it is C## minor.
|
|
3900
4012
|
* The mode mask is unchanged, so the scale keeps its shape.
|
|
3901
4013
|
*
|
|
3902
4014
|
* @param interval The interval to apply, as a name (`'A4'`, `'-A4'`), plain
|
|
@@ -3911,10 +4023,10 @@ var Key = class _Key {
|
|
|
3911
4023
|
* ```
|
|
3912
4024
|
*/
|
|
3913
4025
|
transposeBy(interval) {
|
|
3914
|
-
const step =
|
|
4026
|
+
const step = _chunkS3QELJUEcjs.toSpelledInterval.call(void 0, interval);
|
|
3915
4027
|
return new _Key(
|
|
3916
|
-
{ rootPc:
|
|
3917
|
-
new Note(
|
|
4028
|
+
{ rootPc: _chunkS3QELJUEcjs.pitchClassOf.call(void 0, this.#scale.rootPc + step.semitones), modeMask12: this.#scale.modeMask12 },
|
|
4029
|
+
new Note(_chunkS3QELJUEcjs.transposeByInterval.call(void 0, this.#tonic.data, step)),
|
|
3918
4030
|
this.#variant
|
|
3919
4031
|
);
|
|
3920
4032
|
}
|
|
@@ -3962,8 +4074,8 @@ var Key = class _Key {
|
|
|
3962
4074
|
* ```
|
|
3963
4075
|
*/
|
|
3964
4076
|
transpose(semitones) {
|
|
3965
|
-
|
|
3966
|
-
const rootPc =
|
|
4077
|
+
_chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, semitones, "semitones");
|
|
4078
|
+
const rootPc = _chunkS3QELJUEcjs.pitchClassOf.call(void 0, this.#scale.rootPc + Math.round(semitones));
|
|
3967
4079
|
const scale = { rootPc, modeMask12: this.#scale.modeMask12 };
|
|
3968
4080
|
return new _Key(scale, this.#tonic.transpose(semitones), this.#variant).#asWritten();
|
|
3969
4081
|
}
|
|
@@ -3987,9 +4099,9 @@ var Key = class _Key {
|
|
|
3987
4099
|
if (this.#isWritten()) {
|
|
3988
4100
|
return this;
|
|
3989
4101
|
}
|
|
3990
|
-
const other =
|
|
4102
|
+
const other = _chunkYDGMWH43cjs.enharmonicKeyOf.call(void 0, this.#tonic.data, this.#scale);
|
|
3991
4103
|
const respelled = other === null ? null : new Note(other.tonic);
|
|
3992
|
-
return respelled === null || respelled.pitchClass !==
|
|
4104
|
+
return respelled === null || respelled.pitchClass !== _chunkS3QELJUEcjs.pitchClassOf.call(void 0, this.#scale.rootPc) ? this : new _Key(this.#scale, respelled, this.#variant);
|
|
3993
4105
|
}
|
|
3994
4106
|
/**
|
|
3995
4107
|
* Whether this key is spelled the way keys are actually written, which is
|
|
@@ -4003,7 +4115,7 @@ var Key = class _Key {
|
|
|
4003
4115
|
* drawn from the mode itself disagree.
|
|
4004
4116
|
*/
|
|
4005
4117
|
#isWritten() {
|
|
4006
|
-
return
|
|
4118
|
+
return _chunkYDGMWH43cjs.isWrittenTonic.call(void 0, this.#tonic.data, this.#scale);
|
|
4007
4119
|
}
|
|
4008
4120
|
/**
|
|
4009
4121
|
* The key a transposing instrument's part is written in, for this key at
|
|
@@ -4039,7 +4151,7 @@ var Key = class _Key {
|
|
|
4039
4151
|
* ```
|
|
4040
4152
|
*/
|
|
4041
4153
|
forInstrument(instrument) {
|
|
4042
|
-
const tonic = new Note(
|
|
4154
|
+
const tonic = new Note(_chunkU4EQTDGNcjs.toWrittenPitch.call(void 0, this.#tonic.data, instrument));
|
|
4043
4155
|
return new _Key(
|
|
4044
4156
|
{ rootPc: tonic.pitchClass, modeMask12: this.#scale.modeMask12 },
|
|
4045
4157
|
tonic,
|
|
@@ -4052,7 +4164,7 @@ var Key = class _Key {
|
|
|
4052
4164
|
* @returns Spelled octave-less notes in scale-degree order.
|
|
4053
4165
|
*/
|
|
4054
4166
|
notes() {
|
|
4055
|
-
return
|
|
4167
|
+
return _chunkYDGMWH43cjs.spellScale.call(void 0, this.#tonic.data, this.#scale).map((note) => new Note(note));
|
|
4056
4168
|
}
|
|
4057
4169
|
/**
|
|
4058
4170
|
* Alias of {@link Key.notes}.
|
|
@@ -4106,8 +4218,17 @@ var Key = class _Key {
|
|
|
4106
4218
|
* ```
|
|
4107
4219
|
*/
|
|
4108
4220
|
spellPitchClasses(pcs, tonic) {
|
|
4109
|
-
const anchor = tonic === void 0 ? this.#tonic.data :
|
|
4110
|
-
return
|
|
4221
|
+
const anchor = tonic === void 0 ? this.#tonic.data : _chunkS3QELJUEcjs.toNoteData.call(void 0, tonic);
|
|
4222
|
+
return _chunkYDGMWH43cjs.spellPitchClasses.call(void 0, [...pcs], anchor, this.#scale).map((note) => new Note(note));
|
|
4223
|
+
}
|
|
4224
|
+
/**
|
|
4225
|
+
* A degree chord without the spelling its builder attached.
|
|
4226
|
+
*
|
|
4227
|
+
* The chord carries this key, which spells its root on read, so a chord
|
|
4228
|
+
* re-keyed later follows its new key instead of keeping these letters.
|
|
4229
|
+
*/
|
|
4230
|
+
#withoutSpelling(chord) {
|
|
4231
|
+
return _chunkYDGMWH43cjs.makeChord.call(void 0, chord.rootPc, chord.quality);
|
|
4111
4232
|
}
|
|
4112
4233
|
/**
|
|
4113
4234
|
* Build a chord on a scale degree, carrying this key as context.
|
|
@@ -4126,8 +4247,8 @@ var Key = class _Key {
|
|
|
4126
4247
|
* an explicit `quality` for those.
|
|
4127
4248
|
*/
|
|
4128
4249
|
chord(degree, quality) {
|
|
4129
|
-
const data = quality === void 0 ?
|
|
4130
|
-
return new Chord(data, this);
|
|
4250
|
+
const data = quality === void 0 ? _chunkYDGMWH43cjs.diatonicTriad.call(void 0, degree, this) : _chunkYDGMWH43cjs.chordFromDegree.call(void 0, degree, quality, this);
|
|
4251
|
+
return new Chord(this.#withoutSpelling(data), this);
|
|
4131
4252
|
}
|
|
4132
4253
|
/**
|
|
4133
4254
|
* The diatonic triad on a scale degree, carrying this key as context.
|
|
@@ -4139,7 +4260,7 @@ var Key = class _Key {
|
|
|
4139
4260
|
* degrees. Use {@link Key.chord} with an explicit quality instead.
|
|
4140
4261
|
*/
|
|
4141
4262
|
diatonicTriad(degree) {
|
|
4142
|
-
return new Chord(
|
|
4263
|
+
return new Chord(this.#withoutSpelling(_chunkYDGMWH43cjs.diatonicTriad.call(void 0, degree, this)), this);
|
|
4143
4264
|
}
|
|
4144
4265
|
/**
|
|
4145
4266
|
* The diatonic seventh chord on a scale degree, carrying this key as context.
|
|
@@ -4151,7 +4272,7 @@ var Key = class _Key {
|
|
|
4151
4272
|
* degrees. Use {@link Key.chord} with an explicit quality instead.
|
|
4152
4273
|
*/
|
|
4153
4274
|
diatonicSeventh(degree) {
|
|
4154
|
-
return new Chord(
|
|
4275
|
+
return new Chord(this.#withoutSpelling(_chunkYDGMWH43cjs.diatonicSeventh.call(void 0, degree, this)), this);
|
|
4155
4276
|
}
|
|
4156
4277
|
/**
|
|
4157
4278
|
* Build the chord denoted by a Roman numeral in this key (including applied
|
|
@@ -4162,7 +4283,7 @@ var Key = class _Key {
|
|
|
4162
4283
|
* @throws If the numeral is not valid.
|
|
4163
4284
|
*/
|
|
4164
4285
|
roman(text) {
|
|
4165
|
-
return new Chord(
|
|
4286
|
+
return new Chord(_chunkLQZQDBCDcjs.romanToChord.call(void 0, text, this), this);
|
|
4166
4287
|
}
|
|
4167
4288
|
/**
|
|
4168
4289
|
* The augmented sixth chord of a kind, built in this key.
|
|
@@ -4183,7 +4304,7 @@ var Key = class _Key {
|
|
|
4183
4304
|
* ```
|
|
4184
4305
|
*/
|
|
4185
4306
|
augmentedSixth(kind) {
|
|
4186
|
-
return new Chord(
|
|
4307
|
+
return new Chord(_chunkLQZQDBCDcjs.augmentedSixthChord.call(void 0, kind, keyIdentity(this)), this);
|
|
4187
4308
|
}
|
|
4188
4309
|
/**
|
|
4189
4310
|
* Build a progression from Roman numerals in this key.
|
|
@@ -4216,7 +4337,7 @@ var Key = class _Key {
|
|
|
4216
4337
|
* @returns True if the pitch class is a scale tone.
|
|
4217
4338
|
*/
|
|
4218
4339
|
contains(x) {
|
|
4219
|
-
return
|
|
4340
|
+
return _chunkYDGMWH43cjs.isScaleTone.call(void 0, typeof x === "number" ? x : x.pitchClass, this.#scale);
|
|
4220
4341
|
}
|
|
4221
4342
|
/**
|
|
4222
4343
|
* The nearest MIDI pitch whose pitch class is in the scale.
|
|
@@ -4235,7 +4356,7 @@ var Key = class _Key {
|
|
|
4235
4356
|
* ```
|
|
4236
4357
|
*/
|
|
4237
4358
|
nearestTone(pitch) {
|
|
4238
|
-
return
|
|
4359
|
+
return _chunkYDGMWH43cjs.nearestScaleTone.call(void 0, pitch, this.#scale);
|
|
4239
4360
|
}
|
|
4240
4361
|
/**
|
|
4241
4362
|
* The scale degree a pitch sits on, counted from 1: the tonic is degree 1.
|
|
@@ -4253,7 +4374,7 @@ var Key = class _Key {
|
|
|
4253
4374
|
* ```
|
|
4254
4375
|
*/
|
|
4255
4376
|
degreeOf(pitch) {
|
|
4256
|
-
const degree =
|
|
4377
|
+
const degree = _chunkYDGMWH43cjs.pitchToScaleDegree.call(void 0, pitch, this.#scale);
|
|
4257
4378
|
return degree === -1 ? null : degree;
|
|
4258
4379
|
}
|
|
4259
4380
|
/**
|
|
@@ -4261,12 +4382,11 @@ var Key = class _Key {
|
|
|
4261
4382
|
*
|
|
4262
4383
|
* Private class fields do not serialize, so an explicit `toJSON` keeps
|
|
4263
4384
|
* `JSON.stringify(key)` from collapsing to `{}`. The result pairs the
|
|
4264
|
-
* `KeyScale` with the spelled tonic and
|
|
4265
|
-
*
|
|
4266
|
-
*
|
|
4385
|
+
* `KeyScale` with the spelled tonic and the scale form — everything
|
|
4386
|
+
* {@link Key.fromJSON} needs to rebuild a key that reads and prints as this
|
|
4387
|
+
* one.
|
|
4267
4388
|
*
|
|
4268
|
-
* @returns The key/scale, its spelled tonic, and its scale form
|
|
4269
|
-
* one.
|
|
4389
|
+
* @returns The key/scale, its spelled tonic, and its scale form.
|
|
4270
4390
|
*/
|
|
4271
4391
|
toJSON() {
|
|
4272
4392
|
return { scale: this.scale, tonic: this.#tonic.data, variant: this.#variant };
|
|
@@ -4299,8 +4419,8 @@ var Key = class _Key {
|
|
|
4299
4419
|
* ```
|
|
4300
4420
|
*/
|
|
4301
4421
|
toString(opts) {
|
|
4302
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
4303
|
-
return
|
|
4422
|
+
if (_optionalChain([opts, 'optionalAccess', _33 => _33.system]) !== void 0 && opts.system !== "english") {
|
|
4423
|
+
return _chunkS3QELJUEcjs.formatKeyName.call(void 0,
|
|
4304
4424
|
{ tonic: this.#tonic.data, mode: this.isMinor ? "minor" : "major" },
|
|
4305
4425
|
opts
|
|
4306
4426
|
);
|
|
@@ -4317,13 +4437,13 @@ function toKey(value) {
|
|
|
4317
4437
|
if (typeof data === "object" && data !== null) {
|
|
4318
4438
|
const record = data;
|
|
4319
4439
|
if (record.scale === void 0) {
|
|
4320
|
-
const scale =
|
|
4440
|
+
const scale = _chunkYDGMWH43cjs.toKeyScale.call(void 0, data);
|
|
4321
4441
|
return record.tonic === void 0 ? new Key(scale, spelledTonicFor(scale), record.variant) : new Key(scale, new Note(record.tonic), record.variant);
|
|
4322
4442
|
}
|
|
4323
|
-
return record.tonic === void 0 ? Key.of(
|
|
4443
|
+
return record.tonic === void 0 ? Key.of(_chunkYDGMWH43cjs.toKeyScale.call(void 0, record.scale)) : Key.fromJSON(record);
|
|
4324
4444
|
}
|
|
4325
4445
|
}
|
|
4326
|
-
throw new (0,
|
|
4446
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(`key must be a key name or a key/scale; received ${typeof value}`);
|
|
4327
4447
|
}
|
|
4328
4448
|
function keyIdentity(key) {
|
|
4329
4449
|
return { scale: key.scale, tonic: key.tonic.data, variant: key.variant };
|
|
@@ -4351,7 +4471,7 @@ function copyMeters(meters) {
|
|
|
4351
4471
|
}
|
|
4352
4472
|
function copyTempo(tempo) {
|
|
4353
4473
|
assertDataObjects(tempo, "score tempo");
|
|
4354
|
-
|
|
4474
|
+
_chunk3FDBMIPRcjs.tempoAt.call(void 0, 0, tempo);
|
|
4355
4475
|
return tempo.map((event) => ({
|
|
4356
4476
|
startBeat: withoutNegativeZero(event.startBeat),
|
|
4357
4477
|
bpm: event.bpm
|
|
@@ -4363,7 +4483,7 @@ function copyScore(data) {
|
|
|
4363
4483
|
notes: orderNotes(data.notes, "score notes"),
|
|
4364
4484
|
// The map is validated by the same resolver every meter-aware entry point
|
|
4365
4485
|
// reads its options through, so a score accepts exactly what they accept.
|
|
4366
|
-
meters: copyMeters(
|
|
4486
|
+
meters: copyMeters(_chunkS3QELJUEcjs.resolveMeters.call(void 0, { meters: data.meters }, "score meters")),
|
|
4367
4487
|
tempo: copyTempo(data.tempo)
|
|
4368
4488
|
};
|
|
4369
4489
|
if (data.key !== void 0) {
|
|
@@ -4377,29 +4497,17 @@ function tempoFrom(tempo) {
|
|
|
4377
4497
|
}
|
|
4378
4498
|
return typeof tempo === "number" ? [{ startBeat: 0, bpm: tempo }] : tempo;
|
|
4379
4499
|
}
|
|
4380
|
-
function
|
|
4500
|
+
function scoreKeyRegions(key, notes, totalBeats) {
|
|
4381
4501
|
const first = notes[0];
|
|
4382
|
-
|
|
4383
|
-
return [];
|
|
4384
|
-
}
|
|
4385
|
-
return [
|
|
4386
|
-
{
|
|
4387
|
-
// The region starts where the music does, as an inferred one does, so a
|
|
4388
|
-
// pickup is covered by the key it sounds in.
|
|
4389
|
-
startBeat: first.startBeat,
|
|
4390
|
-
endBeat: totalBeats,
|
|
4391
|
-
key: keyIdentity(key),
|
|
4392
|
-
confidence: STATED_KEY_CONFIDENCE
|
|
4393
|
-
}
|
|
4394
|
-
];
|
|
4502
|
+
return first === void 0 ? [] : _chunkLQZQDBCDcjs.statedKeyRegions.call(void 0, keyIdentity(key), first.startBeat, totalBeats);
|
|
4395
4503
|
}
|
|
4396
4504
|
function scoreData(notes, opts) {
|
|
4397
4505
|
const data = {
|
|
4398
4506
|
notes: [...assertDataArray(notes, "score notes")],
|
|
4399
|
-
meters:
|
|
4400
|
-
tempo: tempoFrom(_optionalChain([opts, 'optionalAccess',
|
|
4507
|
+
meters: _chunkS3QELJUEcjs.resolveMeters.call(void 0, { meters: _optionalChain([opts, 'optionalAccess', _34 => _34.meters]) }, "score meters"),
|
|
4508
|
+
tempo: tempoFrom(_optionalChain([opts, 'optionalAccess', _35 => _35.tempo]))
|
|
4401
4509
|
};
|
|
4402
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
4510
|
+
if (_optionalChain([opts, 'optionalAccess', _36 => _36.key]) !== void 0) {
|
|
4403
4511
|
data.key = toKey(opts.key).toJSON();
|
|
4404
4512
|
}
|
|
4405
4513
|
return data;
|
|
@@ -4411,6 +4519,8 @@ var Score = class _Score {
|
|
|
4411
4519
|
#chords;
|
|
4412
4520
|
/** The key regions, made on the first member that needs them. */
|
|
4413
4521
|
#regions;
|
|
4522
|
+
/** The reference profile asked for with no options, made on first read. */
|
|
4523
|
+
#profile;
|
|
4414
4524
|
/**
|
|
4415
4525
|
* Wrap plain score data.
|
|
4416
4526
|
*
|
|
@@ -4471,8 +4581,8 @@ var Score = class _Score {
|
|
|
4471
4581
|
static fromTicks(events, ppq, opts) {
|
|
4472
4582
|
const notes = assertDataObjects(events, "score notes").map((event) => ({
|
|
4473
4583
|
...event,
|
|
4474
|
-
startBeat:
|
|
4475
|
-
durationBeat:
|
|
4584
|
+
startBeat: _chunk3FDBMIPRcjs.ticksToBeats.call(void 0, event.startBeat, ppq),
|
|
4585
|
+
durationBeat: _chunk3FDBMIPRcjs.ticksToBeats.call(void 0, event.durationBeat, ppq)
|
|
4476
4586
|
}));
|
|
4477
4587
|
return new _Score(scoreData(notes, opts));
|
|
4478
4588
|
}
|
|
@@ -4521,8 +4631,8 @@ var Score = class _Score {
|
|
|
4521
4631
|
* @returns The score holding those notes.
|
|
4522
4632
|
*/
|
|
4523
4633
|
slice(fromBeat, toBeat) {
|
|
4524
|
-
|
|
4525
|
-
|
|
4634
|
+
_chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, fromBeat, "slice fromBeat");
|
|
4635
|
+
_chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, toBeat, "slice toBeat");
|
|
4526
4636
|
return this.#withNotes(
|
|
4527
4637
|
this.#data.notes.filter((note) => note.startBeat >= fromBeat && note.startBeat < toBeat)
|
|
4528
4638
|
);
|
|
@@ -4554,7 +4664,7 @@ var Score = class _Score {
|
|
|
4554
4664
|
* @returns The moved score.
|
|
4555
4665
|
*/
|
|
4556
4666
|
shift(beats) {
|
|
4557
|
-
|
|
4667
|
+
_chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, beats, "shift beats");
|
|
4558
4668
|
return this.#withNotes(
|
|
4559
4669
|
this.#data.notes.map((note) => ({ ...note, startBeat: note.startBeat + beats }))
|
|
4560
4670
|
);
|
|
@@ -4572,7 +4682,7 @@ var Score = class _Score {
|
|
|
4572
4682
|
* @throws If a note would leave the MIDI range.
|
|
4573
4683
|
*/
|
|
4574
4684
|
transpose(semitones) {
|
|
4575
|
-
|
|
4685
|
+
_chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, semitones, "transpose semitones");
|
|
4576
4686
|
return this.#moved(
|
|
4577
4687
|
this.#data.notes.map((note) => ({ ...note, pitch: note.pitch + semitones })),
|
|
4578
4688
|
(key) => key.transpose(semitones)
|
|
@@ -4592,7 +4702,7 @@ var Score = class _Score {
|
|
|
4592
4702
|
* @returns The transposed score.
|
|
4593
4703
|
*/
|
|
4594
4704
|
transposeBy(interval) {
|
|
4595
|
-
const step =
|
|
4705
|
+
const step = _chunkS3QELJUEcjs.toSpelledInterval.call(void 0, interval);
|
|
4596
4706
|
return this.#moved(
|
|
4597
4707
|
this.#data.notes.map((note) => ({ ...note, pitch: note.pitch + step.semitones })),
|
|
4598
4708
|
// Moved by the interval rather than by its semitone count, so a key taken
|
|
@@ -4603,7 +4713,7 @@ var Score = class _Score {
|
|
|
4603
4713
|
}
|
|
4604
4714
|
/** The same notes read against a different meter. */
|
|
4605
4715
|
withMeters(meters) {
|
|
4606
|
-
return new _Score({ ...this.#data, meters:
|
|
4716
|
+
return new _Score({ ...this.#data, meters: _chunkS3QELJUEcjs.resolveMeters.call(void 0, { meters }, "score meters") });
|
|
4607
4717
|
}
|
|
4608
4718
|
/** The same notes read against a different tempo. */
|
|
4609
4719
|
withTempo(tempo) {
|
|
@@ -4632,7 +4742,7 @@ var Score = class _Score {
|
|
|
4632
4742
|
* ```
|
|
4633
4743
|
*/
|
|
4634
4744
|
quantize(grid) {
|
|
4635
|
-
|
|
4745
|
+
_chunkS3QELJUEcjs.assertRange.call(void 0, grid, Number.MIN_VALUE, Number.MAX_SAFE_INTEGER, "quantize grid");
|
|
4636
4746
|
return this.#withNotes(
|
|
4637
4747
|
this.#data.notes.map((note) => ({
|
|
4638
4748
|
...note,
|
|
@@ -4644,43 +4754,42 @@ var Score = class _Score {
|
|
|
4644
4754
|
/**
|
|
4645
4755
|
* The notes pushed off the grid the way a player would.
|
|
4646
4756
|
*
|
|
4647
|
-
* The metric accents are read
|
|
4648
|
-
* {@link
|
|
4649
|
-
* to read a later stretch of a score that changes meter.
|
|
4757
|
+
* The metric accents are read against the score's meter map, exactly as
|
|
4758
|
+
* {@link humanize} reads that map; pass `ts` to read against another meter.
|
|
4650
4759
|
*
|
|
4651
4760
|
* @param opts Jitter amounts, accent depth and the seed; see
|
|
4652
4761
|
* {@link HumanizeOptions}.
|
|
4653
4762
|
* @returns The humanized score.
|
|
4654
4763
|
*/
|
|
4655
4764
|
humanize(opts) {
|
|
4656
|
-
return this.#withNotes(
|
|
4765
|
+
return this.#withNotes(_chunk6TTBEON3cjs.humanize.call(void 0, this.#data.notes, { ts: this.#data.meters, ...opts }));
|
|
4657
4766
|
}
|
|
4658
4767
|
/**
|
|
4659
4768
|
* The notes with ornaments added.
|
|
4660
4769
|
*
|
|
4661
|
-
* Strong positions are read
|
|
4662
|
-
* {@link
|
|
4770
|
+
* Strong positions are read against the score's meter map, exactly as
|
|
4771
|
+
* {@link ornament} reads that map.
|
|
4663
4772
|
*
|
|
4664
4773
|
* @param opts The ornament style, how much is decorated, and the seed; see
|
|
4665
4774
|
* {@link OrnamentOptions}.
|
|
4666
4775
|
* @returns The ornamented score.
|
|
4667
4776
|
*/
|
|
4668
4777
|
ornament(opts) {
|
|
4669
|
-
return this.#withNotes(
|
|
4778
|
+
return this.#withNotes(_chunk6TTBEON3cjs.ornament.call(void 0, this.#data.notes, { ts: this.#data.meters, ...opts }));
|
|
4670
4779
|
}
|
|
4671
4780
|
/**
|
|
4672
4781
|
* The notes placed on a groove template's slots.
|
|
4673
4782
|
*
|
|
4674
|
-
* The template's per-bar grid is laid out against the score's
|
|
4675
|
-
*
|
|
4676
|
-
* under
|
|
4783
|
+
* The template's per-bar grid is laid out against the score's meter map,
|
|
4784
|
+
* exactly as {@link applyGrooveTemplate} reads that map; a template extracted
|
|
4785
|
+
* under another meter is refused rather than drifting.
|
|
4677
4786
|
*
|
|
4678
4787
|
* @param template The groove template, from `extractGrooveTemplate`.
|
|
4679
4788
|
* @returns The score with the template's feel imposed.
|
|
4680
4789
|
* @throws If the template was extracted under another meter.
|
|
4681
4790
|
*/
|
|
4682
4791
|
groove(template) {
|
|
4683
|
-
return this.#withNotes(
|
|
4792
|
+
return this.#withNotes(_chunk6TTBEON3cjs.applyGrooveTemplate.call(void 0, this.#data.notes, template, this.#data.meters));
|
|
4684
4793
|
}
|
|
4685
4794
|
/**
|
|
4686
4795
|
* The feel of the score's own timing, as a template another score can take on.
|
|
@@ -4689,8 +4798,8 @@ var Score = class _Score {
|
|
|
4689
4798
|
* slot by slot for how far ahead of or behind the grid it sits and how hard
|
|
4690
4799
|
* it is struck, and the reading is handed back as a template. Only the
|
|
4691
4800
|
* subdivision is named, because the score already holds the meter the grid is
|
|
4692
|
-
* laid out against — its
|
|
4693
|
-
*
|
|
4801
|
+
* laid out against — its meter map, read exactly as
|
|
4802
|
+
* {@link extractGrooveTemplate} reads that map.
|
|
4694
4803
|
*
|
|
4695
4804
|
* @param subdivision Grid steps per quarter-note beat; a sixteenth-note grid
|
|
4696
4805
|
* by default, which is where swing, push and drag are audible.
|
|
@@ -4704,7 +4813,7 @@ var Score = class _Score {
|
|
|
4704
4813
|
* ```
|
|
4705
4814
|
*/
|
|
4706
4815
|
grooveTemplate(subdivision) {
|
|
4707
|
-
return
|
|
4816
|
+
return _chunk6TTBEON3cjs.extractGrooveTemplate.call(void 0, this.#data.notes, this.#data.meters, subdivision);
|
|
4708
4817
|
}
|
|
4709
4818
|
/**
|
|
4710
4819
|
* The harmony the notes spell out, in time.
|
|
@@ -4717,10 +4826,10 @@ var Score = class _Score {
|
|
|
4717
4826
|
* and how sure it is of each segment.
|
|
4718
4827
|
*/
|
|
4719
4828
|
timeline(opts) {
|
|
4720
|
-
const result = opts === void 0 ? this.#chordAnalysis() :
|
|
4829
|
+
const result = opts === void 0 ? this.#chordAnalysis() : _chunkLQZQDBCDcjs.chordTimelineFromNotes.call(void 0, this.#data.notes, this.#analysisOptions(opts));
|
|
4721
4830
|
return Timeline.fromData({
|
|
4722
4831
|
segments: result.timeline.segments,
|
|
4723
|
-
totalBeats: _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
4832
|
+
totalBeats: _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _37 => _37.totalBeats]), () => ( this.totalBeats)),
|
|
4724
4833
|
keys: result.keys,
|
|
4725
4834
|
segmentConfidence: result.segmentConfidence
|
|
4726
4835
|
});
|
|
@@ -4739,7 +4848,7 @@ var Score = class _Score {
|
|
|
4739
4848
|
if (this.#key !== void 0) {
|
|
4740
4849
|
return this.#key;
|
|
4741
4850
|
}
|
|
4742
|
-
const prevailing =
|
|
4851
|
+
const prevailing = _chunkLQZQDBCDcjs.prevailingKeyOf.call(void 0, this.#keyRegions());
|
|
4743
4852
|
return prevailing === null ? void 0 : toKey(prevailing);
|
|
4744
4853
|
}
|
|
4745
4854
|
/**
|
|
@@ -4758,9 +4867,10 @@ var Score = class _Score {
|
|
|
4758
4867
|
keys(opts) {
|
|
4759
4868
|
if (opts !== void 0) {
|
|
4760
4869
|
if (this.#key !== void 0) {
|
|
4761
|
-
|
|
4870
|
+
const totalBeats = opts.totalBeats === void 0 || opts.totalBeats === null ? this.totalBeats : _chunkS3QELJUEcjs.assertRange.call(void 0, opts.totalBeats, 0, Number.MAX_SAFE_INTEGER, "key timeline totalBeats");
|
|
4871
|
+
return scoreKeyRegions(this.#key, this.#data.notes, totalBeats);
|
|
4762
4872
|
}
|
|
4763
|
-
return
|
|
4873
|
+
return _chunkLQZQDBCDcjs.keyTimelineFromNotes.call(void 0, this.#data.notes, { meters: this.#data.meters, ...opts });
|
|
4764
4874
|
}
|
|
4765
4875
|
return this.#keyRegions().map(copyKeyRegion);
|
|
4766
4876
|
}
|
|
@@ -4788,7 +4898,7 @@ var Score = class _Score {
|
|
|
4788
4898
|
* ```
|
|
4789
4899
|
*/
|
|
4790
4900
|
detectKeys(opts) {
|
|
4791
|
-
return
|
|
4901
|
+
return _chunkLQZQDBCDcjs.detectKeyFromNotes.call(void 0, this.#data.notes, opts).map(detectedKeyMatch);
|
|
4792
4902
|
}
|
|
4793
4903
|
/**
|
|
4794
4904
|
* The phrases the notes fall into.
|
|
@@ -4800,7 +4910,7 @@ var Score = class _Score {
|
|
|
4800
4910
|
* @returns The phrases, in time order.
|
|
4801
4911
|
*/
|
|
4802
4912
|
phrases(opts) {
|
|
4803
|
-
return
|
|
4913
|
+
return _chunk3MDOEFIQcjs.phrasesFromTimeline.call(void 0, this.#chordTimeline(), this.#data.notes, {
|
|
4804
4914
|
meters: this.#data.meters,
|
|
4805
4915
|
...this.#key === void 0 ? {} : { key: keyIdentity(this.#key) },
|
|
4806
4916
|
...opts
|
|
@@ -4820,7 +4930,7 @@ var Score = class _Score {
|
|
|
4820
4930
|
* @returns The cadences, heaviest first; ties keep the earlier one.
|
|
4821
4931
|
*/
|
|
4822
4932
|
structuralCadences(opts) {
|
|
4823
|
-
return
|
|
4933
|
+
return _chunk3MDOEFIQcjs.structuralCadences.call(void 0, this.phrases(opts));
|
|
4824
4934
|
}
|
|
4825
4935
|
/**
|
|
4826
4936
|
* The sections the score divides into.
|
|
@@ -4829,7 +4939,7 @@ var Score = class _Score {
|
|
|
4829
4939
|
* @returns The sections, in time order.
|
|
4830
4940
|
*/
|
|
4831
4941
|
sections(opts) {
|
|
4832
|
-
return
|
|
4942
|
+
return _chunk3MDOEFIQcjs.sectionsFromNotes.call(void 0, this.#data.notes, { meters: this.#data.meters, ...opts });
|
|
4833
4943
|
}
|
|
4834
4944
|
/**
|
|
4835
4945
|
* The bar-level pulse above the meter.
|
|
@@ -4842,10 +4952,16 @@ var Score = class _Score {
|
|
|
4842
4952
|
* @returns The grouping, its downbeats, a confidence, and a rationale.
|
|
4843
4953
|
*/
|
|
4844
4954
|
hypermeter(opts) {
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
}
|
|
4955
|
+
const asked = { ...opts };
|
|
4956
|
+
if ((_nullishCoalesce(asked.cadenceBeats, () => ( null))) !== null) {
|
|
4957
|
+
return _chunk3MDOEFIQcjs.hypermeter.call(void 0, this.#data.notes, this.#data.meters, asked);
|
|
4958
|
+
}
|
|
4959
|
+
return _chunk3MDOEFIQcjs.hypermeterOver.call(void 0,
|
|
4960
|
+
this.#data.notes,
|
|
4961
|
+
this.#data.meters,
|
|
4962
|
+
asked,
|
|
4963
|
+
() => this.#cadenceSpans(asked.budget)
|
|
4964
|
+
);
|
|
4849
4965
|
}
|
|
4850
4966
|
/**
|
|
4851
4967
|
* The motifs the melody repeats.
|
|
@@ -4860,8 +4976,9 @@ var Score = class _Score {
|
|
|
4860
4976
|
*
|
|
4861
4977
|
* A melody is one line, so a score holding several is read as its top voice:
|
|
4862
4978
|
* notes struck together are one event and the highest of them stands for it.
|
|
4863
|
-
* A
|
|
4864
|
-
*
|
|
4979
|
+
* A block-chord part read whole therefore answers for its top voice rather
|
|
4980
|
+
* than for a line assembled from the insides of its chords; a lower note
|
|
4981
|
+
* struck while a higher one still sounds stays in the line, though. Split the
|
|
4865
4982
|
* score into lines first to have each of them answered for.
|
|
4866
4983
|
*
|
|
4867
4984
|
* @param opts Cell-length bounds and the recurrence threshold; see
|
|
@@ -4884,7 +5001,7 @@ var Score = class _Score {
|
|
|
4884
5001
|
* ```
|
|
4885
5002
|
*/
|
|
4886
5003
|
motifs(opts) {
|
|
4887
|
-
return
|
|
5004
|
+
return _chunkLQZQDBCDcjs.extractMotifs.call(void 0, this.#data.notes, opts);
|
|
4888
5005
|
}
|
|
4889
5006
|
/**
|
|
4890
5007
|
* The shape the melody traces.
|
|
@@ -4896,7 +5013,144 @@ var Score = class _Score {
|
|
|
4896
5013
|
* answered for; {@link Score.voices} is what reads the polyphony as polyphony.
|
|
4897
5014
|
*/
|
|
4898
5015
|
contour() {
|
|
4899
|
-
return
|
|
5016
|
+
return _chunkLQZQDBCDcjs.melodicContour.call(void 0, this.#data.notes);
|
|
5017
|
+
}
|
|
5018
|
+
/**
|
|
5019
|
+
* The score's structural fingerprint: form, phrase shape, harmonic function
|
|
5020
|
+
* and rhythm, and how its motifs derive from one another.
|
|
5021
|
+
*
|
|
5022
|
+
* The harmony is the score's own kept chord analysis, read once whether this
|
|
5023
|
+
* is asked before or after {@link Score.timeline} — unless `opts.timeline`
|
|
5024
|
+
* gives the harmony directly, in which case the reading runs fresh through
|
|
5025
|
+
* {@link analyzeReference} rather than the harmony this score already holds.
|
|
5026
|
+
* The meter, the key and the span are the score's own and are not on offer
|
|
5027
|
+
* here: a caller wanting another meter reads through {@link
|
|
5028
|
+
* Score.withMeters}, and one wanting another key or span calls {@link
|
|
5029
|
+
* analyzeReference} directly.
|
|
5030
|
+
*
|
|
5031
|
+
* Asked with no options, the answer is kept and a copy of it handed back, as
|
|
5032
|
+
* {@link Score.timeline} keeps its own reading; asked with options, the
|
|
5033
|
+
* answer is read afresh and not kept.
|
|
5034
|
+
*
|
|
5035
|
+
* @param opts The harmony, the melody, and the budget; see {@link
|
|
5036
|
+
* ReferenceProfileOptions}. Meter, key and span are the score's own.
|
|
5037
|
+
* @returns The profile.
|
|
5038
|
+
* @example
|
|
5039
|
+
* ```ts
|
|
5040
|
+
* import { Score } from '@libraz/libcantus';
|
|
5041
|
+
* const triad = (pitches: number[], startBeat: number) =>
|
|
5042
|
+
* pitches.map((pitch) => ({ pitch, startBeat, durationBeat: 4 }));
|
|
5043
|
+
* const score = Score.of(
|
|
5044
|
+
* [
|
|
5045
|
+
* ...triad([60, 64, 67], 0),
|
|
5046
|
+
* ...triad([65, 69, 72], 4),
|
|
5047
|
+
* ...triad([67, 71, 74], 8),
|
|
5048
|
+
* ...triad([60, 64, 67], 12),
|
|
5049
|
+
* ],
|
|
5050
|
+
* { key: 'C major' },
|
|
5051
|
+
* );
|
|
5052
|
+
* score.reference().harmony.chords.map((chord) => chord.roman); // ['I', 'IV', 'V', 'I']
|
|
5053
|
+
* ```
|
|
5054
|
+
*/
|
|
5055
|
+
reference(opts) {
|
|
5056
|
+
if (opts === void 0 && this.#profile !== void 0) {
|
|
5057
|
+
return copyPlain(this.#profile, "reference profile");
|
|
5058
|
+
}
|
|
5059
|
+
const keyed = this.#key === void 0 ? {} : { key: keyIdentity(this.#key) };
|
|
5060
|
+
const asked = {
|
|
5061
|
+
meters: this.#data.meters,
|
|
5062
|
+
totalBeats: this.totalBeats,
|
|
5063
|
+
...keyed,
|
|
5064
|
+
...opts
|
|
5065
|
+
};
|
|
5066
|
+
const profile = _optionalChain([opts, 'optionalAccess', _38 => _38.timeline]) === void 0 ? _chunk3MDOEFIQcjs.referenceFromReadings.call(void 0, this.#data.notes, this.#chordAnalysis(), asked) : _chunk3MDOEFIQcjs.analyzeReference.call(void 0, this.#data.notes, asked);
|
|
5067
|
+
if (opts === void 0) {
|
|
5068
|
+
this.#profile = profile;
|
|
5069
|
+
return copyPlain(profile, "reference profile");
|
|
5070
|
+
}
|
|
5071
|
+
return profile;
|
|
5072
|
+
}
|
|
5073
|
+
/**
|
|
5074
|
+
* The onset placement of the score's melodic line.
|
|
5075
|
+
*
|
|
5076
|
+
* A melody is one line, so a score holding several is read as its top voice,
|
|
5077
|
+
* as {@link Score.motifs} and {@link Score.contour} are.
|
|
5078
|
+
*
|
|
5079
|
+
* @param opts The span's end and the budget; see {@link
|
|
5080
|
+
* RhythmAnalysisOptions}. The meter is the score's own.
|
|
5081
|
+
* @returns The rhythm reading.
|
|
5082
|
+
* @example
|
|
5083
|
+
* ```ts
|
|
5084
|
+
* import { Score } from '@libraz/libcantus';
|
|
5085
|
+
* const score = Score.of([
|
|
5086
|
+
* { pitch: 60, startBeat: 0, durationBeat: 1 },
|
|
5087
|
+
* { pitch: 62, startBeat: 1, durationBeat: 1 },
|
|
5088
|
+
* { pitch: 64, startBeat: 2, durationBeat: 1 },
|
|
5089
|
+
* { pitch: 65, startBeat: 3, durationBeat: 1 },
|
|
5090
|
+
* ]);
|
|
5091
|
+
* score.rhythm().onsetDensity; // 4
|
|
5092
|
+
* ```
|
|
5093
|
+
*/
|
|
5094
|
+
rhythm(opts) {
|
|
5095
|
+
return _chunkLQZQDBCDcjs.analyzeRhythm.call(void 0, this.#data.notes, {
|
|
5096
|
+
meters: this.#data.meters,
|
|
5097
|
+
totalBeats: this.totalBeats,
|
|
5098
|
+
...opts
|
|
5099
|
+
});
|
|
5100
|
+
}
|
|
5101
|
+
/**
|
|
5102
|
+
* How the score's motifs derive from one another: which statement grew out
|
|
5103
|
+
* of which, and by what transformation.
|
|
5104
|
+
*
|
|
5105
|
+
* {@link Score.motifs} finds the cells; this reads across their occurrences
|
|
5106
|
+
* and names, for every statement after the first, the earlier one it most
|
|
5107
|
+
* plausibly grew out of. A melody is one line, so a score holding several is
|
|
5108
|
+
* read as its top voice, as {@link Score.motifs} is.
|
|
5109
|
+
*
|
|
5110
|
+
* @param opts Cell-length bounds and the recurrence threshold {@link
|
|
5111
|
+
* Score.motifs} takes, plus the variation threshold and the budget; see
|
|
5112
|
+
* {@link MotifGraphOptions} and {@link ExtractMotifsOptions}.
|
|
5113
|
+
* @returns The derivation forest.
|
|
5114
|
+
* @example
|
|
5115
|
+
* ```ts
|
|
5116
|
+
* import { Score } from '@libraz/libcantus';
|
|
5117
|
+
* const score = Score.of([
|
|
5118
|
+
* { pitch: 60, startBeat: 0, durationBeat: 1 },
|
|
5119
|
+
* { pitch: 62, startBeat: 1, durationBeat: 1 },
|
|
5120
|
+
* { pitch: 64, startBeat: 2, durationBeat: 1 },
|
|
5121
|
+
* { pitch: 60, startBeat: 3, durationBeat: 1 },
|
|
5122
|
+
* { pitch: 62, startBeat: 4, durationBeat: 1 },
|
|
5123
|
+
* { pitch: 64, startBeat: 5, durationBeat: 1 },
|
|
5124
|
+
* ]);
|
|
5125
|
+
* score.motifGraph().edges.length; // 1
|
|
5126
|
+
* ```
|
|
5127
|
+
*/
|
|
5128
|
+
motifGraph(opts) {
|
|
5129
|
+
return _chunkLQZQDBCDcjs.motifGraph.call(void 0, this.#data.notes, _chunkLQZQDBCDcjs.extractMotifs.call(void 0, this.#data.notes, opts), {
|
|
5130
|
+
key: this.key(),
|
|
5131
|
+
...opts
|
|
5132
|
+
});
|
|
5133
|
+
}
|
|
5134
|
+
/**
|
|
5135
|
+
* How this score, read as a melody, keeps to a composition plan.
|
|
5136
|
+
*
|
|
5137
|
+
* @param plan The plan the melody was written for.
|
|
5138
|
+
* @param opts The budget; see {@link EvaluateCompositionOptions}.
|
|
5139
|
+
* @returns The violations found and the fit reading; see {@link
|
|
5140
|
+
* evaluateComposition}.
|
|
5141
|
+
* @example
|
|
5142
|
+
* ```ts
|
|
5143
|
+
* import { Composer, Score } from '@libraz/libcantus';
|
|
5144
|
+
* const notes = [60, 62, 64, 65, 67, 65, 64, 62, 60, 62, 64, 65, 67, 65, 64, 60].map(
|
|
5145
|
+
* (pitch, startBeat) => ({ pitch, startBeat, durationBeat: 1 }),
|
|
5146
|
+
* );
|
|
5147
|
+
* const composer = Composer.of({ key: 'C major', seed: 5 });
|
|
5148
|
+
* const plan = composer.plan(Score.of(notes, { key: 'C major' }).reference());
|
|
5149
|
+
* composer.melody(plan).evaluate(plan).violations.some((v) => v.severity === 'error'); // false
|
|
5150
|
+
* ```
|
|
5151
|
+
*/
|
|
5152
|
+
evaluate(plan, opts) {
|
|
5153
|
+
return _chunk6TTBEON3cjs.evaluateComposition.call(void 0, this.#data.notes, plan, opts);
|
|
4900
5154
|
}
|
|
4901
5155
|
/**
|
|
4902
5156
|
* Each note's role in the harmony sounding under it.
|
|
@@ -4920,7 +5174,7 @@ var Score = class _Score {
|
|
|
4920
5174
|
*/
|
|
4921
5175
|
voices(key) {
|
|
4922
5176
|
const timeline = this.#chordTimeline();
|
|
4923
|
-
return
|
|
5177
|
+
return _chunk3MDOEFIQcjs.analyzePolyphony.call(void 0, this.#data.notes, timeline.at, this.#keyContext(key));
|
|
4924
5178
|
}
|
|
4925
5179
|
/**
|
|
4926
5180
|
* The notes carrying the ids the voice analysis reports them back under.
|
|
@@ -4934,7 +5188,7 @@ var Score = class _Score {
|
|
|
4934
5188
|
* @returns One voice note per note, in the score's own time order.
|
|
4935
5189
|
*/
|
|
4936
5190
|
voiceNotes() {
|
|
4937
|
-
return
|
|
5191
|
+
return _chunkLQZQDBCDcjs.toVoiceNotes.call(void 0, this.#data.notes);
|
|
4938
5192
|
}
|
|
4939
5193
|
/**
|
|
4940
5194
|
* Whether an instrument can play the score, and what makes it hard.
|
|
@@ -4958,14 +5212,14 @@ var Score = class _Score {
|
|
|
4958
5212
|
* ```
|
|
4959
5213
|
*/
|
|
4960
5214
|
playability(instrument) {
|
|
4961
|
-
const profile =
|
|
5215
|
+
const profile = _chunkWOMCXN2Wcjs.toInstrumentProfile.call(void 0, instrument);
|
|
4962
5216
|
const tempo = this.#data.tempo;
|
|
4963
|
-
const openingBpm =
|
|
5217
|
+
const openingBpm = _chunk3FDBMIPRcjs.tempoAt.call(void 0, 0, tempo);
|
|
4964
5218
|
if (tempo.length < 2) {
|
|
4965
|
-
return
|
|
5219
|
+
return _chunkWOMCXN2Wcjs.playability.call(void 0, this.#data.notes, profile, openingBpm);
|
|
4966
5220
|
}
|
|
4967
|
-
const played =
|
|
4968
|
-
const evenly =
|
|
5221
|
+
const played = _chunk3FDBMIPRcjs.tempoReader.call(void 0, tempo);
|
|
5222
|
+
const evenly = _chunk3FDBMIPRcjs.tempoReader.call(void 0, [{ startBeat: 0, bpm: openingBpm }]);
|
|
4969
5223
|
const restate = (beat) => evenly.beatAt(played.secondsAt(beat));
|
|
4970
5224
|
const scoreBeats = /* @__PURE__ */ new Map();
|
|
4971
5225
|
const evenlyPaced = this.#data.notes.map((note) => {
|
|
@@ -4977,7 +5231,7 @@ var Score = class _Score {
|
|
|
4977
5231
|
durationBeat: restate(note.startBeat + note.durationBeat) - startBeat
|
|
4978
5232
|
};
|
|
4979
5233
|
});
|
|
4980
|
-
const report =
|
|
5234
|
+
const report = _chunkWOMCXN2Wcjs.playability.call(void 0, evenlyPaced, profile, openingBpm);
|
|
4981
5235
|
return {
|
|
4982
5236
|
...report,
|
|
4983
5237
|
issues: report.issues.map((issue) => ({
|
|
@@ -4993,7 +5247,7 @@ var Score = class _Score {
|
|
|
4993
5247
|
* @returns The index.
|
|
4994
5248
|
*/
|
|
4995
5249
|
index(opts) {
|
|
4996
|
-
return
|
|
5250
|
+
return _chunkKMYGRFZ6cjs.createNoteEventIndex.call(void 0, this.#data.notes, {
|
|
4997
5251
|
allowNonPositiveDuration: true,
|
|
4998
5252
|
name: "score notes",
|
|
4999
5253
|
...opts
|
|
@@ -5010,7 +5264,7 @@ var Score = class _Score {
|
|
|
5010
5264
|
* @returns Elapsed seconds from the tempo map's origin.
|
|
5011
5265
|
*/
|
|
5012
5266
|
secondsAt(beat) {
|
|
5013
|
-
return
|
|
5267
|
+
return _chunk3FDBMIPRcjs.beatsToSeconds.call(void 0, beat, this.#data.tempo);
|
|
5014
5268
|
}
|
|
5015
5269
|
/**
|
|
5016
5270
|
* Where a beat falls in bars, read through the meter map.
|
|
@@ -5020,7 +5274,7 @@ var Score = class _Score {
|
|
|
5020
5274
|
* reports bar -1.
|
|
5021
5275
|
*/
|
|
5022
5276
|
barAt(beat) {
|
|
5023
|
-
return
|
|
5277
|
+
return _chunkS3QELJUEcjs.beatToBarPosition.call(void 0, beat, this.#data.meters);
|
|
5024
5278
|
}
|
|
5025
5279
|
/**
|
|
5026
5280
|
* The time signature sounding at a beat.
|
|
@@ -5029,7 +5283,7 @@ var Score = class _Score {
|
|
|
5029
5283
|
* @returns The signature in force there.
|
|
5030
5284
|
*/
|
|
5031
5285
|
meterAt(beat) {
|
|
5032
|
-
return
|
|
5286
|
+
return _chunkS3QELJUEcjs.meterAt.call(void 0, beat, this.#data.meters);
|
|
5033
5287
|
}
|
|
5034
5288
|
/**
|
|
5035
5289
|
* The score's beats as MIDI ticks, for a writer that counts in them.
|
|
@@ -5040,8 +5294,8 @@ var Score = class _Score {
|
|
|
5040
5294
|
toTicks(ppq) {
|
|
5041
5295
|
return this.#data.notes.map((note) => ({
|
|
5042
5296
|
...note,
|
|
5043
|
-
startBeat:
|
|
5044
|
-
durationBeat:
|
|
5297
|
+
startBeat: _chunk3FDBMIPRcjs.beatsToTicks.call(void 0, note.startBeat, ppq),
|
|
5298
|
+
durationBeat: _chunk3FDBMIPRcjs.beatsToTicks.call(void 0, note.durationBeat, ppq)
|
|
5045
5299
|
}));
|
|
5046
5300
|
}
|
|
5047
5301
|
/**
|
|
@@ -5114,7 +5368,7 @@ var Score = class _Score {
|
|
|
5114
5368
|
* Score.timeline} hands all three to the class it builds.
|
|
5115
5369
|
*/
|
|
5116
5370
|
#chordAnalysis() {
|
|
5117
|
-
const analysis = _nullishCoalesce(this.#chords, () => (
|
|
5371
|
+
const analysis = _nullishCoalesce(this.#chords, () => ( _chunkLQZQDBCDcjs.chordTimelineFromNotes.call(void 0, this.#data.notes, this.#analysisOptions())));
|
|
5118
5372
|
this.#chords = analysis;
|
|
5119
5373
|
return analysis;
|
|
5120
5374
|
}
|
|
@@ -5125,15 +5379,24 @@ var Score = class _Score {
|
|
|
5125
5379
|
* Kept on first reading for the same reason the chord timeline is.
|
|
5126
5380
|
*/
|
|
5127
5381
|
#keyRegions() {
|
|
5128
|
-
const regions = _nullishCoalesce(this.#regions, () => ( (this.#key === void 0 ?
|
|
5382
|
+
const regions = _nullishCoalesce(this.#regions, () => ( (this.#key === void 0 ? _chunkLQZQDBCDcjs.keyTimelineFromNotes.call(void 0, this.#data.notes, { meters: this.#data.meters }) : scoreKeyRegions(this.#key, this.#data.notes, this.totalBeats))));
|
|
5129
5383
|
this.#regions = regions;
|
|
5130
5384
|
return regions;
|
|
5131
5385
|
}
|
|
5132
|
-
/**
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5386
|
+
/**
|
|
5387
|
+
* Where the score's own harmony closes, as the spans its arrival chords sound
|
|
5388
|
+
* through, read in the key {@link Score.phrases} reads them in.
|
|
5389
|
+
*/
|
|
5390
|
+
#cadenceSpans(budget) {
|
|
5391
|
+
const timeline = this.#chordTimeline();
|
|
5392
|
+
const key = _chunk3MDOEFIQcjs.keyContextFor.call(void 0,
|
|
5393
|
+
this.#key === void 0 ? void 0 : keyIdentity(this.#key),
|
|
5394
|
+
timeline,
|
|
5395
|
+
this.#data.meters,
|
|
5396
|
+
void 0,
|
|
5397
|
+
budget
|
|
5136
5398
|
);
|
|
5399
|
+
return _chunk3MDOEFIQcjs.boundaryCadences.call(void 0, timeline, key).spans;
|
|
5137
5400
|
}
|
|
5138
5401
|
/** The score's context as chord-timeline options, with the caller's on top. */
|
|
5139
5402
|
#analysisOptions(opts) {
|
|
@@ -5156,9 +5419,9 @@ var Score = class _Score {
|
|
|
5156
5419
|
return keyIdentity(this.#key);
|
|
5157
5420
|
}
|
|
5158
5421
|
const regions = this.#keyRegions();
|
|
5159
|
-
const prevailing = _nullishCoalesce(
|
|
5160
|
-
const keyAt =
|
|
5161
|
-
return (beat) =>
|
|
5422
|
+
const prevailing = _nullishCoalesce(_chunkLQZQDBCDcjs.prevailingKeyOf.call(void 0, regions), () => ( keyIdentity(Key.major("C"))));
|
|
5423
|
+
const keyAt = _chunkLQZQDBCDcjs.keyLookup.call(void 0, regions, prevailing);
|
|
5424
|
+
return (beat) => _chunkYDGMWH43cjs.scaleOf.call(void 0, keyAt(beat));
|
|
5162
5425
|
}
|
|
5163
5426
|
};
|
|
5164
5427
|
function sameNote(note, other) {
|
|
@@ -5194,7 +5457,7 @@ function copyTrack(track, index, budget) {
|
|
|
5194
5457
|
copy.name = track.name;
|
|
5195
5458
|
}
|
|
5196
5459
|
if (track.role !== void 0) {
|
|
5197
|
-
copy.role =
|
|
5460
|
+
copy.role = _chunk3MDOEFIQcjs.trackRoleOf.call(void 0, track.role, `tracks[${index}].role`);
|
|
5198
5461
|
}
|
|
5199
5462
|
return copy;
|
|
5200
5463
|
}
|
|
@@ -5209,21 +5472,21 @@ function copySegments(segments) {
|
|
|
5209
5472
|
function chordTimelineOf(segments) {
|
|
5210
5473
|
return new Timeline({ segments: [...segments], totalBeats: spanEnd(segments) }).chordTimeline;
|
|
5211
5474
|
}
|
|
5212
|
-
function copySettings(settings,
|
|
5475
|
+
function copySettings(settings, tracks) {
|
|
5213
5476
|
if (settings === void 0) {
|
|
5214
5477
|
return void 0;
|
|
5215
5478
|
}
|
|
5216
5479
|
assertDataObject(settings, "arrangement settings");
|
|
5217
5480
|
const copy = {};
|
|
5218
|
-
const meters =
|
|
5481
|
+
const meters = _chunkS3QELJUEcjs.resolveMeters.call(void 0, { ts: settings.ts, meters: settings.meters }, "arrangement meters");
|
|
5219
5482
|
if (settings.ts !== void 0) {
|
|
5220
|
-
copy.ts = copyPlain(
|
|
5483
|
+
copy.ts = copyPlain(_chunkS3QELJUEcjs.toMeterData.call(void 0, settings.ts, "arrangement ts"), "arrangement ts");
|
|
5221
5484
|
}
|
|
5222
5485
|
if (settings.meters !== void 0) {
|
|
5223
5486
|
copy.meters = copyPlain(meters, "arrangement meters");
|
|
5224
5487
|
}
|
|
5225
5488
|
if (settings.key !== void 0) {
|
|
5226
|
-
copy.key =
|
|
5489
|
+
copy.key = _chunkYDGMWH43cjs.resolveKey.call(void 0, settings.key);
|
|
5227
5490
|
}
|
|
5228
5491
|
if (settings.keys !== void 0) {
|
|
5229
5492
|
copy.keys = copyKeyRegions(settings.keys);
|
|
@@ -5236,11 +5499,12 @@ function copySettings(settings, trackCount) {
|
|
|
5236
5499
|
settings.harmonyTracks,
|
|
5237
5500
|
"arrangement harmonyTracks"
|
|
5238
5501
|
).map(
|
|
5239
|
-
(track, index) =>
|
|
5502
|
+
(track, index) => _chunkS3QELJUEcjs.assertInteger.call(void 0, track, `arrangement harmonyTracks[${index}]`, 0, tracks.length - 1)
|
|
5240
5503
|
);
|
|
5504
|
+
_chunk3MDOEFIQcjs.harmonyTrackSet.call(void 0, copy.harmonyTracks, tracks, "arrangement harmonyTracks");
|
|
5241
5505
|
}
|
|
5242
5506
|
if (settings.minSeverity !== void 0) {
|
|
5243
|
-
copy.minSeverity =
|
|
5507
|
+
copy.minSeverity = _chunkS3QELJUEcjs.assertInteger.call(void 0,
|
|
5244
5508
|
settings.minSeverity,
|
|
5245
5509
|
"arrangement minSeverity",
|
|
5246
5510
|
0 /* Safe */,
|
|
@@ -5248,15 +5512,20 @@ function copySettings(settings, trackCount) {
|
|
|
5248
5512
|
);
|
|
5249
5513
|
}
|
|
5250
5514
|
if (settings.pickupBeats !== void 0) {
|
|
5251
|
-
copy.pickupBeats =
|
|
5515
|
+
copy.pickupBeats = _chunkS3QELJUEcjs.assertRange.call(void 0,
|
|
5252
5516
|
settings.pickupBeats,
|
|
5253
5517
|
0,
|
|
5254
5518
|
Number.MAX_SAFE_INTEGER,
|
|
5255
5519
|
"arrangement pickupBeats"
|
|
5256
5520
|
);
|
|
5521
|
+
_chunk3MDOEFIQcjs.assertTrackNotes.call(void 0, tracks, {
|
|
5522
|
+
allowNonPositiveDuration: true,
|
|
5523
|
+
minStartBeat: -copy.pickupBeats,
|
|
5524
|
+
budget: settings.budget
|
|
5525
|
+
});
|
|
5257
5526
|
}
|
|
5258
5527
|
if (settings.harmonicRhythm !== void 0) {
|
|
5259
|
-
copy.harmonicRhythm =
|
|
5528
|
+
copy.harmonicRhythm = _chunkS3QELJUEcjs.assertRange.call(void 0,
|
|
5260
5529
|
settings.harmonicRhythm,
|
|
5261
5530
|
Number.MIN_VALUE,
|
|
5262
5531
|
Number.MAX_SAFE_INTEGER,
|
|
@@ -5264,20 +5533,20 @@ function copySettings(settings, trackCount) {
|
|
|
5264
5533
|
);
|
|
5265
5534
|
}
|
|
5266
5535
|
if (settings.profile !== void 0) {
|
|
5267
|
-
copy.profile = settings.profile;
|
|
5536
|
+
copy.profile = _chunk3MDOEFIQcjs.arrangementProfile.call(void 0, settings.profile);
|
|
5268
5537
|
}
|
|
5269
5538
|
if (settings.budget !== void 0) {
|
|
5270
|
-
copy.budget =
|
|
5539
|
+
copy.budget = _chunkS3QELJUEcjs.assertPositiveInt.call(void 0, settings.budget, "arrangement budget", Number.MAX_SAFE_INTEGER);
|
|
5271
5540
|
}
|
|
5272
5541
|
return Object.keys(copy).length === 0 ? void 0 : copy;
|
|
5273
5542
|
}
|
|
5274
5543
|
function copyArrangement(data) {
|
|
5275
5544
|
assertDataObject(data, "arrangement data");
|
|
5276
|
-
const budget = _optionalChain([data, 'access',
|
|
5545
|
+
const budget = _optionalChain([data, 'access', _39 => _39.settings, 'optionalAccess', _40 => _40.budget]);
|
|
5277
5546
|
const tracks = assertDataArray(data.tracks, "arrangement tracks").map(
|
|
5278
5547
|
(track, index) => copyTrack(track, index, budget)
|
|
5279
5548
|
);
|
|
5280
|
-
const settings = copySettings(data.settings, tracks
|
|
5549
|
+
const settings = copySettings(data.settings, tracks);
|
|
5281
5550
|
return settings === void 0 ? { tracks } : { tracks, settings };
|
|
5282
5551
|
}
|
|
5283
5552
|
function arrangementData(tracks, settings) {
|
|
@@ -5297,10 +5566,10 @@ function settingsFrom(setup) {
|
|
|
5297
5566
|
const { key, meters, timeline, ...rest } = setup;
|
|
5298
5567
|
const settings = { ...rest };
|
|
5299
5568
|
if (key !== void 0) {
|
|
5300
|
-
settings.key =
|
|
5569
|
+
settings.key = _chunkYDGMWH43cjs.resolveKey.call(void 0, key);
|
|
5301
5570
|
}
|
|
5302
5571
|
if (meters !== void 0) {
|
|
5303
|
-
settings.meters =
|
|
5572
|
+
settings.meters = _chunkS3QELJUEcjs.resolveMeters.call(void 0, { meters }, "arrangement meters");
|
|
5304
5573
|
}
|
|
5305
5574
|
if (timeline !== void 0) {
|
|
5306
5575
|
assertDataObject(timeline, "arrangement timeline");
|
|
@@ -5318,10 +5587,10 @@ function analysisOptionsOf(setup) {
|
|
|
5318
5587
|
const { key, meters, ...rest } = setup;
|
|
5319
5588
|
const opts = { ...rest };
|
|
5320
5589
|
if (key !== void 0) {
|
|
5321
|
-
opts.key =
|
|
5590
|
+
opts.key = _chunkYDGMWH43cjs.resolveKey.call(void 0, key);
|
|
5322
5591
|
}
|
|
5323
5592
|
if (meters !== void 0) {
|
|
5324
|
-
opts.meters =
|
|
5593
|
+
opts.meters = _chunkS3QELJUEcjs.resolveMeters.call(void 0, { meters }, "arrangement meters");
|
|
5325
5594
|
}
|
|
5326
5595
|
return opts;
|
|
5327
5596
|
}
|
|
@@ -5463,7 +5732,7 @@ var Arrangement = class _Arrangement {
|
|
|
5463
5732
|
}
|
|
5464
5733
|
copied.push({
|
|
5465
5734
|
trackIndex: edit.trackIndex,
|
|
5466
|
-
notes: copyNotes(edit.notes, `edits[${index}].notes`, _optionalChain([this, 'access',
|
|
5735
|
+
notes: copyNotes(edit.notes, `edits[${index}].notes`, _optionalChain([this, 'access', _41 => _41.#data, 'access', _42 => _42.settings, 'optionalAccess', _43 => _43.budget]))
|
|
5467
5736
|
});
|
|
5468
5737
|
}
|
|
5469
5738
|
const session = this.#session().update(copied);
|
|
@@ -5488,7 +5757,7 @@ var Arrangement = class _Arrangement {
|
|
|
5488
5757
|
* @returns One tension reading per sampled beat, in beat order.
|
|
5489
5758
|
*/
|
|
5490
5759
|
tension(opts) {
|
|
5491
|
-
return
|
|
5760
|
+
return _chunk3MDOEFIQcjs.tensionCurveFrom.call(void 0,
|
|
5492
5761
|
[...this.#data.tracks],
|
|
5493
5762
|
this.#session().analysis,
|
|
5494
5763
|
this.#layered(analysisOptionsOf(opts))
|
|
@@ -5514,7 +5783,7 @@ var Arrangement = class _Arrangement {
|
|
|
5514
5783
|
* tracks exceed the budget.
|
|
5515
5784
|
*/
|
|
5516
5785
|
analyze(opts) {
|
|
5517
|
-
return
|
|
5786
|
+
return _chunk3MDOEFIQcjs.analyzeArrangement.call(void 0, [...this.#data.tracks], this.#layered(analysisOptionsOf(opts)));
|
|
5518
5787
|
}
|
|
5519
5788
|
/**
|
|
5520
5789
|
* The harmony the tracks spell out together, in time.
|
|
@@ -5532,6 +5801,71 @@ var Arrangement = class _Arrangement {
|
|
|
5532
5801
|
keys: [...keys]
|
|
5533
5802
|
});
|
|
5534
5803
|
}
|
|
5804
|
+
/**
|
|
5805
|
+
* The arrangement's structural fingerprint: form, phrase shape, harmonic
|
|
5806
|
+
* function and rhythm, and how its melody's motifs derive from one another.
|
|
5807
|
+
*
|
|
5808
|
+
* The harmony reads the arrangement's own session analysis directly — the
|
|
5809
|
+
* tracks `settings.harmonyTracks` names, or else every track but the
|
|
5810
|
+
* percussion ones — so the harmony is never inferred a second time. The
|
|
5811
|
+
* melody is the notes of the tracks played with `role: 'melody'`, joined in
|
|
5812
|
+
* the order the tracks were given; an arrangement naming none reads the top
|
|
5813
|
+
* line of the harmony notes instead, as {@link analyzeReference} does
|
|
5814
|
+
* without a `melody` option. Meter, key, harmony and melody are the
|
|
5815
|
+
* arrangement's own and are not on offer here: a caller wanting others calls
|
|
5816
|
+
* {@link analyzeReference} directly, with the same notes {@link
|
|
5817
|
+
* Arrangement.tracks} hands out.
|
|
5818
|
+
*
|
|
5819
|
+
* @param opts The budget; see {@link ReferenceProfileOptions}.
|
|
5820
|
+
* @returns The profile.
|
|
5821
|
+
* @example
|
|
5822
|
+
* ```ts
|
|
5823
|
+
* import { Arrangement } from '@libraz/libcantus';
|
|
5824
|
+
* const triad = (pitches: number[], startBeat: number) =>
|
|
5825
|
+
* pitches.map((pitch) => ({ pitch, startBeat, durationBeat: 4 }));
|
|
5826
|
+
* const arrangement = Arrangement.of(
|
|
5827
|
+
* [
|
|
5828
|
+
* {
|
|
5829
|
+
* name: 'lead',
|
|
5830
|
+
* role: 'melody',
|
|
5831
|
+
* notes: [
|
|
5832
|
+
* ...triad([60, 64, 67], 0),
|
|
5833
|
+
* ...triad([65, 69, 72], 4),
|
|
5834
|
+
* ...triad([67, 71, 74], 8),
|
|
5835
|
+
* ...triad([60, 64, 67], 12),
|
|
5836
|
+
* ],
|
|
5837
|
+
* },
|
|
5838
|
+
* ],
|
|
5839
|
+
* { key: 'C major' },
|
|
5840
|
+
* );
|
|
5841
|
+
* arrangement.reference().harmony.chords.map((chord) => chord.roman); // ['I', 'IV', 'V', 'I']
|
|
5842
|
+
* ```
|
|
5843
|
+
*/
|
|
5844
|
+
reference(opts) {
|
|
5845
|
+
const tracks = this.#data.tracks;
|
|
5846
|
+
const harmonyTracks = _optionalChain([this, 'access', _44 => _44.#data, 'access', _45 => _45.settings, 'optionalAccess', _46 => _46.harmonyTracks]);
|
|
5847
|
+
const harmony = [];
|
|
5848
|
+
const melody = [];
|
|
5849
|
+
for (let index = 0; index < tracks.length; index += 1) {
|
|
5850
|
+
const track = tracks[index];
|
|
5851
|
+
if (track === void 0) {
|
|
5852
|
+
continue;
|
|
5853
|
+
}
|
|
5854
|
+
if (track.role !== "drums" && (harmonyTracks === void 0 || harmonyTracks.includes(index))) {
|
|
5855
|
+
harmony.push(...track.notes);
|
|
5856
|
+
}
|
|
5857
|
+
if (track.role === "melody") {
|
|
5858
|
+
melody.push(...track.notes);
|
|
5859
|
+
}
|
|
5860
|
+
}
|
|
5861
|
+
return _chunk3MDOEFIQcjs.referenceFromReadings.call(void 0, harmony, this.#session().analysis, {
|
|
5862
|
+
// The meter the arrangement's own analysis reads, `ts` included.
|
|
5863
|
+
meters: _nullishCoalesce(_optionalChain([this, 'access', _47 => _47.#data, 'access', _48 => _48.settings, 'optionalAccess', _49 => _49.meters]), () => ( _optionalChain([this, 'access', _50 => _50.#data, 'access', _51 => _51.settings, 'optionalAccess', _52 => _52.ts]))),
|
|
5864
|
+
totalBeats: this.timeline().totalBeats,
|
|
5865
|
+
...melody.length === 0 ? {} : { melody },
|
|
5866
|
+
...opts
|
|
5867
|
+
});
|
|
5868
|
+
}
|
|
5535
5869
|
/**
|
|
5536
5870
|
* Whether another arrangement holds the same tracks under the same settings.
|
|
5537
5871
|
*
|
|
@@ -5556,7 +5890,7 @@ var Arrangement = class _Arrangement {
|
|
|
5556
5890
|
}
|
|
5557
5891
|
/** The open reading, analysing the tracks on the first call. */
|
|
5558
5892
|
#session() {
|
|
5559
|
-
const open = _nullishCoalesce(this.#open, () => (
|
|
5893
|
+
const open = _nullishCoalesce(this.#open, () => ( _chunk3MDOEFIQcjs.createArrangementSession.call(void 0, [...this.#data.tracks], this.#analysisOptions())));
|
|
5560
5894
|
this.#open = open;
|
|
5561
5895
|
return open;
|
|
5562
5896
|
}
|
|
@@ -5596,12 +5930,12 @@ var Arrangement = class _Arrangement {
|
|
|
5596
5930
|
#scoreOptions() {
|
|
5597
5931
|
const settings = this.#data.settings;
|
|
5598
5932
|
const opts = {};
|
|
5599
|
-
if (_optionalChain([settings, 'optionalAccess',
|
|
5933
|
+
if (_optionalChain([settings, 'optionalAccess', _53 => _53.meters]) !== void 0) {
|
|
5600
5934
|
opts.meters = settings.meters;
|
|
5601
|
-
} else if (_optionalChain([settings, 'optionalAccess',
|
|
5935
|
+
} else if (_optionalChain([settings, 'optionalAccess', _54 => _54.ts]) !== void 0) {
|
|
5602
5936
|
opts.meters = settings.ts;
|
|
5603
5937
|
}
|
|
5604
|
-
if (_optionalChain([settings, 'optionalAccess',
|
|
5938
|
+
if (_optionalChain([settings, 'optionalAccess', _55 => _55.key]) !== void 0) {
|
|
5605
5939
|
opts.key = settings.key;
|
|
5606
5940
|
}
|
|
5607
5941
|
return opts;
|
|
@@ -5637,7 +5971,9 @@ function copyProfile(profile) {
|
|
|
5637
5971
|
}
|
|
5638
5972
|
const reach = {};
|
|
5639
5973
|
for (const [pitch, limbs] of Object.entries(profile.reach)) {
|
|
5640
|
-
|
|
5974
|
+
if (String(Number(pitch)) === pitch) {
|
|
5975
|
+
reach[Number(pitch)] = [...limbs];
|
|
5976
|
+
}
|
|
5641
5977
|
}
|
|
5642
5978
|
const percussion = {
|
|
5643
5979
|
kind: "percussion",
|
|
@@ -5651,7 +5987,7 @@ function copyProfile(profile) {
|
|
|
5651
5987
|
return percussion;
|
|
5652
5988
|
}
|
|
5653
5989
|
function checkedProfile(profile) {
|
|
5654
|
-
return copyProfile(
|
|
5990
|
+
return copyProfile(_chunkWOMCXN2Wcjs.toInstrumentProfile.call(void 0, profile));
|
|
5655
5991
|
}
|
|
5656
5992
|
var Instrument = class _Instrument {
|
|
5657
5993
|
#profile;
|
|
@@ -5687,7 +6023,7 @@ var Instrument = class _Instrument {
|
|
|
5687
6023
|
* @returns The instrument.
|
|
5688
6024
|
*/
|
|
5689
6025
|
static guitar() {
|
|
5690
|
-
return _Instrument.of(
|
|
6026
|
+
return _Instrument.of(_chunkWOMCXN2Wcjs.GUITAR_STANDARD);
|
|
5691
6027
|
}
|
|
5692
6028
|
/**
|
|
5693
6029
|
* Six-string guitar in drop D: the lowest string down a tone to D2, the rest
|
|
@@ -5696,7 +6032,7 @@ var Instrument = class _Instrument {
|
|
|
5696
6032
|
* @returns The instrument.
|
|
5697
6033
|
*/
|
|
5698
6034
|
static guitarDropD() {
|
|
5699
|
-
return _Instrument.of(
|
|
6035
|
+
return _Instrument.of(_chunkWOMCXN2Wcjs.GUITAR_DROP_D);
|
|
5700
6036
|
}
|
|
5701
6037
|
/**
|
|
5702
6038
|
* Electric bass in standard tuning: E1 A1 D2 G2.
|
|
@@ -5704,7 +6040,7 @@ var Instrument = class _Instrument {
|
|
|
5704
6040
|
* @returns The instrument.
|
|
5705
6041
|
*/
|
|
5706
6042
|
static bass4() {
|
|
5707
|
-
return _Instrument.of(
|
|
6043
|
+
return _Instrument.of(_chunkWOMCXN2Wcjs.BASS_4_STRING);
|
|
5708
6044
|
}
|
|
5709
6045
|
/**
|
|
5710
6046
|
* Five-string bass with the low B: B0 E1 A1 D2 G2.
|
|
@@ -5717,7 +6053,7 @@ var Instrument = class _Instrument {
|
|
|
5717
6053
|
* ```
|
|
5718
6054
|
*/
|
|
5719
6055
|
static bass5() {
|
|
5720
|
-
return _Instrument.of(
|
|
6056
|
+
return _Instrument.of(_chunkWOMCXN2Wcjs.BASS_5_STRING);
|
|
5721
6057
|
}
|
|
5722
6058
|
/**
|
|
5723
6059
|
* Rebuild an instrument from the plain profile {@link Instrument.data} hands
|
|
@@ -5775,7 +6111,7 @@ var Instrument = class _Instrument {
|
|
|
5775
6111
|
* ```
|
|
5776
6112
|
*/
|
|
5777
6113
|
range() {
|
|
5778
|
-
return
|
|
6114
|
+
return _chunkWOMCXN2Wcjs.rangeIn.call(void 0, this.#profile);
|
|
5779
6115
|
}
|
|
5780
6116
|
/**
|
|
5781
6117
|
* Whether the instrument has this pitch at all.
|
|
@@ -5785,8 +6121,8 @@ var Instrument = class _Instrument {
|
|
|
5785
6121
|
* produces it.
|
|
5786
6122
|
*/
|
|
5787
6123
|
canSound(pitch) {
|
|
5788
|
-
|
|
5789
|
-
return
|
|
6124
|
+
_chunkS3QELJUEcjs.assertMidiPitch.call(void 0, pitch, "pitch");
|
|
6125
|
+
return _chunkWOMCXN2Wcjs.soundsIn.call(void 0, this.#profile, pitch);
|
|
5790
6126
|
}
|
|
5791
6127
|
/**
|
|
5792
6128
|
* Every position on the neck that sounds a pitch, lowest string first.
|
|
@@ -5798,10 +6134,10 @@ var Instrument = class _Instrument {
|
|
|
5798
6134
|
fingerings(pitch) {
|
|
5799
6135
|
const profile = this.#profile;
|
|
5800
6136
|
if (profile.kind !== "stringed") {
|
|
5801
|
-
throw new (0,
|
|
6137
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(`${profile.name} has no strings to finger`);
|
|
5802
6138
|
}
|
|
5803
|
-
|
|
5804
|
-
return
|
|
6139
|
+
_chunkS3QELJUEcjs.assertMidiPitch.call(void 0, pitch, "pitch");
|
|
6140
|
+
return _chunkWOMCXN2Wcjs.fingeringsIn.call(void 0, profile, pitch);
|
|
5805
6141
|
}
|
|
5806
6142
|
/**
|
|
5807
6143
|
* Move a pitch by whole octaves until the instrument can sound it, which is
|
|
@@ -5818,8 +6154,8 @@ var Instrument = class _Instrument {
|
|
|
5818
6154
|
* ```
|
|
5819
6155
|
*/
|
|
5820
6156
|
foldIntoRange(pitch) {
|
|
5821
|
-
|
|
5822
|
-
return
|
|
6157
|
+
_chunkS3QELJUEcjs.assertMidiPitch.call(void 0, pitch, "pitch");
|
|
6158
|
+
return _chunkWOMCXN2Wcjs.foldIn.call(void 0, pitch, this.#profile);
|
|
5823
6159
|
}
|
|
5824
6160
|
/**
|
|
5825
6161
|
* The pitch this instrument sounds for a note written in its part.
|
|
@@ -5851,7 +6187,7 @@ var Instrument = class _Instrument {
|
|
|
5851
6187
|
* ```
|
|
5852
6188
|
*/
|
|
5853
6189
|
soundingPitch(note, transposition = this.#profile.name) {
|
|
5854
|
-
return new Note(
|
|
6190
|
+
return new Note(_chunkU4EQTDGNcjs.toSoundingPitch.call(void 0, _chunkS3QELJUEcjs.toNoteData.call(void 0, note), transposition));
|
|
5855
6191
|
}
|
|
5856
6192
|
/**
|
|
5857
6193
|
* Judge whether a passage can be played on this instrument, and how hard it
|
|
@@ -5877,7 +6213,7 @@ var Instrument = class _Instrument {
|
|
|
5877
6213
|
* ```
|
|
5878
6214
|
*/
|
|
5879
6215
|
playability(notes, bpm) {
|
|
5880
|
-
return
|
|
6216
|
+
return _chunkWOMCXN2Wcjs.playability.call(void 0, notes, this.#profile, bpm);
|
|
5881
6217
|
}
|
|
5882
6218
|
/**
|
|
5883
6219
|
* Whether another instrument is described identically.
|
|
@@ -5937,7 +6273,7 @@ function copyComplexity(complexity) {
|
|
|
5937
6273
|
for (const dial of ["rhythmic", "harmonic", "ornament", "difficulty"]) {
|
|
5938
6274
|
const value = complexity[dial];
|
|
5939
6275
|
if (value !== void 0) {
|
|
5940
|
-
copy[dial] =
|
|
6276
|
+
copy[dial] = _chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, value, `composer complexity ${dial}`);
|
|
5941
6277
|
}
|
|
5942
6278
|
}
|
|
5943
6279
|
return copy;
|
|
@@ -5953,10 +6289,10 @@ function copyInstruments(instruments) {
|
|
|
5953
6289
|
function copyOptions(options) {
|
|
5954
6290
|
assertDataObject(options, "composer options");
|
|
5955
6291
|
const copy = {
|
|
5956
|
-
meters:
|
|
6292
|
+
meters: _chunkS3QELJUEcjs.resolveMeters.call(void 0, { meters: options.meters }, "composer meters")
|
|
5957
6293
|
};
|
|
5958
6294
|
if (options.key !== void 0) {
|
|
5959
|
-
copy.key =
|
|
6295
|
+
copy.key = _chunkYDGMWH43cjs.resolveKey.call(void 0, options.key);
|
|
5960
6296
|
}
|
|
5961
6297
|
if (options.bpm !== void 0) {
|
|
5962
6298
|
copy.bpm = options.bpm;
|
|
@@ -5982,7 +6318,7 @@ function copyOptions(options) {
|
|
|
5982
6318
|
if (options.rng !== void 0) {
|
|
5983
6319
|
copy.rng = options.rng;
|
|
5984
6320
|
}
|
|
5985
|
-
const resolved =
|
|
6321
|
+
const resolved = _chunk6TTBEON3cjs.resolveContext.call(void 0, contextOf(copy));
|
|
5986
6322
|
copy.seed = resolved.seed;
|
|
5987
6323
|
copy.algorithmVersion = resolved.algorithmVersion;
|
|
5988
6324
|
return copy;
|
|
@@ -6039,8 +6375,8 @@ var Composer = class _Composer {
|
|
|
6039
6375
|
*/
|
|
6040
6376
|
constructor(options) {
|
|
6041
6377
|
this.#options = copyOptions(options);
|
|
6042
|
-
this.#meters =
|
|
6043
|
-
this.#key = this.#options.key === void 0 ? void 0 :
|
|
6378
|
+
this.#meters = _chunkS3QELJUEcjs.resolveMeters.call(void 0, { meters: this.#options.meters }, "composer meters");
|
|
6379
|
+
this.#key = this.#options.key === void 0 ? void 0 : _chunkYDGMWH43cjs.resolveKey.call(void 0, this.#options.key);
|
|
6044
6380
|
}
|
|
6045
6381
|
/**
|
|
6046
6382
|
* Start from a set of settings.
|
|
@@ -6097,8 +6433,8 @@ var Composer = class _Composer {
|
|
|
6097
6433
|
progression(opts) {
|
|
6098
6434
|
const key = this.#requireKey("progression");
|
|
6099
6435
|
const ts = this.#unchangingMeter("progression");
|
|
6100
|
-
const chords =
|
|
6101
|
-
return Timeline.fromChords(chords, opts.bars *
|
|
6436
|
+
const chords = _chunk6TTBEON3cjs.generateProgression.call(void 0, { ...opts, key, ts, ctx: this.context });
|
|
6437
|
+
return Timeline.fromChords(chords, opts.bars * _chunkS3QELJUEcjs.beatsPerBar.call(void 0, ts), key);
|
|
6102
6438
|
}
|
|
6103
6439
|
/**
|
|
6104
6440
|
* A drum part.
|
|
@@ -6117,7 +6453,7 @@ var Composer = class _Composer {
|
|
|
6117
6453
|
* request is refused rather than answered with 4/4 bars over the change.
|
|
6118
6454
|
*/
|
|
6119
6455
|
drums(opts) {
|
|
6120
|
-
const hits =
|
|
6456
|
+
const hits = _chunk6TTBEON3cjs.generateDrums.call(void 0, { ...opts, ts: this.#unchangingMeter("drums"), ctx: this.context });
|
|
6121
6457
|
return Score.of(hits, this.#scoreOptions());
|
|
6122
6458
|
}
|
|
6123
6459
|
/**
|
|
@@ -6144,12 +6480,12 @@ var Composer = class _Composer {
|
|
|
6144
6480
|
const segments = Array.isArray(source) ? source : source.segments;
|
|
6145
6481
|
const key = this.#requireKey("bass");
|
|
6146
6482
|
const { instrument, ...rest } = _nullishCoalesce(opts, () => ( {}));
|
|
6147
|
-
const notes =
|
|
6483
|
+
const notes = _chunk6TTBEON3cjs.generateBassLine.call(void 0, {
|
|
6148
6484
|
...rest,
|
|
6149
|
-
...instrument === void 0 ? {} : { instrument:
|
|
6485
|
+
...instrument === void 0 ? {} : { instrument: _chunkWOMCXN2Wcjs.toStringedProfile.call(void 0, instrument, "bass instrument") },
|
|
6150
6486
|
segments,
|
|
6151
6487
|
key,
|
|
6152
|
-
ts: this.#
|
|
6488
|
+
ts: this.#meters,
|
|
6153
6489
|
ctx: this.context
|
|
6154
6490
|
});
|
|
6155
6491
|
return Score.of(notes, this.#scoreOptions(key));
|
|
@@ -6176,12 +6512,12 @@ var Composer = class _Composer {
|
|
|
6176
6512
|
counterMelody(melody, opts) {
|
|
6177
6513
|
const key = this.#requireKey("counterMelody");
|
|
6178
6514
|
const { timeline, ...rest } = _nullishCoalesce(opts, () => ( {}));
|
|
6179
|
-
const notes =
|
|
6515
|
+
const notes = _chunk6TTBEON3cjs.generateCounterMelody.call(void 0, {
|
|
6180
6516
|
...rest,
|
|
6181
6517
|
...timeline === void 0 ? {} : { timeline: toChordTimeline(timeline) },
|
|
6182
6518
|
melody: melody.notes,
|
|
6183
6519
|
key,
|
|
6184
|
-
ts: this.#
|
|
6520
|
+
ts: this.#meters,
|
|
6185
6521
|
ctx: this.context
|
|
6186
6522
|
});
|
|
6187
6523
|
return Score.of(notes, this.#scoreOptions(key));
|
|
@@ -6207,18 +6543,19 @@ var Composer = class _Composer {
|
|
|
6207
6543
|
* ```
|
|
6208
6544
|
*/
|
|
6209
6545
|
harmonize(melody, opts) {
|
|
6210
|
-
const result =
|
|
6546
|
+
const result = _chunk6TTBEON3cjs.harmonizeMelody.call(void 0, {
|
|
6211
6547
|
...opts,
|
|
6212
6548
|
melody: melody.notes,
|
|
6213
6549
|
...this.#key === void 0 ? {} : { key: this.#key },
|
|
6214
|
-
ts: this.#
|
|
6550
|
+
ts: this.#meters,
|
|
6215
6551
|
ctx: this.context
|
|
6216
6552
|
});
|
|
6217
6553
|
const moved = melody.transpose(result.transposeSemitones);
|
|
6554
|
+
const last = result.chords[result.chords.length - 1];
|
|
6218
6555
|
const totalBeats = harmonizedSpan(
|
|
6219
6556
|
moved.totalBeats,
|
|
6220
6557
|
result.chords,
|
|
6221
|
-
|
|
6558
|
+
_chunkS3QELJUEcjs.beatsPerBarAt.call(void 0, _nullishCoalesce(_optionalChain([last, 'optionalAccess', _56 => _56.startBeat]), () => ( 0)), this.#meters)
|
|
6222
6559
|
);
|
|
6223
6560
|
return {
|
|
6224
6561
|
chords: Timeline.fromChords(result.chords, totalBeats, result.key),
|
|
@@ -6228,6 +6565,73 @@ var Composer = class _Composer {
|
|
|
6228
6565
|
transposeSemitones: result.transposeSemitones
|
|
6229
6566
|
};
|
|
6230
6567
|
}
|
|
6568
|
+
/**
|
|
6569
|
+
* A composition plan derived from a reference profile.
|
|
6570
|
+
*
|
|
6571
|
+
* The composer's key is the plan's home key unless `opts.key` names another,
|
|
6572
|
+
* and its seed and algorithm version are the ones the plan records, so the
|
|
6573
|
+
* plan is written under the same recipe as the composer's other parts.
|
|
6574
|
+
*
|
|
6575
|
+
* @param reference The reference profile to derive from.
|
|
6576
|
+
* @param opts Everything {@link deriveCompositionPlan} takes but the context,
|
|
6577
|
+
* which is the composer's.
|
|
6578
|
+
* @returns The plan.
|
|
6579
|
+
* @throws If the composer draws from a caller-held `rng`: a plan records its
|
|
6580
|
+
* seed, and a source cannot be written into it.
|
|
6581
|
+
* @example
|
|
6582
|
+
* ```ts
|
|
6583
|
+
* import { Composer, Score } from '@libraz/libcantus';
|
|
6584
|
+
* const notes = [60, 62, 64, 65, 67, 65, 64, 62, 60, 62, 64, 65, 67, 65, 64, 60].map(
|
|
6585
|
+
* (pitch, startBeat) => ({ pitch, startBeat, durationBeat: 1 }),
|
|
6586
|
+
* );
|
|
6587
|
+
* const reference = Score.of(notes, { key: 'C major' }).reference();
|
|
6588
|
+
* const plan = Composer.of({ key: 'D major', seed: 5 }).plan(reference);
|
|
6589
|
+
* plan.seed; // 5
|
|
6590
|
+
* plan.keys[0].scale.rootPc; // 2
|
|
6591
|
+
* ```
|
|
6592
|
+
*/
|
|
6593
|
+
plan(reference, opts) {
|
|
6594
|
+
const ctx = this.context;
|
|
6595
|
+
if (ctx.rng !== void 0) {
|
|
6596
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
6597
|
+
"composer plan cannot record a caller-held rng; give the composer a seed instead"
|
|
6598
|
+
);
|
|
6599
|
+
}
|
|
6600
|
+
return _chunk6TTBEON3cjs.deriveCompositionPlan.call(void 0, reference, {
|
|
6601
|
+
...this.#key === void 0 ? {} : { key: this.#key },
|
|
6602
|
+
...opts,
|
|
6603
|
+
ctx
|
|
6604
|
+
});
|
|
6605
|
+
}
|
|
6606
|
+
/**
|
|
6607
|
+
* A melody written to a composition plan.
|
|
6608
|
+
*
|
|
6609
|
+
* The plan is the reproduction recipe, so its seed and algorithm version are
|
|
6610
|
+
* the ones the melody is drawn under, not the composer's. The score is read
|
|
6611
|
+
* in the plan's meter and home key, at the composer's tempo.
|
|
6612
|
+
*
|
|
6613
|
+
* @param plan The plan to follow.
|
|
6614
|
+
* @param opts The budget; see {@link MelodyOptions}.
|
|
6615
|
+
* @returns The melody, as a score.
|
|
6616
|
+
* @example
|
|
6617
|
+
* ```ts
|
|
6618
|
+
* import { Composer, Score } from '@libraz/libcantus';
|
|
6619
|
+
* const notes = [60, 62, 64, 65, 67, 65, 64, 62, 60, 62, 64, 65, 67, 65, 64, 60].map(
|
|
6620
|
+
* (pitch, startBeat) => ({ pitch, startBeat, durationBeat: 1 }),
|
|
6621
|
+
* );
|
|
6622
|
+
* const composer = Composer.of({ key: 'C major', seed: 5 });
|
|
6623
|
+
* const plan = composer.plan(Score.of(notes, { key: 'C major' }).reference());
|
|
6624
|
+
* composer.melody(plan).notes.length > 0; // true
|
|
6625
|
+
* ```
|
|
6626
|
+
*/
|
|
6627
|
+
melody(plan, opts) {
|
|
6628
|
+
const notes = _chunk6TTBEON3cjs.generateMelody.call(void 0, plan, opts);
|
|
6629
|
+
const score = { meters: plan.meters, key: plan.keys[0] };
|
|
6630
|
+
if (this.#options.bpm !== void 0) {
|
|
6631
|
+
score.tempo = this.#options.bpm;
|
|
6632
|
+
}
|
|
6633
|
+
return Score.of(notes, score);
|
|
6634
|
+
}
|
|
6231
6635
|
/**
|
|
6232
6636
|
* Whether another composer holds the same settings.
|
|
6233
6637
|
*
|
|
@@ -6280,22 +6684,12 @@ var Composer = class _Composer {
|
|
|
6280
6684
|
*/
|
|
6281
6685
|
#requireKey(part) {
|
|
6282
6686
|
if (this.#key === void 0) {
|
|
6283
|
-
throw new (0,
|
|
6687
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
6284
6688
|
`composer ${part} needs a key for the part it writes; the composer names none \u2014 give it one, or take the key harmonize reads off a melody and pass it on with with({ key })`
|
|
6285
6689
|
);
|
|
6286
6690
|
}
|
|
6287
6691
|
return this.#key;
|
|
6288
6692
|
}
|
|
6289
|
-
/**
|
|
6290
|
-
* The signature the parts are written against.
|
|
6291
|
-
*
|
|
6292
|
-
* Each generator names one time signature rather than a map, so a composer
|
|
6293
|
-
* whose meter changes hands over the signature its music opens on — the same
|
|
6294
|
-
* reading {@link Score.humanize} and its siblings take.
|
|
6295
|
-
*/
|
|
6296
|
-
#openingMeter() {
|
|
6297
|
-
return _chunkS5BKZZGMcjs.meterAt.call(void 0, 0, this.#meters);
|
|
6298
|
-
}
|
|
6299
6693
|
/**
|
|
6300
6694
|
* The one signature a part laid out in bars is written against.
|
|
6301
6695
|
*
|
|
@@ -6306,11 +6700,11 @@ var Composer = class _Composer {
|
|
|
6306
6700
|
*/
|
|
6307
6701
|
#unchangingMeter(part) {
|
|
6308
6702
|
if (this.#meters.length > 1) {
|
|
6309
|
-
throw new (0,
|
|
6703
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
|
|
6310
6704
|
`composer ${part} needs one meter for the whole part; the composer changes meter`
|
|
6311
6705
|
);
|
|
6312
6706
|
}
|
|
6313
|
-
return this.#
|
|
6707
|
+
return _chunkS3QELJUEcjs.meterAt.call(void 0, 0, this.#meters);
|
|
6314
6708
|
}
|
|
6315
6709
|
/** The context every score a composer hands back is read against. */
|
|
6316
6710
|
#scoreOptions(key) {
|
|
@@ -6327,7 +6721,7 @@ var Composer = class _Composer {
|
|
|
6327
6721
|
|
|
6328
6722
|
// src/model/duration.ts
|
|
6329
6723
|
function copyDuration(value) {
|
|
6330
|
-
|
|
6724
|
+
_chunk3FDBMIPRcjs.durationToBeats.call(void 0, value);
|
|
6331
6725
|
if (typeof value === "string") {
|
|
6332
6726
|
return { base: value, dots: 0 };
|
|
6333
6727
|
}
|
|
@@ -6378,7 +6772,7 @@ var Duration = class _Duration {
|
|
|
6378
6772
|
* {@link Duration.tieChain} for those.
|
|
6379
6773
|
*/
|
|
6380
6774
|
static ofBeats(beats, options = {}) {
|
|
6381
|
-
return new _Duration(
|
|
6775
|
+
return new _Duration(_chunk3FDBMIPRcjs.beatsToDuration.call(void 0, beats, options));
|
|
6382
6776
|
}
|
|
6383
6777
|
/**
|
|
6384
6778
|
* Spell a length in beats as a chain of tied durations.
|
|
@@ -6402,7 +6796,7 @@ var Duration = class _Duration {
|
|
|
6402
6796
|
* ```
|
|
6403
6797
|
*/
|
|
6404
6798
|
static tieChain(beats, options = {}) {
|
|
6405
|
-
return
|
|
6799
|
+
return _chunk3FDBMIPRcjs.beatsToTiedDurations.call(void 0, beats, options).map((spelled) => new _Duration(spelled));
|
|
6406
6800
|
}
|
|
6407
6801
|
/**
|
|
6408
6802
|
* Wrap a plain duration, or a bare base value as shorthand for an undotted
|
|
@@ -6466,7 +6860,7 @@ var Duration = class _Duration {
|
|
|
6466
6860
|
* ```
|
|
6467
6861
|
*/
|
|
6468
6862
|
beats(options = {}) {
|
|
6469
|
-
return
|
|
6863
|
+
return _chunk3FDBMIPRcjs.durationToBeats.call(void 0, this.toJSON(), options);
|
|
6470
6864
|
}
|
|
6471
6865
|
/**
|
|
6472
6866
|
* Whether another duration is written identically.
|
|
@@ -6480,7 +6874,7 @@ var Duration = class _Duration {
|
|
|
6480
6874
|
*/
|
|
6481
6875
|
equals(other) {
|
|
6482
6876
|
const b = other.data;
|
|
6483
|
-
return this.#base === b.base && this.#dots === b.dots && _optionalChain([this, 'access',
|
|
6877
|
+
return this.#base === b.base && this.#dots === b.dots && _optionalChain([this, 'access', _57 => _57.#tuplet, 'optionalAccess', _58 => _58.actual]) === _optionalChain([b, 'access', _59 => _59.tuplet, 'optionalAccess', _60 => _60.actual]) && _optionalChain([this, 'access', _61 => _61.#tuplet, 'optionalAccess', _62 => _62.normal]) === _optionalChain([b, 'access', _63 => _63.tuplet, 'optionalAccess', _64 => _64.normal]);
|
|
6484
6878
|
}
|
|
6485
6879
|
/**
|
|
6486
6880
|
* The plain duration, for JSON serialization.
|
|
@@ -6547,7 +6941,7 @@ var Meter = class _Meter {
|
|
|
6547
6941
|
* is ordinary, such as a meter field read on every keystroke.
|
|
6548
6942
|
*/
|
|
6549
6943
|
static parse(text) {
|
|
6550
|
-
return new _Meter(
|
|
6944
|
+
return new _Meter(_chunkS3QELJUEcjs.parseTimeSignature.call(void 0, text));
|
|
6551
6945
|
}
|
|
6552
6946
|
/**
|
|
6553
6947
|
* Parse a time signature, reporting failure instead of throwing it.
|
|
@@ -6566,7 +6960,7 @@ var Meter = class _Meter {
|
|
|
6566
6960
|
* ```
|
|
6567
6961
|
*/
|
|
6568
6962
|
static tryParse(text) {
|
|
6569
|
-
const parsed =
|
|
6963
|
+
const parsed = _chunkS3QELJUEcjs.tryParseTimeSignature.call(void 0, text);
|
|
6570
6964
|
return parsed.ok ? { ok: true, value: new _Meter(parsed.value) } : parsed;
|
|
6571
6965
|
}
|
|
6572
6966
|
/**
|
|
@@ -6611,22 +7005,22 @@ var Meter = class _Meter {
|
|
|
6611
7005
|
* neither is a signature whose grouping selects the additive reading.
|
|
6612
7006
|
*/
|
|
6613
7007
|
get isCompound() {
|
|
6614
|
-
return
|
|
7008
|
+
return _chunkS3QELJUEcjs.isCompound.call(void 0, this.#ts);
|
|
6615
7009
|
}
|
|
6616
7010
|
/** Length of a bar in quarter-note beats. */
|
|
6617
7011
|
get beatsPerBar() {
|
|
6618
|
-
return
|
|
7012
|
+
return _chunkS3QELJUEcjs.beatsPerBar.call(void 0, this.#ts);
|
|
6619
7013
|
}
|
|
6620
7014
|
/** Main pulses (felt beats) in a bar: 2 in 6/8, 4 in 4/4. */
|
|
6621
7015
|
get pulsesPerBar() {
|
|
6622
|
-
return
|
|
7016
|
+
return _chunkS3QELJUEcjs.pulsesPerBar.call(void 0, this.#ts);
|
|
6623
7017
|
}
|
|
6624
7018
|
/**
|
|
6625
7019
|
* Length of one felt beat in quarter-note beats: a quarter note in simple
|
|
6626
7020
|
* meters, a dotted quarter in compound ones.
|
|
6627
7021
|
*/
|
|
6628
7022
|
get pulseBeats() {
|
|
6629
|
-
return
|
|
7023
|
+
return _chunkS3QELJUEcjs.pulseBeats.call(void 0, this.#ts);
|
|
6630
7024
|
}
|
|
6631
7025
|
/**
|
|
6632
7026
|
* Render the signature as `'n/d'`, or as `'a+b+c/d'` when it carries an
|
|
@@ -6649,7 +7043,7 @@ var Meter = class _Meter {
|
|
|
6649
7043
|
* ```
|
|
6650
7044
|
*/
|
|
6651
7045
|
format(opts = {}) {
|
|
6652
|
-
return
|
|
7046
|
+
return _chunkS3QELJUEcjs.formatTimeSignature.call(void 0, this.#ts, opts);
|
|
6653
7047
|
}
|
|
6654
7048
|
/**
|
|
6655
7049
|
* Metric weight of a position within its bar, on a 0–3 scale: 3 the
|
|
@@ -6662,7 +7056,7 @@ var Meter = class _Meter {
|
|
|
6662
7056
|
* @throws If the position is not finite.
|
|
6663
7057
|
*/
|
|
6664
7058
|
weightAt(beatInQuarters) {
|
|
6665
|
-
return
|
|
7059
|
+
return _chunkS3QELJUEcjs.metricWeight.call(void 0, beatInQuarters, this.#ts);
|
|
6666
7060
|
}
|
|
6667
7061
|
/**
|
|
6668
7062
|
* Whether a position is metrically accented — a downbeat or a secondary
|
|
@@ -6673,7 +7067,7 @@ var Meter = class _Meter {
|
|
|
6673
7067
|
* @throws If the position is not finite.
|
|
6674
7068
|
*/
|
|
6675
7069
|
isStrongBeat(beatInQuarters) {
|
|
6676
|
-
return
|
|
7070
|
+
return _chunkS3QELJUEcjs.isStrongBeat.call(void 0, beatInQuarters, this.#ts);
|
|
6677
7071
|
}
|
|
6678
7072
|
/**
|
|
6679
7073
|
* Convert a position in quarter-note beats to a bar index and in-bar offset.
|
|
@@ -6683,7 +7077,7 @@ var Meter = class _Meter {
|
|
|
6683
7077
|
* @throws If the position is not finite.
|
|
6684
7078
|
*/
|
|
6685
7079
|
barPositionAt(beatInQuarters) {
|
|
6686
|
-
return
|
|
7080
|
+
return _chunkS3QELJUEcjs.beatToBarPosition.call(void 0, beatInQuarters, this.#ts);
|
|
6687
7081
|
}
|
|
6688
7082
|
/**
|
|
6689
7083
|
* Render a position as the `bar.beat` a DAW or a score shows: 1-based bar,
|
|
@@ -6706,7 +7100,7 @@ var Meter = class _Meter {
|
|
|
6706
7100
|
* ```
|
|
6707
7101
|
*/
|
|
6708
7102
|
formatPosition(beatInQuarters, decimals = 2) {
|
|
6709
|
-
return
|
|
7103
|
+
return _chunkS3QELJUEcjs.formatBarPosition.call(void 0, beatInQuarters, this.#ts, decimals);
|
|
6710
7104
|
}
|
|
6711
7105
|
/**
|
|
6712
7106
|
* Subdivide a span into equal tuplet durations — an eighth-note triplet is
|
|
@@ -6718,7 +7112,7 @@ var Meter = class _Meter {
|
|
|
6718
7112
|
* @throws If the span is negative or `count` is not a positive integer.
|
|
6719
7113
|
*/
|
|
6720
7114
|
tuplet(totalBeats, count) {
|
|
6721
|
-
return
|
|
7115
|
+
return _chunkS3QELJUEcjs.tuplet.call(void 0, totalBeats, count);
|
|
6722
7116
|
}
|
|
6723
7117
|
/**
|
|
6724
7118
|
* Whether another meter is the same signature, grouping included.
|
|
@@ -6736,7 +7130,7 @@ var Meter = class _Meter {
|
|
|
6736
7130
|
if (grouping === void 0 || b.grouping === void 0) {
|
|
6737
7131
|
return this.#ts.numerator === b.numerator && this.#ts.denominator === b.denominator && grouping === b.grouping;
|
|
6738
7132
|
}
|
|
6739
|
-
return this.#ts.numerator === b.numerator && this.#ts.denominator === b.denominator && grouping.length === b.grouping.length && grouping.every((entry, index) => entry === _optionalChain([b, 'access',
|
|
7133
|
+
return this.#ts.numerator === b.numerator && this.#ts.denominator === b.denominator && grouping.length === b.grouping.length && grouping.every((entry, index) => entry === _optionalChain([b, 'access', _65 => _65.grouping, 'optionalAccess', _66 => _66[index]]));
|
|
6740
7134
|
}
|
|
6741
7135
|
/**
|
|
6742
7136
|
* The plain time signature, for JSON serialization.
|
|
@@ -6775,7 +7169,7 @@ function copyCell(cell) {
|
|
|
6775
7169
|
return { notes: assertNoteEventArray(cell.notes, "motif notes").map(copyNote2) };
|
|
6776
7170
|
}
|
|
6777
7171
|
function chordFrom(chord) {
|
|
6778
|
-
return chord === void 0 || chord === null ? chord :
|
|
7172
|
+
return chord === void 0 || chord === null ? chord : _chunkYDGMWH43cjs.toChordData.call(void 0, chord);
|
|
6779
7173
|
}
|
|
6780
7174
|
var Motif = class _Motif {
|
|
6781
7175
|
#cell;
|
|
@@ -6807,7 +7201,8 @@ var Motif = class _Motif {
|
|
|
6807
7201
|
* ```
|
|
6808
7202
|
*/
|
|
6809
7203
|
static generate(opts) {
|
|
6810
|
-
|
|
7204
|
+
_chunkS3QELJUEcjs.assertRecord.call(void 0, opts, "motif options");
|
|
7205
|
+
return new _Motif(_chunk6TTBEON3cjs.generateMotif.call(void 0, { ...opts, chord: chordFrom(opts.chord) }));
|
|
6811
7206
|
}
|
|
6812
7207
|
/**
|
|
6813
7208
|
* Read a run of notes as a motif.
|
|
@@ -6821,7 +7216,7 @@ var Motif = class _Motif {
|
|
|
6821
7216
|
* @throws If a note carries a value the transforms cannot hold.
|
|
6822
7217
|
*/
|
|
6823
7218
|
static fromNotes(notes) {
|
|
6824
|
-
return new _Motif({ notes: [...notes] });
|
|
7219
|
+
return new _Motif({ notes: [..._chunkS3QELJUEcjs.assertArray.call(void 0, notes, "motif notes")] });
|
|
6825
7220
|
}
|
|
6826
7221
|
/** Rebuild a motif from the plain data {@link Motif.data} hands out. */
|
|
6827
7222
|
static fromData(cell) {
|
|
@@ -6837,7 +7232,7 @@ var Motif = class _Motif {
|
|
|
6837
7232
|
}
|
|
6838
7233
|
/** Where the cell stops sounding, measured from its own first onset. */
|
|
6839
7234
|
get totalBeats() {
|
|
6840
|
-
return
|
|
7235
|
+
return _chunk6TTBEON3cjs.cellSpan.call(void 0, this.#cell);
|
|
6841
7236
|
}
|
|
6842
7237
|
/** A copy of the underlying plain cell. */
|
|
6843
7238
|
get data() {
|
|
@@ -6874,7 +7269,7 @@ var Motif = class _Motif {
|
|
|
6874
7269
|
* ```
|
|
6875
7270
|
*/
|
|
6876
7271
|
transform(kind, amount, key) {
|
|
6877
|
-
return new _Motif(
|
|
7272
|
+
return new _Motif(_chunk6TTBEON3cjs.transformMotif.call(void 0, this.#cell, kind, amount, key));
|
|
6878
7273
|
}
|
|
6879
7274
|
/**
|
|
6880
7275
|
* The cell laid across a span and snapped to the harmony under it.
|
|
@@ -6896,7 +7291,7 @@ var Motif = class _Motif {
|
|
|
6896
7291
|
*/
|
|
6897
7292
|
develop(timeline, key, bars, ts) {
|
|
6898
7293
|
const chords = "chordTimeline" in timeline ? timeline.chordTimeline : timeline;
|
|
6899
|
-
return new _Motif(
|
|
7294
|
+
return new _Motif(_chunk6TTBEON3cjs.developMotif.call(void 0, this.#cell, chords, key, bars, ts));
|
|
6900
7295
|
}
|
|
6901
7296
|
/**
|
|
6902
7297
|
* How this motif stands to another: the transformation that turns one into
|
|
@@ -6910,7 +7305,7 @@ var Motif = class _Motif {
|
|
|
6910
7305
|
* @returns The relation, or null when the two stand in none.
|
|
6911
7306
|
*/
|
|
6912
7307
|
relateTo(other, key) {
|
|
6913
|
-
return
|
|
7308
|
+
return _chunkLQZQDBCDcjs.relateMotifs.call(void 0, _chunkLQZQDBCDcjs.motifFromNotes.call(void 0, this.#cell.notes), _chunkLQZQDBCDcjs.motifFromNotes.call(void 0, other.notes), key);
|
|
6914
7309
|
}
|
|
6915
7310
|
/**
|
|
6916
7311
|
* How alike two lines are, in [0, 1].
|
|
@@ -6923,7 +7318,7 @@ var Motif = class _Motif {
|
|
|
6923
7318
|
* @returns The likeness: 1 for the same line, a transposition of it included.
|
|
6924
7319
|
*/
|
|
6925
7320
|
similarityTo(other) {
|
|
6926
|
-
return
|
|
7321
|
+
return _chunkLQZQDBCDcjs.melodicSimilarity.call(void 0, this.#cell.notes, other.notes);
|
|
6927
7322
|
}
|
|
6928
7323
|
/**
|
|
6929
7324
|
* The cell as a score, so it reaches the rest of the class API.
|
|
@@ -6933,7 +7328,7 @@ var Motif = class _Motif {
|
|
|
6933
7328
|
* @returns The score holding the cell.
|
|
6934
7329
|
*/
|
|
6935
7330
|
toScore(opts) {
|
|
6936
|
-
return Score.of(
|
|
7331
|
+
return Score.of(_chunk6TTBEON3cjs.motifToNoteEvents.call(void 0, this.#cell), opts);
|
|
6937
7332
|
}
|
|
6938
7333
|
/**
|
|
6939
7334
|
* Whether another motif holds the same notes in the same order.
|
|
@@ -6966,10 +7361,10 @@ var PART = "rhythm";
|
|
|
6966
7361
|
function copyEvent(event, name) {
|
|
6967
7362
|
return {
|
|
6968
7363
|
position: withoutNegativeZero(
|
|
6969
|
-
|
|
7364
|
+
_chunkS3QELJUEcjs.assertRange.call(void 0, event.position, 0, Number.MAX_SAFE_INTEGER, `${name}.position`)
|
|
6970
7365
|
),
|
|
6971
7366
|
duration: withoutNegativeZero(
|
|
6972
|
-
|
|
7367
|
+
_chunkS3QELJUEcjs.assertRange.call(void 0, event.duration, 0, Number.MAX_SAFE_INTEGER, `${name}.duration`)
|
|
6973
7368
|
)
|
|
6974
7369
|
};
|
|
6975
7370
|
}
|
|
@@ -6988,13 +7383,13 @@ function spanOf(events) {
|
|
|
6988
7383
|
}
|
|
6989
7384
|
function toGrid(events) {
|
|
6990
7385
|
return events.map((event) => ({
|
|
6991
|
-
step: event.position /
|
|
7386
|
+
step: event.position / _chunk6TTBEON3cjs.STEP_BEATS,
|
|
6992
7387
|
velocity: GRID_VELOCITY,
|
|
6993
7388
|
source: event
|
|
6994
7389
|
}));
|
|
6995
7390
|
}
|
|
6996
7391
|
function fromGrid(events, spanBeats) {
|
|
6997
|
-
const positions = [...new Set(events.map((event) => event.step *
|
|
7392
|
+
const positions = [...new Set(events.map((event) => event.step * _chunk6TTBEON3cjs.STEP_BEATS))].sort(
|
|
6998
7393
|
(a, b) => a - b
|
|
6999
7394
|
);
|
|
7000
7395
|
return positions.map((position, index) => ({
|
|
@@ -7034,8 +7429,8 @@ var Rhythm = class _Rhythm {
|
|
|
7034
7429
|
* ```
|
|
7035
7430
|
*/
|
|
7036
7431
|
static generate(ts, opts) {
|
|
7037
|
-
const meter =
|
|
7038
|
-
return new _Rhythm({ events:
|
|
7432
|
+
const meter = _chunkS3QELJUEcjs.meterAt.call(void 0, 0, _chunkS3QELJUEcjs.toMeterData.call(void 0, ts, "ts"));
|
|
7433
|
+
return new _Rhythm({ events: _chunk6TTBEON3cjs.generateRhythm.call(void 0, meter, opts), ts: meter });
|
|
7039
7434
|
}
|
|
7040
7435
|
/**
|
|
7041
7436
|
* Build a pattern from onsets that already exist.
|
|
@@ -7055,7 +7450,7 @@ var Rhythm = class _Rhythm {
|
|
|
7055
7450
|
static of(events, ts) {
|
|
7056
7451
|
return new _Rhythm({
|
|
7057
7452
|
events: [...assertDataArray(events, "rhythm events")],
|
|
7058
|
-
ts:
|
|
7453
|
+
ts: _chunkS3QELJUEcjs.meterAt.call(void 0, 0, _chunkS3QELJUEcjs.toMeterData.call(void 0, ts, "ts"))
|
|
7059
7454
|
});
|
|
7060
7455
|
}
|
|
7061
7456
|
/** Rebuild a pattern from the plain data {@link Rhythm.data} hands out. */
|
|
@@ -7091,7 +7486,7 @@ var Rhythm = class _Rhythm {
|
|
|
7091
7486
|
* @returns The onset count divided by the number of bars it spans.
|
|
7092
7487
|
*/
|
|
7093
7488
|
density() {
|
|
7094
|
-
return
|
|
7489
|
+
return _chunk6TTBEON3cjs.rhythmDensity.call(void 0, this.#data.events, this.#data.ts);
|
|
7095
7490
|
}
|
|
7096
7491
|
/**
|
|
7097
7492
|
* Drop the onsets carrying the least of the metre.
|
|
@@ -7106,7 +7501,7 @@ var Rhythm = class _Rhythm {
|
|
|
7106
7501
|
* @throws If the amount is outside [0, 1].
|
|
7107
7502
|
*/
|
|
7108
7503
|
thin(amount) {
|
|
7109
|
-
return this.#withGrid(
|
|
7504
|
+
return this.#withGrid(_chunk6TTBEON3cjs.thin.call(void 0, toGrid(this.#data.events), amount, this.#data.ts));
|
|
7110
7505
|
}
|
|
7111
7506
|
/**
|
|
7112
7507
|
* Anticipate beats, one sixteenth early.
|
|
@@ -7125,10 +7520,10 @@ var Rhythm = class _Rhythm {
|
|
|
7125
7520
|
*/
|
|
7126
7521
|
syncopate(amount, ctx) {
|
|
7127
7522
|
return this.#withGrid(
|
|
7128
|
-
|
|
7523
|
+
_chunk6TTBEON3cjs.syncopate.call(void 0,
|
|
7129
7524
|
toGrid(this.#data.events),
|
|
7130
7525
|
{ amount, ts: this.#data.ts },
|
|
7131
|
-
|
|
7526
|
+
_chunk6TTBEON3cjs.resolveContext.call(void 0, ctx).part(PART)
|
|
7132
7527
|
)
|
|
7133
7528
|
);
|
|
7134
7529
|
}
|
|
@@ -7140,7 +7535,7 @@ var Rhythm = class _Rhythm {
|
|
|
7140
7535
|
* @returns The compressed pattern.
|
|
7141
7536
|
*/
|
|
7142
7537
|
doubleTime() {
|
|
7143
|
-
return this.#withGrid(
|
|
7538
|
+
return this.#withGrid(_chunk6TTBEON3cjs.doubleTimeFigure.call(void 0, toGrid(this.#data.events), this.#spanSteps()));
|
|
7144
7539
|
}
|
|
7145
7540
|
/**
|
|
7146
7541
|
* Stretch the pattern to twice its length: everything falls half as often.
|
|
@@ -7151,7 +7546,7 @@ var Rhythm = class _Rhythm {
|
|
|
7151
7546
|
* @returns The stretched pattern.
|
|
7152
7547
|
*/
|
|
7153
7548
|
halfTime() {
|
|
7154
|
-
return this.#withGrid(
|
|
7549
|
+
return this.#withGrid(_chunk6TTBEON3cjs.halfTimeFigure.call(void 0, toGrid(this.#data.events), this.#spanSteps()));
|
|
7155
7550
|
}
|
|
7156
7551
|
/**
|
|
7157
7552
|
* Keep as much decoration as the ornament dial asks for.
|
|
@@ -7168,11 +7563,11 @@ var Rhythm = class _Rhythm {
|
|
|
7168
7563
|
*/
|
|
7169
7564
|
ornamentBy(isOrnament, amount, ctx) {
|
|
7170
7565
|
return this.#withGrid(
|
|
7171
|
-
|
|
7566
|
+
_chunk6TTBEON3cjs.ornamentBy.call(void 0,
|
|
7172
7567
|
toGrid(this.#data.events),
|
|
7173
7568
|
(grid) => isOrnament(grid.source),
|
|
7174
7569
|
amount,
|
|
7175
|
-
|
|
7570
|
+
_chunk6TTBEON3cjs.resolveContext.call(void 0, ctx).part(PART)
|
|
7176
7571
|
)
|
|
7177
7572
|
);
|
|
7178
7573
|
}
|
|
@@ -7192,20 +7587,22 @@ var Rhythm = class _Rhythm {
|
|
|
7192
7587
|
* @throws If a dial is outside [0, 1].
|
|
7193
7588
|
*/
|
|
7194
7589
|
deform(opts, ctx) {
|
|
7195
|
-
const resolved =
|
|
7196
|
-
const isOrnament = _optionalChain([opts, 'optionalAccess',
|
|
7590
|
+
const resolved = _chunk6TTBEON3cjs.resolveContext.call(void 0, ctx);
|
|
7591
|
+
const isOrnament = _optionalChain([opts, 'optionalAccess', _67 => _67.isOrnament]);
|
|
7197
7592
|
const options = {
|
|
7198
7593
|
rhythmic: resolved.rhythmic,
|
|
7199
7594
|
ornament: resolved.ornament,
|
|
7200
|
-
rate: _optionalChain([opts, 'optionalAccess',
|
|
7201
|
-
spanSteps: this.#spanSteps(),
|
|
7595
|
+
rate: _optionalChain([opts, 'optionalAccess', _68 => _68.rate]),
|
|
7202
7596
|
ts: this.#data.ts,
|
|
7203
7597
|
// The transform hands the predicate the events it was given, which carry
|
|
7204
7598
|
// the onset each was built from; the parameter is declared over the bare
|
|
7205
7599
|
// grid event the rule reads, so the field is named back here.
|
|
7206
7600
|
isOrnament: isOrnament === void 0 ? void 0 : (grid) => isOrnament(grid.source)
|
|
7207
7601
|
};
|
|
7208
|
-
|
|
7602
|
+
const dials = _chunk6TTBEON3cjs.resolveDials.call(void 0, options);
|
|
7603
|
+
return this.#withGrid(
|
|
7604
|
+
_chunk6TTBEON3cjs.deformFigure.call(void 0, toGrid(this.#data.events), this.#spanSteps(), dials, resolved.part(PART), [])
|
|
7605
|
+
);
|
|
7209
7606
|
}
|
|
7210
7607
|
/**
|
|
7211
7608
|
* Whether one player can sustain the pattern at the context's tempo.
|
|
@@ -7219,8 +7616,8 @@ var Rhythm = class _Rhythm {
|
|
|
7219
7616
|
* @returns True when the pattern is inside the ceiling.
|
|
7220
7617
|
*/
|
|
7221
7618
|
withinCeiling(ctx) {
|
|
7222
|
-
const resolved =
|
|
7223
|
-
return
|
|
7619
|
+
const resolved = _chunk6TTBEON3cjs.resolveContext.call(void 0, ctx);
|
|
7620
|
+
return _chunk6TTBEON3cjs.withinCeiling.call(void 0, toGrid(this.#data.events), resolved.bpm, resolved.difficulty);
|
|
7224
7621
|
}
|
|
7225
7622
|
/**
|
|
7226
7623
|
* The pattern as sounding notes at one pitch, in its own meter.
|
|
@@ -7244,7 +7641,7 @@ var Rhythm = class _Rhythm {
|
|
|
7244
7641
|
* ```
|
|
7245
7642
|
*/
|
|
7246
7643
|
toScore(pitch, velocity) {
|
|
7247
|
-
return Score.of(
|
|
7644
|
+
return Score.of(_chunk6TTBEON3cjs.rhythmToNoteEvents.call(void 0, this.#data.events, pitch, velocity), {
|
|
7248
7645
|
meters: this.#data.ts
|
|
7249
7646
|
});
|
|
7250
7647
|
}
|
|
@@ -7266,9 +7663,13 @@ var Rhythm = class _Rhythm {
|
|
|
7266
7663
|
toJSON() {
|
|
7267
7664
|
return this.data;
|
|
7268
7665
|
}
|
|
7269
|
-
/**
|
|
7666
|
+
/**
|
|
7667
|
+
* The pattern's span as a count of sixteenths, for the transforms: whatever
|
|
7668
|
+
* span the pattern covers, an empty one or one ending off the straight grid
|
|
7669
|
+
* included.
|
|
7670
|
+
*/
|
|
7270
7671
|
#spanSteps() {
|
|
7271
|
-
return spanOf(this.#data.events) /
|
|
7672
|
+
return spanOf(this.#data.events) / _chunk6TTBEON3cjs.STEP_BEATS;
|
|
7272
7673
|
}
|
|
7273
7674
|
/** The same meter carrying the onsets a transform returned. */
|
|
7274
7675
|
#withGrid(events) {
|
|
@@ -7293,7 +7694,7 @@ var MIN_BPM = 0.1;
|
|
|
7293
7694
|
var Tempo = class _Tempo {
|
|
7294
7695
|
#bpm;
|
|
7295
7696
|
constructor(bpm) {
|
|
7296
|
-
this.#bpm =
|
|
7697
|
+
this.#bpm = _chunkS3QELJUEcjs.assertRange.call(void 0, bpm, MIN_BPM, MAX_BPM, "bpm");
|
|
7297
7698
|
}
|
|
7298
7699
|
/**
|
|
7299
7700
|
* The one-event tempo map every conversion here is measured against.
|
|
@@ -7353,7 +7754,7 @@ var Tempo = class _Tempo {
|
|
|
7353
7754
|
* @throws If the position is not finite.
|
|
7354
7755
|
*/
|
|
7355
7756
|
secondsAt(beat) {
|
|
7356
|
-
return
|
|
7757
|
+
return _chunk3FDBMIPRcjs.beatsToSeconds.call(void 0, beat, this.#map);
|
|
7357
7758
|
}
|
|
7358
7759
|
/**
|
|
7359
7760
|
* The position reached after a number of seconds — the inverse of
|
|
@@ -7370,7 +7771,7 @@ var Tempo = class _Tempo {
|
|
|
7370
7771
|
* ```
|
|
7371
7772
|
*/
|
|
7372
7773
|
beatAtSeconds(seconds) {
|
|
7373
|
-
return
|
|
7774
|
+
return _chunk3FDBMIPRcjs.secondsToBeats.call(void 0, seconds, this.#map);
|
|
7374
7775
|
}
|
|
7375
7776
|
/**
|
|
7376
7777
|
* Duration in seconds of a span of beats.
|
|
@@ -7383,7 +7784,7 @@ var Tempo = class _Tempo {
|
|
|
7383
7784
|
* @throws If the length is negative or not finite.
|
|
7384
7785
|
*/
|
|
7385
7786
|
secondsOf(lengthBeats) {
|
|
7386
|
-
return
|
|
7787
|
+
return _chunk3FDBMIPRcjs.durationToSeconds.call(void 0, 0, lengthBeats, this.#map);
|
|
7387
7788
|
}
|
|
7388
7789
|
/**
|
|
7389
7790
|
* Convert quarter-note beats to MIDI ticks, rounded to the nearest tick.
|
|
@@ -7394,7 +7795,7 @@ var Tempo = class _Tempo {
|
|
|
7394
7795
|
* @throws If the position is not finite or `ppq` is not a positive integer.
|
|
7395
7796
|
*/
|
|
7396
7797
|
ticksAt(beat, ppq) {
|
|
7397
|
-
return
|
|
7798
|
+
return _chunk3FDBMIPRcjs.beatsToTicks.call(void 0, beat, ppq);
|
|
7398
7799
|
}
|
|
7399
7800
|
/**
|
|
7400
7801
|
* Convert MIDI ticks to quarter-note beats.
|
|
@@ -7405,7 +7806,7 @@ var Tempo = class _Tempo {
|
|
|
7405
7806
|
* @throws If `ticks` is not an integer or `ppq` is not a positive integer.
|
|
7406
7807
|
*/
|
|
7407
7808
|
beatAtTicks(ticks, ppq) {
|
|
7408
|
-
return
|
|
7809
|
+
return _chunk3FDBMIPRcjs.ticksToBeats.call(void 0, ticks, ppq);
|
|
7409
7810
|
}
|
|
7410
7811
|
/**
|
|
7411
7812
|
* Whether another tempo carries the same marking.
|
|
@@ -7465,10 +7866,10 @@ var Tuning = class _Tuning {
|
|
|
7465
7866
|
*/
|
|
7466
7867
|
static of(table) {
|
|
7467
7868
|
const given = assertDataObject(table, "tuning table");
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
return new _Tuning(
|
|
7869
|
+
_chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, given.divisions, "tuning table.divisions");
|
|
7870
|
+
_chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, given.refFreq, "tuning table.refFreq");
|
|
7871
|
+
_chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, given.refStep, "tuning table.refStep");
|
|
7872
|
+
return new _Tuning(_chunk3FDBMIPRcjs.edo.call(void 0, given.divisions, given.refFreq, given.refStep));
|
|
7472
7873
|
}
|
|
7473
7874
|
/**
|
|
7474
7875
|
* Build an equal temperament with `divisions` divisions of the octave.
|
|
@@ -7489,7 +7890,7 @@ var Tuning = class _Tuning {
|
|
|
7489
7890
|
* ```
|
|
7490
7891
|
*/
|
|
7491
7892
|
static edo(divisions, refFreq, refStep) {
|
|
7492
|
-
return new _Tuning(
|
|
7893
|
+
return new _Tuning(_chunk3FDBMIPRcjs.edo.call(void 0, divisions, refFreq, refStep));
|
|
7493
7894
|
}
|
|
7494
7895
|
/**
|
|
7495
7896
|
* Standard twelve-tone equal temperament, A4 (MIDI 69) = 440 Hz.
|
|
@@ -7502,7 +7903,7 @@ var Tuning = class _Tuning {
|
|
|
7502
7903
|
* ```
|
|
7503
7904
|
*/
|
|
7504
7905
|
static twelveTet() {
|
|
7505
|
-
return _Tuning.of(
|
|
7906
|
+
return _Tuning.of(_chunk3FDBMIPRcjs.TWELVE_TET);
|
|
7506
7907
|
}
|
|
7507
7908
|
/**
|
|
7508
7909
|
* Rebuild a tuning from the plain table {@link Tuning.data} hands out.
|
|
@@ -7541,7 +7942,7 @@ var Tuning = class _Tuning {
|
|
|
7541
7942
|
* ```
|
|
7542
7943
|
*/
|
|
7543
7944
|
static ratioToCents(numerator, denominator) {
|
|
7544
|
-
return
|
|
7945
|
+
return _chunk3FDBMIPRcjs.ratioToCents.call(void 0, numerator, denominator);
|
|
7545
7946
|
}
|
|
7546
7947
|
/**
|
|
7547
7948
|
* The frequency ratio an interval in cents spans, the inverse of
|
|
@@ -7559,7 +7960,7 @@ var Tuning = class _Tuning {
|
|
|
7559
7960
|
* ```
|
|
7560
7961
|
*/
|
|
7561
7962
|
static centsToRatio(cents) {
|
|
7562
|
-
return
|
|
7963
|
+
return _chunk3FDBMIPRcjs.centsToRatio.call(void 0, cents);
|
|
7563
7964
|
}
|
|
7564
7965
|
/**
|
|
7565
7966
|
* Interval in cents between two frequencies.
|
|
@@ -7575,7 +7976,7 @@ var Tuning = class _Tuning {
|
|
|
7575
7976
|
* ```
|
|
7576
7977
|
*/
|
|
7577
7978
|
static centsBetweenFreq(a, b) {
|
|
7578
|
-
return
|
|
7979
|
+
return _chunk3FDBMIPRcjs.centsBetweenFreq.call(void 0, a, b);
|
|
7579
7980
|
}
|
|
7580
7981
|
/**
|
|
7581
7982
|
* Cents by which a five-limit just interval departs from its 12-TET
|
|
@@ -7591,7 +7992,7 @@ var Tuning = class _Tuning {
|
|
|
7591
7992
|
* ```
|
|
7592
7993
|
*/
|
|
7593
7994
|
static justDeviationCents(semitoneClass) {
|
|
7594
|
-
return
|
|
7995
|
+
return _chunk3FDBMIPRcjs.justDeviationCents.call(void 0, semitoneClass);
|
|
7595
7996
|
}
|
|
7596
7997
|
/** Step index whose frequency is {@link Tuning.refFreq}. */
|
|
7597
7998
|
get refStep() {
|
|
@@ -7633,7 +8034,7 @@ var Tuning = class _Tuning {
|
|
|
7633
8034
|
* ```
|
|
7634
8035
|
*/
|
|
7635
8036
|
frequencyOf(note, tuning = this.#table) {
|
|
7636
|
-
return
|
|
8037
|
+
return _chunk3FDBMIPRcjs.frequencyOf.call(void 0, _chunkS3QELJUEcjs.noteToMidi.call(void 0, _chunkS3QELJUEcjs.toNoteData.call(void 0, note)), tuning);
|
|
7637
8038
|
}
|
|
7638
8039
|
/**
|
|
7639
8040
|
* Frequency in Hz of a step index.
|
|
@@ -7655,7 +8056,7 @@ var Tuning = class _Tuning {
|
|
|
7655
8056
|
* ```
|
|
7656
8057
|
*/
|
|
7657
8058
|
frequencyOfStep(step, tuning = this.#table) {
|
|
7658
|
-
return
|
|
8059
|
+
return _chunk3FDBMIPRcjs.frequencyOf.call(void 0, step, tuning);
|
|
7659
8060
|
}
|
|
7660
8061
|
/**
|
|
7661
8062
|
* Nearest step index to a frequency, the rounded inverse of
|
|
@@ -7672,7 +8073,7 @@ var Tuning = class _Tuning {
|
|
|
7672
8073
|
* ```
|
|
7673
8074
|
*/
|
|
7674
8075
|
nearestStep(freq, tuning = this.#table) {
|
|
7675
|
-
return
|
|
8076
|
+
return _chunk3FDBMIPRcjs.nearestStep.call(void 0, freq, tuning);
|
|
7676
8077
|
}
|
|
7677
8078
|
/**
|
|
7678
8079
|
* Step index of a frequency, unrounded.
|
|
@@ -7692,7 +8093,7 @@ var Tuning = class _Tuning {
|
|
|
7692
8093
|
* ```
|
|
7693
8094
|
*/
|
|
7694
8095
|
stepOf(freq, tuning = this.#table) {
|
|
7695
|
-
return
|
|
8096
|
+
return _chunk3FDBMIPRcjs.stepOf.call(void 0, freq, tuning);
|
|
7696
8097
|
}
|
|
7697
8098
|
/**
|
|
7698
8099
|
* How far a frequency sits from its nearest step, in cents; positive means
|
|
@@ -7709,7 +8110,7 @@ var Tuning = class _Tuning {
|
|
|
7709
8110
|
* ```
|
|
7710
8111
|
*/
|
|
7711
8112
|
centsFromNearestStep(freq, tuning = this.#table) {
|
|
7712
|
-
return
|
|
8113
|
+
return _chunk3FDBMIPRcjs.centsFromNearestStep.call(void 0, freq, tuning);
|
|
7713
8114
|
}
|
|
7714
8115
|
/**
|
|
7715
8116
|
* Cents spanned by a number of steps.
|
|
@@ -7725,7 +8126,7 @@ var Tuning = class _Tuning {
|
|
|
7725
8126
|
* ```
|
|
7726
8127
|
*/
|
|
7727
8128
|
centsOfSteps(steps, tuning = this.#table) {
|
|
7728
|
-
return
|
|
8129
|
+
return _chunk3FDBMIPRcjs.centsOfSteps.call(void 0, steps, tuning);
|
|
7729
8130
|
}
|
|
7730
8131
|
/**
|
|
7731
8132
|
* Steps spanned by an interval in cents, unrounded — the inverse of
|
|
@@ -7742,7 +8143,7 @@ var Tuning = class _Tuning {
|
|
|
7742
8143
|
* ```
|
|
7743
8144
|
*/
|
|
7744
8145
|
stepsOfCents(cents, tuning = this.#table) {
|
|
7745
|
-
return
|
|
8146
|
+
return _chunk3FDBMIPRcjs.stepsOfCents.call(void 0, cents, tuning);
|
|
7746
8147
|
}
|
|
7747
8148
|
/**
|
|
7748
8149
|
* Whether another tuning divides the octave the same way from the same
|
|
@@ -7791,17 +8192,17 @@ var Tuning = class _Tuning {
|
|
|
7791
8192
|
function copyPitches(pitches) {
|
|
7792
8193
|
assertDataArray(pitches, "voicing pitches");
|
|
7793
8194
|
if (pitches.length === 0) {
|
|
7794
|
-
throw new (0,
|
|
8195
|
+
throw new (0, _chunkS3QELJUEcjs.InvalidInputError)("a voicing must contain at least one pitch");
|
|
7795
8196
|
}
|
|
7796
|
-
return pitches.map((pitch, index) =>
|
|
8197
|
+
return pitches.map((pitch, index) => _chunkS3QELJUEcjs.assertMidiPitch.call(void 0, pitch, `pitches[${index}]`));
|
|
7797
8198
|
}
|
|
7798
8199
|
function spellLine(line, key) {
|
|
7799
8200
|
return line.map(
|
|
7800
|
-
(value) => typeof value === "number" ?
|
|
8201
|
+
(value) => typeof value === "number" ? _chunkYDGMWH43cjs.spellPitch.call(void 0, value, key.tonic, key) : _chunkS3QELJUEcjs.toNoteData.call(void 0, value)
|
|
7801
8202
|
);
|
|
7802
8203
|
}
|
|
7803
8204
|
function lineOf(pitches, key) {
|
|
7804
|
-
return key === void 0 ? pitches.map((pitch) =>
|
|
8205
|
+
return key === void 0 ? pitches.map((pitch) => _chunkS3QELJUEcjs.toNoteData.call(void 0, pitch)) : spellLine(pitches, key);
|
|
7805
8206
|
}
|
|
7806
8207
|
function carriedKeyOf(chord) {
|
|
7807
8208
|
if (typeof chord !== "object" || chord === null) {
|
|
@@ -7811,7 +8212,7 @@ function carriedKeyOf(chord) {
|
|
|
7811
8212
|
return typeof key === "object" && key !== null ? key : void 0;
|
|
7812
8213
|
}
|
|
7813
8214
|
function withCarriedKey(chord, opts) {
|
|
7814
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
8215
|
+
if (_optionalChain([opts, 'optionalAccess', _69 => _69.key]) !== void 0) {
|
|
7815
8216
|
return opts;
|
|
7816
8217
|
}
|
|
7817
8218
|
const key = carriedKeyOf(chord);
|
|
@@ -7857,7 +8258,7 @@ var Voicing = class _Voicing {
|
|
|
7857
8258
|
* ```
|
|
7858
8259
|
*/
|
|
7859
8260
|
static forChord(chord, opts) {
|
|
7860
|
-
return new _Voicing(
|
|
8261
|
+
return new _Voicing(_chunkU4EQTDGNcjs.voiceChordStyled.call(void 0, chord, opts));
|
|
7861
8262
|
}
|
|
7862
8263
|
/**
|
|
7863
8264
|
* Realize a chord as one pitch per voice inside the voice ranges, defaulting
|
|
@@ -7881,7 +8282,7 @@ var Voicing = class _Voicing {
|
|
|
7881
8282
|
* ```
|
|
7882
8283
|
*/
|
|
7883
8284
|
static satb(chord, opts) {
|
|
7884
|
-
return new _Voicing(
|
|
8285
|
+
return new _Voicing(_chunkU4EQTDGNcjs.voiceChord.call(void 0, _chunkYDGMWH43cjs.toChordData.call(void 0, chord), withCarriedKey(chord, opts)));
|
|
7885
8286
|
}
|
|
7886
8287
|
/**
|
|
7887
8288
|
* Wrap a plain pitch array, as {@link Voicing.data} hands it out.
|
|
@@ -7909,7 +8310,7 @@ var Voicing = class _Voicing {
|
|
|
7909
8310
|
* four-voice exercise against.
|
|
7910
8311
|
*/
|
|
7911
8312
|
static get satbRanges() {
|
|
7912
|
-
return
|
|
8313
|
+
return _chunkU4EQTDGNcjs.SATB_RANGES.map((range) => ({ min: range.min, max: range.max }));
|
|
7913
8314
|
}
|
|
7914
8315
|
/** A copy of the sounding MIDI pitches, lowest voice first. */
|
|
7915
8316
|
get pitches() {
|
|
@@ -7952,7 +8353,7 @@ var Voicing = class _Voicing {
|
|
|
7952
8353
|
*/
|
|
7953
8354
|
spell(key, chord) {
|
|
7954
8355
|
assertKeyArgument(key, "voicing key");
|
|
7955
|
-
return this.#spelled(
|
|
8356
|
+
return this.#spelled(_chunkYDGMWH43cjs.resolveKey.call(void 0, key), chord).map((note) => new Note(note));
|
|
7956
8357
|
}
|
|
7957
8358
|
/**
|
|
7958
8359
|
* Voice a chord to follow smoothly from this voicing.
|
|
@@ -7982,7 +8383,7 @@ var Voicing = class _Voicing {
|
|
|
7982
8383
|
* ```
|
|
7983
8384
|
*/
|
|
7984
8385
|
next(chord, opts) {
|
|
7985
|
-
return new _Voicing(
|
|
8386
|
+
return new _Voicing(_chunkU4EQTDGNcjs.nextVoicing.call(void 0, this.pitches, _chunkYDGMWH43cjs.toChordData.call(void 0, chord), withCarriedKey(chord, opts)));
|
|
7986
8387
|
}
|
|
7987
8388
|
/**
|
|
7988
8389
|
* The voice-leading cost from this voicing to another: the summed absolute
|
|
@@ -7994,7 +8395,7 @@ var Voicing = class _Voicing {
|
|
|
7994
8395
|
* voices and are therefore not comparable.
|
|
7995
8396
|
*/
|
|
7996
8397
|
costTo(other) {
|
|
7997
|
-
return
|
|
8398
|
+
return _chunkU4EQTDGNcjs.voiceLeadingCost.call(void 0, this.pitches, other.pitches);
|
|
7998
8399
|
}
|
|
7999
8400
|
/**
|
|
8000
8401
|
* Check the motion from this voicing to another against the four-part rules,
|
|
@@ -8025,14 +8426,14 @@ var Voicing = class _Voicing {
|
|
|
8025
8426
|
*/
|
|
8026
8427
|
checkTo(other, chords, key, opts) {
|
|
8027
8428
|
assertKeyArgument(key, "voicing key");
|
|
8028
|
-
const resolved =
|
|
8029
|
-
const from =
|
|
8030
|
-
const to =
|
|
8429
|
+
const resolved = _chunkYDGMWH43cjs.resolveKey.call(void 0, key);
|
|
8430
|
+
const from = _chunkYDGMWH43cjs.toChordData.call(void 0, chords[0]);
|
|
8431
|
+
const to = _chunkYDGMWH43cjs.toChordData.call(void 0, chords[1]);
|
|
8031
8432
|
const voicings = [
|
|
8032
|
-
|
|
8033
|
-
|
|
8433
|
+
_chunkU4EQTDGNcjs.spellVoicing.call(void 0, this.pitches, from, resolved),
|
|
8434
|
+
_chunkU4EQTDGNcjs.spellVoicing.call(void 0, other.pitches, to, resolved)
|
|
8034
8435
|
];
|
|
8035
|
-
return
|
|
8436
|
+
return _chunkU4EQTDGNcjs.checkPartWriting.call(void 0, voicings, [from, to], resolved, opts);
|
|
8036
8437
|
}
|
|
8037
8438
|
/**
|
|
8038
8439
|
* Mark this voicing, read as a written counterpoint line, against a cantus
|
|
@@ -8062,8 +8463,8 @@ var Voicing = class _Voicing {
|
|
|
8062
8463
|
*/
|
|
8063
8464
|
species(cantusFirmus, species, mode, opts) {
|
|
8064
8465
|
assertKeyArgument(mode, "voicing mode");
|
|
8065
|
-
const resolved =
|
|
8066
|
-
return
|
|
8466
|
+
const resolved = _chunkYDGMWH43cjs.resolveKey.call(void 0, mode);
|
|
8467
|
+
return _chunkU4EQTDGNcjs.checkSpecies.call(void 0,
|
|
8067
8468
|
spellLine(cantusFirmus, resolved),
|
|
8068
8469
|
spellLine(this.#pitches, resolved),
|
|
8069
8470
|
species,
|
|
@@ -8089,8 +8490,8 @@ var Voicing = class _Voicing {
|
|
|
8089
8490
|
*/
|
|
8090
8491
|
independence(other, opts) {
|
|
8091
8492
|
const { key, ...rest } = _nullishCoalesce(opts, () => ( {}));
|
|
8092
|
-
const resolved = key === void 0 ? void 0 :
|
|
8093
|
-
return
|
|
8493
|
+
const resolved = key === void 0 ? void 0 : _chunkYDGMWH43cjs.resolveKey.call(void 0, key);
|
|
8494
|
+
return _chunkYDGMWH43cjs.voiceIndependence.call(void 0,
|
|
8094
8495
|
lineOf(this.#pitches, resolved),
|
|
8095
8496
|
lineOf(other.pitches, resolved),
|
|
8096
8497
|
rest
|
|
@@ -8121,7 +8522,7 @@ var Voicing = class _Voicing {
|
|
|
8121
8522
|
* ```
|
|
8122
8523
|
*/
|
|
8123
8524
|
safetyOf(pitch, query, opts) {
|
|
8124
|
-
return
|
|
8525
|
+
return _chunkYDGMWH43cjs.evaluateSafety.call(void 0, { ...this.#context(query), candidatePitch: pitch }, opts);
|
|
8125
8526
|
}
|
|
8126
8527
|
/**
|
|
8127
8528
|
* Enumerate the pitches placeable against these voices in a range, chord
|
|
@@ -8136,7 +8537,7 @@ var Voicing = class _Voicing {
|
|
|
8136
8537
|
* bound is not a MIDI pitch in 0..127 or is reversed.
|
|
8137
8538
|
*/
|
|
8138
8539
|
safePitches(query, pitchLow, pitchHigh) {
|
|
8139
|
-
return
|
|
8540
|
+
return _chunkYDGMWH43cjs.enumerateSafePitches.call(void 0, this.#context(query), pitchLow, pitchHigh);
|
|
8140
8541
|
}
|
|
8141
8542
|
/**
|
|
8142
8543
|
* The n-th inversion of the voicing: the lowest voice taken up an octave, n
|
|
@@ -8160,7 +8561,7 @@ var Voicing = class _Voicing {
|
|
|
8160
8561
|
* ```
|
|
8161
8562
|
*/
|
|
8162
8563
|
invert(n) {
|
|
8163
|
-
|
|
8564
|
+
_chunkS3QELJUEcjs.assertInteger.call(void 0, n, "voicing inversion", -128, 128);
|
|
8164
8565
|
if (n === 0) {
|
|
8165
8566
|
return this;
|
|
8166
8567
|
}
|
|
@@ -8169,7 +8570,7 @@ var Voicing = class _Voicing {
|
|
|
8169
8570
|
const index = n > 0 ? 0 : pitches.length - 1;
|
|
8170
8571
|
const pitch = pitches[index] + (n > 0 ? 12 : -12);
|
|
8171
8572
|
pitches.splice(index, 1);
|
|
8172
|
-
pitches.push(
|
|
8573
|
+
pitches.push(_chunkS3QELJUEcjs.assertMidiPitch.call(void 0, pitch, "inverted voice"));
|
|
8173
8574
|
pitches.sort((a, b) => a - b);
|
|
8174
8575
|
}
|
|
8175
8576
|
return new _Voicing(pitches);
|
|
@@ -8209,19 +8610,19 @@ var Voicing = class _Voicing {
|
|
|
8209
8610
|
}
|
|
8210
8611
|
/** Spell the voicing, by the key alone or against a chord as well. */
|
|
8211
8612
|
#spelled(key, chord) {
|
|
8212
|
-
return chord === void 0 ? spellLine(this.#pitches, key) :
|
|
8613
|
+
return chord === void 0 ? spellLine(this.#pitches, key) : _chunkU4EQTDGNcjs.spellVoicing.call(void 0, this.pitches, _chunkYDGMWH43cjs.toChordData.call(void 0, chord), key);
|
|
8213
8614
|
}
|
|
8214
8615
|
/** The safety context these voices supply, minus the candidate pitch. */
|
|
8215
8616
|
#context(query) {
|
|
8216
|
-
const previous = _optionalChain([query, 'access',
|
|
8617
|
+
const previous = _optionalChain([query, 'access', _70 => _70.previous, 'optionalAccess', _71 => _71.pitches]);
|
|
8217
8618
|
const otherVoices = this.#pitches.map((pitch, index) => {
|
|
8218
|
-
const prevPitch = _optionalChain([previous, 'optionalAccess',
|
|
8619
|
+
const prevPitch = _optionalChain([previous, 'optionalAccess', _72 => _72[index]]);
|
|
8219
8620
|
return prevPitch === void 0 ? { pitch } : { pitch, prevPitch };
|
|
8220
8621
|
});
|
|
8221
8622
|
return {
|
|
8222
8623
|
profile: query.profile,
|
|
8223
|
-
chord: query.chord === null ? null :
|
|
8224
|
-
key:
|
|
8624
|
+
chord: query.chord === null ? null : _chunkYDGMWH43cjs.toChordData.call(void 0, query.chord),
|
|
8625
|
+
key: _chunkYDGMWH43cjs.resolveKey.call(void 0, query.key).scale,
|
|
8225
8626
|
otherVoices,
|
|
8226
8627
|
strongBeat: query.strongBeat,
|
|
8227
8628
|
prevPitch: query.prevPitch,
|
|
@@ -8250,4 +8651,4 @@ var Voicing = class _Voicing {
|
|
|
8250
8651
|
|
|
8251
8652
|
|
|
8252
8653
|
exports.Interval = Interval; exports.Note = Note; exports.Timeline = Timeline; exports.Progression = Progression; exports.Chord = Chord; exports.Key = Key; exports.Score = Score; exports.Arrangement = Arrangement; exports.Instrument = Instrument; exports.Composer = Composer; exports.Duration = Duration; exports.Meter = Meter; exports.Motif = Motif; exports.Rhythm = Rhythm; exports.Tempo = Tempo; exports.Tuning = Tuning; exports.Voicing = Voicing;
|
|
8253
|
-
//# sourceMappingURL=chunk-
|
|
8654
|
+
//# sourceMappingURL=chunk-HYSVSFNI.cjs.map
|