@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.
Files changed (131) hide show
  1. package/NOTICE +63 -0
  2. package/README.md +7 -1
  3. package/README_ja.md +17 -11
  4. package/dist/analyze/index.cjs +31 -7
  5. package/dist/analyze/index.cjs.map +1 -1
  6. package/dist/analyze/index.d.cts +161 -13
  7. package/dist/analyze/index.d.ts +161 -13
  8. package/dist/analyze/index.js +37 -13
  9. package/dist/{chunk-NB25P3EH.js → chunk-2G5MCGYU.js} +33 -11
  10. package/dist/chunk-2G5MCGYU.js.map +1 -0
  11. package/dist/{chunk-NM7UAMC3.cjs → chunk-3FDBMIPR.cjs} +64 -64
  12. package/dist/chunk-3FDBMIPR.cjs.map +1 -0
  13. package/dist/{chunk-HPVSH7SF.cjs → chunk-3MDOEFIQ.cjs} +618 -954
  14. package/dist/chunk-3MDOEFIQ.cjs.map +1 -0
  15. package/dist/{chunk-FBH75DAY.js → chunk-5MWRBYAT.js} +560 -159
  16. package/dist/chunk-5MWRBYAT.js.map +1 -0
  17. package/dist/{chunk-J7FHVZII.cjs → chunk-6TTBEON3.cjs} +3074 -740
  18. package/dist/chunk-6TTBEON3.cjs.map +1 -0
  19. package/dist/{chunk-UMWZ4ZET.js → chunk-7NQ6AL3H.js} +4 -4
  20. package/dist/chunk-7NQ6AL3H.js.map +1 -0
  21. package/dist/{chunk-HWHGOVO6.cjs → chunk-E3QO3UET.cjs} +31 -23
  22. package/dist/chunk-E3QO3UET.cjs.map +1 -0
  23. package/dist/{chunk-H2KJHBW4.js → chunk-FJFULJZE.js} +2375 -191
  24. package/dist/chunk-FJFULJZE.js.map +1 -0
  25. package/dist/{chunk-Q6LFSAKV.js → chunk-FK3DGAIZ.js} +2657 -323
  26. package/dist/chunk-FK3DGAIZ.js.map +1 -0
  27. package/dist/chunk-GEDTJHAC.cjs.map +1 -1
  28. package/dist/{chunk-RFIBF2RR.js → chunk-H7FVMBUC.js} +138 -65
  29. package/dist/chunk-H7FVMBUC.js.map +1 -0
  30. package/dist/{chunk-DSMJRXCZ.cjs → chunk-HYSVSFNI.cjs} +931 -530
  31. package/dist/chunk-HYSVSFNI.cjs.map +1 -0
  32. package/dist/{chunk-35NBV2FT.cjs → chunk-KMYGRFZ6.cjs} +47 -24
  33. package/dist/chunk-KMYGRFZ6.cjs.map +1 -0
  34. package/dist/chunk-LQZQDBCD.cjs +5513 -0
  35. package/dist/chunk-LQZQDBCD.cjs.map +1 -0
  36. package/dist/{chunk-PM4XJE2Y.cjs → chunk-P3CPXAJ5.cjs} +76 -54
  37. package/dist/chunk-P3CPXAJ5.cjs.map +1 -0
  38. package/dist/{chunk-S5BKZZGM.cjs → chunk-S3QELJUE.cjs} +72 -56
  39. package/dist/chunk-S3QELJUE.cjs.map +1 -0
  40. package/dist/{chunk-PUKJP2Z5.js → chunk-TXFWSU5D.js} +31 -8
  41. package/dist/chunk-TXFWSU5D.js.map +1 -0
  42. package/dist/{chunk-76ZBTRG2.cjs → chunk-U4EQTDGN.cjs} +258 -218
  43. package/dist/chunk-U4EQTDGN.cjs.map +1 -0
  44. package/dist/chunk-UGLFDG7L.cjs.map +1 -1
  45. package/dist/{chunk-HYJJ2V2I.js → chunk-UTE5A36R.js} +483 -819
  46. package/dist/chunk-UTE5A36R.js.map +1 -0
  47. package/dist/{chunk-NFJ4P6ZZ.js → chunk-UZKQISRF.js} +17 -9
  48. package/dist/chunk-UZKQISRF.js.map +1 -0
  49. package/dist/{chunk-7KG3RTYS.js → chunk-VL5NXVCN.js} +281 -155
  50. package/dist/chunk-VL5NXVCN.js.map +1 -0
  51. package/dist/{chunk-CGBADIO5.cjs → chunk-WOMCXN2W.cjs} +328 -202
  52. package/dist/chunk-WOMCXN2W.cjs.map +1 -0
  53. package/dist/{chunk-3R3QVKY5.cjs → chunk-YDGMWH43.cjs} +397 -324
  54. package/dist/chunk-YDGMWH43.cjs.map +1 -0
  55. package/dist/{chunk-AGOVW7U6.js → chunk-YYVXRV3V.js} +72 -56
  56. package/dist/chunk-YYVXRV3V.js.map +1 -0
  57. package/dist/{chunk-M5RYMAFI.js → chunk-ZLNSH4UL.js} +71 -31
  58. package/dist/chunk-ZLNSH4UL.js.map +1 -0
  59. package/dist/{coerce-DRERzdve.d.cts → coerce-CUhHc3Tu.d.ts} +16 -8
  60. package/dist/{coerce-DP0vYu-x.d.ts → coerce-Ytt2Eiq9.d.cts} +16 -8
  61. package/dist/core/index.cjs +5 -5
  62. package/dist/core/index.cjs.map +1 -1
  63. package/dist/core/index.d.cts +9 -8
  64. package/dist/core/index.d.ts +9 -8
  65. package/dist/core/index.js +4 -4
  66. package/dist/generate/index.cjs +20 -8
  67. package/dist/generate/index.cjs.map +1 -1
  68. package/dist/generate/index.d.cts +105 -17
  69. package/dist/generate/index.d.ts +105 -17
  70. package/dist/generate/index.js +19 -7
  71. package/dist/{index-CL4b4gUQ.d.ts → index-5VJgKz_Q.d.cts} +6 -2
  72. package/dist/{index-B9QLziDe.d.cts → index-BLuDesVG.d.ts} +20 -13
  73. package/dist/{index-BHIUyjhZ.d.ts → index-BV6APVa6.d.cts} +20 -13
  74. package/dist/{index-BMweUlm5.d.cts → index-Bf0Sv8a9.d.ts} +6 -2
  75. package/dist/{index-Dw2DP7vm.d.ts → index-BkT21EMv.d.cts} +3 -2
  76. package/dist/{index-BL5N2Oyz.d.cts → index-C7KCaTRz.d.ts} +3 -2
  77. package/dist/{index-Cy15oTvh.d.ts → index-C9MYbuKS.d.cts} +7 -3
  78. package/dist/{index-Cy15oTvh.d.cts → index-C9MYbuKS.d.ts} +7 -3
  79. package/dist/{index-BNSM-DSk.d.cts → index-DVInzCDS.d.cts} +533 -28
  80. package/dist/{index-9eoQs2C1.d.ts → index-Dg-SAfhz.d.ts} +6 -4
  81. package/dist/{index-BJgP97N1.d.ts → index-jgeug9EA.d.ts} +533 -28
  82. package/dist/{index-cHvbYgJI.d.cts → index-pQihL4z7.d.cts} +6 -4
  83. package/dist/index.cjs +49 -13
  84. package/dist/index.cjs.map +1 -1
  85. package/dist/index.d.cts +13 -13
  86. package/dist/index.d.ts +13 -13
  87. package/dist/index.js +55 -19
  88. package/dist/{masks-Cc7-MzzY.d.ts → masks-BnzXnBj0.d.cts} +3 -2
  89. package/dist/{masks-pADfTOiD.d.cts → masks-tycmkrgs.d.ts} +3 -2
  90. package/dist/model/index.cjs +12 -12
  91. package/dist/model/index.cjs.map +1 -1
  92. package/dist/model/index.d.cts +259 -48
  93. package/dist/model/index.d.ts +259 -48
  94. package/dist/model/index.js +11 -11
  95. package/dist/{positional-DJgs6ltD.d.ts → positional-CscpxtlE.d.cts} +3 -2
  96. package/dist/{positional-DMZer-FM.d.cts → positional-DLnfUgqG.d.ts} +3 -2
  97. package/dist/{index-BRMbPkHE.d.ts → profile-B4WqcM4H.d.ts} +85 -610
  98. package/dist/{index-DGCNKAUr.d.cts → profile-BJd1XkPB.d.cts} +85 -610
  99. package/dist/theory/index.cjs +5 -5
  100. package/dist/theory/index.cjs.map +1 -1
  101. package/dist/theory/index.d.cts +18 -14
  102. package/dist/theory/index.d.ts +18 -14
  103. package/dist/theory/index.js +4 -4
  104. package/dist/{index-CJBBiAmU.d.ts → types-7mGFwvMm.d.ts} +1210 -31
  105. package/dist/{index-BBWNZS0f.d.cts → types-_ofpb2be.d.cts} +1210 -31
  106. package/package.json +13 -13
  107. package/dist/chunk-35NBV2FT.cjs.map +0 -1
  108. package/dist/chunk-3R3QVKY5.cjs.map +0 -1
  109. package/dist/chunk-76ZBTRG2.cjs.map +0 -1
  110. package/dist/chunk-7KG3RTYS.js.map +0 -1
  111. package/dist/chunk-AGOVW7U6.js.map +0 -1
  112. package/dist/chunk-CGBADIO5.cjs.map +0 -1
  113. package/dist/chunk-DSMJRXCZ.cjs.map +0 -1
  114. package/dist/chunk-FBH75DAY.js.map +0 -1
  115. package/dist/chunk-H2KJHBW4.js.map +0 -1
  116. package/dist/chunk-HPVSH7SF.cjs.map +0 -1
  117. package/dist/chunk-HWHGOVO6.cjs.map +0 -1
  118. package/dist/chunk-HYJJ2V2I.js.map +0 -1
  119. package/dist/chunk-J7FHVZII.cjs.map +0 -1
  120. package/dist/chunk-M5RYMAFI.js.map +0 -1
  121. package/dist/chunk-NB25P3EH.js.map +0 -1
  122. package/dist/chunk-NFJ4P6ZZ.js.map +0 -1
  123. package/dist/chunk-NM7UAMC3.cjs.map +0 -1
  124. package/dist/chunk-PM4XJE2Y.cjs.map +0 -1
  125. package/dist/chunk-PUKJP2Z5.js.map +0 -1
  126. package/dist/chunk-Q6LFSAKV.js.map +0 -1
  127. package/dist/chunk-RFIBF2RR.js.map +0 -1
  128. package/dist/chunk-S5BKZZGM.cjs.map +0 -1
  129. package/dist/chunk-SGLEQVJH.cjs +0 -3329
  130. package/dist/chunk-SGLEQVJH.cjs.map +0 -1
  131. package/dist/chunk-UMWZ4ZET.js.map +0 -1
@@ -33,8 +33,8 @@
33
33
 
34
34
 
35
35
 
36
- var _chunk3R3QVKY5cjs = require('./chunk-3R3QVKY5.cjs');
37
36
 
37
+ var _chunkYDGMWH43cjs = require('./chunk-YDGMWH43.cjs');
38
38
 
39
39
 
40
40
 
@@ -55,7 +55,9 @@ var _chunk3R3QVKY5cjs = require('./chunk-3R3QVKY5.cjs');
55
55
 
56
56
 
57
57
 
58
- var _chunkS5BKZZGMcjs = require('./chunk-S5BKZZGM.cjs');
58
+
59
+
60
+ var _chunkS3QELJUEcjs = require('./chunk-S3QELJUE.cjs');
59
61
 
60
62
  // src/theory/transposition/index.ts
