@libraz/libcantus 1.1.0 → 1.3.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/README.md +4 -0
- package/README_ja.md +4 -0
- package/dist/analyze/index.cjs +31 -7
- package/dist/analyze/index.cjs.map +1 -1
- package/dist/analyze/index.d.cts +155 -9
- package/dist/analyze/index.d.ts +155 -9
- package/dist/analyze/index.js +37 -13
- package/dist/{chunk-TT6PKMPR.cjs → chunk-35NBV2FT.cjs} +16 -16
- package/dist/{chunk-TT6PKMPR.cjs.map → chunk-35NBV2FT.cjs.map} +1 -1
- package/dist/{chunk-YPB3A3EY.cjs → chunk-3R3QVKY5.cjs} +314 -285
- package/dist/chunk-3R3QVKY5.cjs.map +1 -0
- package/dist/{chunk-GDKE6RQW.cjs → chunk-4R2LWV7E.cjs} +691 -413
- package/dist/chunk-4R2LWV7E.cjs.map +1 -0
- package/dist/{chunk-RVS4G4MR.cjs → chunk-76ZBTRG2.cjs} +198 -198
- package/dist/{chunk-RVS4G4MR.cjs.map → chunk-76ZBTRG2.cjs.map} +1 -1
- package/dist/{chunk-X6RJAHII.js → chunk-7KG3RTYS.js} +2 -2
- package/dist/{chunk-PQL7E5F6.js → chunk-AGOVW7U6.js} +1 -1
- package/dist/{chunk-PQL7E5F6.js.map → chunk-AGOVW7U6.js.map} +1 -1
- package/dist/{chunk-5KW7DNCJ.cjs → chunk-B2PW6EHN.cjs} +2423 -453
- package/dist/chunk-B2PW6EHN.cjs.map +1 -0
- package/dist/{chunk-J772DL3B.cjs → chunk-CGBADIO5.cjs} +53 -53
- package/dist/{chunk-J772DL3B.cjs.map → chunk-CGBADIO5.cjs.map} +1 -1
- package/dist/{chunk-R5VUXQMP.js → chunk-CPMB7P75.js} +1978 -8
- package/dist/chunk-CPMB7P75.js.map +1 -0
- package/dist/{chunk-VLE5R7PF.js → chunk-GNVN4PPJ.js} +1874 -8
- package/dist/chunk-GNVN4PPJ.js.map +1 -0
- package/dist/{chunk-Q6R3QAZD.cjs → chunk-IFZDWIKM.cjs} +2199 -333
- package/dist/chunk-IFZDWIKM.cjs.map +1 -0
- package/dist/{chunk-DKICR7AN.js → chunk-IPEF6NWB.js} +296 -18
- package/dist/chunk-IPEF6NWB.js.map +1 -0
- package/dist/{chunk-AWEMD747.js → chunk-M5RYMAFI.js} +3 -3
- package/dist/{chunk-HSY2VQXZ.js → chunk-MLBPXA4Z.js} +330 -728
- package/dist/chunk-MLBPXA4Z.js.map +1 -0
- package/dist/{chunk-H66ARFU5.js → chunk-NB25P3EH.js} +3 -3
- package/dist/{chunk-5JJ6EHEZ.cjs → chunk-NM7UAMC3.cjs} +62 -62
- package/dist/{chunk-5JJ6EHEZ.cjs.map → chunk-NM7UAMC3.cjs.map} +1 -1
- package/dist/{chunk-R7B5N2JK.cjs → chunk-PM4XJE2Y.cjs} +47 -47
- package/dist/{chunk-R7B5N2JK.cjs.map → chunk-PM4XJE2Y.cjs.map} +1 -1
- package/dist/{chunk-7GOKQJTQ.js → chunk-PUKJP2Z5.js} +2 -2
- package/dist/{chunk-QCXYKSZS.cjs → chunk-PWC4CRWT.cjs} +19 -19
- package/dist/{chunk-QCXYKSZS.cjs.map → chunk-PWC4CRWT.cjs.map} +1 -1
- package/dist/{chunk-FPBZFNCD.js → chunk-RFIBF2RR.js} +47 -18
- package/dist/{chunk-FPBZFNCD.js.map → chunk-RFIBF2RR.js.map} +1 -1
- package/dist/{chunk-XKSO2V5I.cjs → chunk-S5BKZZGM.cjs} +1 -1
- package/dist/{chunk-XKSO2V5I.cjs.map → chunk-S5BKZZGM.cjs.map} +1 -1
- package/dist/{chunk-HOHFYGKW.js → chunk-UMWZ4ZET.js} +2 -2
- package/dist/{chunk-XVMJO3QF.cjs → chunk-YFA7X2F6.cjs} +489 -887
- package/dist/chunk-YFA7X2F6.cjs.map +1 -0
- package/dist/{chunk-57WB2EDF.js → chunk-ZBUROTJQ.js} +3 -3
- package/dist/{coerce-wwdELNYS.d.ts → coerce-DP0vYu-x.d.ts} +77 -1
- package/dist/{coerce-CJlgULrQ.d.cts → coerce-DRERzdve.d.cts} +77 -1
- package/dist/core/index.cjs +5 -5
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.ts +2 -2
- 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 +87 -9
- package/dist/generate/index.d.ts +87 -9
- package/dist/generate/index.js +19 -7
- package/dist/{index-BaoKVVhE.d.cts → index-B9QLziDe.d.cts} +2 -2
- package/dist/{index-CnHQgqNh.d.ts → index-BHIUyjhZ.d.ts} +2 -2
- package/dist/{index-CBCP84rv.d.cts → index-BL5N2Oyz.d.cts} +1 -1
- package/dist/{index-D_hzxD8w.d.cts → index-BMweUlm5.d.cts} +3 -0
- package/dist/{index-Ci3xyows.d.ts → index-CL4b4gUQ.d.ts} +3 -0
- package/dist/{index-BzLNkmA7.d.cts → index-CY-3NVfy.d.cts} +486 -5
- package/dist/{index-CnIdP4EZ.d.ts → index-Dw2DP7vm.d.ts} +1 -1
- package/dist/{index-DpC-mDlV.d.ts → index-zaZdmnU4.d.ts} +486 -5
- package/dist/index.cjs +49 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +55 -19
- package/dist/{masks-O73Rhj5d.d.ts → masks-Cc7-MzzY.d.ts} +1 -1
- package/dist/{masks-C8TWLFIi.d.cts → masks-pADfTOiD.d.cts} +1 -1
- package/dist/model/index.cjs +12 -12
- package/dist/model/index.d.cts +213 -16
- package/dist/model/index.d.ts +213 -16
- package/dist/model/index.js +11 -11
- package/dist/{index-DTsKaPaC.d.cts → profile-CQMEqdH9.d.cts} +88 -601
- package/dist/{index-BUtIf2go.d.ts → profile-DLdlIpS9.d.ts} +88 -601
- package/dist/theory/index.cjs +5 -5
- package/dist/theory/index.d.cts +7 -7
- package/dist/theory/index.d.ts +7 -7
- package/dist/theory/index.js +4 -4
- package/dist/{index-BpWOhkkE.d.ts → types-D-XgxGvp.d.cts} +1170 -14
- package/dist/{index-B3WCj_Hm.d.cts → types-Dh7C064C.d.ts} +1170 -14
- package/package.json +6 -5
- package/dist/chunk-5KW7DNCJ.cjs.map +0 -1
- package/dist/chunk-DKICR7AN.js.map +0 -1
- package/dist/chunk-GDKE6RQW.cjs.map +0 -1
- package/dist/chunk-HSY2VQXZ.js.map +0 -1
- package/dist/chunk-Q6R3QAZD.cjs.map +0 -1
- package/dist/chunk-R5VUXQMP.js.map +0 -1
- package/dist/chunk-VLE5R7PF.js.map +0 -1
- package/dist/chunk-XVMJO3QF.cjs.map +0 -1
- package/dist/chunk-YPB3A3EY.cjs.map +0 -1
- /package/dist/{chunk-X6RJAHII.js.map → chunk-7KG3RTYS.js.map} +0 -0
- /package/dist/{chunk-AWEMD747.js.map → chunk-M5RYMAFI.js.map} +0 -0
- /package/dist/{chunk-H66ARFU5.js.map → chunk-NB25P3EH.js.map} +0 -0
- /package/dist/{chunk-7GOKQJTQ.js.map → chunk-PUKJP2Z5.js.map} +0 -0
- /package/dist/{chunk-HOHFYGKW.js.map → chunk-UMWZ4ZET.js.map} +0 -0
- /package/dist/{chunk-57WB2EDF.js.map → chunk-ZBUROTJQ.js.map} +0 -0
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
var
|
|
36
|
+
var _chunk3R3QVKY5cjs = require('./chunk-3R3QVKY5.cjs');
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
@@ -55,7 +55,7 @@ var _chunkYPB3A3EYcjs = require('./chunk-YPB3A3EY.cjs');
|
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
|
|
58
|
-
var
|
|
58
|
+
var _chunkS5BKZZGMcjs = require('./chunk-S5BKZZGM.cjs');
|
|
59
59
|
|
|
60
60
|
// src/theory/transposition/index.ts
|
|
61
61
|
var TRANSPOSING_INSTRUMENTS = Object.freeze({
|
|
@@ -90,17 +90,17 @@ var PROFILE_NAME_ALIASES = Object.freeze({
|
|
|
90
90
|
});
|
|
91
91
|
function instrumentTransposition(instrument) {
|
|
92
92
|
if (typeof instrument !== "string") {
|
|
93
|
-
return
|
|
93
|
+
return _chunkS5BKZZGMcjs.toSpelledInterval.call(void 0, instrument);
|
|
94
94
|
}
|
|
95
95
|
const name = Object.hasOwn(PROFILE_NAME_ALIASES, instrument) ? PROFILE_NAME_ALIASES[instrument] : instrument;
|
|
96
96
|
if (Object.hasOwn(TRANSPOSING_INSTRUMENTS, name)) {
|
|
97
|
-
return
|
|
97
|
+
return _chunkS5BKZZGMcjs.parseInterval.call(void 0, TRANSPOSING_INSTRUMENTS[name]);
|
|
98
98
|
}
|
|
99
99
|
try {
|
|
100
|
-
return
|
|
100
|
+
return _chunkS5BKZZGMcjs.parseInterval.call(void 0, instrument);
|
|
101
101
|
} catch (error) {
|
|
102
|
-
if (error instanceof
|
|
103
|
-
throw new (0,
|
|
102
|
+
if (error instanceof _chunkS5BKZZGMcjs.InvalidInputError) {
|
|
103
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
|
|
104
104
|
`unknown transposing instrument ${JSON.stringify(instrument)}; pass a name from TRANSPOSING_INSTRUMENTS or an interval such as '-M2'`
|
|
105
105
|
);
|
|
106
106
|
}
|
|
@@ -117,11 +117,11 @@ function reversedInterval(step) {
|
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
function toSoundingPitch(note, instrument) {
|
|
120
|
-
return
|
|
120
|
+
return _chunkS5BKZZGMcjs.transposeByInterval.call(void 0, _chunkS5BKZZGMcjs.toNoteData.call(void 0, note), instrumentTransposition(instrument));
|
|
121
121
|
}
|
|
122
122
|
function toWrittenPitch(note, instrument) {
|
|
123
|
-
return
|
|
124
|
-
|
|
123
|
+
return _chunkS5BKZZGMcjs.transposeByInterval.call(void 0,
|
|
124
|
+
_chunkS5BKZZGMcjs.toNoteData.call(void 0, note),
|
|
125
125
|
reversedInterval(instrumentTransposition(instrument))
|
|
126
126
|
);
|
|
127
127
|
}
|
|
@@ -162,7 +162,7 @@ var ACCIDENTAL_GLYPHS = new Map(
|
|
|
162
162
|
PRINTED_ACCIDENTALS.map(([, glyph, alter]) => [alter, glyph])
|
|
163
163
|
);
|
|
164
164
|
function invalidFigures(figures, detail) {
|
|
165
|
-
return new (0,
|
|
165
|
+
return new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`figured bass ${_chunkS5BKZZGMcjs.describeRejected.call(void 0, figures)} ${detail}`);
|
|
166
166
|
}
|
|
167
167
|
function alteredBy(diatonicAlter, accidental) {
|
|
168
168
|
const printed = PRINTED_ALTERS.get(accidental);
|
|
@@ -268,8 +268,8 @@ var FIGURE_ABBREVIATIONS = /* @__PURE__ */ new Map([
|
|
|
268
268
|
]);
|
|
269
269
|
function tertianQualityIndex() {
|
|
270
270
|
const index = /* @__PURE__ */ new Map();
|
|
271
|
-
for (const quality of
|
|
272
|
-
const { intervals } =
|
|
271
|
+
for (const quality of _chunk3R3QVKY5cjs.chordQualities.call(void 0, )) {
|
|
272
|
+
const { intervals } = _chunk3R3QVKY5cjs.makeChord.call(void 0, 0, quality);
|
|
273
273
|
const template = intervals.join(",");
|
|
274
274
|
if (intervals.length >= 3 && intervals.length <= MAX_STACK_SIZE && !index.has(template)) {
|
|
275
275
|
index.set(template, quality);
|
|
@@ -279,22 +279,22 @@ function tertianQualityIndex() {
|
|
|
279
279
|
}
|
|
280
280
|
var TERTIAN_QUALITIES = tertianQualityIndex();
|
|
281
281
|
function keyLetterAlters(key) {
|
|
282
|
-
const size =
|
|
282
|
+
const size = _chunk3R3QVKY5cjs.scaleTonesInDegreeOrder.call(void 0, key.scale).length;
|
|
283
283
|
if (size !== 7) {
|
|
284
|
-
throw new (0,
|
|
284
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`figured bass requires a heptatonic key (received ${size} tones)`);
|
|
285
285
|
}
|
|
286
286
|
const alters = [];
|
|
287
|
-
for (const note of
|
|
288
|
-
alters[
|
|
287
|
+
for (const note of _chunk3R3QVKY5cjs.spellScale.call(void 0, key.tonic, key.scale)) {
|
|
288
|
+
alters[_chunkS5BKZZGMcjs.diatonicLetterOf.call(void 0, note.letter)] = note.alter;
|
|
289
289
|
}
|
|
290
290
|
return alters;
|
|
291
291
|
}
|
|
292
292
|
function noteAbove(bass, figure, alters) {
|
|
293
|
-
const letter =
|
|
293
|
+
const letter = _chunkS5BKZZGMcjs.diatonicLetterOf.call(void 0, bass.letter + figure.number - 1);
|
|
294
294
|
return { letter, alter: alteredBy(_nullishCoalesce(alters[letter], () => ( 0)), figure.accidental) };
|
|
295
295
|
}
|
|
296
296
|
function bareNote(note) {
|
|
297
|
-
return { letter:
|
|
297
|
+
return { letter: _chunkS5BKZZGMcjs.diatonicLetterOf.call(void 0, note.letter), alter: note.alter };
|
|
298
298
|
}
|
|
299
299
|
function realizeSonority(bass, resolved, text, alters) {
|
|
300
300
|
const numbers = [...new Set(resolved.map((figure) => figure.number))].sort((a, b) => a - b);
|
|
@@ -308,35 +308,35 @@ function realizeSonority(bass, resolved, text, alters) {
|
|
|
308
308
|
);
|
|
309
309
|
const tones = [bass, ...notes];
|
|
310
310
|
const root = _nullishCoalesce(tones[[1, ...sonority.intervals].indexOf(sonority.rootInterval)], () => ( bass));
|
|
311
|
-
const rootPc =
|
|
311
|
+
const rootPc = _chunkS5BKZZGMcjs.noteToPitchClass.call(void 0, root);
|
|
312
312
|
const stack = [];
|
|
313
313
|
for (let step = 0; step < tones.length; step += 1) {
|
|
314
|
-
const tone = tones.find((candidate) =>
|
|
314
|
+
const tone = tones.find((candidate) => _chunkS5BKZZGMcjs.diatonicLetterOf.call(void 0, candidate.letter - root.letter) === step * 2);
|
|
315
315
|
if (tone === void 0) {
|
|
316
|
-
throw new (0,
|
|
317
|
-
`figured bass ${
|
|
316
|
+
throw new (0, _chunkS5BKZZGMcjs.NoSolutionError)(
|
|
317
|
+
`figured bass ${_chunkS5BKZZGMcjs.describeRejected.call(void 0, text)} sounds ${_chunk3R3QVKY5cjs.noteNames.call(void 0, tones).join(" ")}, which does not stack in thirds`
|
|
318
318
|
);
|
|
319
319
|
}
|
|
320
|
-
stack.push(
|
|
320
|
+
stack.push(_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, _chunkS5BKZZGMcjs.noteToPitchClass.call(void 0, tone) - rootPc));
|
|
321
321
|
}
|
|
322
322
|
const quality = TERTIAN_QUALITIES.get(stack.join(","));
|
|
323
323
|
if (quality === void 0) {
|
|
324
|
-
throw new (0,
|
|
325
|
-
`figured bass ${
|
|
324
|
+
throw new (0, _chunkS5BKZZGMcjs.NoSolutionError)(
|
|
325
|
+
`figured bass ${_chunkS5BKZZGMcjs.describeRejected.call(void 0, text)} sounds ${_chunk3R3QVKY5cjs.noteNames.call(void 0, tones).join(" ")}, which no chord quality names`
|
|
326
326
|
);
|
|
327
327
|
}
|
|
328
|
-
const chord =
|
|
328
|
+
const chord = _chunk3R3QVKY5cjs.makeChord.call(void 0, rootPc, quality, _chunkS5BKZZGMcjs.noteToPitchClass.call(void 0, bass));
|
|
329
329
|
chord.rootSpelling = { letter: root.letter, alter: root.alter };
|
|
330
330
|
chord.bassSpelling = { letter: bass.letter, alter: bass.alter };
|
|
331
331
|
return { chord, notes };
|
|
332
332
|
}
|
|
333
333
|
function figuredBassRealization(bass, figures, key) {
|
|
334
334
|
if (typeof figures !== "string") {
|
|
335
|
-
throw new (0,
|
|
335
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`figured bass must be a string; received ${typeof figures}`);
|
|
336
336
|
}
|
|
337
|
-
const bassData =
|
|
338
|
-
const alters = keyLetterAlters(
|
|
339
|
-
|
|
337
|
+
const bassData = _chunkS5BKZZGMcjs.toNoteData.call(void 0, bass);
|
|
338
|
+
const alters = keyLetterAlters(_chunk3R3QVKY5cjs.resolveKey.call(void 0, key));
|
|
339
|
+
_chunkS5BKZZGMcjs.noteToPitchClass.call(void 0, bassData);
|
|
340
340
|
const bassNote = bareNote(bassData);
|
|
341
341
|
const text = figures.trim();
|
|
342
342
|
const { figures: written, motions } = parseFigures(text);
|
|
@@ -357,37 +357,37 @@ function realizeFiguredBass(bass, figures, key) {
|
|
|
357
357
|
return figuredBassRealization(bass, figures, key).chord;
|
|
358
358
|
}
|
|
359
359
|
function figuredBassOf(chord, key) {
|
|
360
|
-
const data =
|
|
361
|
-
const resolved =
|
|
360
|
+
const data = _chunk3R3QVKY5cjs.toChordData.call(void 0, chord);
|
|
361
|
+
const resolved = _chunk3R3QVKY5cjs.resolveKey.call(void 0, key);
|
|
362
362
|
const alters = keyLetterAlters(resolved);
|
|
363
|
-
const tones =
|
|
364
|
-
const bassPc =
|
|
365
|
-
const bass = tones.find((tone) =>
|
|
363
|
+
const tones = _chunk3R3QVKY5cjs.spellChord.call(void 0, data, resolved.tonic, resolved.scale);
|
|
364
|
+
const bassPc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, _nullishCoalesce(data.bassPc, () => ( data.rootPc)));
|
|
365
|
+
const bass = tones.find((tone) => _chunkS5BKZZGMcjs.noteToPitchClass.call(void 0, tone) === bassPc);
|
|
366
366
|
if (bass === void 0) {
|
|
367
|
-
throw new (0,
|
|
367
|
+
throw new (0, _chunkS5BKZZGMcjs.NoSolutionError)(
|
|
368
368
|
"figured bass measures intervals above a chord tone, and this chord's bass is not one of its tones"
|
|
369
369
|
);
|
|
370
370
|
}
|
|
371
371
|
const written = /* @__PURE__ */ new Map();
|
|
372
372
|
for (const tone of tones) {
|
|
373
373
|
if (tone !== bass) {
|
|
374
|
-
written.set(
|
|
374
|
+
written.set(_chunkS5BKZZGMcjs.diatonicLetterOf.call(void 0, tone.letter - bass.letter) + 1, tone);
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
377
|
const digits = FIGURE_ABBREVIATIONS.get([...written.keys()].sort((a, b) => a - b).join(","));
|
|
378
378
|
if (digits === void 0) {
|
|
379
|
-
throw new (0,
|
|
380
|
-
`no figured bass names ${
|
|
379
|
+
throw new (0, _chunkS5BKZZGMcjs.NoSolutionError)(
|
|
380
|
+
`no figured bass names ${_chunk3R3QVKY5cjs.noteNames.call(void 0, tones).join(" ")} over ${_chunk3R3QVKY5cjs.noteNames.call(void 0, [bass])[0]}`
|
|
381
381
|
);
|
|
382
382
|
}
|
|
383
383
|
const accidentals = /* @__PURE__ */ new Map();
|
|
384
384
|
for (const [number, tone] of written) {
|
|
385
|
-
if (tone.alter === (_nullishCoalesce(alters[
|
|
385
|
+
if (tone.alter === (_nullishCoalesce(alters[_chunkS5BKZZGMcjs.diatonicLetterOf.call(void 0, tone.letter)], () => ( 0)))) {
|
|
386
386
|
continue;
|
|
387
387
|
}
|
|
388
388
|
const glyph = ACCIDENTAL_GLYPHS.get(tone.alter);
|
|
389
389
|
if (glyph === void 0) {
|
|
390
|
-
throw new (0,
|
|
390
|
+
throw new (0, _chunkS5BKZZGMcjs.NoSolutionError)(`no accidental writes a note altered by ${tone.alter} semitones`);
|
|
391
391
|
}
|
|
392
392
|
accidentals.set(number, glyph);
|
|
393
393
|
}
|
|
@@ -396,48 +396,48 @@ function figuredBassOf(chord, key) {
|
|
|
396
396
|
return figures;
|
|
397
397
|
}
|
|
398
398
|
function pitchClassesOf(notes) {
|
|
399
|
-
return [...new Set(notes.map(
|
|
399
|
+
return [...new Set(notes.map(_chunkS5BKZZGMcjs.noteToPitchClass))].sort((a, b) => a - b);
|
|
400
400
|
}
|
|
401
401
|
function assertRealizesAs(bass, figures, key, tones) {
|
|
402
|
-
const noFigures = (detail) => new (0,
|
|
403
|
-
`no figured bass names ${
|
|
402
|
+
const noFigures = (detail) => new (0, _chunkS5BKZZGMcjs.NoSolutionError)(
|
|
403
|
+
`no figured bass names ${_chunk3R3QVKY5cjs.noteNames.call(void 0, tones).join(" ")} over ${_chunk3R3QVKY5cjs.noteNames.call(void 0, [bass])[0]}: the figures ${_chunkS5BKZZGMcjs.describeRejected.call(void 0, figures)} ${detail}`
|
|
404
404
|
);
|
|
405
405
|
let realized;
|
|
406
406
|
try {
|
|
407
407
|
realized = figuredBassRealization(bass, figures, key);
|
|
408
408
|
} catch (error) {
|
|
409
|
-
throw error instanceof
|
|
409
|
+
throw error instanceof _chunkS5BKZZGMcjs.NoSolutionError ? noFigures("read back as no chord at all") : error;
|
|
410
410
|
}
|
|
411
411
|
const written = pitchClassesOf(realized.notes);
|
|
412
412
|
const expected = pitchClassesOf(tones);
|
|
413
413
|
if (written.length !== expected.length || written.some((pc, index) => pc !== expected[index])) {
|
|
414
|
-
throw noFigures(`sound ${
|
|
414
|
+
throw noFigures(`sound ${_chunk3R3QVKY5cjs.noteNames.call(void 0, realized.notes).join(" ")} instead`);
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
417
|
|
|
418
418
|
// src/theory/partwriting/cross-relation.ts
|
|
419
419
|
function resolvesAsAppliedDominant(chord, next, key) {
|
|
420
|
-
if (next === void 0 || !
|
|
420
|
+
if (next === void 0 || !_chunk3R3QVKY5cjs.hasDominantSonority.call(void 0, chord)) {
|
|
421
421
|
return false;
|
|
422
422
|
}
|
|
423
|
-
const target =
|
|
424
|
-
return target !== null &&
|
|
423
|
+
const target = _chunk3R3QVKY5cjs.appliedDominantTarget.call(void 0, chord.rootPc + 5, key);
|
|
424
|
+
return target !== null && _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, next.rootPc) === target.rootPc;
|
|
425
425
|
}
|
|
426
426
|
function soundsAugmentedSixth(moment, key) {
|
|
427
427
|
const bass = moment.notes[0];
|
|
428
|
-
if (bass === void 0 ||
|
|
428
|
+
if (bass === void 0 || _chunkS5BKZZGMcjs.noteToPitchClass.call(void 0, bass) !== _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, key.rootPc + 8)) {
|
|
429
429
|
return false;
|
|
430
430
|
}
|
|
431
431
|
return moment.notes.some((note, voice) => {
|
|
432
432
|
if (voice === 0) {
|
|
433
433
|
return false;
|
|
434
434
|
}
|
|
435
|
-
const interval =
|
|
436
|
-
return (interval.number - 1) % 7 + 1 === 6 &&
|
|
435
|
+
const interval = _chunkS5BKZZGMcjs.spelledInterval.call(void 0, bass, note);
|
|
436
|
+
return (interval.number - 1) % 7 + 1 === 6 && _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, interval.semitones) === 10;
|
|
437
437
|
});
|
|
438
438
|
}
|
|
439
439
|
function isChromaticHarmony(moment, next, key) {
|
|
440
|
-
return resolvesAsAppliedDominant(moment.chord, next, key) ||
|
|
440
|
+
return resolvesAsAppliedDominant(moment.chord, next, key) || _chunk3R3QVKY5cjs.isNeapolitanChordOf.call(void 0, moment.chord, key) || soundsAugmentedSixth(moment, key);
|
|
441
441
|
}
|
|
442
442
|
function approachedByStep(before, moment, voice) {
|
|
443
443
|
const earlier = _optionalChain([before, 'optionalAccess', _2 => _2[voice]]);
|
|
@@ -445,7 +445,7 @@ function approachedByStep(before, moment, voice) {
|
|
|
445
445
|
if (earlier === void 0 || later === void 0) {
|
|
446
446
|
return false;
|
|
447
447
|
}
|
|
448
|
-
return
|
|
448
|
+
return _chunkS5BKZZGMcjs.spelledInterval.call(void 0, earlier, later).number === 2;
|
|
449
449
|
}
|
|
450
450
|
function isOuterVoice(voice, notes) {
|
|
451
451
|
return voice === 0 || voice === notes.length - 1;
|
|
@@ -467,8 +467,8 @@ function crossRelations(from, to, key, context = {}) {
|
|
|
467
467
|
if (earlier === void 0 || later === void 0) {
|
|
468
468
|
continue;
|
|
469
469
|
}
|
|
470
|
-
const letter =
|
|
471
|
-
if (letter !==
|
|
470
|
+
const letter = _chunkS5BKZZGMcjs.diatonicLetterOf.call(void 0, earlier.letter);
|
|
471
|
+
if (letter !== _chunkS5BKZZGMcjs.diatonicLetterOf.call(void 0, later.letter) || earlier.alter === later.alter) {
|
|
472
472
|
continue;
|
|
473
473
|
}
|
|
474
474
|
if (approachedByStep(context.before, from.notes, first) || approachedByStep(from.notes, to.notes, second) || !isOuterVoice(first, from.notes) && !isOuterVoice(second, to.notes)) {
|
|
@@ -487,18 +487,18 @@ function crossRelations(from, to, key, context = {}) {
|
|
|
487
487
|
|
|
488
488
|
// src/theory/voicing/tendency.ts
|
|
489
489
|
function spellingTable(keyLike, chord) {
|
|
490
|
-
const { tonic, scale: key } =
|
|
490
|
+
const { tonic, scale: key } = _chunk3R3QVKY5cjs.resolveKey.call(void 0, keyLike);
|
|
491
491
|
const notes = [];
|
|
492
492
|
const bases = [];
|
|
493
493
|
for (let pc = 0; pc < 12; pc += 1) {
|
|
494
|
-
const note = chord === void 0 ?
|
|
494
|
+
const note = chord === void 0 ? _chunk3R3QVKY5cjs.spellPitchClass.call(void 0, pc, tonic, key) : _chunk3R3QVKY5cjs.spellPitchClass.call(void 0, pc, tonic, key, { chord });
|
|
495
495
|
notes.push(note);
|
|
496
|
-
bases.push(
|
|
496
|
+
bases.push(_chunkS5BKZZGMcjs.noteToMidi.call(void 0, { letter: note.letter, alter: note.alter, octave: 0 }));
|
|
497
497
|
}
|
|
498
498
|
return { notes, bases };
|
|
499
499
|
}
|
|
500
500
|
function spelledAt(table, pitch) {
|
|
501
|
-
const pc =
|
|
501
|
+
const pc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, pitch);
|
|
502
502
|
const note = table.notes[pc];
|
|
503
503
|
const base = table.bases[pc];
|
|
504
504
|
if (note === void 0 || base === void 0) {
|
|
@@ -512,7 +512,7 @@ function movesByAugmentedInterval(from, fromPitch, to, toPitch) {
|
|
|
512
512
|
if (earlier === void 0 || later === void 0) {
|
|
513
513
|
return false;
|
|
514
514
|
}
|
|
515
|
-
return
|
|
515
|
+
return _chunk3R3QVKY5cjs.isAugmentedMelodicInterval.call(void 0, earlier, later);
|
|
516
516
|
}
|
|
517
517
|
function movesByDescendingStep(from, fromPitch, to, toPitch) {
|
|
518
518
|
const earlier = spelledAt(from, fromPitch);
|
|
@@ -520,7 +520,7 @@ function movesByDescendingStep(from, fromPitch, to, toPitch) {
|
|
|
520
520
|
if (earlier === void 0 || later === void 0) {
|
|
521
521
|
return false;
|
|
522
522
|
}
|
|
523
|
-
return
|
|
523
|
+
return _chunk3R3QVKY5cjs.isDescendingStep.call(void 0, _chunkS5BKZZGMcjs.spelledInterval.call(void 0, earlier, later));
|
|
524
524
|
}
|
|
525
525
|
|
|
526
526
|
// src/theory/voicing/internal.ts
|
|
@@ -545,7 +545,7 @@ function createCandidateBuffer() {
|
|
|
545
545
|
function pitchesForPc(pc, range) {
|
|
546
546
|
const result = [];
|
|
547
547
|
for (let midi = Math.ceil(range.min); midi <= range.max; midi += 1) {
|
|
548
|
-
if (
|
|
548
|
+
if (_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, midi) === pc) {
|
|
549
549
|
result.push(midi);
|
|
550
550
|
}
|
|
551
551
|
}
|
|
@@ -557,14 +557,14 @@ function pitchesForPc(pc, range) {
|
|
|
557
557
|
});
|
|
558
558
|
}
|
|
559
559
|
function enumerateVoicings(chord, ranges, maxSpacing, maxCandidates = DEFAULT_MAX_CANDIDATES, into = createCandidateBuffer()) {
|
|
560
|
-
const chordPcs =
|
|
561
|
-
const bassPc =
|
|
560
|
+
const chordPcs = _chunk3R3QVKY5cjs.chordPitchClasses.call(void 0, chord);
|
|
561
|
+
const bassPc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, _nullishCoalesce(chord.bassPc, () => ( chord.rootPc)));
|
|
562
562
|
const byVoice = ranges.map(
|
|
563
563
|
(range, voice) => (voice === 0 ? [bassPc] : chordPcs).flatMap((pc) => pitchesForPc(pc, range))
|
|
564
564
|
);
|
|
565
565
|
for (let voice = 0; voice < byVoice.length; voice += 1) {
|
|
566
566
|
if ((_nullishCoalesce(byVoice[voice], () => ( []))).length === 0) {
|
|
567
|
-
throw new (0,
|
|
567
|
+
throw new (0, _chunkS5BKZZGMcjs.NoSolutionError)("no voicing satisfies the given ranges");
|
|
568
568
|
}
|
|
569
569
|
}
|
|
570
570
|
const voices = ranges.length;
|
|
@@ -613,17 +613,17 @@ function enumerateVoicings(chord, ranges, maxSpacing, maxCandidates = DEFAULT_MA
|
|
|
613
613
|
return into;
|
|
614
614
|
}
|
|
615
615
|
function structuralTables(chord, key) {
|
|
616
|
-
const tones =
|
|
616
|
+
const tones = _chunk3R3QVKY5cjs.chordPitchClasses.call(void 0, chord);
|
|
617
617
|
const missing = tones.map(
|
|
618
|
-
(pc) =>
|
|
618
|
+
(pc) => _chunk3R3QVKY5cjs.chordToneRole.call(void 0, pc, chord) === "fifth" ? MISSING_FIFTH_PENALTY : MISSING_TONE_PENALTY
|
|
619
619
|
);
|
|
620
|
-
const rootPc =
|
|
621
|
-
const leadingTonePc = key !== void 0 &&
|
|
620
|
+
const rootPc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, chord.rootPc);
|
|
621
|
+
const leadingTonePc = key !== void 0 && _chunk3R3QVKY5cjs.isFunctioningLeadingTone.call(void 0, chord, key) ? _chunk3R3QVKY5cjs.leadingTonePcOf.call(void 0, key) : -1;
|
|
622
622
|
const doubling = new Float64Array(12);
|
|
623
623
|
for (let pc = 0; pc < 12; pc += 1) {
|
|
624
624
|
if (pc === leadingTonePc) {
|
|
625
625
|
doubling[pc] = LEADING_TONE_DOUBLING_PENALTY;
|
|
626
|
-
} else if (pc !== rootPc &&
|
|
626
|
+
} else if (pc !== rootPc && _chunk3R3QVKY5cjs.chordToneRole.call(void 0, pc, chord) !== "fifth") {
|
|
627
627
|
doubling[pc] = POOR_DOUBLING_PENALTY;
|
|
628
628
|
}
|
|
629
629
|
}
|
|
@@ -638,7 +638,7 @@ function structuralPenalty(tables, pitches, offset, voices) {
|
|
|
638
638
|
if (pitch === void 0) {
|
|
639
639
|
continue;
|
|
640
640
|
}
|
|
641
|
-
const pc =
|
|
641
|
+
const pc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, pitch);
|
|
642
642
|
PITCH_CLASS_COUNTS[pc] = (_nullishCoalesce(PITCH_CLASS_COUNTS[pc], () => ( 0))) + 1;
|
|
643
643
|
if (index > 0 && pitch === pitches[offset + index - 1]) {
|
|
644
644
|
penalty += UNISON_PENALTY;
|
|
@@ -660,13 +660,13 @@ function structuralPenalty(tables, pitches, offset, voices) {
|
|
|
660
660
|
}
|
|
661
661
|
function resolutionTables(prevChord, nextChord, key) {
|
|
662
662
|
const nextHas = new Uint8Array(12);
|
|
663
|
-
for (const pc of
|
|
663
|
+
for (const pc of _chunk3R3QVKY5cjs.chordPitchClasses.call(void 0, nextChord)) {
|
|
664
664
|
nextHas[pc] = 1;
|
|
665
665
|
}
|
|
666
666
|
return {
|
|
667
|
-
seventhPc: _nullishCoalesce(
|
|
668
|
-
leadingTonePc: key !== void 0 &&
|
|
669
|
-
tonicPc: key === void 0 ? -1 :
|
|
667
|
+
seventhPc: _nullishCoalesce(_chunk3R3QVKY5cjs.seventhPcOf.call(void 0, prevChord), () => ( -1)),
|
|
668
|
+
leadingTonePc: key !== void 0 && _chunk3R3QVKY5cjs.isFunctioningLeadingTone.call(void 0, prevChord, key) ? _chunk3R3QVKY5cjs.leadingTonePcOf.call(void 0, key) : -1,
|
|
669
|
+
tonicPc: key === void 0 ? -1 : _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, key.rootPc),
|
|
670
670
|
nextHas,
|
|
671
671
|
nextChord
|
|
672
672
|
};
|
|
@@ -680,14 +680,14 @@ function resolutionViolations(tables, spelling, prev, prevOffset, cur, curOffset
|
|
|
680
680
|
if (from === void 0 || to === void 0) {
|
|
681
681
|
continue;
|
|
682
682
|
}
|
|
683
|
-
const fromPc =
|
|
683
|
+
const fromPc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, from);
|
|
684
684
|
const motion = to - from;
|
|
685
685
|
const resolved = spelling === void 0 ? motion === -1 || motion === -2 : movesByDescendingStep(spelling.from, from, spelling.to, to);
|
|
686
686
|
if (fromPc === seventhPc && nextHas[fromPc] === 0 && !resolved) {
|
|
687
687
|
count += 1;
|
|
688
688
|
}
|
|
689
689
|
const inner = voice > 0 && voice < voices - 1;
|
|
690
|
-
if (fromPc === leadingTonePc && tonicPc >= 0 && nextHas[tonicPc] === 1 && nextHas[fromPc] === 0 && motion !== 1 && !(inner &&
|
|
690
|
+
if (fromPc === leadingTonePc && tonicPc >= 0 && nextHas[tonicPc] === 1 && nextHas[fromPc] === 0 && motion !== 1 && !(inner && _chunk3R3QVKY5cjs.isFrustratedLeadingTone.call(void 0, from, to, nextChord))) {
|
|
691
691
|
count += 1;
|
|
692
692
|
}
|
|
693
693
|
}
|
|
@@ -716,7 +716,7 @@ function createsOuterHiddenPerfect(prev, prevOffset, cur, curOffset, voices) {
|
|
|
716
716
|
if (bassPrev === void 0 || bassCur === void 0 || sopPrev === void 0 || sopCur === void 0) {
|
|
717
717
|
return false;
|
|
718
718
|
}
|
|
719
|
-
return
|
|
719
|
+
return _chunk3R3QVKY5cjs.createsHiddenParallelPerfect.call(void 0, sopPrev, sopCur, bassPrev, bassCur);
|
|
720
720
|
}
|
|
721
721
|
function augmentedMelodicCount(spelling, prev, prevOffset, cur, curOffset, voices) {
|
|
722
722
|
let count = 0;
|
|
@@ -746,7 +746,7 @@ function spellRow(table, pitches, offset, voices) {
|
|
|
746
746
|
function contradictsALetter(spelling, prev, prevOffset, cur, curOffset, voices) {
|
|
747
747
|
for (let voice = 0; voice < voices; voice += 1) {
|
|
748
748
|
const from = prev[prevOffset + voice];
|
|
749
|
-
const earlier = from === void 0 ? void 0 : spelling.from.notes[
|
|
749
|
+
const earlier = from === void 0 ? void 0 : spelling.from.notes[_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, from)];
|
|
750
750
|
if (earlier === void 0) {
|
|
751
751
|
continue;
|
|
752
752
|
}
|
|
@@ -755,8 +755,8 @@ function contradictsALetter(spelling, prev, prevOffset, cur, curOffset, voices)
|
|
|
755
755
|
continue;
|
|
756
756
|
}
|
|
757
757
|
const to = cur[curOffset + other];
|
|
758
|
-
const later = to === void 0 ? void 0 : spelling.to.notes[
|
|
759
|
-
if (later !== void 0 && earlier.alter !== later.alter &&
|
|
758
|
+
const later = to === void 0 ? void 0 : spelling.to.notes[_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, to)];
|
|
759
|
+
if (later !== void 0 && earlier.alter !== later.alter && _chunkS5BKZZGMcjs.diatonicLetterOf.call(void 0, earlier.letter) === _chunkS5BKZZGMcjs.diatonicLetterOf.call(void 0, later.letter)) {
|
|
760
760
|
return true;
|
|
761
761
|
}
|
|
762
762
|
}
|
|
@@ -785,11 +785,11 @@ function violationCount(prev, prevOffset, cur, curOffset, voices) {
|
|
|
785
785
|
if (prevLower === void 0 || prevUpper === void 0 || curLower === void 0 || curUpper === void 0) {
|
|
786
786
|
continue;
|
|
787
787
|
}
|
|
788
|
-
if (
|
|
788
|
+
if (_chunk3R3QVKY5cjs.createsParallelPerfect.call(void 0, prevUpper, curUpper, prevLower, curLower)) {
|
|
789
789
|
count += 1;
|
|
790
790
|
}
|
|
791
791
|
if (upper === lower + 1) {
|
|
792
|
-
if (
|
|
792
|
+
if (_chunk3R3QVKY5cjs.createsVoiceOverlap.call(void 0, prevUpper, curUpper, prevLower, curLower)) {
|
|
793
793
|
count += 1;
|
|
794
794
|
}
|
|
795
795
|
}
|
|
@@ -827,19 +827,19 @@ var DERIVED_LOW = 40;
|
|
|
827
827
|
var DERIVED_HIGH = 79;
|
|
828
828
|
var DERIVED_SPAN = 19;
|
|
829
829
|
function resolveRanges(opts) {
|
|
830
|
-
|
|
830
|
+
_chunkS5BKZZGMcjs.assertOptions.call(void 0, opts, "opts");
|
|
831
831
|
if (_optionalChain([opts, 'optionalAccess', _5 => _5.ranges]) !== void 0) {
|
|
832
832
|
if (opts.ranges.length === 0) {
|
|
833
|
-
throw new (0,
|
|
833
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)("ranges must contain at least one voice range");
|
|
834
834
|
}
|
|
835
|
-
|
|
835
|
+
_chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, opts.ranges.length, "voice ranges", 128);
|
|
836
836
|
return opts.ranges.map((range, index) => {
|
|
837
|
-
|
|
838
|
-
|
|
837
|
+
_chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, range.min, `ranges[${index}].min`);
|
|
838
|
+
_chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, range.max, `ranges[${index}].max`);
|
|
839
839
|
if (range.min > range.max) {
|
|
840
|
-
throw new (0,
|
|
840
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`ranges[${index}].min must not exceed max`);
|
|
841
841
|
}
|
|
842
|
-
|
|
842
|
+
_chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0,
|
|
843
843
|
Math.floor(range.max) - Math.ceil(range.min) + 1,
|
|
844
844
|
`ranges[${index}] span`,
|
|
845
845
|
4096
|
|
@@ -848,7 +848,7 @@ function resolveRanges(opts) {
|
|
|
848
848
|
});
|
|
849
849
|
}
|
|
850
850
|
const voices = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _6 => _6.voices]), () => ( 4));
|
|
851
|
-
|
|
851
|
+
_chunkS5BKZZGMcjs.assertPositiveInt.call(void 0, voices, "voices", 128);
|
|
852
852
|
if (voices === 4) {
|
|
853
853
|
return SATB_RANGES.map((range) => ({ ...range }));
|
|
854
854
|
}
|
|
@@ -866,21 +866,21 @@ function resolveRanges(opts) {
|
|
|
866
866
|
}
|
|
867
867
|
function resolveMaxSpacing(opts) {
|
|
868
868
|
const maxSpacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _7 => _7.maxSpacing]), () => ( DEFAULT_MAX_SPACING));
|
|
869
|
-
|
|
869
|
+
_chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, maxSpacing, "maxSpacing");
|
|
870
870
|
if (maxSpacing < 0) {
|
|
871
|
-
throw new (0,
|
|
871
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)("maxSpacing must be non-negative");
|
|
872
872
|
}
|
|
873
873
|
return maxSpacing;
|
|
874
874
|
}
|
|
875
875
|
function resolvedKeyOf(opts) {
|
|
876
|
-
return _optionalChain([opts, 'optionalAccess', _8 => _8.key]) === void 0 ? void 0 :
|
|
876
|
+
return _optionalChain([opts, 'optionalAccess', _8 => _8.key]) === void 0 ? void 0 : _chunk3R3QVKY5cjs.resolveKey.call(void 0, opts.key);
|
|
877
877
|
}
|
|
878
878
|
function resolvePreviousChord(opts) {
|
|
879
|
-
return _optionalChain([opts, 'optionalAccess', _9 => _9.previousChord]) === void 0 ? void 0 :
|
|
879
|
+
return _optionalChain([opts, 'optionalAccess', _9 => _9.previousChord]) === void 0 ? void 0 : _chunk3R3QVKY5cjs.toChordData.call(void 0, opts.previousChord);
|
|
880
880
|
}
|
|
881
881
|
function resolveMaxCandidates(opts) {
|
|
882
882
|
if (_optionalChain([opts, 'optionalAccess', _10 => _10.maxCandidates]) === void 0) return void 0;
|
|
883
|
-
|
|
883
|
+
_chunkS5BKZZGMcjs.assertPositiveInt.call(void 0, opts.maxCandidates, "maxCandidates", 1e6);
|
|
884
884
|
return opts.maxCandidates;
|
|
885
885
|
}
|
|
886
886
|
function centeringPenalty(ranges, pitches, offset, voices) {
|
|
@@ -896,7 +896,7 @@ function centeringPenalty(ranges, pitches, offset, voices) {
|
|
|
896
896
|
return penalty;
|
|
897
897
|
}
|
|
898
898
|
function voiceChord(chord, opts) {
|
|
899
|
-
const data =
|
|
899
|
+
const data = _chunk3R3QVKY5cjs.toChordData.call(void 0, chord);
|
|
900
900
|
const ranges = resolveRanges(opts);
|
|
901
901
|
const maxSpacing = resolveMaxSpacing(opts);
|
|
902
902
|
const candidates = enumerateVoicings(data, ranges, maxSpacing, resolveMaxCandidates(opts));
|
|
@@ -913,15 +913,15 @@ function voiceChord(chord, opts) {
|
|
|
913
913
|
}
|
|
914
914
|
}
|
|
915
915
|
if (bestOffset < 0) {
|
|
916
|
-
throw new (0,
|
|
917
|
-
`no voicing satisfies the given ranges for ${
|
|
916
|
+
throw new (0, _chunkS5BKZZGMcjs.NoSolutionError)(
|
|
917
|
+
`no voicing satisfies the given ranges for ${_chunk3R3QVKY5cjs.formatChordSymbol.call(void 0, chord)}`
|
|
918
918
|
);
|
|
919
919
|
}
|
|
920
920
|
return [...pitches.subarray(bestOffset, bestOffset + voices)];
|
|
921
921
|
}
|
|
922
922
|
function noSolutionAt(index, chord) {
|
|
923
|
-
return new (0,
|
|
924
|
-
`no voicing satisfies the given ranges for ${
|
|
923
|
+
return new (0, _chunkS5BKZZGMcjs.NoSolutionError)(
|
|
924
|
+
`no voicing satisfies the given ranges for ${_chunk3R3QVKY5cjs.formatChordSymbol.call(void 0, chord)} at index ${index}`,
|
|
925
925
|
{ at: index }
|
|
926
926
|
);
|
|
927
927
|
}
|
|
@@ -929,7 +929,7 @@ function locate(index, chord, work) {
|
|
|
929
929
|
try {
|
|
930
930
|
return work();
|
|
931
931
|
} catch (error) {
|
|
932
|
-
if (error instanceof
|
|
932
|
+
if (error instanceof _chunkS5BKZZGMcjs.NoSolutionError) {
|
|
933
933
|
throw noSolutionAt(index, chord);
|
|
934
934
|
}
|
|
935
935
|
throw error;
|
|
@@ -952,9 +952,9 @@ function successorWeight(next, cur, curOffset, voices) {
|
|
|
952
952
|
return bestWeight;
|
|
953
953
|
}
|
|
954
954
|
function voiceProgression(chords, opts) {
|
|
955
|
-
const progression =
|
|
956
|
-
|
|
957
|
-
const data = progression.map((chord) =>
|
|
955
|
+
const progression = _chunkS5BKZZGMcjs.assertArray.call(void 0, chords, "chords");
|
|
956
|
+
_chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, progression.length, "voiced progression chords", _optionalChain([opts, 'optionalAccess', _11 => _11.budget]));
|
|
957
|
+
const data = progression.map((chord) => _chunk3R3QVKY5cjs.toChordData.call(void 0, chord));
|
|
958
958
|
const key = resolvedKeyOf(opts);
|
|
959
959
|
const ranges = resolveRanges(opts);
|
|
960
960
|
const maxSpacing = resolveMaxSpacing(opts);
|
|
@@ -1017,9 +1017,9 @@ function voiceProgression(chords, opts) {
|
|
|
1017
1017
|
|
|
1018
1018
|
// src/theory/voicing/leading.ts
|
|
1019
1019
|
function assertVoicing(pitches, name) {
|
|
1020
|
-
const voices =
|
|
1020
|
+
const voices = _chunkS5BKZZGMcjs.assertArray.call(void 0, pitches, name);
|
|
1021
1021
|
for (let index = 0; index < voices.length; index += 1) {
|
|
1022
|
-
|
|
1022
|
+
_chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, _nullishCoalesce(voices[index], () => ( Number.NaN)), `${name}[${index}]`);
|
|
1023
1023
|
}
|
|
1024
1024
|
return voices;
|
|
1025
1025
|
}
|
|
@@ -1032,13 +1032,13 @@ function voiceLeadingCost(from, to) {
|
|
|
1032
1032
|
return leadingCost(previous, 0, next, 0, previous.length);
|
|
1033
1033
|
}
|
|
1034
1034
|
function nextVoicing(current, chord, opts) {
|
|
1035
|
-
|
|
1035
|
+
_chunkS5BKZZGMcjs.assertOptions.call(void 0, opts, "opts");
|
|
1036
1036
|
assertVoicing(current, "current");
|
|
1037
|
-
const data =
|
|
1037
|
+
const data = _chunk3R3QVKY5cjs.toChordData.call(void 0, chord);
|
|
1038
1038
|
const derived = _optionalChain([opts, 'optionalAccess', _12 => _12.ranges]) === void 0 && _optionalChain([opts, 'optionalAccess', _13 => _13.voices]) === void 0;
|
|
1039
1039
|
if (derived) {
|
|
1040
1040
|
if (current.length === 0) {
|
|
1041
|
-
throw new (0,
|
|
1041
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)("current must contain at least one pitch");
|
|
1042
1042
|
}
|
|
1043
1043
|
assertVoicing(current, "current");
|
|
1044
1044
|
}
|
|
@@ -1050,7 +1050,7 @@ function nextVoicing(current, chord, opts) {
|
|
|
1050
1050
|
}) : resolveRanges(opts);
|
|
1051
1051
|
assertVoicing(current, "current");
|
|
1052
1052
|
if (current.length < ranges.length) {
|
|
1053
|
-
throw new (0,
|
|
1053
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
|
|
1054
1054
|
`current has ${current.length} voices but the requested ranges require ${ranges.length}`
|
|
1055
1055
|
);
|
|
1056
1056
|
}
|
|
@@ -1074,7 +1074,7 @@ function nextVoicing(current, chord, opts) {
|
|
|
1074
1074
|
}
|
|
1075
1075
|
}
|
|
1076
1076
|
if (bestOffset < 0) {
|
|
1077
|
-
throw new (0,
|
|
1077
|
+
throw new (0, _chunkS5BKZZGMcjs.NoSolutionError)("no voicing satisfies the given ranges");
|
|
1078
1078
|
}
|
|
1079
1079
|
return [...pitches.subarray(bestOffset, bestOffset + voices)];
|
|
1080
1080
|
}
|
|
@@ -1099,7 +1099,7 @@ function dedupePcs(pcs) {
|
|
|
1099
1099
|
return result;
|
|
1100
1100
|
}
|
|
1101
1101
|
function lowestPitchAtOrAbove(pc, floor) {
|
|
1102
|
-
return floor + ((pc -
|
|
1102
|
+
return floor + ((pc - _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, floor)) % 12 + 12) % 12;
|
|
1103
1103
|
}
|
|
1104
1104
|
function nearestPc(target, pcs) {
|
|
1105
1105
|
let best = _nullishCoalesce(pcs[0], () => ( target));
|
|
@@ -1114,19 +1114,19 @@ function nearestPc(target, pcs) {
|
|
|
1114
1114
|
return best;
|
|
1115
1115
|
}
|
|
1116
1116
|
function voiceChordStyled(given, opts) {
|
|
1117
|
-
|
|
1118
|
-
const chord =
|
|
1117
|
+
_chunkS5BKZZGMcjs.assertOptions.call(void 0, opts, "opts");
|
|
1118
|
+
const chord = _chunk3R3QVKY5cjs.toChordData.call(void 0, given);
|
|
1119
1119
|
const style = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _14 => _14.style]), () => ( "close"));
|
|
1120
1120
|
const octave = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _15 => _15.octave]), () => ( DEFAULT_STYLE_OCTAVE));
|
|
1121
|
-
|
|
1121
|
+
_chunkS5BKZZGMcjs.assertInteger.call(void 0, octave, "styled voicing octave", -10, 10);
|
|
1122
1122
|
if (_optionalChain([opts, 'optionalAccess', _16 => _16.topNote]) !== void 0) {
|
|
1123
|
-
|
|
1123
|
+
_chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, opts.topNote, "styled voicing topNote");
|
|
1124
1124
|
}
|
|
1125
1125
|
const base = 12 * (octave + 1);
|
|
1126
|
-
const rootPc =
|
|
1127
|
-
const bassPc =
|
|
1126
|
+
const rootPc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, chord.rootPc);
|
|
1127
|
+
const bassPc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, _nullishCoalesce(chord.bassPc, () => ( chord.rootPc)));
|
|
1128
1128
|
const omitRoot = style === "rootless" || _optionalChain([opts, 'optionalAccess', _17 => _17.rootless]) === true;
|
|
1129
|
-
let order = dedupePcs(chord.intervals.map((interval) =>
|
|
1129
|
+
let order = dedupePcs(chord.intervals.map((interval) => _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, chord.rootPc + interval)));
|
|
1130
1130
|
const bassIndex = order.indexOf(bassPc);
|
|
1131
1131
|
const bassIsChordTone = bassIndex >= 0;
|
|
1132
1132
|
if (bassIndex > 0) {
|
|
@@ -1135,7 +1135,7 @@ function voiceChordStyled(given, opts) {
|
|
|
1135
1135
|
order = [bassPc, ...order];
|
|
1136
1136
|
}
|
|
1137
1137
|
if (style === "shell") {
|
|
1138
|
-
const roles = order.map((pc) =>
|
|
1138
|
+
const roles = order.map((pc) => _chunk3R3QVKY5cjs.chordToneRole.call(void 0, pc, chord));
|
|
1139
1139
|
const guide = roles.includes("seventh") ? "seventh" : roles.includes("sixth") ? "sixth" : "fifth";
|
|
1140
1140
|
order = order.filter((_pc, i) => {
|
|
1141
1141
|
const role = roles[i];
|
|
@@ -1149,7 +1149,7 @@ function voiceChordStyled(given, opts) {
|
|
|
1149
1149
|
return [];
|
|
1150
1150
|
}
|
|
1151
1151
|
if (_optionalChain([opts, 'optionalAccess', _18 => _18.topNote]) !== void 0) {
|
|
1152
|
-
const target = order.includes(
|
|
1152
|
+
const target = order.includes(_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, opts.topNote)) ? _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, opts.topNote) : nearestPc(_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, opts.topNote), order);
|
|
1153
1153
|
const targetIndex = order.indexOf(target);
|
|
1154
1154
|
order = [...order.slice(targetIndex + 1), ...order.slice(0, targetIndex + 1)];
|
|
1155
1155
|
}
|
|
@@ -1168,7 +1168,7 @@ function voiceChordStyled(given, opts) {
|
|
|
1168
1168
|
if (prev === void 0) {
|
|
1169
1169
|
prev = lowestPitchAtOrAbove(pc, base);
|
|
1170
1170
|
} else {
|
|
1171
|
-
let delta = ((pc -
|
|
1171
|
+
let delta = ((pc - _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, prev)) % 12 + 12) % 12;
|
|
1172
1172
|
if (delta === 0) {
|
|
1173
1173
|
delta = 12;
|
|
1174
1174
|
}
|
|
@@ -1182,7 +1182,7 @@ function voiceChordStyled(given, opts) {
|
|
|
1182
1182
|
stack[dropIndex] = (_nullishCoalesce(stack[dropIndex], () => ( 0))) - 12;
|
|
1183
1183
|
}
|
|
1184
1184
|
if (chord.bassPc !== void 0) {
|
|
1185
|
-
const bassIndexInStack = stack.findIndex((pitch) =>
|
|
1185
|
+
const bassIndexInStack = stack.findIndex((pitch) => _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, pitch) === bassPc);
|
|
1186
1186
|
if (bassIndexInStack >= 0) {
|
|
1187
1187
|
const otherLowest = Math.min(
|
|
1188
1188
|
...stack.filter((_pitch, index) => index !== bassIndexInStack),
|
|
@@ -1197,7 +1197,7 @@ function voiceChordStyled(given, opts) {
|
|
|
1197
1197
|
const lowest = _nullishCoalesce(voicing[0], () => ( 0));
|
|
1198
1198
|
const highest = _nullishCoalesce(voicing[voicing.length - 1], () => ( 0));
|
|
1199
1199
|
if (lowest < 0 || highest > 127) {
|
|
1200
|
-
throw new (0,
|
|
1200
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
|
|
1201
1201
|
`styled voicing at octave ${octave} spans MIDI ${lowest}..${highest}, outside 0..127`
|
|
1202
1202
|
);
|
|
1203
1203
|
}
|
|
@@ -1240,7 +1240,7 @@ function meanPitch(notes) {
|
|
|
1240
1240
|
if (notes.length === 0) {
|
|
1241
1241
|
return 0;
|
|
1242
1242
|
}
|
|
1243
|
-
return notes.reduce((sum, note) => sum +
|
|
1243
|
+
return notes.reduce((sum, note) => sum + _chunkS5BKZZGMcjs.noteToMidi.call(void 0, note), 0) / notes.length;
|
|
1244
1244
|
}
|
|
1245
1245
|
function impliedDurations(count, measures, ratio) {
|
|
1246
1246
|
const full = ratio * Math.max(measures - 1, 0);
|
|
@@ -1263,8 +1263,8 @@ function isPassedThrough(entries, position, species) {
|
|
|
1263
1263
|
if (previous === void 0 || current === void 0 || next === void 0) {
|
|
1264
1264
|
return false;
|
|
1265
1265
|
}
|
|
1266
|
-
const incoming =
|
|
1267
|
-
const outgoing =
|
|
1266
|
+
const incoming = _chunkS5BKZZGMcjs.spelledInterval.call(void 0, previous.note, current.note);
|
|
1267
|
+
const outgoing = _chunkS5BKZZGMcjs.spelledInterval.call(void 0, current.note, next.note);
|
|
1268
1268
|
if (!isStep(incoming) || !isStep(outgoing)) {
|
|
1269
1269
|
return false;
|
|
1270
1270
|
}
|
|
@@ -1295,9 +1295,9 @@ function isCambiata(entries, start) {
|
|
|
1295
1295
|
if (first.consonance === 2 /* Dissonance */ || third.consonance === 2 /* Dissonance */) {
|
|
1296
1296
|
return false;
|
|
1297
1297
|
}
|
|
1298
|
-
const approach =
|
|
1299
|
-
const leap =
|
|
1300
|
-
const answer =
|
|
1298
|
+
const approach = _chunkS5BKZZGMcjs.spelledInterval.call(void 0, first.note, second.note);
|
|
1299
|
+
const leap = _chunkS5BKZZGMcjs.spelledInterval.call(void 0, second.note, third.note);
|
|
1300
|
+
const answer = _chunkS5BKZZGMcjs.spelledInterval.call(void 0, third.note, fourth.note);
|
|
1301
1301
|
return isStep(approach) && direction(approach) < 0 && isThird(leap) && direction(leap) < 0 && isStep(answer) && direction(answer) > 0;
|
|
1302
1302
|
}
|
|
1303
1303
|
function isDoubleNeighbour(entries, start) {
|
|
@@ -1309,9 +1309,9 @@ function isDoubleNeighbour(entries, start) {
|
|
|
1309
1309
|
if (first.consonance === 2 /* Dissonance */ || !sameNote(first.note, fourth.note)) {
|
|
1310
1310
|
return false;
|
|
1311
1311
|
}
|
|
1312
|
-
const away =
|
|
1313
|
-
const across =
|
|
1314
|
-
const back =
|
|
1312
|
+
const away = _chunkS5BKZZGMcjs.spelledInterval.call(void 0, first.note, second.note);
|
|
1313
|
+
const across = _chunkS5BKZZGMcjs.spelledInterval.call(void 0, second.note, third.note);
|
|
1314
|
+
const back = _chunkS5BKZZGMcjs.spelledInterval.call(void 0, third.note, fourth.note);
|
|
1315
1315
|
return isStep(away) && isThird(across) && isStep(back) && direction(away) !== 0 && direction(across) === -direction(away);
|
|
1316
1316
|
}
|
|
1317
1317
|
function isFiguredDissonance(entries, position, species) {
|
|
@@ -1340,7 +1340,7 @@ function verticalViolations(entries, position, species, counterpointAbove, cross
|
|
|
1340
1340
|
const found = [];
|
|
1341
1341
|
const upper = counterpointAbove ? entry.note : entry.against;
|
|
1342
1342
|
const lower = counterpointAbove ? entry.against : entry.note;
|
|
1343
|
-
if (!crossed.has(entry.index) &&
|
|
1343
|
+
if (!crossed.has(entry.index) && _chunk3R3QVKY5cjs.createsVoiceCrossing.call(void 0, upper, lower)) {
|
|
1344
1344
|
crossed.add(entry.index);
|
|
1345
1345
|
found.push(
|
|
1346
1346
|
violation(
|
|
@@ -1393,7 +1393,7 @@ function suspensionViolations(entries, position) {
|
|
|
1393
1393
|
)
|
|
1394
1394
|
];
|
|
1395
1395
|
}
|
|
1396
|
-
const resolution = next === void 0 ? void 0 :
|
|
1396
|
+
const resolution = next === void 0 ? void 0 : _chunkS5BKZZGMcjs.spelledInterval.call(void 0, entry.note, next.note);
|
|
1397
1397
|
if (next === void 0 || resolution === void 0 || !isStep(resolution) || direction(resolution) >= 0) {
|
|
1398
1398
|
return [
|
|
1399
1399
|
violation(
|
|
@@ -1419,8 +1419,8 @@ function suspensionViolations(entries, position) {
|
|
|
1419
1419
|
return [];
|
|
1420
1420
|
}
|
|
1421
1421
|
function melodicViolations(from, to) {
|
|
1422
|
-
const interval =
|
|
1423
|
-
if (
|
|
1422
|
+
const interval = _chunkS5BKZZGMcjs.spelledInterval.call(void 0, from.note, to.note);
|
|
1423
|
+
if (_chunk3R3QVKY5cjs.isAugmentedMelodicInterval.call(void 0, from.note, to.note)) {
|
|
1424
1424
|
return [
|
|
1425
1425
|
violation(
|
|
1426
1426
|
"augmentedMelodicInterval",
|
|
@@ -1431,7 +1431,7 @@ function melodicViolations(from, to) {
|
|
|
1431
1431
|
)
|
|
1432
1432
|
];
|
|
1433
1433
|
}
|
|
1434
|
-
if (
|
|
1434
|
+
if (_chunk3R3QVKY5cjs.isForbiddenMelodicLeap.call(void 0, from.note, to.note)) {
|
|
1435
1435
|
return [
|
|
1436
1436
|
violation(
|
|
1437
1437
|
"illegalLeap",
|
|
@@ -1459,19 +1459,19 @@ function melodicMoves(entries) {
|
|
|
1459
1459
|
if (from === void 0 || to === void 0) {
|
|
1460
1460
|
continue;
|
|
1461
1461
|
}
|
|
1462
|
-
moves.push({ from, to, interval:
|
|
1462
|
+
moves.push({ from, to, interval: _chunkS5BKZZGMcjs.spelledInterval.call(void 0, from.note, to.note) });
|
|
1463
1463
|
}
|
|
1464
1464
|
return moves;
|
|
1465
1465
|
}
|
|
1466
1466
|
function climaxViolations(entries) {
|
|
1467
1467
|
const body = entries.slice(0, -1);
|
|
1468
1468
|
const peak = body.reduce(
|
|
1469
|
-
(high, entry) => Math.max(high,
|
|
1469
|
+
(high, entry) => Math.max(high, _chunkS5BKZZGMcjs.noteToMidi.call(void 0, entry.note)),
|
|
1470
1470
|
Number.NEGATIVE_INFINITY
|
|
1471
1471
|
);
|
|
1472
1472
|
const arrivals = body.filter((entry, position) => {
|
|
1473
1473
|
const previous = body[position - 1];
|
|
1474
|
-
return
|
|
1474
|
+
return _chunkS5BKZZGMcjs.noteToMidi.call(void 0, entry.note) === peak && (previous === void 0 || _chunkS5BKZZGMcjs.noteToMidi.call(void 0, previous.note) !== peak);
|
|
1475
1475
|
});
|
|
1476
1476
|
const first = arrivals[0];
|
|
1477
1477
|
const second = arrivals[1];
|
|
@@ -1565,7 +1565,7 @@ function tritoneOutlineViolations(entries) {
|
|
|
1565
1565
|
const first = run[0];
|
|
1566
1566
|
const last = run[run.length - 1];
|
|
1567
1567
|
if (first !== void 0 && last !== void 0 && run.length > 1) {
|
|
1568
|
-
const outline =
|
|
1568
|
+
const outline = _chunkS5BKZZGMcjs.spelledInterval.call(void 0, first.from.note, last.to.note);
|
|
1569
1569
|
if (Math.abs(outline.semitones) === TRITONE_SEMITONES) {
|
|
1570
1570
|
found.push(
|
|
1571
1571
|
violation(
|
|
@@ -1629,8 +1629,8 @@ function motionViolations(from, to, counterpointAbove) {
|
|
|
1629
1629
|
const upperCur = counterpointAbove ? to.note : to.against;
|
|
1630
1630
|
const lowerPrev = counterpointAbove ? from.against : from.note;
|
|
1631
1631
|
const lowerCur = counterpointAbove ? to.against : to.note;
|
|
1632
|
-
if (
|
|
1633
|
-
const fifth =
|
|
1632
|
+
if (_chunk3R3QVKY5cjs.createsParallelPerfect.call(void 0, upperPrev, upperCur, lowerPrev, lowerCur)) {
|
|
1633
|
+
const fifth = _chunk3R3QVKY5cjs.simpleIntervalNumber.call(void 0, to.interval.number) === 5;
|
|
1634
1634
|
found.push(
|
|
1635
1635
|
violation(
|
|
1636
1636
|
fifth ? "parallelFifth" : "parallelOctave",
|
|
@@ -1641,7 +1641,7 @@ function motionViolations(from, to, counterpointAbove) {
|
|
|
1641
1641
|
)
|
|
1642
1642
|
);
|
|
1643
1643
|
}
|
|
1644
|
-
if (
|
|
1644
|
+
if (_chunk3R3QVKY5cjs.createsHiddenParallelPerfect.call(void 0, upperPrev, upperCur, lowerPrev, lowerCur, "twoVoice")) {
|
|
1645
1645
|
found.push(
|
|
1646
1646
|
violation(
|
|
1647
1647
|
"hiddenPerfect",
|
|
@@ -1652,7 +1652,7 @@ function motionViolations(from, to, counterpointAbove) {
|
|
|
1652
1652
|
)
|
|
1653
1653
|
);
|
|
1654
1654
|
}
|
|
1655
|
-
if (
|
|
1655
|
+
if (_chunk3R3QVKY5cjs.createsBattuta.call(void 0, upperPrev, upperCur, lowerPrev, lowerCur)) {
|
|
1656
1656
|
found.push(
|
|
1657
1657
|
violation(
|
|
1658
1658
|
"battuta",
|
|
@@ -1681,7 +1681,7 @@ function cadenceViolations(entries, mode, counterpointAbove) {
|
|
|
1681
1681
|
if (first === void 0 || last === void 0) {
|
|
1682
1682
|
return found;
|
|
1683
1683
|
}
|
|
1684
|
-
if (
|
|
1684
|
+
if (_chunk3R3QVKY5cjs.classifySpelledInterval.call(void 0, first.interval) !== 0 /* PerfectConsonance */) {
|
|
1685
1685
|
found.push(
|
|
1686
1686
|
violation(
|
|
1687
1687
|
"missingCadence",
|
|
@@ -1692,7 +1692,7 @@ function cadenceViolations(entries, mode, counterpointAbove) {
|
|
|
1692
1692
|
)
|
|
1693
1693
|
);
|
|
1694
1694
|
}
|
|
1695
|
-
if (
|
|
1695
|
+
if (_chunkS5BKZZGMcjs.noteToPitchClass.call(void 0, last.note) !== _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, mode.rootPc)) {
|
|
1696
1696
|
found.push(
|
|
1697
1697
|
violation(
|
|
1698
1698
|
"missingCadence",
|
|
@@ -1704,7 +1704,7 @@ function cadenceViolations(entries, mode, counterpointAbove) {
|
|
|
1704
1704
|
);
|
|
1705
1705
|
}
|
|
1706
1706
|
const closing = last.interval;
|
|
1707
|
-
if (closing.quality !== "P" ||
|
|
1707
|
+
if (closing.quality !== "P" || _chunk3R3QVKY5cjs.simpleIntervalNumber.call(void 0, closing.number) !== 1) {
|
|
1708
1708
|
found.push(
|
|
1709
1709
|
violation(
|
|
1710
1710
|
"missingCadence",
|
|
@@ -1721,9 +1721,9 @@ function cadenceViolations(entries, mode, counterpointAbove) {
|
|
|
1721
1721
|
return found;
|
|
1722
1722
|
}
|
|
1723
1723
|
const arrival = _nullishCoalesce(entries.find((entry) => entry.againstIndex === last.againstIndex), () => ( last));
|
|
1724
|
-
const approach =
|
|
1724
|
+
const approach = _chunkS5BKZZGMcjs.spelledInterval.call(void 0, penultimate.note, arrival.note);
|
|
1725
1725
|
const expected = counterpointAbove ? { quality: "M", number: 6 } : { quality: "m", number: 3 };
|
|
1726
|
-
if (penultimate.interval.quality !== expected.quality ||
|
|
1726
|
+
if (penultimate.interval.quality !== expected.quality || _chunk3R3QVKY5cjs.simpleIntervalNumber.call(void 0, penultimate.interval.number) !== expected.number || !isStep(approach)) {
|
|
1727
1727
|
found.push(
|
|
1728
1728
|
violation(
|
|
1729
1729
|
"missingCadence",
|
|
@@ -1746,20 +1746,20 @@ function resolveDurations(counterpoint, measures, species, opts) {
|
|
|
1746
1746
|
}
|
|
1747
1747
|
for (const duration of given) {
|
|
1748
1748
|
const units = duration / MIN_FLORID_VALUE;
|
|
1749
|
-
if (!(duration > 0) || duration > 1 || Math.abs(units - Math.round(units)) >
|
|
1749
|
+
if (!(duration > 0) || duration > 1 || Math.abs(units - Math.round(units)) > _chunkS5BKZZGMcjs.BEAT_EPS) {
|
|
1750
1750
|
return {
|
|
1751
1751
|
problem: `A note lasts ${duration} of a measure, which this style does not write`
|
|
1752
1752
|
};
|
|
1753
1753
|
}
|
|
1754
1754
|
}
|
|
1755
1755
|
const total = given.reduce((sum, duration) => sum + duration, 0);
|
|
1756
|
-
if (Math.abs(total - measures) >
|
|
1756
|
+
if (Math.abs(total - measures) > _chunkS5BKZZGMcjs.BEAT_EPS) {
|
|
1757
1757
|
return { problem: `The counterpoint fills ${total} of the ${measures} measures` };
|
|
1758
1758
|
}
|
|
1759
1759
|
return { durations: [...given] };
|
|
1760
1760
|
}
|
|
1761
1761
|
if (species === 5) {
|
|
1762
|
-
throw new (0,
|
|
1762
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
|
|
1763
1763
|
"checkSpecies needs durations for the fifth species, whose note values are not fixed"
|
|
1764
1764
|
);
|
|
1765
1765
|
}
|
|
@@ -1781,9 +1781,9 @@ function buildEntries(cantusFirmus, counterpoint, durations, counterpointAbove)
|
|
|
1781
1781
|
if (note === void 0) {
|
|
1782
1782
|
continue;
|
|
1783
1783
|
}
|
|
1784
|
-
const struckOver = Math.min(Math.floor(onset +
|
|
1784
|
+
const struckOver = Math.min(Math.floor(onset + _chunkS5BKZZGMcjs.BEAT_EPS), cantusFirmus.length - 1);
|
|
1785
1785
|
const lastOver = Math.min(
|
|
1786
|
-
Math.max(Math.ceil(onset + duration -
|
|
1786
|
+
Math.max(Math.ceil(onset + duration - _chunkS5BKZZGMcjs.BEAT_EPS) - 1, struckOver),
|
|
1787
1787
|
cantusFirmus.length - 1
|
|
1788
1788
|
);
|
|
1789
1789
|
for (let againstIndex = struckOver; againstIndex <= lastOver; againstIndex += 1) {
|
|
@@ -1793,7 +1793,7 @@ function buildEntries(cantusFirmus, counterpoint, durations, counterpointAbove)
|
|
|
1793
1793
|
}
|
|
1794
1794
|
const held = againstIndex > struckOver;
|
|
1795
1795
|
const begins = held ? againstIndex : onset;
|
|
1796
|
-
const interval = counterpointAbove ?
|
|
1796
|
+
const interval = counterpointAbove ? _chunkS5BKZZGMcjs.spelledInterval.call(void 0, against, note) : _chunkS5BKZZGMcjs.spelledInterval.call(void 0, note, against);
|
|
1797
1797
|
entries.push({
|
|
1798
1798
|
note,
|
|
1799
1799
|
index,
|
|
@@ -1802,9 +1802,9 @@ function buildEntries(cantusFirmus, counterpoint, durations, counterpointAbove)
|
|
|
1802
1802
|
held,
|
|
1803
1803
|
against,
|
|
1804
1804
|
againstIndex,
|
|
1805
|
-
downbeat: Math.abs(begins - Math.round(begins)) <
|
|
1805
|
+
downbeat: Math.abs(begins - Math.round(begins)) < _chunkS5BKZZGMcjs.BEAT_EPS,
|
|
1806
1806
|
interval,
|
|
1807
|
-
consonance:
|
|
1807
|
+
consonance: _chunk3R3QVKY5cjs.classifySpelledInterval.call(void 0, interval)
|
|
1808
1808
|
});
|
|
1809
1809
|
}
|
|
1810
1810
|
onset += duration;
|
|
@@ -1826,17 +1826,17 @@ function motionPairs(entries) {
|
|
|
1826
1826
|
return pairs;
|
|
1827
1827
|
}
|
|
1828
1828
|
function checkSpecies(cantusFirmus, counterpoint, species, modeLike, opts) {
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
const asked =
|
|
1832
|
-
const mode =
|
|
1829
|
+
_chunkS5BKZZGMcjs.assertArray.call(void 0, cantusFirmus, "cantus firmus");
|
|
1830
|
+
_chunkS5BKZZGMcjs.assertArray.call(void 0, counterpoint, "counterpoint");
|
|
1831
|
+
const asked = _chunkS5BKZZGMcjs.assertOptions.call(void 0, opts, "opts");
|
|
1832
|
+
const mode = _chunk3R3QVKY5cjs.toKeyScale.call(void 0, modeLike);
|
|
1833
1833
|
if (!SPECIES_NUMBERS.includes(species)) {
|
|
1834
|
-
throw new (0,
|
|
1835
|
-
`species must be one of ${SPECIES_NUMBERS.join(", ")}; received ${
|
|
1834
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
|
|
1835
|
+
`species must be one of ${SPECIES_NUMBERS.join(", ")}; received ${_chunkS5BKZZGMcjs.describeRejected.call(void 0, species)}`
|
|
1836
1836
|
);
|
|
1837
1837
|
}
|
|
1838
1838
|
if (cantusFirmus.length === 0 || counterpoint.length === 0) {
|
|
1839
|
-
throw new (0,
|
|
1839
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)("checkSpecies needs both a cantus firmus and a counterpoint");
|
|
1840
1840
|
}
|
|
1841
1841
|
const resolved = resolveDurations(counterpoint, cantusFirmus.length, species, asked);
|
|
1842
1842
|
if ("problem" in resolved) {
|
|
@@ -1877,9 +1877,9 @@ function bare(note) {
|
|
|
1877
1877
|
}
|
|
1878
1878
|
function midiOf(note, index, voice) {
|
|
1879
1879
|
if (note.octave === void 0) {
|
|
1880
|
-
throw new (0,
|
|
1880
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`voicings[${index}][${voice}] must carry an octave`);
|
|
1881
1881
|
}
|
|
1882
|
-
return
|
|
1882
|
+
return _chunkS5BKZZGMcjs.noteToMidi.call(void 0, note);
|
|
1883
1883
|
}
|
|
1884
1884
|
function verticalViolations2(moment, ranges, maxSpacing) {
|
|
1885
1885
|
const found = [];
|
|
@@ -1890,7 +1890,7 @@ function verticalViolations2(moment, ranges, maxSpacing) {
|
|
|
1890
1890
|
if (upper === void 0 || lower === void 0) {
|
|
1891
1891
|
continue;
|
|
1892
1892
|
}
|
|
1893
|
-
if (
|
|
1893
|
+
if (_chunk3R3QVKY5cjs.createsVoiceCrossing.call(void 0, upper, lower)) {
|
|
1894
1894
|
found.push(
|
|
1895
1895
|
violation(
|
|
1896
1896
|
"voiceCrossing",
|
|
@@ -1901,7 +1901,7 @@ function verticalViolations2(moment, ranges, maxSpacing) {
|
|
|
1901
1901
|
)
|
|
1902
1902
|
);
|
|
1903
1903
|
}
|
|
1904
|
-
if (voice >= 2 &&
|
|
1904
|
+
if (voice >= 2 && _chunk3R3QVKY5cjs.exceedsSpacing.call(void 0, upper, lower, maxSpacing)) {
|
|
1905
1905
|
found.push(
|
|
1906
1906
|
violation(
|
|
1907
1907
|
"spacing",
|
|
@@ -1941,8 +1941,8 @@ function pairViolations(transition) {
|
|
|
1941
1941
|
if (upperPrev === void 0 || upperCur === void 0 || lowerPrev === void 0 || lowerCur === void 0) {
|
|
1942
1942
|
continue;
|
|
1943
1943
|
}
|
|
1944
|
-
if (
|
|
1945
|
-
const fifth =
|
|
1944
|
+
if (_chunk3R3QVKY5cjs.createsParallelPerfect.call(void 0, upperPrev, upperCur, lowerPrev, lowerCur)) {
|
|
1945
|
+
const fifth = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, upperCur - lowerCur) === 7;
|
|
1946
1946
|
found.push(
|
|
1947
1947
|
violation(
|
|
1948
1948
|
fifth ? "parallelFifth" : "parallelOctave",
|
|
@@ -1953,7 +1953,7 @@ function pairViolations(transition) {
|
|
|
1953
1953
|
)
|
|
1954
1954
|
);
|
|
1955
1955
|
}
|
|
1956
|
-
if (upper === lower + 1 &&
|
|
1956
|
+
if (upper === lower + 1 && _chunk3R3QVKY5cjs.createsVoiceOverlap.call(void 0, upperPrev, upperCur, lowerPrev, lowerCur)) {
|
|
1957
1957
|
found.push(
|
|
1958
1958
|
violation(
|
|
1959
1959
|
"overlap",
|
|
@@ -1970,7 +1970,7 @@ function pairViolations(transition) {
|
|
|
1970
1970
|
const bassCur = to.pitches[0];
|
|
1971
1971
|
const topPrev = from.pitches[voices - 1];
|
|
1972
1972
|
const topCur = to.pitches[voices - 1];
|
|
1973
|
-
if (voices >= 2 && bassPrev !== void 0 && bassCur !== void 0 && topPrev !== void 0 && topCur !== void 0 &&
|
|
1973
|
+
if (voices >= 2 && bassPrev !== void 0 && bassCur !== void 0 && topPrev !== void 0 && topCur !== void 0 && _chunk3R3QVKY5cjs.createsHiddenParallelPerfect.call(void 0, topPrev, topCur, bassPrev, bassCur)) {
|
|
1974
1974
|
found.push(
|
|
1975
1975
|
violation(
|
|
1976
1976
|
"hiddenPerfect",
|
|
@@ -1991,17 +1991,17 @@ function crossRelationViolations(transition) {
|
|
|
1991
1991
|
[clash.earlierVoice, clash.laterVoice],
|
|
1992
1992
|
from.index,
|
|
1993
1993
|
to.index,
|
|
1994
|
-
`${
|
|
1994
|
+
`${_chunkS5BKZZGMcjs.formatNote.call(void 0, bare(clash.earlier))} is contradicted by ${_chunkS5BKZZGMcjs.formatNote.call(void 0, bare(clash.later))} in another voice`
|
|
1995
1995
|
)
|
|
1996
1996
|
);
|
|
1997
1997
|
}
|
|
1998
1998
|
function melodicViolations2(transition) {
|
|
1999
1999
|
const found = [];
|
|
2000
2000
|
const { from, to, key } = transition;
|
|
2001
|
-
const seventhPc =
|
|
2002
|
-
const nextPcs = new Set(
|
|
2003
|
-
const leadingTonePc =
|
|
2004
|
-
const tonicPc =
|
|
2001
|
+
const seventhPc = _chunk3R3QVKY5cjs.seventhPcOf.call(void 0, from.chord);
|
|
2002
|
+
const nextPcs = new Set(_chunk3R3QVKY5cjs.chordPitchClasses.call(void 0, to.chord));
|
|
2003
|
+
const leadingTonePc = _chunk3R3QVKY5cjs.leadingTonePcOf.call(void 0, key);
|
|
2004
|
+
const tonicPc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, key.rootPc);
|
|
2005
2005
|
const voices = Math.min(from.notes.length, to.notes.length);
|
|
2006
2006
|
for (let voice = 0; voice < voices; voice += 1) {
|
|
2007
2007
|
const earlier = from.notes[voice];
|
|
@@ -2011,8 +2011,8 @@ function melodicViolations2(transition) {
|
|
|
2011
2011
|
if (earlier === void 0 || later === void 0 || earlierPitch === void 0 || laterPitch === void 0) {
|
|
2012
2012
|
continue;
|
|
2013
2013
|
}
|
|
2014
|
-
const interval =
|
|
2015
|
-
if (
|
|
2014
|
+
const interval = _chunkS5BKZZGMcjs.spelledInterval.call(void 0, earlier, later);
|
|
2015
|
+
if (_chunk3R3QVKY5cjs.isAugmentedMelodicInterval.call(void 0, earlier, later)) {
|
|
2016
2016
|
found.push(
|
|
2017
2017
|
violation(
|
|
2018
2018
|
"augmentedMelodicInterval",
|
|
@@ -2023,8 +2023,8 @@ function melodicViolations2(transition) {
|
|
|
2023
2023
|
)
|
|
2024
2024
|
);
|
|
2025
2025
|
}
|
|
2026
|
-
const earlierPc =
|
|
2027
|
-
if (earlierPc === seventhPc && !nextPcs.has(earlierPc) && !
|
|
2026
|
+
const earlierPc = _chunkS5BKZZGMcjs.noteToPitchClass.call(void 0, earlier);
|
|
2027
|
+
if (earlierPc === seventhPc && !nextPcs.has(earlierPc) && !_chunk3R3QVKY5cjs.isDescendingStep.call(void 0, interval)) {
|
|
2028
2028
|
found.push(
|
|
2029
2029
|
violation(
|
|
2030
2030
|
"unresolvedSeventh",
|
|
@@ -2036,7 +2036,7 @@ function melodicViolations2(transition) {
|
|
|
2036
2036
|
);
|
|
2037
2037
|
}
|
|
2038
2038
|
const inner = !isOuterVoice(voice, from.notes) && !isOuterVoice(voice, to.notes);
|
|
2039
|
-
if (earlierPc === leadingTonePc &&
|
|
2039
|
+
if (earlierPc === leadingTonePc && _chunk3R3QVKY5cjs.isFunctioningLeadingTone.call(void 0, from.chord, key) && nextPcs.has(tonicPc) && !nextPcs.has(earlierPc) && !_chunk3R3QVKY5cjs.isLeadingToneResolution.call(void 0, earlierPitch, laterPitch, key) && !(inner && _chunk3R3QVKY5cjs.isFrustratedLeadingTone.call(void 0, earlierPitch, laterPitch, to.chord))) {
|
|
2040
2040
|
found.push(
|
|
2041
2041
|
violation(
|
|
2042
2042
|
"unresolvedLeadingTone",
|
|
@@ -2051,18 +2051,18 @@ function melodicViolations2(transition) {
|
|
|
2051
2051
|
return found;
|
|
2052
2052
|
}
|
|
2053
2053
|
function spellVoicing(voicing, chord, key) {
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
const { tonic, scale } =
|
|
2057
|
-
return voicing.map((pitch) =>
|
|
2054
|
+
_chunkS5BKZZGMcjs.assertArray.call(void 0, voicing, "voicing");
|
|
2055
|
+
_chunk3R3QVKY5cjs.assertChord.call(void 0, chord);
|
|
2056
|
+
const { tonic, scale } = _chunk3R3QVKY5cjs.resolveKey.call(void 0, key);
|
|
2057
|
+
return voicing.map((pitch) => _chunk3R3QVKY5cjs.spellPitch.call(void 0, pitch, tonic, scale, { chord }));
|
|
2058
2058
|
}
|
|
2059
2059
|
function checkPartWriting(voicings, chords, keyLike, opts) {
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
const asked =
|
|
2063
|
-
const key =
|
|
2060
|
+
_chunkS5BKZZGMcjs.assertArray.call(void 0, voicings, "voicings");
|
|
2061
|
+
_chunkS5BKZZGMcjs.assertArray.call(void 0, chords, "chords");
|
|
2062
|
+
const asked = _chunkS5BKZZGMcjs.assertOptions.call(void 0, opts, "opts");
|
|
2063
|
+
const key = _chunk3R3QVKY5cjs.toKeyScale.call(void 0, keyLike);
|
|
2064
2064
|
if (voicings.length !== chords.length) {
|
|
2065
|
-
throw new (0,
|
|
2065
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
|
|
2066
2066
|
`checkPartWriting needs one chord per voicing; received ${voicings.length} voicings and ${chords.length} chords`
|
|
2067
2067
|
);
|
|
2068
2068
|
}
|
|
@@ -2074,7 +2074,7 @@ function checkPartWriting(voicings, chords, keyLike, opts) {
|
|
|
2074
2074
|
} else {
|
|
2075
2075
|
ranges = resolveRanges(asked);
|
|
2076
2076
|
if (ranges.length < voiceCount) {
|
|
2077
|
-
throw new (0,
|
|
2077
|
+
throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
|
|
2078
2078
|
`checkPartWriting needs one range per voice; received ${ranges.length} ranges for ${voiceCount} voices`
|
|
2079
2079
|
);
|
|
2080
2080
|
}
|
|
@@ -2135,4 +2135,4 @@ function checkPartWriting(voicings, chords, keyLike, opts) {
|
|
|
2135
2135
|
|
|
2136
2136
|
|
|
2137
2137
|
exports.TRANSPOSING_INSTRUMENTS = TRANSPOSING_INSTRUMENTS; exports.instrumentTransposition = instrumentTransposition; exports.toSoundingPitch = toSoundingPitch; exports.toWrittenPitch = toWrittenPitch; exports.figuredBassRealization = figuredBassRealization; exports.realizeFiguredBass = realizeFiguredBass; exports.figuredBassOf = figuredBassOf; exports.SATB_RANGES = SATB_RANGES; exports.voiceChord = voiceChord; exports.voiceProgression = voiceProgression; exports.voiceLeadingCost = voiceLeadingCost; exports.nextVoicing = nextVoicing; exports.voiceChordStyled = voiceChordStyled; exports.checkSpecies = checkSpecies; exports.spellVoicing = spellVoicing; exports.checkPartWriting = checkPartWriting;
|
|
2138
|
-
//# sourceMappingURL=chunk-
|
|
2138
|
+
//# sourceMappingURL=chunk-76ZBTRG2.cjs.map
|