61
63
  var TRANSPOSING_INSTRUMENTS = Object.freeze({
@@ -90,17 +92,17 @@ var PROFILE_NAME_ALIASES = Object.freeze({
90
92
  });
91
93
  function instrumentTransposition(instrument) {
92
94
  if (typeof instrument !== "string") {
93
- return _chunkS5BKZZGMcjs.toSpelledInterval.call(void 0, instrument);
95
+ return _chunkS3QELJUEcjs.toSpelledInterval.call(void 0, instrument);
94
96
  }
95
97
  const name = Object.hasOwn(PROFILE_NAME_ALIASES, instrument) ? PROFILE_NAME_ALIASES[instrument] : instrument;
96
98
  if (Object.hasOwn(TRANSPOSING_INSTRUMENTS, name)) {
97
- return _chunkS5BKZZGMcjs.parseInterval.call(void 0, TRANSPOSING_INSTRUMENTS[name]);
99
+ return _chunkS3QELJUEcjs.parseInterval.call(void 0, TRANSPOSING_INSTRUMENTS[name]);
98
100
  }
99
101
  try {
100
- return _chunkS5BKZZGMcjs.parseInterval.call(void 0, instrument);
102
+ return _chunkS3QELJUEcjs.parseInterval.call(void 0, instrument);
101
103
  } catch (error) {
102
- if (error instanceof _chunkS5BKZZGMcjs.InvalidInputError) {
103
- throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
104
+ if (error instanceof _chunkS3QELJUEcjs.InvalidInputError) {
105
+ throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
104
106
  `unknown transposing instrument ${JSON.stringify(instrument)}; pass a name from TRANSPOSING_INSTRUMENTS or an interval such as '-M2'`
105
107
  );
106
108
  }
@@ -117,11 +119,11 @@ function reversedInterval(step) {
117
119
  };
118
120
  }
119
121
  function toSoundingPitch(note, instrument) {
120
- return _chunkS5BKZZGMcjs.transposeByInterval.call(void 0, _chunkS5BKZZGMcjs.toNoteData.call(void 0, note), instrumentTransposition(instrument));
122
+ return _chunkS3QELJUEcjs.transposeByInterval.call(void 0, _chunkS3QELJUEcjs.toNoteData.call(void 0, note), instrumentTransposition(instrument));
121
123
  }
122
124
  function toWrittenPitch(note, instrument) {
123
- return _chunkS5BKZZGMcjs.transposeByInterval.call(void 0,
124
- _chunkS5BKZZGMcjs.toNoteData.call(void 0, note),
125
+ return _chunkS3QELJUEcjs.transposeByInterval.call(void 0,
126
+ _chunkS3QELJUEcjs.toNoteData.call(void 0, note),
125
127
  reversedInterval(instrumentTransposition(instrument))
126
128
  );
127
129
  }
@@ -146,8 +148,10 @@ var SINGLE_ACCIDENTALS = {
146
148
  n: "natural",
147
149
  "\u266E": "natural"
148
150
  };
149
- var FIGURE_SEPARATORS = /* @__PURE__ */ new Set([" ", " ", ",", "/"]);
150
- var MOTION_MARKS = /* @__PURE__ */ new Set(["-", "\u2013"]);
151
+ var FIGURE_SEPARATOR_LIST = [" ", " ", ",", "/"];
152
+ var FIGURE_SEPARATORS = new Set(FIGURE_SEPARATOR_LIST);
153
+ var MOTION_MARK_LIST = ["-", "\u2013"];
154
+ var MOTION_MARKS = new Set(MOTION_MARK_LIST);
151
155
  var PRINTED_ACCIDENTALS = [
152
156
  ["natural", "n", 0],
153
157
  ["sharp", "#", 1],
@@ -162,7 +166,7 @@ var ACCIDENTAL_GLYPHS = new Map(
162
166
  PRINTED_ACCIDENTALS.map(([, glyph, alter]) => [alter, glyph])
163
167
  );
164
168
  function invalidFigures(figures, detail) {
165
- return new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`figured bass ${_chunkS5BKZZGMcjs.describeRejected.call(void 0, figures)} ${detail}`);
169
+ return new (0, _chunkS3QELJUEcjs.InvalidInputError)(`figured bass ${_chunkS3QELJUEcjs.describeRejected.call(void 0, figures)} ${detail}`);
166
170
  }
167
171
  function alteredBy(diatonicAlter, accidental) {
168
172
  const printed = PRINTED_ALTERS.get(accidental);
@@ -203,6 +207,16 @@ function readFigure(text, start) {
203
207
  }
204
208
  return { figure: { number: 3, accidental }, index };
205
209
  }
210
+ function readStack(text, start) {
211
+ const figures = [];
212
+ let index = start;
213
+ do {
214
+ const read = readFigure(text, index);
215
+ figures.push(read.figure);
216
+ index = read.index;
217
+ } while (index < text.length && !FIGURE_SEPARATORS.has(_nullishCoalesce(text[index], () => ( ""))) && !MOTION_MARKS.has(_nullishCoalesce(text[index], () => ( ""))));
218
+ return { figures, index };
219
+ }
206
220
  function parseFigures(text) {
207
221
  const figures = [];
208
222
  const motions = [];
@@ -212,21 +226,30 @@ function parseFigures(text) {
212
226
  index += 1;
213
227
  continue;
214
228
  }
215
- const first = readFigure(text, index);
229
+ const first = readStack(text, index);
216
230
  index = first.index;
217
231
  if (!MOTION_MARKS.has(_nullishCoalesce(text[index], () => ( "")))) {
218
- figures.push(first.figure);
232
+ figures.push(...first.figures);
219
233
  continue;
220
234
  }
221
- const second = readFigure(text, index + 1);
235
+ const second = readStack(text, index + 1);
222
236
  index = second.index;
223
237
  if (MOTION_MARKS.has(_nullishCoalesce(text[index], () => ( "")))) {
224
238
  throw invalidFigures(text, "chains more than one motion onto a single figure");
225
239
  }
226
- if (first.figure.number === second.figure.number) {
227
- throw invalidFigures(text, `moves the interval ${first.figure.number} onto itself`);
240
+ if (first.figures.length !== second.figures.length) {
241
+ throw invalidFigures(
242
+ text,
243
+ `moves ${first.figures.length} run-together figures onto ${second.figures.length}`
244
+ );
228
245
  }
229
- motions.push({ from: first.figure, to: second.figure });
246
+ first.figures.forEach((from, column) => {
247
+ const to = second.figures[column];
248
+ if (from.number === to.number) {
249
+ throw invalidFigures(text, `moves the interval ${from.number} onto itself`);
250
+ }
251
+ motions.push({ from, to });
252
+ });
230
253
  }
231
254
  return { figures, motions };
232
255
  }
@@ -237,7 +260,7 @@ var SEVENTH = { intervals: [3, 5, 7], rootInterval: 1 };
237
260
  var SEVENTH_FIRST = { intervals: [3, 5, 6], rootInterval: 6 };
238
261
  var SEVENTH_SECOND = { intervals: [3, 4, 6], rootInterval: 4 };
239
262
  var SEVENTH_THIRD = { intervals: [2, 4, 6], rootInterval: 2 };
240
- var FIGURE_SETS = /* @__PURE__ */ new Map([
263
+ var FIGURE_SET_ENTRIES = [
241
264
  ["", TRIAD],
242
265
  ["3", TRIAD],
243
266
  ["5", TRIAD],
@@ -256,8 +279,9 @@ var FIGURE_SETS = /* @__PURE__ */ new Map([
256
279
  ["2", SEVENTH_THIRD],
257
280
  ["2,4", SEVENTH_THIRD],
258
281
  ["2,4,6", SEVENTH_THIRD]
259
- ]);
260
- var FIGURE_ABBREVIATIONS = /* @__PURE__ */ new Map([
282
+ ];
283
+ var FIGURE_SETS = new Map(FIGURE_SET_ENTRIES);
284
+ var FIGURE_ABBREVIATION_ENTRIES = [
261
285
  [TRIAD.intervals.join(","), []],
262
286
  [TRIAD_FIRST.intervals.join(","), [6]],
263
287
  [TRIAD_SECOND.intervals.join(","), [6, 4]],
@@ -265,13 +289,18 @@ var FIGURE_ABBREVIATIONS = /* @__PURE__ */ new Map([
265
289
  [SEVENTH_FIRST.intervals.join(","), [6, 5]],
266
290
  [SEVENTH_SECOND.intervals.join(","), [4, 3]],
267
291
  [SEVENTH_THIRD.intervals.join(","), [4, 2]]
268
- ]);
292
+ ];
293
+ var FIGURE_ABBREVIATIONS = new Map(
294
+ FIGURE_ABBREVIATION_ENTRIES
295
+ );
296
+ var TERTIAN_BASES = /* @__PURE__ */ new Set(["maj", "min", "dim", "aug"]);
269
297
  function tertianQualityIndex() {
270
298
  const index = /* @__PURE__ */ new Map();
271
- for (const quality of _chunk3R3QVKY5cjs.chordQualities.call(void 0, )) {
272
- const { intervals } = _chunk3R3QVKY5cjs.makeChord.call(void 0, 0, quality);
299
+ for (const quality of _chunkYDGMWH43cjs.chordQualities.call(void 0, )) {
300
+ const { intervals } = _chunkYDGMWH43cjs.makeChord.call(void 0, 0, quality);
273
301
  const template = intervals.join(",");
274
- if (intervals.length >= 3 && intervals.length <= MAX_STACK_SIZE && !index.has(template)) {
302
+ const spec = _chunkYDGMWH43cjs.chordSpecForQuality.call(void 0, quality, 0);
303
+ if (intervals.length >= 3 && intervals.length <= MAX_STACK_SIZE && TERTIAN_BASES.has(spec.base) && spec.additions.length === 0 && !index.has(template)) {
275
304
  index.set(template, quality);
276
305
  }
277
306
  }
@@ -279,22 +308,22 @@ function tertianQualityIndex() {
279
308
  }
280
309
  var TERTIAN_QUALITIES = tertianQualityIndex();
281
310
  function keyLetterAlters(key) {
282
- const size = _chunk3R3QVKY5cjs.scaleTonesInDegreeOrder.call(void 0, key.scale).length;
311
+ const size = _chunkYDGMWH43cjs.scaleTonesInDegreeOrder.call(void 0, key.scale).length;
283
312
  if (size !== 7) {
284
- throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`figured bass requires a heptatonic key (received ${size} tones)`);
313
+ throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(`figured bass requires a heptatonic key (received ${size} tones)`);
285
314
  }
286
315
  const 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;
316
+ for (const note of _chunkYDGMWH43cjs.spellScale.call(void 0, key.tonic, key.scale)) {
317
+ alters[_chunkS3QELJUEcjs.diatonicLetterOf.call(void 0, note.letter)] = note.alter;
289
318
  }
290
319
  return alters;
291
320
  }
292
321
  function noteAbove(bass, figure, alters) {
293
- const letter = _chunkS5BKZZGMcjs.diatonicLetterOf.call(void 0, bass.letter + figure.number - 1);
322
+ const letter = _chunkS3QELJUEcjs.diatonicLetterOf.call(void 0, bass.letter + figure.number - 1);
294
323
  return { letter, alter: alteredBy(_nullishCoalesce(alters[letter], () => ( 0)), figure.accidental) };
295
324
  }
296
325
  function bareNote(note) {
297
- return { letter: _chunkS5BKZZGMcjs.diatonicLetterOf.call(void 0, note.letter), alter: note.alter };
326
+ return { letter: _chunkS3QELJUEcjs.diatonicLetterOf.call(void 0, note.letter), alter: note.alter };
298
327
  }
299
328
  function realizeSonority(bass, resolved, text, alters) {
300
329
  const numbers = [...new Set(resolved.map((figure) => figure.number))].sort((a, b) => a - b);
@@ -308,35 +337,37 @@ function realizeSonority(bass, resolved, text, alters) {
308
337
  );
309
338
  const tones = [bass, ...notes];
310
339
  const root = _nullishCoalesce(tones[[1, ...sonority.intervals].indexOf(sonority.rootInterval)], () => ( bass));
311
- const rootPc = _chunkS5BKZZGMcjs.noteToPitchClass.call(void 0, root);
340
+ const rootPc = _chunkS3QELJUEcjs.noteToPitchClass.call(void 0, root);
312
341
  const stack = [];
313
342
  for (let step = 0; step < tones.length; step += 1) {
314
- const tone = tones.find((candidate) => _chunkS5BKZZGMcjs.diatonicLetterOf.call(void 0, candidate.letter - root.letter) === step * 2);
343
+ const tone = tones.find((candidate) => _chunkS3QELJUEcjs.diatonicLetterOf.call(void 0, candidate.letter - root.letter) === step * 2);
315
344
  if (tone === void 0) {
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`
345
+ throw new (0, _chunkS3QELJUEcjs.NoSolutionError)(
346
+ `figured bass ${_chunkS3QELJUEcjs.describeRejected.call(void 0, text)} sounds ${_chunkYDGMWH43cjs.noteNames.call(void 0, tones).join(" ")}, which does not stack in thirds`
318
347
  );
319
348
  }
320
- stack.push(_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, _chunkS5BKZZGMcjs.noteToPitchClass.call(void 0, tone) - rootPc));
349
+ stack.push(_chunkS3QELJUEcjs.pitchClassOf.call(void 0, _chunkS3QELJUEcjs.noteToPitchClass.call(void 0, tone) - rootPc));
321
350
  }
322
351
  const quality = TERTIAN_QUALITIES.get(stack.join(","));
323
352
  if (quality === void 0) {
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`
353
+ throw new (0, _chunkS3QELJUEcjs.NoSolutionError)(
354
+ `figured bass ${_chunkS3QELJUEcjs.describeRejected.call(void 0, text)} sounds ${_chunkYDGMWH43cjs.noteNames.call(void 0, tones).join(" ")}, which no chord quality names`
326
355
  );
327
356
  }
328
- const chord = _chunk3R3QVKY5cjs.makeChord.call(void 0, rootPc, quality, _chunkS5BKZZGMcjs.noteToPitchClass.call(void 0, bass));
329
- chord.rootSpelling = { letter: root.letter, alter: root.alter };
330
- chord.bassSpelling = { letter: bass.letter, alter: bass.alter };
357
+ const chord = _chunkYDGMWH43cjs.makeSpelledChord.call(void 0, rootPc, quality, {
358
+ bassPc: _chunkS3QELJUEcjs.noteToPitchClass.call(void 0, bass),
359
+ rootSpelling: { letter: root.letter, alter: root.alter },
360
+ bassSpelling: { letter: bass.letter, alter: bass.alter }
361
+ });
331
362
  return { chord, notes };
332
363
  }
333
364
  function figuredBassRealization(bass, figures, key) {
334
365
  if (typeof figures !== "string") {
335
- throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`figured bass must be a string; received ${typeof figures}`);
366
+ throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(`figured bass must be a string; received ${typeof figures}`);
336
367
  }
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);
368
+ const bassData = _chunkS3QELJUEcjs.toNoteData.call(void 0, bass);
369
+ const alters = keyLetterAlters(_chunkYDGMWH43cjs.resolveKey.call(void 0, key));
370
+ _chunkS3QELJUEcjs.noteToPitchClass.call(void 0, bassData);
340
371
  const bassNote = bareNote(bassData);
341
372
  const text = figures.trim();
342
373
  const { figures: written, motions } = parseFigures(text);
@@ -357,37 +388,37 @@ function realizeFiguredBass(bass, figures, key) {
357
388
  return figuredBassRealization(bass, figures, key).chord;
358
389
  }
359
390
  function figuredBassOf(chord, key) {
360
- const data = _chunk3R3QVKY5cjs.toChordData.call(void 0, chord);
361
- const resolved = _chunk3R3QVKY5cjs.resolveKey.call(void 0, key);
391
+ const data = _chunkYDGMWH43cjs.toChordData.call(void 0, chord);
392
+ const resolved = _chunkYDGMWH43cjs.resolveKey.call(void 0, key);
362
393
  const alters = keyLetterAlters(resolved);
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);
394
+ const tones = _chunkYDGMWH43cjs.spellChord.call(void 0, data, resolved.tonic, resolved.scale);
395
+ const bassPc = _chunkS3QELJUEcjs.pitchClassOf.call(void 0, _nullishCoalesce(data.bassPc, () => ( data.rootPc)));
396
+ const bass = tones.find((tone) => _chunkS3QELJUEcjs.noteToPitchClass.call(void 0, tone) === bassPc);
366
397
  if (bass === void 0) {
367
- throw new (0, _chunkS5BKZZGMcjs.NoSolutionError)(
398
+ throw new (0, _chunkS3QELJUEcjs.NoSolutionError)(
368
399
  "figured bass measures intervals above a chord tone, and this chord's bass is not one of its tones"
369
400
  );
370
401
  }
371
402
  const written = /* @__PURE__ */ new Map();
372
403
  for (const tone of tones) {
373
404
  if (tone !== bass) {
374
- written.set(_chunkS5BKZZGMcjs.diatonicLetterOf.call(void 0, tone.letter - bass.letter) + 1, tone);
405
+ written.set(_chunkS3QELJUEcjs.diatonicLetterOf.call(void 0, tone.letter - bass.letter) + 1, tone);
375
406
  }
376
407
  }
377
408
  const digits = FIGURE_ABBREVIATIONS.get([...written.keys()].sort((a, b) => a - b).join(","));
378
409
  if (digits === void 0) {
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]}`
410
+ throw new (0, _chunkS3QELJUEcjs.NoSolutionError)(
411
+ `no figured bass names ${_chunkYDGMWH43cjs.noteNames.call(void 0, tones).join(" ")} over ${_chunkYDGMWH43cjs.noteNames.call(void 0, [bass])[0]}`
381
412
  );
382
413
  }
383
414
  const accidentals = /* @__PURE__ */ new Map();
384
415
  for (const [number, tone] of written) {
385
- if (tone.alter === (_nullishCoalesce(alters[_chunkS5BKZZGMcjs.diatonicLetterOf.call(void 0, tone.letter)], () => ( 0)))) {
416
+ if (tone.alter === (_nullishCoalesce(alters[_chunkS3QELJUEcjs.diatonicLetterOf.call(void 0, tone.letter)], () => ( 0)))) {
386
417
  continue;
387
418
  }
388
419
  const glyph = ACCIDENTAL_GLYPHS.get(tone.alter);
389
420
  if (glyph === void 0) {
390
- throw new (0, _chunkS5BKZZGMcjs.NoSolutionError)(`no accidental writes a note altered by ${tone.alter} semitones`);
421
+ throw new (0, _chunkS3QELJUEcjs.NoSolutionError)(`no accidental writes a note altered by ${tone.alter} semitones`);
391
422
  }
392
423
  accidentals.set(number, glyph);
393
424
  }
@@ -396,48 +427,48 @@ function figuredBassOf(chord, key) {
396
427
  return figures;
397
428
  }
398
429
  function pitchClassesOf(notes) {
399
- return [...new Set(notes.map(_chunkS5BKZZGMcjs.noteToPitchClass))].sort((a, b) => a - b);
430
+ return [...new Set(notes.map(_chunkS3QELJUEcjs.noteToPitchClass))].sort((a, b) => a - b);
400
431
  }
401
432
  function assertRealizesAs(bass, figures, key, tones) {
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}`
433
+ const noFigures = (detail) => new (0, _chunkS3QELJUEcjs.NoSolutionError)(
434
+ `no figured bass names ${_chunkYDGMWH43cjs.noteNames.call(void 0, tones).join(" ")} over ${_chunkYDGMWH43cjs.noteNames.call(void 0, [bass])[0]}: the figures ${_chunkS3QELJUEcjs.describeRejected.call(void 0, figures)} ${detail}`
404
435
  );
405
436
  let realized;
406
437
  try {
407
438
  realized = figuredBassRealization(bass, figures, key);
408
439
  } catch (error) {
409
- throw error instanceof _chunkS5BKZZGMcjs.NoSolutionError ? noFigures("read back as no chord at all") : error;
440
+ throw error instanceof _chunkS3QELJUEcjs.NoSolutionError ? noFigures("read back as no chord at all") : error;
410
441
  }
411
442
  const written = pitchClassesOf(realized.notes);
412
443
  const expected = pitchClassesOf(tones);
413
444
  if (written.length !== expected.length || written.some((pc, index) => pc !== expected[index])) {
414
- throw noFigures(`sound ${_chunk3R3QVKY5cjs.noteNames.call(void 0, realized.notes).join(" ")} instead`);
445
+ throw noFigures(`sound ${_chunkYDGMWH43cjs.noteNames.call(void 0, realized.notes).join(" ")} instead`);
415
446
  }
416
447
  }
417
448
 
418
449
  // src/theory/partwriting/cross-relation.ts
419
- function resolvesAsAppliedDominant(chord, next, key) {
420
- if (next === void 0 || !_chunk3R3QVKY5cjs.hasDominantSonority.call(void 0, chord)) {
450
+ function resolvesAsAppliedChord(chord, next, key) {
451
+ if (next === void 0) {
421
452
  return false;
422
453
  }
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;
454
+ const target = _chunkYDGMWH43cjs.appliedChordTarget.call(void 0, chord, key);
455
+ return target !== null && _chunkS3QELJUEcjs.pitchClassOf.call(void 0, next.rootPc) === target.rootPc;
425
456
  }
426
457
  function soundsAugmentedSixth(moment, key) {
427
458
  const bass = moment.notes[0];
428
- if (bass === void 0 || _chunkS5BKZZGMcjs.noteToPitchClass.call(void 0, bass) !== _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, key.rootPc + 8)) {
459
+ if (bass === void 0 || _chunkS3QELJUEcjs.noteToPitchClass.call(void 0, bass) !== _chunkS3QELJUEcjs.pitchClassOf.call(void 0, key.rootPc + 8)) {
429
460
  return false;
430
461
  }
431
462
  return moment.notes.some((note, voice) => {
432
463
  if (voice === 0) {
433
464
  return false;
434
465
  }
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;
466
+ const interval = _chunkS3QELJUEcjs.spelledInterval.call(void 0, bass, note);
467
+ return (interval.number - 1) % 7 + 1 === 6 && _chunkS3QELJUEcjs.pitchClassOf.call(void 0, interval.semitones) === 10;
437
468
  });
438
469
  }
439
470
  function isChromaticHarmony(moment, next, key) {
440
- return resolvesAsAppliedDominant(moment.chord, next, key) || _chunk3R3QVKY5cjs.isNeapolitanChordOf.call(void 0, moment.chord, key) || soundsAugmentedSixth(moment, key);
471
+ return resolvesAsAppliedChord(moment.chord, next, key) || _chunkYDGMWH43cjs.isNeapolitanChordOf.call(void 0, moment.chord, key) || soundsAugmentedSixth(moment, key);
441
472
  }
442
473
  function approachedByStep(before, moment, voice) {
443
474
  const earlier = _optionalChain([before, 'optionalAccess', _2 => _2[voice]]);
@@ -445,7 +476,8 @@ function approachedByStep(before, moment, voice) {
445
476
  if (earlier === void 0 || later === void 0) {
446
477
  return false;
447
478
  }
448
- return _chunkS5BKZZGMcjs.spelledInterval.call(void 0, earlier, later).number === 2;
479
+ const interval = _chunkS3QELJUEcjs.spelledInterval.call(void 0, earlier, later);
480
+ return interval.number === 2 || interval.number === 1 && Math.abs(interval.semitones) === 1;
449
481
  }
450
482
  function isOuterVoice(voice, notes) {
451
483
  return voice === 0 || voice === notes.length - 1;
@@ -467,8 +499,8 @@ function crossRelations(from, to, key, context = {}) {
467
499
  if (earlier === void 0 || later === void 0) {
468
500
  continue;
469
501
  }
470
- const letter = _chunkS5BKZZGMcjs.diatonicLetterOf.call(void 0, earlier.letter);
471
- if (letter !== _chunkS5BKZZGMcjs.diatonicLetterOf.call(void 0, later.letter) || earlier.alter === later.alter) {
502
+ const letter = _chunkS3QELJUEcjs.diatonicLetterOf.call(void 0, earlier.letter);
503
+ if (letter !== _chunkS3QELJUEcjs.diatonicLetterOf.call(void 0, later.letter) || earlier.alter === later.alter) {
472
504
  continue;
473
505
  }
474
506
  if (approachedByStep(context.before, from.notes, first) || approachedByStep(from.notes, to.notes, second) || !isOuterVoice(first, from.notes) && !isOuterVoice(second, to.notes)) {
@@ -487,18 +519,18 @@ function crossRelations(from, to, key, context = {}) {
487
519
 
488
520
  // src/theory/voicing/tendency.ts
489
521
  function spellingTable(keyLike, chord) {
490
- const { tonic, scale: key } = _chunk3R3QVKY5cjs.resolveKey.call(void 0, keyLike);
522
+ const { tonic, scale: key } = _chunkYDGMWH43cjs.resolveKey.call(void 0, keyLike);
491
523
  const notes = [];
492
524
  const bases = [];
493
525
  for (let pc = 0; pc < 12; pc += 1) {
494
- const note = chord === void 0 ? _chunk3R3QVKY5cjs.spellPitchClass.call(void 0, pc, tonic, key) : _chunk3R3QVKY5cjs.spellPitchClass.call(void 0, pc, tonic, key, { chord });
526
+ const note = chord === void 0 ? _chunkYDGMWH43cjs.spellPitchClass.call(void 0, pc, tonic, key) : _chunkYDGMWH43cjs.spellPitchClass.call(void 0, pc, tonic, key, { chord });
495
527
  notes.push(note);
496
- bases.push(_chunkS5BKZZGMcjs.noteToMidi.call(void 0, { letter: note.letter, alter: note.alter, octave: 0 }));
528
+ bases.push(_chunkS3QELJUEcjs.noteToMidi.call(void 0, { letter: note.letter, alter: note.alter, octave: 0 }));
497
529
  }
498
530
  return { notes, bases };
499
531
  }
500
532
  function spelledAt(table, pitch) {
501
- const pc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, pitch);
533
+ const pc = _chunkS3QELJUEcjs.pitchClassOf.call(void 0, pitch);
502
534
  const note = table.notes[pc];
503
535
  const base = table.bases[pc];
504
536
  if (note === void 0 || base === void 0) {
@@ -512,7 +544,7 @@ function movesByAugmentedInterval(from, fromPitch, to, toPitch) {
512
544
  if (earlier === void 0 || later === void 0) {
513
545
  return false;
514
546
  }
515
- return _chunk3R3QVKY5cjs.isAugmentedMelodicInterval.call(void 0, earlier, later);
547
+ return _chunkYDGMWH43cjs.isAugmentedMelodicInterval.call(void 0, earlier, later);
516
548
  }
517
549
  function movesByDescendingStep(from, fromPitch, to, toPitch) {
518
550
  const earlier = spelledAt(from, fromPitch);
@@ -520,7 +552,7 @@ function movesByDescendingStep(from, fromPitch, to, toPitch) {
520
552
  if (earlier === void 0 || later === void 0) {
521
553
  return false;
522
554
  }
523
- return _chunk3R3QVKY5cjs.isDescendingStep.call(void 0, _chunkS5BKZZGMcjs.spelledInterval.call(void 0, earlier, later));
555
+ return _chunkYDGMWH43cjs.isDescendingStep.call(void 0, _chunkS3QELJUEcjs.spelledInterval.call(void 0, earlier, later));
524
556
  }
525
557
 
526
558
  // src/theory/voicing/internal.ts
@@ -545,7 +577,7 @@ function createCandidateBuffer() {
545
577
  function pitchesForPc(pc, range) {
546
578
  const result = [];
547
579
  for (let midi = Math.ceil(range.min); midi <= range.max; midi += 1) {
548
- if (_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, midi) === pc) {
580
+ if (_chunkS3QELJUEcjs.pitchClassOf.call(void 0, midi) === pc) {
549
581
  result.push(midi);
550
582
  }
551
583
  }
@@ -557,14 +589,14 @@ function pitchesForPc(pc, range) {
557
589
  });
558
590
  }
559
591
  function enumerateVoicings(chord, ranges, maxSpacing, maxCandidates = DEFAULT_MAX_CANDIDATES, into = createCandidateBuffer()) {
560
- const chordPcs = _chunk3R3QVKY5cjs.chordPitchClasses.call(void 0, chord);
561
- const bassPc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, _nullishCoalesce(chord.bassPc, () => ( chord.rootPc)));
592
+ const chordPcs = _chunkYDGMWH43cjs.chordPitchClasses.call(void 0, chord);
593
+ const bassPc = _chunkS3QELJUEcjs.pitchClassOf.call(void 0, _nullishCoalesce(chord.bassPc, () => ( chord.rootPc)));
562
594
  const byVoice = ranges.map(
563
595
  (range, voice) => (voice === 0 ? [bassPc] : chordPcs).flatMap((pc) => pitchesForPc(pc, range))
564
596
  );
565
597
  for (let voice = 0; voice < byVoice.length; voice += 1) {
566
598
  if ((_nullishCoalesce(byVoice[voice], () => ( []))).length === 0) {
567
- throw new (0, _chunkS5BKZZGMcjs.NoSolutionError)("no voicing satisfies the given ranges");
599
+ throw new (0, _chunkS3QELJUEcjs.NoSolutionError)("no voicing satisfies the given ranges");
568
600
  }
569
601
  }
570
602
  const voices = ranges.length;
@@ -613,17 +645,17 @@ function enumerateVoicings(chord, ranges, maxSpacing, maxCandidates = DEFAULT_MA
613
645
  return into;
614
646
  }
615
647
  function structuralTables(chord, key) {
616
- const tones = _chunk3R3QVKY5cjs.chordPitchClasses.call(void 0, chord);
648
+ const tones = _chunkYDGMWH43cjs.chordPitchClasses.call(void 0, chord);
617
649
  const missing = tones.map(
618
- (pc) => _chunk3R3QVKY5cjs.chordToneRole.call(void 0, pc, chord) === "fifth" ? MISSING_FIFTH_PENALTY : MISSING_TONE_PENALTY
650
+ (pc) => _chunkYDGMWH43cjs.chordToneRole.call(void 0, pc, chord) === "fifth" ? MISSING_FIFTH_PENALTY : MISSING_TONE_PENALTY
619
651
  );
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;
652
+ const rootPc = _chunkS3QELJUEcjs.pitchClassOf.call(void 0, chord.rootPc);
653
+ const leadingTonePc = key !== void 0 && _chunkYDGMWH43cjs.isFunctioningLeadingTone.call(void 0, chord, key) ? _chunkYDGMWH43cjs.leadingTonePcOf.call(void 0, key) : -1;
622
654
  const doubling = new Float64Array(12);
623
655
  for (let pc = 0; pc < 12; pc += 1) {
624
656
  if (pc === leadingTonePc) {
625
657
  doubling[pc] = LEADING_TONE_DOUBLING_PENALTY;
626
- } else if (pc !== rootPc && _chunk3R3QVKY5cjs.chordToneRole.call(void 0, pc, chord) !== "fifth") {
658
+ } else if (pc !== rootPc && _chunkYDGMWH43cjs.chordToneRole.call(void 0, pc, chord) !== "fifth") {
627
659
  doubling[pc] = POOR_DOUBLING_PENALTY;
628
660
  }
629
661
  }
@@ -638,7 +670,7 @@ function structuralPenalty(tables, pitches, offset, voices) {
638
670
  if (pitch === void 0) {
639
671
  continue;
640
672
  }
641
- const pc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, pitch);
673
+ const pc = _chunkS3QELJUEcjs.pitchClassOf.call(void 0, pitch);
642
674
  PITCH_CLASS_COUNTS[pc] = (_nullishCoalesce(PITCH_CLASS_COUNTS[pc], () => ( 0))) + 1;
643
675
  if (index > 0 && pitch === pitches[offset + index - 1]) {
644
676
  penalty += UNISON_PENALTY;
@@ -660,13 +692,13 @@ function structuralPenalty(tables, pitches, offset, voices) {
660
692
  }
661
693
  function resolutionTables(prevChord, nextChord, key) {
662
694
  const nextHas = new Uint8Array(12);
663
- for (const pc of _chunk3R3QVKY5cjs.chordPitchClasses.call(void 0, nextChord)) {
695
+ for (const pc of _chunkYDGMWH43cjs.chordPitchClasses.call(void 0, nextChord)) {
664
696
  nextHas[pc] = 1;
665
697
  }
666
698
  return {
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),
699
+ seventhPc: _nullishCoalesce(_chunkYDGMWH43cjs.seventhPcOf.call(void 0, prevChord), () => ( -1)),
700
+ leadingTonePc: key !== void 0 && _chunkYDGMWH43cjs.isFunctioningLeadingTone.call(void 0, prevChord, key) ? _chunkYDGMWH43cjs.leadingTonePcOf.call(void 0, key) : -1,
701
+ tonicPc: key === void 0 ? -1 : _chunkS3QELJUEcjs.pitchClassOf.call(void 0, key.rootPc),
670
702
  nextHas,
671
703
  nextChord
672
704
  };
@@ -680,14 +712,14 @@ function resolutionViolations(tables, spelling, prev, prevOffset, cur, curOffset
680
712
  if (from === void 0 || to === void 0) {
681
713
  continue;
682
714
  }
683
- const fromPc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, from);
715
+ const fromPc = _chunkS3QELJUEcjs.pitchClassOf.call(void 0, from);
684
716
  const motion = to - from;
685
717
  const resolved = spelling === void 0 ? motion === -1 || motion === -2 : movesByDescendingStep(spelling.from, from, spelling.to, to);
686
718
  if (fromPc === seventhPc && nextHas[fromPc] === 0 && !resolved) {
687
719
  count += 1;
688
720
  }
689
721
  const inner = voice > 0 && voice < voices - 1;
690
- if (fromPc === leadingTonePc && tonicPc >= 0 && nextHas[tonicPc] === 1 && nextHas[fromPc] === 0 && motion !== 1 && !(inner && _chunk3R3QVKY5cjs.isFrustratedLeadingTone.call(void 0, from, to, nextChord))) {
722
+ if (fromPc === leadingTonePc && tonicPc >= 0 && nextHas[tonicPc] === 1 && nextHas[fromPc] === 0 && motion !== 1 && !(inner && _chunkYDGMWH43cjs.isFrustratedLeadingTone.call(void 0, from, to, nextChord))) {
691
723
  count += 1;
692
724
  }
693
725
  }
@@ -716,7 +748,7 @@ function createsOuterHiddenPerfect(prev, prevOffset, cur, curOffset, voices) {
716
748
  if (bassPrev === void 0 || bassCur === void 0 || sopPrev === void 0 || sopCur === void 0) {
717
749
  return false;
718
750
  }
719
- return _chunk3R3QVKY5cjs.createsHiddenParallelPerfect.call(void 0, sopPrev, sopCur, bassPrev, bassCur);
751
+ return _chunkYDGMWH43cjs.createsHiddenParallelPerfect.call(void 0, sopPrev, sopCur, bassPrev, bassCur);
720
752
  }
721
753
  function augmentedMelodicCount(spelling, prev, prevOffset, cur, curOffset, voices) {
722
754
  let count = 0;
@@ -746,7 +778,7 @@ function spellRow(table, pitches, offset, voices) {
746
778
  function contradictsALetter(spelling, prev, prevOffset, cur, curOffset, voices) {
747
779
  for (let voice = 0; voice < voices; voice += 1) {
748
780
  const from = prev[prevOffset + voice];
749
- const earlier = from === void 0 ? void 0 : spelling.from.notes[_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, from)];
781
+ const earlier = from === void 0 ? void 0 : spelling.from.notes[_chunkS3QELJUEcjs.pitchClassOf.call(void 0, from)];
750
782
  if (earlier === void 0) {
751
783
  continue;
752
784
  }
@@ -755,8 +787,8 @@ function contradictsALetter(spelling, prev, prevOffset, cur, curOffset, voices)
755
787
  continue;
756
788
  }
757
789
  const to = cur[curOffset + other];
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)) {
790
+ const later = to === void 0 ? void 0 : spelling.to.notes[_chunkS3QELJUEcjs.pitchClassOf.call(void 0, to)];
791
+ if (later !== void 0 && earlier.alter !== later.alter && _chunkS3QELJUEcjs.diatonicLetterOf.call(void 0, earlier.letter) === _chunkS3QELJUEcjs.diatonicLetterOf.call(void 0, later.letter)) {
760
792
  return true;
761
793
  }
762
794
  }
@@ -785,11 +817,11 @@ function violationCount(prev, prevOffset, cur, curOffset, voices) {
785
817
  if (prevLower === void 0 || prevUpper === void 0 || curLower === void 0 || curUpper === void 0) {
786
818
  continue;
787
819
  }
788
- if (_chunk3R3QVKY5cjs.createsParallelPerfect.call(void 0, prevUpper, curUpper, prevLower, curLower)) {
820
+ if (_chunkYDGMWH43cjs.createsParallelPerfect.call(void 0, prevUpper, curUpper, prevLower, curLower)) {
789
821
  count += 1;
790
822
  }
791
823
  if (upper === lower + 1) {
792
- if (_chunk3R3QVKY5cjs.createsVoiceOverlap.call(void 0, prevUpper, curUpper, prevLower, curLower)) {
824
+ if (_chunkYDGMWH43cjs.createsVoiceOverlap.call(void 0, prevUpper, curUpper, prevLower, curLower)) {
793
825
  count += 1;
794
826
  }
795
827
  }
@@ -827,19 +859,19 @@ var DERIVED_LOW = 40;
827
859
  var DERIVED_HIGH = 79;
828
860
  var DERIVED_SPAN = 19;
829
861
  function resolveRanges(opts) {
830
- _chunkS5BKZZGMcjs.assertOptions.call(void 0, opts, "opts");
862
+ _chunkS3QELJUEcjs.assertOptions.call(void 0, opts, "opts");
831
863
  if (_optionalChain([opts, 'optionalAccess', _5 => _5.ranges]) !== void 0) {
832
864
  if (opts.ranges.length === 0) {
833
- throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)("ranges must contain at least one voice range");
865
+ throw new (0, _chunkS3QELJUEcjs.InvalidInputError)("ranges must contain at least one voice range");
834
866
  }
835
- _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, opts.ranges.length, "voice ranges", 128);
867
+ _chunkS3QELJUEcjs.assertGenerationBudget.call(void 0, opts.ranges.length, "voice ranges", 128);
836
868
  return opts.ranges.map((range, index) => {
837
- _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, range.min, `ranges[${index}].min`);
838
- _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, range.max, `ranges[${index}].max`);
869
+ _chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, range.min, `ranges[${index}].min`);
870
+ _chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, range.max, `ranges[${index}].max`);
839
871
  if (range.min > range.max) {
840
- throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`ranges[${index}].min must not exceed max`);
872
+ throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(`ranges[${index}].min must not exceed max`);
841
873
  }
842
- _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0,
874
+ _chunkS3QELJUEcjs.assertGenerationBudget.call(void 0,
843
875
  Math.floor(range.max) - Math.ceil(range.min) + 1,
844
876
  `ranges[${index}] span`,
845
877
  4096
@@ -848,7 +880,7 @@ function resolveRanges(opts) {
848
880
  });
849
881
  }
850
882
  const voices = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _6 => _6.voices]), () => ( 4));
851
- _chunkS5BKZZGMcjs.assertPositiveInt.call(void 0, voices, "voices", 128);
883
+ _chunkS3QELJUEcjs.assertPositiveInt.call(void 0, voices, "voices", 128);
852
884
  if (voices === 4) {
853
885
  return SATB_RANGES.map((range) => ({ ...range }));
854
886
  }
@@ -866,21 +898,21 @@ function resolveRanges(opts) {
866
898
  }
867
899
  function resolveMaxSpacing(opts) {
868
900
  const maxSpacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _7 => _7.maxSpacing]), () => ( DEFAULT_MAX_SPACING));
869
- _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, maxSpacing, "maxSpacing");
901
+ _chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, maxSpacing, "maxSpacing");
870
902
  if (maxSpacing < 0) {
871
- throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)("maxSpacing must be non-negative");
903
+ throw new (0, _chunkS3QELJUEcjs.InvalidInputError)("maxSpacing must be non-negative");
872
904
  }
873
905
  return maxSpacing;
874
906
  }
875
907
  function resolvedKeyOf(opts) {
876
- return _optionalChain([opts, 'optionalAccess', _8 => _8.key]) === void 0 ? void 0 : _chunk3R3QVKY5cjs.resolveKey.call(void 0, opts.key);
908
+ return _optionalChain([opts, 'optionalAccess', _8 => _8.key]) === void 0 ? void 0 : _chunkYDGMWH43cjs.resolveKey.call(void 0, opts.key);
877
909
  }
878
910
  function resolvePreviousChord(opts) {
879
- return _optionalChain([opts, 'optionalAccess', _9 => _9.previousChord]) === void 0 ? void 0 : _chunk3R3QVKY5cjs.toChordData.call(void 0, opts.previousChord);
911
+ return _optionalChain([opts, 'optionalAccess', _9 => _9.previousChord]) === void 0 ? void 0 : _chunkYDGMWH43cjs.toChordData.call(void 0, opts.previousChord);
880
912
  }
881
913
  function resolveMaxCandidates(opts) {
882
914
  if (_optionalChain([opts, 'optionalAccess', _10 => _10.maxCandidates]) === void 0) return void 0;
883
- _chunkS5BKZZGMcjs.assertPositiveInt.call(void 0, opts.maxCandidates, "maxCandidates", 1e6);
915
+ _chunkS3QELJUEcjs.assertPositiveInt.call(void 0, opts.maxCandidates, "maxCandidates", 1e6);
884
916
  return opts.maxCandidates;
885
917
  }
886
918
  function centeringPenalty(ranges, pitches, offset, voices) {
@@ -896,7 +928,7 @@ function centeringPenalty(ranges, pitches, offset, voices) {
896
928
  return penalty;
897
929
  }
898
930
  function voiceChord(chord, opts) {
899
- const data = _chunk3R3QVKY5cjs.toChordData.call(void 0, chord);
931
+ const data = _chunkYDGMWH43cjs.toChordData.call(void 0, chord);
900
932
  const ranges = resolveRanges(opts);
901
933
  const maxSpacing = resolveMaxSpacing(opts);
902
934
  const candidates = enumerateVoicings(data, ranges, maxSpacing, resolveMaxCandidates(opts));
@@ -913,15 +945,15 @@ function voiceChord(chord, opts) {
913
945
  }
914
946
  }
915
947
  if (bestOffset < 0) {
916
- throw new (0, _chunkS5BKZZGMcjs.NoSolutionError)(
917
- `no voicing satisfies the given ranges for ${_chunk3R3QVKY5cjs.formatChordSymbol.call(void 0, chord)}`
948
+ throw new (0, _chunkS3QELJUEcjs.NoSolutionError)(
949
+ `no voicing satisfies the given ranges for ${_chunkYDGMWH43cjs.formatChordSymbol.call(void 0, chord)}`
918
950
  );
919
951
  }
920
952
  return [...pitches.subarray(bestOffset, bestOffset + voices)];
921
953
  }
922
954
  function noSolutionAt(index, chord) {
923
- return new (0, _chunkS5BKZZGMcjs.NoSolutionError)(
924
- `no voicing satisfies the given ranges for ${_chunk3R3QVKY5cjs.formatChordSymbol.call(void 0, chord)} at index ${index}`,
955
+ return new (0, _chunkS3QELJUEcjs.NoSolutionError)(
956
+ `no voicing satisfies the given ranges for ${_chunkYDGMWH43cjs.formatChordSymbol.call(void 0, chord)} at index ${index}`,
925
957
  { at: index }
926
958
  );
927
959
  }
@@ -929,7 +961,7 @@ function locate(index, chord, work) {
929
961
  try {
930
962
  return work();
931
963
  } catch (error) {
932
- if (error instanceof _chunkS5BKZZGMcjs.NoSolutionError) {
964
+ if (error instanceof _chunkS3QELJUEcjs.NoSolutionError) {
933
965
  throw noSolutionAt(index, chord);
934
966
  }
935
967
  throw error;
@@ -952,9 +984,9 @@ function successorWeight(next, cur, curOffset, voices) {
952
984
  return bestWeight;
953
985
  }
954
986
  function voiceProgression(chords, opts) {
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));
987
+ const progression = _chunkS3QELJUEcjs.assertArray.call(void 0, chords, "chords");
988
+ _chunkS3QELJUEcjs.assertGenerationBudget.call(void 0, progression.length, "voiced progression chords", _optionalChain([opts, 'optionalAccess', _11 => _11.budget]));
989
+ const data = progression.map((chord) => _chunkYDGMWH43cjs.toChordData.call(void 0, chord));
958
990
  const key = resolvedKeyOf(opts);
959
991
  const ranges = resolveRanges(opts);
960
992
  const maxSpacing = resolveMaxSpacing(opts);
@@ -1017,9 +1049,9 @@ function voiceProgression(chords, opts) {
1017
1049
 
1018
1050
  // src/theory/voicing/leading.ts
1019
1051
  function assertVoicing(pitches, name) {
1020
- const voices = _chunkS5BKZZGMcjs.assertArray.call(void 0, pitches, name);
1052
+ const voices = _chunkS3QELJUEcjs.assertArray.call(void 0, pitches, name);
1021
1053
  for (let index = 0; index < voices.length; index += 1) {
1022
- _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, _nullishCoalesce(voices[index], () => ( Number.NaN)), `${name}[${index}]`);
1054
+ _chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, _nullishCoalesce(voices[index], () => ( Number.NaN)), `${name}[${index}]`);
1023
1055
  }
1024
1056
  return voices;
1025
1057
  }
@@ -1032,13 +1064,13 @@ function voiceLeadingCost(from, to) {
1032
1064
  return leadingCost(previous, 0, next, 0, previous.length);
1033
1065
  }
1034
1066
  function nextVoicing(current, chord, opts) {
1035
- _chunkS5BKZZGMcjs.assertOptions.call(void 0, opts, "opts");
1067
+ _chunkS3QELJUEcjs.assertOptions.call(void 0, opts, "opts");
1036
1068
  assertVoicing(current, "current");
1037
- const data = _chunk3R3QVKY5cjs.toChordData.call(void 0, chord);
1069
+ const data = _chunkYDGMWH43cjs.toChordData.call(void 0, chord);
1038
1070
  const derived = _optionalChain([opts, 'optionalAccess', _12 => _12.ranges]) === void 0 && _optionalChain([opts, 'optionalAccess', _13 => _13.voices]) === void 0;
1039
1071
  if (derived) {
1040
1072
  if (current.length === 0) {
1041
- throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)("current must contain at least one pitch");
1073
+ throw new (0, _chunkS3QELJUEcjs.InvalidInputError)("current must contain at least one pitch");
1042
1074
  }
1043
1075
  assertVoicing(current, "current");
1044
1076
  }
@@ -1050,7 +1082,7 @@ function nextVoicing(current, chord, opts) {
1050
1082
  }) : resolveRanges(opts);
1051
1083
  assertVoicing(current, "current");
1052
1084
  if (current.length < ranges.length) {
1053
- throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
1085
+ throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
1054
1086
  `current has ${current.length} voices but the requested ranges require ${ranges.length}`
1055
1087
  );
1056
1088
  }
@@ -1074,7 +1106,7 @@ function nextVoicing(current, chord, opts) {
1074
1106
  }
1075
1107
  }
1076
1108
  if (bestOffset < 0) {
1077
- throw new (0, _chunkS5BKZZGMcjs.NoSolutionError)("no voicing satisfies the given ranges");
1109
+ throw new (0, _chunkS3QELJUEcjs.NoSolutionError)("no voicing satisfies the given ranges");
1078
1110
  }
1079
1111
  return [...pitches.subarray(bestOffset, bestOffset + voices)];
1080
1112
  }
@@ -1099,7 +1131,7 @@ function dedupePcs(pcs) {
1099
1131
  return result;
1100
1132
  }
1101
1133
  function lowestPitchAtOrAbove(pc, floor) {
1102
- return floor + ((pc - _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, floor)) % 12 + 12) % 12;
1134
+ return floor + ((pc - _chunkS3QELJUEcjs.pitchClassOf.call(void 0, floor)) % 12 + 12) % 12;
1103
1135
  }
1104
1136
  function nearestPc(target, pcs) {
1105
1137
  let best = _nullishCoalesce(pcs[0], () => ( target));
@@ -1114,19 +1146,23 @@ function nearestPc(target, pcs) {
1114
1146
  return best;
1115
1147
  }
1116
1148
  function voiceChordStyled(given, opts) {
1117
- _chunkS5BKZZGMcjs.assertOptions.call(void 0, opts, "opts");
1118
- const chord = _chunk3R3QVKY5cjs.toChordData.call(void 0, given);
1119
- const style = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _14 => _14.style]), () => ( "close"));
1149
+ _chunkS3QELJUEcjs.assertOptions.call(void 0, opts, "opts");
1150
+ const chord = _chunkYDGMWH43cjs.toChordData.call(void 0, given);
1151
+ const style = _chunkS3QELJUEcjs.assertOneOf.call(void 0,
1152
+ _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _14 => _14.style]), () => ( "close")),
1153
+ ["close", "drop2", "drop3", "shell", "rootless"],
1154
+ "styled voicing style"
1155
+ );
1120
1156
  const octave = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _15 => _15.octave]), () => ( DEFAULT_STYLE_OCTAVE));
1121
- _chunkS5BKZZGMcjs.assertInteger.call(void 0, octave, "styled voicing octave", -10, 10);
1157
+ _chunkS3QELJUEcjs.assertInteger.call(void 0, octave, "styled voicing octave", -10, 10);
1122
1158
  if (_optionalChain([opts, 'optionalAccess', _16 => _16.topNote]) !== void 0) {
1123
- _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, opts.topNote, "styled voicing topNote");
1159
+ _chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, opts.topNote, "styled voicing topNote");
1124
1160
  }
1125
1161
  const base = 12 * (octave + 1);
1126
- const rootPc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, chord.rootPc);
1127
- const bassPc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, _nullishCoalesce(chord.bassPc, () => ( chord.rootPc)));
1162
+ const rootPc = _chunkS3QELJUEcjs.pitchClassOf.call(void 0, chord.rootPc);
1163
+ const bassPc = _chunkS3QELJUEcjs.pitchClassOf.call(void 0, _nullishCoalesce(chord.bassPc, () => ( chord.rootPc)));
1128
1164
  const omitRoot = style === "rootless" || _optionalChain([opts, 'optionalAccess', _17 => _17.rootless]) === true;
1129
- let order = dedupePcs(chord.intervals.map((interval) => _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, chord.rootPc + interval)));
1165
+ let order = dedupePcs(chord.intervals.map((interval) => _chunkS3QELJUEcjs.pitchClassOf.call(void 0, chord.rootPc + interval)));
1130
1166
  const bassIndex = order.indexOf(bassPc);
1131
1167
  const bassIsChordTone = bassIndex >= 0;
1132
1168
  if (bassIndex > 0) {
@@ -1135,7 +1171,7 @@ function voiceChordStyled(given, opts) {
1135
1171
  order = [bassPc, ...order];
1136
1172
  }
1137
1173
  if (style === "shell") {
1138
- const roles = order.map((pc) => _chunk3R3QVKY5cjs.chordToneRole.call(void 0, pc, chord));
1174
+ const roles = order.map((pc) => _chunkYDGMWH43cjs.chordToneRole.call(void 0, pc, chord));
1139
1175
  const guide = roles.includes("seventh") ? "seventh" : roles.includes("sixth") ? "sixth" : "fifth";
1140
1176
  order = order.filter((_pc, i) => {
1141
1177
  const role = roles[i];
@@ -1149,7 +1185,7 @@ function voiceChordStyled(given, opts) {
1149
1185
  return [];
1150
1186
  }
1151
1187
  if (_optionalChain([opts, 'optionalAccess', _18 => _18.topNote]) !== void 0) {
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);
1188
+ const target = order.includes(_chunkS3QELJUEcjs.pitchClassOf.call(void 0, opts.topNote)) ? _chunkS3QELJUEcjs.pitchClassOf.call(void 0, opts.topNote) : nearestPc(_chunkS3QELJUEcjs.pitchClassOf.call(void 0, opts.topNote), order);
1153
1189
  const targetIndex = order.indexOf(target);
1154
1190
  order = [...order.slice(targetIndex + 1), ...order.slice(0, targetIndex + 1)];
1155
1191
  }
@@ -1168,7 +1204,7 @@ function voiceChordStyled(given, opts) {
1168
1204
  if (prev === void 0) {
1169
1205
  prev = lowestPitchAtOrAbove(pc, base);
1170
1206
  } else {
1171
- let delta = ((pc - _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, prev)) % 12 + 12) % 12;
1207
+ let delta = ((pc - _chunkS3QELJUEcjs.pitchClassOf.call(void 0, prev)) % 12 + 12) % 12;
1172
1208
  if (delta === 0) {
1173
1209
  delta = 12;
1174
1210
  }
@@ -1182,7 +1218,7 @@ function voiceChordStyled(given, opts) {
1182
1218
  stack[dropIndex] = (_nullishCoalesce(stack[dropIndex], () => ( 0))) - 12;
1183
1219
  }
1184
1220
  if (chord.bassPc !== void 0) {
1185
- const bassIndexInStack = stack.findIndex((pitch) => _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, pitch) === bassPc);
1221
+ const bassIndexInStack = stack.findIndex((pitch) => _chunkS3QELJUEcjs.pitchClassOf.call(void 0, pitch) === bassPc);
1186
1222
  if (bassIndexInStack >= 0) {
1187
1223
  const otherLowest = Math.min(
1188
1224
  ...stack.filter((_pitch, index) => index !== bassIndexInStack),
@@ -1197,7 +1233,7 @@ function voiceChordStyled(given, opts) {
1197
1233
  const lowest = _nullishCoalesce(voicing[0], () => ( 0));
1198
1234
  const highest = _nullishCoalesce(voicing[voicing.length - 1], () => ( 0));
1199
1235
  if (lowest < 0 || highest > 127) {
1200
- throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
1236
+ throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
1201
1237
  `styled voicing at octave ${octave} spans MIDI ${lowest}..${highest}, outside 0..127`
1202
1238
  );
1203
1239
  }
@@ -1240,7 +1276,7 @@ function meanPitch(notes) {
1240
1276
  if (notes.length === 0) {
1241
1277
  return 0;
1242
1278
  }
1243
- return notes.reduce((sum, note) => sum + _chunkS5BKZZGMcjs.noteToMidi.call(void 0, note), 0) / notes.length;
1279
+ return notes.reduce((sum, note) => sum + _chunkS3QELJUEcjs.noteToMidi.call(void 0, note), 0) / notes.length;
1244
1280
  }
1245
1281
  function impliedDurations(count, measures, ratio) {
1246
1282
  const full = ratio * Math.max(measures - 1, 0);
@@ -1263,8 +1299,8 @@ function isPassedThrough(entries, position, species) {
1263
1299
  if (previous === void 0 || current === void 0 || next === void 0) {
1264
1300
  return false;
1265
1301
  }
1266
- const incoming = _chunkS5BKZZGMcjs.spelledInterval.call(void 0, previous.note, current.note);
1267
- const outgoing = _chunkS5BKZZGMcjs.spelledInterval.call(void 0, current.note, next.note);
1302
+ const incoming = _chunkS3QELJUEcjs.spelledInterval.call(void 0, previous.note, current.note);
1303
+ const outgoing = _chunkS3QELJUEcjs.spelledInterval.call(void 0, current.note, next.note);
1268
1304
  if (!isStep(incoming) || !isStep(outgoing)) {
1269
1305
  return false;
1270
1306
  }
@@ -1295,9 +1331,9 @@ function isCambiata(entries, start) {
1295
1331
  if (first.consonance === 2 /* Dissonance */ || third.consonance === 2 /* Dissonance */) {
1296
1332
  return false;
1297
1333
  }
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);
1334
+ const approach = _chunkS3QELJUEcjs.spelledInterval.call(void 0, first.note, second.note);
1335
+ const leap = _chunkS3QELJUEcjs.spelledInterval.call(void 0, second.note, third.note);
1336
+ const answer = _chunkS3QELJUEcjs.spelledInterval.call(void 0, third.note, fourth.note);
1301
1337
  return isStep(approach) && direction(approach) < 0 && isThird(leap) && direction(leap) < 0 && isStep(answer) && direction(answer) > 0;
1302
1338
  }
1303
1339
  function isDoubleNeighbour(entries, start) {
@@ -1309,9 +1345,9 @@ function isDoubleNeighbour(entries, start) {
1309
1345
  if (first.consonance === 2 /* Dissonance */ || !sameNote(first.note, fourth.note)) {
1310
1346
  return false;
1311
1347
  }
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);
1348
+ const away = _chunkS3QELJUEcjs.spelledInterval.call(void 0, first.note, second.note);
1349
+ const across = _chunkS3QELJUEcjs.spelledInterval.call(void 0, second.note, third.note);
1350
+ const back = _chunkS3QELJUEcjs.spelledInterval.call(void 0, third.note, fourth.note);
1315
1351
  return isStep(away) && isThird(across) && isStep(back) && direction(away) !== 0 && direction(across) === -direction(away);
1316
1352
  }
1317
1353
  function isFiguredDissonance(entries, position, species) {
@@ -1340,7 +1376,7 @@ function verticalViolations(entries, position, species, counterpointAbove, cross
1340
1376
  const found = [];
1341
1377
  const upper = counterpointAbove ? entry.note : entry.against;
1342
1378
  const lower = counterpointAbove ? entry.against : entry.note;
1343
- if (!crossed.has(entry.index) && _chunk3R3QVKY5cjs.createsVoiceCrossing.call(void 0, upper, lower)) {
1379
+ if (!crossed.has(entry.index) && _chunkYDGMWH43cjs.createsVoiceCrossing.call(void 0, upper, lower)) {
1344
1380
  crossed.add(entry.index);
1345
1381
  found.push(
1346
1382
  violation(
@@ -1393,7 +1429,7 @@ function suspensionViolations(entries, position) {
1393
1429
  )
1394
1430
  ];
1395
1431
  }
1396
- const resolution = next === void 0 ? void 0 : _chunkS5BKZZGMcjs.spelledInterval.call(void 0, entry.note, next.note);
1432
+ const resolution = next === void 0 ? void 0 : _chunkS3QELJUEcjs.spelledInterval.call(void 0, entry.note, next.note);
1397
1433
  if (next === void 0 || resolution === void 0 || !isStep(resolution) || direction(resolution) >= 0) {
1398
1434
  return [
1399
1435
  violation(
@@ -1419,8 +1455,8 @@ function suspensionViolations(entries, position) {
1419
1455
  return [];
1420
1456
  }
1421
1457
  function melodicViolations(from, to) {
1422
- const interval = _chunkS5BKZZGMcjs.spelledInterval.call(void 0, from.note, to.note);
1423
- if (_chunk3R3QVKY5cjs.isAugmentedMelodicInterval.call(void 0, from.note, to.note)) {
1458
+ const interval = _chunkS3QELJUEcjs.spelledInterval.call(void 0, from.note, to.note);
1459
+ if (_chunkYDGMWH43cjs.isAugmentedMelodicInterval.call(void 0, from.note, to.note)) {
1424
1460
  return [
1425
1461
  violation(
1426
1462
  "augmentedMelodicInterval",
@@ -1431,7 +1467,7 @@ function melodicViolations(from, to) {
1431
1467
  )
1432
1468
  ];
1433
1469
  }
1434
- if (_chunk3R3QVKY5cjs.isForbiddenMelodicLeap.call(void 0, from.note, to.note)) {
1470
+ if (_chunkYDGMWH43cjs.isForbiddenMelodicLeap.call(void 0, from.note, to.note)) {
1435
1471
  return [
1436
1472
  violation(
1437
1473
  "illegalLeap",
@@ -1459,19 +1495,19 @@ function melodicMoves(entries) {
1459
1495
  if (from === void 0 || to === void 0) {
1460
1496
  continue;
1461
1497
  }
1462
- moves.push({ from, to, interval: _chunkS5BKZZGMcjs.spelledInterval.call(void 0, from.note, to.note) });
1498
+ moves.push({ from, to, interval: _chunkS3QELJUEcjs.spelledInterval.call(void 0, from.note, to.note) });
1463
1499
  }
1464
1500
  return moves;
1465
1501
  }
1466
1502
  function climaxViolations(entries) {
1467
1503
  const body = entries.slice(0, -1);
1468
1504
  const peak = body.reduce(
1469
- (high, entry) => Math.max(high, _chunkS5BKZZGMcjs.noteToMidi.call(void 0, entry.note)),
1505
+ (high, entry) => Math.max(high, _chunkS3QELJUEcjs.noteToMidi.call(void 0, entry.note)),
1470
1506
  Number.NEGATIVE_INFINITY
1471
1507
  );
1472
1508
  const arrivals = body.filter((entry, position) => {
1473
1509
  const previous = body[position - 1];
1474
- return _chunkS5BKZZGMcjs.noteToMidi.call(void 0, entry.note) === peak && (previous === void 0 || _chunkS5BKZZGMcjs.noteToMidi.call(void 0, previous.note) !== peak);
1510
+ return _chunkS3QELJUEcjs.noteToMidi.call(void 0, entry.note) === peak && (previous === void 0 || _chunkS3QELJUEcjs.noteToMidi.call(void 0, previous.note) !== peak);
1475
1511
  });
1476
1512
  const first = arrivals[0];
1477
1513
  const second = arrivals[1];
@@ -1565,7 +1601,7 @@ function tritoneOutlineViolations(entries) {
1565
1601
  const first = run[0];
1566
1602
  const last = run[run.length - 1];
1567
1603
  if (first !== void 0 && last !== void 0 && run.length > 1) {
1568
- const outline = _chunkS5BKZZGMcjs.spelledInterval.call(void 0, first.from.note, last.to.note);
1604
+ const outline = _chunkS3QELJUEcjs.spelledInterval.call(void 0, first.from.note, last.to.note);
1569
1605
  if (Math.abs(outline.semitones) === TRITONE_SEMITONES) {
1570
1606
  found.push(
1571
1607
  violation(
@@ -1629,8 +1665,8 @@ function motionViolations(from, to, counterpointAbove) {
1629
1665
  const upperCur = counterpointAbove ? to.note : to.against;
1630
1666
  const lowerPrev = counterpointAbove ? from.against : from.note;
1631
1667
  const lowerCur = counterpointAbove ? to.against : to.note;
1632
- if (_chunk3R3QVKY5cjs.createsParallelPerfect.call(void 0, upperPrev, upperCur, lowerPrev, lowerCur)) {
1633
- const fifth = _chunk3R3QVKY5cjs.simpleIntervalNumber.call(void 0, to.interval.number) === 5;
1668
+ if (_chunkYDGMWH43cjs.createsParallelPerfect.call(void 0, upperPrev, upperCur, lowerPrev, lowerCur)) {
1669
+ const fifth = _chunkYDGMWH43cjs.simpleIntervalNumber.call(void 0, to.interval.number) === 5;
1634
1670
  found.push(
1635
1671
  violation(
1636
1672
  fifth ? "parallelFifth" : "parallelOctave",
@@ -1641,7 +1677,7 @@ function motionViolations(from, to, counterpointAbove) {
1641
1677
  )
1642
1678
  );
1643
1679
  }
1644
- if (_chunk3R3QVKY5cjs.createsHiddenParallelPerfect.call(void 0, upperPrev, upperCur, lowerPrev, lowerCur, "twoVoice")) {
1680
+ if (_chunkYDGMWH43cjs.createsHiddenParallelPerfect.call(void 0, upperPrev, upperCur, lowerPrev, lowerCur, "twoVoice")) {
1645
1681
  found.push(
1646
1682
  violation(
1647
1683
  "hiddenPerfect",
@@ -1652,7 +1688,7 @@ function motionViolations(from, to, counterpointAbove) {
1652
1688
  )
1653
1689
  );
1654
1690
  }
1655
- if (_chunk3R3QVKY5cjs.createsBattuta.call(void 0, upperPrev, upperCur, lowerPrev, lowerCur)) {
1691
+ if (_chunkYDGMWH43cjs.createsBattuta.call(void 0, upperPrev, upperCur, lowerPrev, lowerCur)) {
1656
1692
  found.push(
1657
1693
  violation(
1658
1694
  "battuta",
@@ -1681,7 +1717,7 @@ function cadenceViolations(entries, mode, counterpointAbove) {
1681
1717
  if (first === void 0 || last === void 0) {
1682
1718
  return found;
1683
1719
  }
1684
- if (_chunk3R3QVKY5cjs.classifySpelledInterval.call(void 0, first.interval) !== 0 /* PerfectConsonance */) {
1720
+ if (_chunkYDGMWH43cjs.classifySpelledInterval.call(void 0, first.interval) !== 0 /* PerfectConsonance */) {
1685
1721
  found.push(
1686
1722
  violation(
1687
1723
  "missingCadence",
@@ -1692,7 +1728,7 @@ function cadenceViolations(entries, mode, counterpointAbove) {
1692
1728
  )
1693
1729
  );
1694
1730
  }
1695
- if (_chunkS5BKZZGMcjs.noteToPitchClass.call(void 0, last.note) !== _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, mode.rootPc)) {
1731
+ if (_chunkS3QELJUEcjs.noteToPitchClass.call(void 0, last.note) !== _chunkS3QELJUEcjs.pitchClassOf.call(void 0, mode.rootPc)) {
1696
1732
  found.push(
1697
1733
  violation(
1698
1734
  "missingCadence",
@@ -1704,7 +1740,7 @@ function cadenceViolations(entries, mode, counterpointAbove) {
1704
1740
  );
1705
1741
  }
1706
1742
  const closing = last.interval;
1707
- if (closing.quality !== "P" || _chunk3R3QVKY5cjs.simpleIntervalNumber.call(void 0, closing.number) !== 1) {
1743
+ if (closing.quality !== "P" || _chunkYDGMWH43cjs.simpleIntervalNumber.call(void 0, closing.number) !== 1) {
1708
1744
  found.push(
1709
1745
  violation(
1710
1746
  "missingCadence",
@@ -1721,9 +1757,9 @@ function cadenceViolations(entries, mode, counterpointAbove) {
1721
1757
  return found;
1722
1758
  }
1723
1759
  const arrival = _nullishCoalesce(entries.find((entry) => entry.againstIndex === last.againstIndex), () => ( last));
1724
- const approach = _chunkS5BKZZGMcjs.spelledInterval.call(void 0, penultimate.note, arrival.note);
1760
+ const approach = _chunkS3QELJUEcjs.spelledInterval.call(void 0, penultimate.note, arrival.note);
1725
1761
  const expected = counterpointAbove ? { quality: "M", number: 6 } : { quality: "m", number: 3 };
1726
- if (penultimate.interval.quality !== expected.quality || _chunk3R3QVKY5cjs.simpleIntervalNumber.call(void 0, penultimate.interval.number) !== expected.number || !isStep(approach)) {
1762
+ if (penultimate.interval.quality !== expected.quality || _chunkYDGMWH43cjs.simpleIntervalNumber.call(void 0, penultimate.interval.number) !== expected.number || !isStep(approach)) {
1727
1763
  found.push(
1728
1764
  violation(
1729
1765
  "missingCadence",
@@ -1739,6 +1775,10 @@ function cadenceViolations(entries, mode, counterpointAbove) {
1739
1775
  function resolveDurations(counterpoint, measures, species, opts) {
1740
1776
  const given = _optionalChain([opts, 'optionalAccess', _21 => _21.durations]);
1741
1777
  if (given !== void 0) {
1778
+ _chunkS3QELJUEcjs.assertArray.call(void 0, given, "durations");
1779
+ given.forEach((duration, index) => {
1780
+ _chunkS3QELJUEcjs.assertFiniteNumber.call(void 0, duration, `durations[${index}]`);
1781
+ });
1742
1782
  if (given.length !== counterpoint.length) {
1743
1783
  return {
1744
1784
  problem: `The exercise gives ${given.length} durations for ${counterpoint.length} notes`
@@ -1746,20 +1786,20 @@ function resolveDurations(counterpoint, measures, species, opts) {
1746
1786
  }
1747
1787
  for (const duration of given) {
1748
1788
  const units = duration / MIN_FLORID_VALUE;
1749
- if (!(duration > 0) || duration > 1 || Math.abs(units - Math.round(units)) > _chunkS5BKZZGMcjs.BEAT_EPS) {
1789
+ if (!(duration > 0) || duration > 1 || Math.abs(units - Math.round(units)) > _chunkS3QELJUEcjs.BEAT_EPS) {
1750
1790
  return {
1751
1791
  problem: `A note lasts ${duration} of a measure, which this style does not write`
1752
1792
  };
1753
1793
  }
1754
1794
  }
1755
1795
  const total = given.reduce((sum, duration) => sum + duration, 0);
1756
- if (Math.abs(total - measures) > _chunkS5BKZZGMcjs.BEAT_EPS) {
1796
+ if (Math.abs(total - measures) > _chunkS3QELJUEcjs.BEAT_EPS) {
1757
1797
  return { problem: `The counterpoint fills ${total} of the ${measures} measures` };
1758
1798
  }
1759
1799
  return { durations: [...given] };
1760
1800
  }
1761
1801
  if (species === 5) {
1762
- throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
1802
+ throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
1763
1803
  "checkSpecies needs durations for the fifth species, whose note values are not fixed"
1764
1804
  );
1765
1805
  }
@@ -1781,9 +1821,9 @@ function buildEntries(cantusFirmus, counterpoint, durations, counterpointAbove)
1781
1821
  if (note === void 0) {
1782
1822
  continue;
1783
1823
  }
1784
- const struckOver = Math.min(Math.floor(onset + _chunkS5BKZZGMcjs.BEAT_EPS), cantusFirmus.length - 1);
1824
+ const struckOver = Math.min(Math.floor(onset + _chunkS3QELJUEcjs.BEAT_EPS), cantusFirmus.length - 1);
1785
1825
  const lastOver = Math.min(
1786
- Math.max(Math.ceil(onset + duration - _chunkS5BKZZGMcjs.BEAT_EPS) - 1, struckOver),
1826
+ Math.max(Math.ceil(onset + duration - _chunkS3QELJUEcjs.BEAT_EPS) - 1, struckOver),
1787
1827
  cantusFirmus.length - 1
1788
1828
  );
1789
1829
  for (let againstIndex = struckOver; againstIndex <= lastOver; againstIndex += 1) {
@@ -1793,7 +1833,7 @@ function buildEntries(cantusFirmus, counterpoint, durations, counterpointAbove)
1793
1833
  }
1794
1834
  const held = againstIndex > struckOver;
1795
1835
  const begins = held ? againstIndex : onset;
1796
- const interval = counterpointAbove ? _chunkS5BKZZGMcjs.spelledInterval.call(void 0, against, note) : _chunkS5BKZZGMcjs.spelledInterval.call(void 0, note, against);
1836
+ const interval = counterpointAbove ? _chunkS3QELJUEcjs.spelledInterval.call(void 0, against, note) : _chunkS3QELJUEcjs.spelledInterval.call(void 0, note, against);
1797
1837
  entries.push({
1798
1838
  note,
1799
1839
  index,
@@ -1802,9 +1842,9 @@ function buildEntries(cantusFirmus, counterpoint, durations, counterpointAbove)
1802
1842
  held,
1803
1843
  against,
1804
1844
  againstIndex,
1805
- downbeat: Math.abs(begins - Math.round(begins)) < _chunkS5BKZZGMcjs.BEAT_EPS,
1845
+ downbeat: Math.abs(begins - Math.round(begins)) < _chunkS3QELJUEcjs.BEAT_EPS,
1806
1846
  interval,
1807
- consonance: _chunk3R3QVKY5cjs.classifySpelledInterval.call(void 0, interval)
1847
+ consonance: _chunkYDGMWH43cjs.classifySpelledInterval.call(void 0, interval)
1808
1848
  });
1809
1849
  }
1810
1850
  onset += duration;
@@ -1826,17 +1866,17 @@ function motionPairs(entries) {
1826
1866
  return pairs;
1827
1867
  }
1828
1868
  function checkSpecies(cantusFirmus, counterpoint, species, modeLike, opts) {
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);
1869
+ _chunkS3QELJUEcjs.assertArray.call(void 0, cantusFirmus, "cantus firmus");
1870
+ _chunkS3QELJUEcjs.assertArray.call(void 0, counterpoint, "counterpoint");
1871
+ const asked = _chunkS3QELJUEcjs.assertOptions.call(void 0, opts, "opts");
1872
+ const mode = _chunkYDGMWH43cjs.toKeyScale.call(void 0, modeLike);
1833
1873
  if (!SPECIES_NUMBERS.includes(species)) {
1834
- throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
1835
- `species must be one of ${SPECIES_NUMBERS.join(", ")}; received ${_chunkS5BKZZGMcjs.describeRejected.call(void 0, species)}`
1874
+ throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
1875
+ `species must be one of ${SPECIES_NUMBERS.join(", ")}; received ${_chunkS3QELJUEcjs.describeRejected.call(void 0, species)}`
1836
1876
  );
1837
1877
  }
1838
1878
  if (cantusFirmus.length === 0 || counterpoint.length === 0) {
1839
- throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)("checkSpecies needs both a cantus firmus and a counterpoint");
1879
+ throw new (0, _chunkS3QELJUEcjs.InvalidInputError)("checkSpecies needs both a cantus firmus and a counterpoint");
1840
1880
  }
1841
1881
  const resolved = resolveDurations(counterpoint, cantusFirmus.length, species, asked);
1842
1882
  if ("problem" in resolved) {
@@ -1860,9 +1900,9 @@ function checkSpecies(cantusFirmus, counterpoint, species, modeLike, opts) {
1860
1900
  }
1861
1901
  }
1862
1902
  violations.push(...melodicShapeViolations(struck, species));
1863
- for (const [from, to] of motionPairs(struck)) {
1864
- const previous = struck[from];
1865
- const current = struck[to];
1903
+ for (const [from, to] of motionPairs(entries)) {
1904
+ const previous = entries[from];
1905
+ const current = entries[to];
1866
1906
  if (previous !== void 0 && current !== void 0) {
1867
1907
  violations.push(...motionViolations(previous, current, counterpointAbove));
1868
1908
  }
@@ -1877,9 +1917,9 @@ function bare(note) {
1877
1917
  }
1878
1918
  function midiOf(note, index, voice) {
1879
1919
  if (note.octave === void 0) {
1880
- throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`voicings[${index}][${voice}] must carry an octave`);
1920
+ throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(`voicings[${index}][${voice}] must carry an octave`);
1881
1921
  }
1882
- return _chunkS5BKZZGMcjs.noteToMidi.call(void 0, note);
1922
+ return _chunkS3QELJUEcjs.noteToMidi.call(void 0, note);
1883
1923
  }
1884
1924
  function verticalViolations2(moment, ranges, maxSpacing) {
1885
1925
  const found = [];
@@ -1890,7 +1930,7 @@ function verticalViolations2(moment, ranges, maxSpacing) {
1890
1930
  if (upper === void 0 || lower === void 0) {
1891
1931
  continue;
1892
1932
  }
1893
- if (_chunk3R3QVKY5cjs.createsVoiceCrossing.call(void 0, upper, lower)) {
1933
+ if (_chunkYDGMWH43cjs.createsVoiceCrossing.call(void 0, upper, lower)) {
1894
1934
  found.push(
1895
1935
  violation(
1896
1936
  "voiceCrossing",
@@ -1901,7 +1941,7 @@ function verticalViolations2(moment, ranges, maxSpacing) {
1901
1941
  )
1902
1942
  );
1903
1943
  }
1904
- if (voice >= 2 && _chunk3R3QVKY5cjs.exceedsSpacing.call(void 0, upper, lower, maxSpacing)) {
1944
+ if (voice >= 2 && _chunkYDGMWH43cjs.exceedsSpacing.call(void 0, upper, lower, maxSpacing)) {
1905
1945
  found.push(
1906
1946
  violation(
1907
1947
  "spacing",
@@ -1941,8 +1981,8 @@ function pairViolations(transition) {
1941
1981
  if (upperPrev === void 0 || upperCur === void 0 || lowerPrev === void 0 || lowerCur === void 0) {
1942
1982
  continue;
1943
1983
  }
1944
- if (_chunk3R3QVKY5cjs.createsParallelPerfect.call(void 0, upperPrev, upperCur, lowerPrev, lowerCur)) {
1945
- const fifth = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, upperCur - lowerCur) === 7;
1984
+ if (_chunkYDGMWH43cjs.createsParallelPerfect.call(void 0, upperPrev, upperCur, lowerPrev, lowerCur)) {
1985
+ const fifth = _chunkS3QELJUEcjs.pitchClassOf.call(void 0, Math.abs(upperCur - lowerCur)) === 7;
1946
1986
  found.push(
1947
1987
  violation(
1948
1988
  fifth ? "parallelFifth" : "parallelOctave",
@@ -1953,7 +1993,7 @@ function pairViolations(transition) {
1953
1993
  )
1954
1994
  );
1955
1995
  }
1956
- if (upper === lower + 1 && _chunk3R3QVKY5cjs.createsVoiceOverlap.call(void 0, upperPrev, upperCur, lowerPrev, lowerCur)) {
1996
+ if (upper === lower + 1 && _chunkYDGMWH43cjs.createsVoiceOverlap.call(void 0, upperPrev, upperCur, lowerPrev, lowerCur)) {
1957
1997
  found.push(
1958
1998
  violation(
1959
1999
  "overlap",
@@ -1970,7 +2010,7 @@ function pairViolations(transition) {
1970
2010
  const bassCur = to.pitches[0];
1971
2011
  const topPrev = from.pitches[voices - 1];
1972
2012
  const topCur = to.pitches[voices - 1];
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)) {
2013
+ if (voices >= 2 && bassPrev !== void 0 && bassCur !== void 0 && topPrev !== void 0 && topCur !== void 0 && _chunkYDGMWH43cjs.createsHiddenParallelPerfect.call(void 0, topPrev, topCur, bassPrev, bassCur)) {
1974
2014
  found.push(
1975
2015
  violation(
1976
2016
  "hiddenPerfect",
@@ -1991,17 +2031,17 @@ function crossRelationViolations(transition) {
1991
2031
  [clash.earlierVoice, clash.laterVoice],
1992
2032
  from.index,
1993
2033
  to.index,
1994
- `${_chunkS5BKZZGMcjs.formatNote.call(void 0, bare(clash.earlier))} is contradicted by ${_chunkS5BKZZGMcjs.formatNote.call(void 0, bare(clash.later))} in another voice`
2034
+ `${_chunkS3QELJUEcjs.formatNote.call(void 0, bare(clash.earlier))} is contradicted by ${_chunkS3QELJUEcjs.formatNote.call(void 0, bare(clash.later))} in another voice`
1995
2035
  )
1996
2036
  );
1997
2037
  }
1998
2038
  function melodicViolations2(transition) {
1999
2039
  const found = [];
2000
2040
  const { from, to, key } = transition;
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);
2041
+ const seventhPc = _chunkYDGMWH43cjs.seventhPcOf.call(void 0, from.chord);
2042
+ const nextPcs = new Set(_chunkYDGMWH43cjs.chordPitchClasses.call(void 0, to.chord));
2043
+ const leadingTonePc = _chunkYDGMWH43cjs.leadingTonePcOf.call(void 0, key);
2044
+ const tonicPc = _chunkS3QELJUEcjs.pitchClassOf.call(void 0, key.rootPc);
2005
2045
  const voices = Math.min(from.notes.length, to.notes.length);
2006
2046
  for (let voice = 0; voice < voices; voice += 1) {
2007
2047
  const earlier = from.notes[voice];
@@ -2011,8 +2051,8 @@ function melodicViolations2(transition) {
2011
2051
  if (earlier === void 0 || later === void 0 || earlierPitch === void 0 || laterPitch === void 0) {
2012
2052
  continue;
2013
2053
  }
2014
- const interval = _chunkS5BKZZGMcjs.spelledInterval.call(void 0, earlier, later);
2015
- if (_chunk3R3QVKY5cjs.isAugmentedMelodicInterval.call(void 0, earlier, later)) {
2054
+ const interval = _chunkS3QELJUEcjs.spelledInterval.call(void 0, earlier, later);
2055
+ if (_chunkYDGMWH43cjs.isAugmentedMelodicInterval.call(void 0, earlier, later)) {
2016
2056
  found.push(
2017
2057
  violation(
2018
2058
  "augmentedMelodicInterval",
@@ -2023,8 +2063,8 @@ function melodicViolations2(transition) {
2023
2063
  )
2024
2064
  );
2025
2065
  }
2026
- const earlierPc = _chunkS5BKZZGMcjs.noteToPitchClass.call(void 0, earlier);
2027
- if (earlierPc === seventhPc && !nextPcs.has(earlierPc) && !_chunk3R3QVKY5cjs.isDescendingStep.call(void 0, interval)) {
2066
+ const earlierPc = _chunkS3QELJUEcjs.noteToPitchClass.call(void 0, earlier);
2067
+ if (earlierPc === seventhPc && !nextPcs.has(earlierPc) && !_chunkYDGMWH43cjs.isDescendingStep.call(void 0, interval)) {
2028
2068
  found.push(
2029
2069
  violation(
2030
2070
  "unresolvedSeventh",
@@ -2036,7 +2076,7 @@ function melodicViolations2(transition) {
2036
2076
  );
2037
2077
  }
2038
2078
  const inner = !isOuterVoice(voice, from.notes) && !isOuterVoice(voice, to.notes);
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))) {
2079
+ if (earlierPc === leadingTonePc && _chunkYDGMWH43cjs.isFunctioningLeadingTone.call(void 0, from.chord, key) && nextPcs.has(tonicPc) && !nextPcs.has(earlierPc) && !_chunkYDGMWH43cjs.isLeadingToneResolution.call(void 0, earlierPitch, laterPitch, key) && !(inner && _chunkYDGMWH43cjs.isFrustratedLeadingTone.call(void 0, earlierPitch, laterPitch, to.chord))) {
2040
2080
  found.push(
2041
2081
  violation(
2042
2082
  "unresolvedLeadingTone",
@@ -2051,18 +2091,18 @@ function melodicViolations2(transition) {
2051
2091
  return found;
2052
2092
  }
2053
2093
  function spellVoicing(voicing, chord, key) {
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 }));
2094
+ _chunkS3QELJUEcjs.assertArray.call(void 0, voicing, "voicing");
2095
+ _chunkYDGMWH43cjs.assertChord.call(void 0, chord);
2096
+ const { tonic, scale } = _chunkYDGMWH43cjs.resolveKey.call(void 0, key);
2097
+ return voicing.map((pitch) => _chunkYDGMWH43cjs.spellPitch.call(void 0, pitch, tonic, scale, { chord }));
2058
2098
  }
2059
2099
  function checkPartWriting(voicings, chords, keyLike, opts) {
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);
2100
+ _chunkS3QELJUEcjs.assertArray.call(void 0, voicings, "voicings");
2101
+ _chunkS3QELJUEcjs.assertArray.call(void 0, chords, "chords");
2102
+ const asked = _chunkS3QELJUEcjs.assertOptions.call(void 0, opts, "opts");
2103
+ const key = _chunkYDGMWH43cjs.toKeyScale.call(void 0, keyLike);
2064
2104
  if (voicings.length !== chords.length) {
2065
- throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
2105
+ throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
2066
2106
  `checkPartWriting needs one chord per voicing; received ${voicings.length} voicings and ${chords.length} chords`
2067
2107
  );
2068
2108
  }
@@ -2074,7 +2114,7 @@ function checkPartWriting(voicings, chords, keyLike, opts) {
2074
2114
  } else {
2075
2115
  ranges = resolveRanges(asked);
2076
2116
  if (ranges.length < voiceCount) {
2077
- throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
2117
+ throw new (0, _chunkS3QELJUEcjs.InvalidInputError)(
2078
2118
  `checkPartWriting needs one range per voice; received ${ranges.length} ranges for ${voiceCount} voices`
2079
2119
  );
2080
2120
  }
@@ -2135,4 +2175,4 @@ function checkPartWriting(voicings, chords, keyLike, opts) {
2135
2175
 
2136
2176
 
2137
2177
  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-76ZBTRG2.cjs.map
2178
+ //# sourceMappingURL=chunk-U4EQTDGN.cjs.map