@libraz/libcantus 1.1.0 → 1.2.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 (93) hide show
  1. package/dist/analyze/index.cjs +7 -7
  2. package/dist/analyze/index.d.cts +8 -8
  3. package/dist/analyze/index.d.ts +8 -8
  4. package/dist/analyze/index.js +6 -6
  5. package/dist/{chunk-TT6PKMPR.cjs → chunk-35NBV2FT.cjs} +16 -16
  6. package/dist/{chunk-TT6PKMPR.cjs.map → chunk-35NBV2FT.cjs.map} +1 -1
  7. package/dist/{chunk-YPB3A3EY.cjs → chunk-3R3QVKY5.cjs} +314 -285
  8. package/dist/chunk-3R3QVKY5.cjs.map +1 -0
  9. package/dist/{chunk-RVS4G4MR.cjs → chunk-76ZBTRG2.cjs} +198 -198
  10. package/dist/{chunk-RVS4G4MR.cjs.map → chunk-76ZBTRG2.cjs.map} +1 -1
  11. package/dist/{chunk-X6RJAHII.js → chunk-7KG3RTYS.js} +2 -2
  12. package/dist/{chunk-PQL7E5F6.js → chunk-AGOVW7U6.js} +1 -1
  13. package/dist/{chunk-PQL7E5F6.js.map → chunk-AGOVW7U6.js.map} +1 -1
  14. package/dist/{chunk-J772DL3B.cjs → chunk-CGBADIO5.cjs} +53 -53
  15. package/dist/{chunk-J772DL3B.cjs.map → chunk-CGBADIO5.cjs.map} +1 -1
  16. package/dist/{chunk-GDKE6RQW.cjs → chunk-DSMJRXCZ.cjs} +402 -401
  17. package/dist/chunk-DSMJRXCZ.cjs.map +1 -0
  18. package/dist/{chunk-DKICR7AN.js → chunk-FBH75DAY.js} +13 -12
  19. package/dist/{chunk-DKICR7AN.js.map → chunk-FBH75DAY.js.map} +1 -1
  20. package/dist/{chunk-VLE5R7PF.js → chunk-H2KJHBW4.js} +4 -4
  21. package/dist/{chunk-XVMJO3QF.cjs → chunk-HPVSH7SF.cjs} +237 -215
  22. package/dist/chunk-HPVSH7SF.cjs.map +1 -0
  23. package/dist/{chunk-QCXYKSZS.cjs → chunk-HWHGOVO6.cjs} +19 -19
  24. package/dist/{chunk-QCXYKSZS.cjs.map → chunk-HWHGOVO6.cjs.map} +1 -1
  25. package/dist/{chunk-HSY2VQXZ.js → chunk-HYJJ2V2I.js} +32 -10
  26. package/dist/chunk-HYJJ2V2I.js.map +1 -0
  27. package/dist/{chunk-5KW7DNCJ.cjs → chunk-J7FHVZII.cjs} +445 -445
  28. package/dist/{chunk-5KW7DNCJ.cjs.map → chunk-J7FHVZII.cjs.map} +1 -1
  29. package/dist/{chunk-AWEMD747.js → chunk-M5RYMAFI.js} +3 -3
  30. package/dist/{chunk-H66ARFU5.js → chunk-NB25P3EH.js} +3 -3
  31. package/dist/{chunk-57WB2EDF.js → chunk-NFJ4P6ZZ.js} +3 -3
  32. package/dist/{chunk-5JJ6EHEZ.cjs → chunk-NM7UAMC3.cjs} +62 -62
  33. package/dist/{chunk-5JJ6EHEZ.cjs.map → chunk-NM7UAMC3.cjs.map} +1 -1
  34. package/dist/{chunk-R7B5N2JK.cjs → chunk-PM4XJE2Y.cjs} +47 -47
  35. package/dist/{chunk-R7B5N2JK.cjs.map → chunk-PM4XJE2Y.cjs.map} +1 -1
  36. package/dist/{chunk-7GOKQJTQ.js → chunk-PUKJP2Z5.js} +2 -2
  37. package/dist/{chunk-R5VUXQMP.js → chunk-Q6LFSAKV.js} +7 -7
  38. package/dist/{chunk-FPBZFNCD.js → chunk-RFIBF2RR.js} +47 -18
  39. package/dist/{chunk-FPBZFNCD.js.map → chunk-RFIBF2RR.js.map} +1 -1
  40. package/dist/{chunk-XKSO2V5I.cjs → chunk-S5BKZZGM.cjs} +1 -1
  41. package/dist/{chunk-XKSO2V5I.cjs.map → chunk-S5BKZZGM.cjs.map} +1 -1
  42. package/dist/{chunk-Q6R3QAZD.cjs → chunk-SGLEQVJH.cjs} +332 -332
  43. package/dist/{chunk-Q6R3QAZD.cjs.map → chunk-SGLEQVJH.cjs.map} +1 -1
  44. package/dist/{chunk-HOHFYGKW.js → chunk-UMWZ4ZET.js} +2 -2
  45. package/dist/{coerce-wwdELNYS.d.ts → coerce-DP0vYu-x.d.ts} +77 -1
  46. package/dist/{coerce-CJlgULrQ.d.cts → coerce-DRERzdve.d.cts} +77 -1
  47. package/dist/core/index.cjs +5 -5
  48. package/dist/core/index.d.cts +2 -2
  49. package/dist/core/index.d.ts +2 -2
  50. package/dist/core/index.js +4 -4
  51. package/dist/generate/index.cjs +8 -8
  52. package/dist/generate/index.d.cts +8 -8
  53. package/dist/generate/index.d.ts +8 -8
  54. package/dist/generate/index.js +7 -7
  55. package/dist/{index-BaoKVVhE.d.cts → index-B9QLziDe.d.cts} +2 -2
  56. package/dist/{index-B3WCj_Hm.d.cts → index-BBWNZS0f.d.cts} +2 -2
  57. package/dist/{index-CnHQgqNh.d.ts → index-BHIUyjhZ.d.ts} +2 -2
  58. package/dist/{index-DpC-mDlV.d.ts → index-BJgP97N1.d.ts} +4 -4
  59. package/dist/{index-CBCP84rv.d.cts → index-BL5N2Oyz.d.cts} +1 -1
  60. package/dist/{index-D_hzxD8w.d.cts → index-BMweUlm5.d.cts} +3 -0
  61. package/dist/{index-BzLNkmA7.d.cts → index-BNSM-DSk.d.cts} +4 -4
  62. package/dist/{index-BUtIf2go.d.ts → index-BRMbPkHE.d.ts} +25 -5
  63. package/dist/{index-BpWOhkkE.d.ts → index-CJBBiAmU.d.ts} +2 -2
  64. package/dist/{index-Ci3xyows.d.ts → index-CL4b4gUQ.d.ts} +3 -0
  65. package/dist/{index-DTsKaPaC.d.cts → index-DGCNKAUr.d.cts} +25 -5
  66. package/dist/{index-CnIdP4EZ.d.ts → index-Dw2DP7vm.d.ts} +1 -1
  67. package/dist/index.cjs +13 -13
  68. package/dist/index.d.cts +8 -8
  69. package/dist/index.d.ts +8 -8
  70. package/dist/index.js +12 -12
  71. package/dist/{masks-O73Rhj5d.d.ts → masks-Cc7-MzzY.d.ts} +1 -1
  72. package/dist/{masks-C8TWLFIi.d.cts → masks-pADfTOiD.d.cts} +1 -1
  73. package/dist/model/index.cjs +12 -12
  74. package/dist/model/index.d.cts +16 -15
  75. package/dist/model/index.d.ts +16 -15
  76. package/dist/model/index.js +11 -11
  77. package/dist/theory/index.cjs +5 -5
  78. package/dist/theory/index.d.cts +7 -7
  79. package/dist/theory/index.d.ts +7 -7
  80. package/dist/theory/index.js +4 -4
  81. package/package.json +6 -5
  82. package/dist/chunk-GDKE6RQW.cjs.map +0 -1
  83. package/dist/chunk-HSY2VQXZ.js.map +0 -1
  84. package/dist/chunk-XVMJO3QF.cjs.map +0 -1
  85. package/dist/chunk-YPB3A3EY.cjs.map +0 -1
  86. /package/dist/{chunk-X6RJAHII.js.map → chunk-7KG3RTYS.js.map} +0 -0
  87. /package/dist/{chunk-VLE5R7PF.js.map → chunk-H2KJHBW4.js.map} +0 -0
  88. /package/dist/{chunk-AWEMD747.js.map → chunk-M5RYMAFI.js.map} +0 -0
  89. /package/dist/{chunk-H66ARFU5.js.map → chunk-NB25P3EH.js.map} +0 -0
  90. /package/dist/{chunk-57WB2EDF.js.map → chunk-NFJ4P6ZZ.js.map} +0 -0
  91. /package/dist/{chunk-7GOKQJTQ.js.map → chunk-PUKJP2Z5.js.map} +0 -0
  92. /package/dist/{chunk-R5VUXQMP.js.map → chunk-Q6LFSAKV.js.map} +0 -0
  93. /package/dist/{chunk-HOHFYGKW.js.map → chunk-UMWZ4ZET.js.map} +0 -0
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
 
11
- var _chunkQ6R3QAZDcjs = require('./chunk-Q6R3QAZD.cjs');
11
+ var _chunkSGLEQVJHcjs = require('./chunk-SGLEQVJH.cjs');
12
12
 
13
13
 
14
14
 
@@ -19,14 +19,14 @@ var _chunkQ6R3QAZDcjs = require('./chunk-Q6R3QAZD.cjs');
19
19
 
20
20
 
21
21
 
22
- var _chunkJ772DL3Bcjs = require('./chunk-J772DL3B.cjs');
22
+ var _chunkCGBADIO5cjs = require('./chunk-CGBADIO5.cjs');
23
23
 
24
24
 
25
- var _chunkTT6PKMPRcjs = require('./chunk-TT6PKMPR.cjs');
25
+ var _chunk35NBV2FTcjs = require('./chunk-35NBV2FT.cjs');
26
26
 
27
27
 
28
28
 
29
- var _chunkR7B5N2JKcjs = require('./chunk-R7B5N2JK.cjs');
29
+ var _chunkPM4XJE2Ycjs = require('./chunk-PM4XJE2Y.cjs');
30
30
 
31
31
 
32
32
 
@@ -58,7 +58,7 @@ var _chunkR7B5N2JKcjs = require('./chunk-R7B5N2JK.cjs');
58
58
 
59
59
 
60
60
 
61
- var _chunkYPB3A3EYcjs = require('./chunk-YPB3A3EY.cjs');
61
+ var _chunk3R3QVKY5cjs = require('./chunk-3R3QVKY5.cjs');
62
62
 
63
63
 
64
64
 
@@ -95,24 +95,24 @@ var _chunkYPB3A3EYcjs = require('./chunk-YPB3A3EY.cjs');
95
95
 
96
96
 
97
97
 
98
- var _chunkXKSO2V5Icjs = require('./chunk-XKSO2V5I.cjs');
98
+ var _chunkS5BKZZGMcjs = require('./chunk-S5BKZZGM.cjs');
99
99
 
100
100
  // src/generate/context/draw.ts
101
101
  var DRAW_METHODS = ["at", "prob", "range", "float"];
102
102
  function assertDraw(draw, name = "draw") {
103
- const sampler = _chunkXKSO2V5Icjs.assertRecord.call(void 0, draw, name);
103
+ const sampler = _chunkS5BKZZGMcjs.assertRecord.call(void 0, draw, name);
104
104
  for (const method of DRAW_METHODS) {
105
- _chunkXKSO2V5Icjs.assertFunction.call(void 0, sampler[method], `${name}.${method}`);
105
+ _chunkS5BKZZGMcjs.assertFunction.call(void 0, sampler[method], `${name}.${method}`);
106
106
  }
107
107
  return sampler;
108
108
  }
109
109
  function assertSeedPath(path, name = "draw path") {
110
- const steps = _chunkXKSO2V5Icjs.assertArray.call(void 0, path, name);
110
+ const steps = _chunkS5BKZZGMcjs.assertArray.call(void 0, path, name);
111
111
  for (let index = 0; index < steps.length; index += 1) {
112
112
  const step = steps[index];
113
113
  if (typeof step !== "string" && !Number.isFinite(step)) {
114
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(
115
- `${name}[${index}] must be a string or a finite number; received ${_chunkXKSO2V5Icjs.describeRejected.call(void 0, step)}`
114
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
115
+ `${name}[${index}] must be a string or a finite number; received ${_chunkS5BKZZGMcjs.describeRejected.call(void 0, step)}`
116
116
  );
117
117
  }
118
118
  }
@@ -121,7 +121,7 @@ function assertSeedPath(path, name = "draw path") {
121
121
  function drawFrom(rng, path) {
122
122
  const draw = rng.at(...path);
123
123
  if (!(draw >= 0 && draw < 1)) {
124
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(`positional draw must be in [0, 1); received ${draw}`);
124
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`positional draw must be in [0, 1); received ${draw}`);
125
125
  }
126
126
  return draw;
127
127
  }
@@ -129,27 +129,27 @@ function drawsFrom(rng, ...prefix) {
129
129
  const at2 = (...path) => drawFrom(rng, [...prefix, ...path]);
130
130
  return {
131
131
  at: at2,
132
- prob: (p, ...path) => _chunkJ772DL3Bcjs.includeAt.call(void 0, rng, p, ...prefix, ...path),
132
+ prob: (p, ...path) => _chunkCGBADIO5cjs.includeAt.call(void 0, rng, p, ...prefix, ...path),
133
133
  range: (lo, hi, ...path) => {
134
- _chunkXKSO2V5Icjs.assertInteger.call(void 0, lo, "range lower bound");
135
- _chunkXKSO2V5Icjs.assertInteger.call(void 0, hi, "range upper bound");
134
+ _chunkS5BKZZGMcjs.assertInteger.call(void 0, lo, "range lower bound");
135
+ _chunkS5BKZZGMcjs.assertInteger.call(void 0, hi, "range upper bound");
136
136
  if (lo > hi) {
137
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(
137
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
138
138
  `range lower bound must not exceed upper bound; received ${lo} > ${hi}`
139
139
  );
140
140
  }
141
- _chunkXKSO2V5Icjs.assertInteger.call(void 0, hi - lo, "range span", 0);
141
+ _chunkS5BKZZGMcjs.assertInteger.call(void 0, hi - lo, "range span", 0);
142
142
  return lo + Math.floor(at2(...path) * (hi - lo + 1));
143
143
  },
144
144
  float: (lo, hi, ...path) => {
145
- _chunkXKSO2V5Icjs.assertFiniteNumber.call(void 0, lo, "float lower bound");
146
- _chunkXKSO2V5Icjs.assertFiniteNumber.call(void 0, hi, "float upper bound");
145
+ _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, lo, "float lower bound");
146
+ _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, hi, "float upper bound");
147
147
  if (lo > hi) {
148
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(
148
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
149
149
  `float lower bound must not exceed upper bound; received ${lo} > ${hi}`
150
150
  );
151
151
  }
152
- _chunkXKSO2V5Icjs.assertFiniteNumber.call(void 0, hi - lo, "float span");
152
+ _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, hi - lo, "float span");
153
153
  return lo + at2(...path) * (hi - lo);
154
154
  }
155
155
  };
@@ -378,8 +378,8 @@ function sameTs(a, b) {
378
378
  return a.numerator === b.numerator && a.denominator === b.denominator;
379
379
  }
380
380
  function fitsQuery(entry, query) {
381
- const candidate = _chunkXKSO2V5Icjs.assertRecord.call(void 0, entry, "vocabulary entry");
382
- const asked = _chunkXKSO2V5Icjs.assertRecord.call(void 0, query, "vocabulary query");
381
+ const candidate = _chunkS5BKZZGMcjs.assertRecord.call(void 0, entry, "vocabulary entry");
382
+ const asked = _chunkS5BKZZGMcjs.assertRecord.call(void 0, query, "vocabulary query");
383
383
  if (asked.genre !== void 0 && candidate.genre !== asked.genre) {
384
384
  return false;
385
385
  }
@@ -392,7 +392,7 @@ function fitsQuery(entry, query) {
392
392
  return false;
393
393
  }
394
394
  }
395
- if (asked.ts !== void 0 && candidate.ts && !sameTs(candidate.ts, _chunkXKSO2V5Icjs.meterAt.call(void 0, 0, _chunkXKSO2V5Icjs.toMeterData.call(void 0, asked.ts, "ts")))) {
395
+ if (asked.ts !== void 0 && candidate.ts && !sameTs(candidate.ts, _chunkS5BKZZGMcjs.meterAt.call(void 0, 0, _chunkS5BKZZGMcjs.toMeterData.call(void 0, asked.ts, "ts")))) {
396
396
  return false;
397
397
  }
398
398
  if (asked.quality !== void 0 && candidate.fitsOver && !candidate.fitsOver.includes(asked.quality)) {
@@ -407,7 +407,7 @@ function fitsQuery(entry, query) {
407
407
  return asked.difficulty === void 0 || candidate.difficulty <= asked.difficulty;
408
408
  }
409
409
  function selectVocabulary(dictionary, query) {
410
- return _chunkXKSO2V5Icjs.assertArray.call(void 0, dictionary, "dictionary").filter(
410
+ return _chunkS5BKZZGMcjs.assertArray.call(void 0, dictionary, "dictionary").filter(
411
411
  (entry) => fitsQuery(entry, query)
412
412
  );
413
413
  }
@@ -421,12 +421,12 @@ function pickVocabulary(dictionary, query, draw, ...path) {
421
421
  return candidates[sampler.range(0, candidates.length - 1, ...path)];
422
422
  }
423
423
  function mergeVocabulary(builtIn, supplied) {
424
- const library = _chunkXKSO2V5Icjs.assertArray.call(void 0, builtIn, "builtIn");
425
- const extra = supplied === void 0 || supplied === null ? [] : _chunkXKSO2V5Icjs.assertArray.call(void 0, supplied, "supplied");
424
+ const library = _chunkS5BKZZGMcjs.assertArray.call(void 0, builtIn, "builtIn");
425
+ const extra = supplied === void 0 || supplied === null ? [] : _chunkS5BKZZGMcjs.assertArray.call(void 0, supplied, "supplied");
426
426
  if (extra.length === 0) {
427
427
  return [...library];
428
428
  }
429
- const idOf = (entry, index, side) => _chunkXKSO2V5Icjs.assertRecord.call(void 0, entry, `${side}[${index}]`).id;
429
+ const idOf = (entry, index, side) => _chunkS5BKZZGMcjs.assertRecord.call(void 0, entry, `${side}[${index}]`).id;
430
430
  const byId = new Map(extra.map((entry, index) => [idOf(entry, index, "supplied"), entry]));
431
431
  const merged = library.map((entry, index) => _nullishCoalesce(byId.get(idOf(entry, index, "builtIn")), () => ( entry)));
432
432
  const replaced = new Set(library.map((entry, index) => idOf(entry, index, "builtIn")));
@@ -439,9 +439,9 @@ function mergeVocabulary(builtIn, supplied) {
439
439
  }
440
440
  function vocabularyOfKind(entries, isMaterial) {
441
441
  const out = [];
442
- const recognises = _chunkXKSO2V5Icjs.assertFunction.call(void 0, isMaterial, "isMaterial");
443
- for (const entry of _chunkXKSO2V5Icjs.assertArray.call(void 0, entries, "entries")) {
444
- if (recognises(_chunkXKSO2V5Icjs.assertRecord.call(void 0, entry, "entry").material)) {
442
+ const recognises = _chunkS5BKZZGMcjs.assertFunction.call(void 0, isMaterial, "isMaterial");
443
+ for (const entry of _chunkS5BKZZGMcjs.assertArray.call(void 0, entries, "entries")) {
444
+ if (recognises(_chunkS5BKZZGMcjs.assertRecord.call(void 0, entry, "entry").material)) {
445
445
  out.push(entry);
446
446
  }
447
447
  }
@@ -449,42 +449,42 @@ function vocabularyOfKind(entries, isMaterial) {
449
449
  }
450
450
  function assertNames(values, allowed, label) {
451
451
  if (!Array.isArray(values)) {
452
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(
453
- `${label} must be an array of names; received ${_chunkXKSO2V5Icjs.describeRejected.call(void 0, values)}`
452
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
453
+ `${label} must be an array of names; received ${_chunkS5BKZZGMcjs.describeRejected.call(void 0, values)}`
454
454
  );
455
455
  }
456
456
  values.forEach((value, index) => {
457
- _chunkXKSO2V5Icjs.assertOneOf.call(void 0, value, allowed, `${label}[${index}]`);
457
+ _chunkS5BKZZGMcjs.assertOneOf.call(void 0, value, allowed, `${label}[${index}]`);
458
458
  });
459
459
  }
460
460
  function assertVocabulary(entry, label = "vocabulary entry") {
461
461
  if (typeof entry !== "object" || entry === null) {
462
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(
463
- `${label} must be a dictionary entry; received ${_chunkXKSO2V5Icjs.describeRejected.call(void 0, entry)}`
462
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
463
+ `${label} must be a dictionary entry; received ${_chunkS5BKZZGMcjs.describeRejected.call(void 0, entry)}`
464
464
  );
465
465
  }
466
- _chunkXKSO2V5Icjs.assertOneOf.call(void 0, entry.genre, GENRES, `${label} genre`);
467
- _chunkXKSO2V5Icjs.assertOneOf.call(void 0, _optionalChain([entry, 'access', _2 => _2.provenance, 'optionalAccess', _3 => _3.basis]), PROVENANCE_BASES, `${label} provenance basis`);
468
- assertNames(entry.articulations, _chunkXKSO2V5Icjs.ARTICULATIONS, `${label} articulations`);
466
+ _chunkS5BKZZGMcjs.assertOneOf.call(void 0, entry.genre, GENRES, `${label} genre`);
467
+ _chunkS5BKZZGMcjs.assertOneOf.call(void 0, _optionalChain([entry, 'access', _2 => _2.provenance, 'optionalAccess', _3 => _3.basis]), PROVENANCE_BASES, `${label} provenance basis`);
468
+ assertNames(entry.articulations, _chunkS5BKZZGMcjs.ARTICULATIONS, `${label} articulations`);
469
469
  if (entry.sections !== void 0) {
470
470
  assertNames(entry.sections, PUBLIC_SECTIONS, `${label} sections`);
471
471
  }
472
472
  if (entry.fitsOver !== void 0) {
473
- assertNames(entry.fitsOver, _chunkYPB3A3EYcjs.chordQualities.call(void 0, ), `${label} fitsOver`);
473
+ assertNames(entry.fitsOver, _chunk3R3QVKY5cjs.chordQualities.call(void 0, ), `${label} fitsOver`);
474
474
  }
475
475
  if (entry.ts !== void 0) {
476
- _chunkXKSO2V5Icjs.assertTimeSignature.call(void 0, entry.ts, `${label} ts`);
476
+ _chunkS5BKZZGMcjs.assertTimeSignature.call(void 0, entry.ts, `${label} ts`);
477
477
  }
478
- _chunkXKSO2V5Icjs.assertRange.call(void 0, entry.difficulty, 1, 5, `${label} difficulty`);
478
+ _chunkS5BKZZGMcjs.assertRange.call(void 0, entry.difficulty, 1, 5, `${label} difficulty`);
479
479
  if (entry.tempoRange !== void 0) {
480
480
  if (!Array.isArray(entry.tempoRange) || entry.tempoRange.length !== 2) {
481
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(
482
- `${label} tempoRange must be a low and a high tempo; received ${_chunkXKSO2V5Icjs.describeRejected.call(void 0, entry.tempoRange)}`
481
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
482
+ `${label} tempoRange must be a low and a high tempo; received ${_chunkS5BKZZGMcjs.describeRejected.call(void 0, entry.tempoRange)}`
483
483
  );
484
484
  }
485
485
  const [low, high] = entry.tempoRange;
486
- _chunkXKSO2V5Icjs.assertRange.call(void 0, low, Number.MIN_VALUE, 1e3, `${label} tempoRange low`);
487
- _chunkXKSO2V5Icjs.assertRange.call(void 0, high, low, 1e3, `${label} tempoRange high`);
486
+ _chunkS5BKZZGMcjs.assertRange.call(void 0, low, Number.MIN_VALUE, 1e3, `${label} tempoRange low`);
487
+ _chunkS5BKZZGMcjs.assertRange.call(void 0, high, low, 1e3, `${label} tempoRange high`);
488
488
  }
489
489
  return entry;
490
490
  }
@@ -506,15 +506,15 @@ function atLevel(table, difficulty) {
506
506
  return low + (high - low) * (level - lower);
507
507
  }
508
508
  function assertDifficulty(difficulty, label = "complexity difficulty") {
509
- return _chunkXKSO2V5Icjs.assertRange.call(void 0, difficulty, MIN_DIFFICULTY, MAX_DIFFICULTY, label);
509
+ return _chunkS5BKZZGMcjs.assertRange.call(void 0, difficulty, MIN_DIFFICULTY, MAX_DIFFICULTY, label);
510
510
  }
511
511
  function sustainsStrokes(stepBeats, bpm, difficulty) {
512
512
  if (difficulty === void 0 || bpm === void 0) {
513
513
  return true;
514
514
  }
515
515
  assertDifficulty(difficulty);
516
- _chunkXKSO2V5Icjs.assertFiniteNumber.call(void 0, bpm, "bpm");
517
- if (_chunkXKSO2V5Icjs.assertFiniteNumber.call(void 0, stepBeats, "stepBeats") <= 0) {
516
+ _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, bpm, "bpm");
517
+ if (_chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, stepBeats, "stepBeats") <= 0) {
518
518
  return true;
519
519
  }
520
520
  const rate = 1 / (stepBeats * secondsPerBeat(bpm));
@@ -525,9 +525,9 @@ function sustainsShift(semitones, stepBeats, bpm, difficulty) {
525
525
  return true;
526
526
  }
527
527
  assertDifficulty(difficulty);
528
- _chunkXKSO2V5Icjs.assertFiniteNumber.call(void 0, bpm, "bpm");
529
- _chunkXKSO2V5Icjs.assertFiniteSemitones.call(void 0, semitones);
530
- if (_chunkXKSO2V5Icjs.assertFiniteNumber.call(void 0, stepBeats, "stepBeats") <= 0) {
528
+ _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, bpm, "bpm");
529
+ _chunkS5BKZZGMcjs.assertFiniteSemitones.call(void 0, semitones);
530
+ if (_chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, stepBeats, "stepBeats") <= 0) {
531
531
  return true;
532
532
  }
533
533
  const seconds = stepBeats * secondsPerBeat(bpm);
@@ -539,20 +539,20 @@ var DEFAULT_SEED = 0;
539
539
  var VERSION_SEGMENT = "v";
540
540
  function resolveContext(input) {
541
541
  if (input !== null && typeof input !== "number" && input !== void 0) {
542
- _chunkXKSO2V5Icjs.assertRecord.call(void 0, input, "ctx");
542
+ _chunkS5BKZZGMcjs.assertRecord.call(void 0, input, "ctx");
543
543
  }
544
544
  if (input === null) {
545
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)("ctx must be a seed or a generation context; received null");
545
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)("ctx must be a seed or a generation context; received null");
546
546
  }
547
547
  const ctx = typeof input === "number" ? { seed: input } : _nullishCoalesce(input, () => ( { seed: DEFAULT_SEED }));
548
- const seed = _chunkXKSO2V5Icjs.assertInteger.call(void 0, _nullishCoalesce(ctx.seed, () => ( DEFAULT_SEED)), "seed", 0, 4294967295);
548
+ const seed = _chunkS5BKZZGMcjs.assertInteger.call(void 0, _nullishCoalesce(ctx.seed, () => ( DEFAULT_SEED)), "seed", 0, 4294967295);
549
549
  const complexity = _nullishCoalesce(ctx.complexity, () => ( {}));
550
- const rhythmic = complexity.rhythmic === void 0 ? void 0 : _chunkXKSO2V5Icjs.assertRange.call(void 0, complexity.rhythmic, 0, 1, "complexity rhythmic");
551
- const harmonic = complexity.harmonic === void 0 ? void 0 : _chunkXKSO2V5Icjs.assertRange.call(void 0, complexity.harmonic, 0, 1, "complexity harmonic");
552
- const ornament2 = complexity.ornament === void 0 ? void 0 : _chunkXKSO2V5Icjs.assertRange.call(void 0, complexity.ornament, 0, 1, "complexity ornament");
550
+ const rhythmic = complexity.rhythmic === void 0 ? void 0 : _chunkS5BKZZGMcjs.assertRange.call(void 0, complexity.rhythmic, 0, 1, "complexity rhythmic");
551
+ const harmonic = complexity.harmonic === void 0 ? void 0 : _chunkS5BKZZGMcjs.assertRange.call(void 0, complexity.harmonic, 0, 1, "complexity harmonic");
552
+ const ornament2 = complexity.ornament === void 0 ? void 0 : _chunkS5BKZZGMcjs.assertRange.call(void 0, complexity.ornament, 0, 1, "complexity ornament");
553
553
  const difficulty = complexity.difficulty === void 0 ? void 0 : assertDifficulty(complexity.difficulty);
554
- const bpm = ctx.bpm === void 0 ? void 0 : _chunkXKSO2V5Icjs.assertRange.call(void 0, ctx.bpm, Number.MIN_VALUE, 1e3, "bpm");
555
- const algorithmVersion = _chunkJ772DL3Bcjs.resolveAlgorithmVersion.call(void 0, ctx.algorithmVersion);
554
+ const bpm = ctx.bpm === void 0 ? void 0 : _chunkS5BKZZGMcjs.assertRange.call(void 0, ctx.bpm, Number.MIN_VALUE, 1e3, "bpm");
555
+ const algorithmVersion = _chunkCGBADIO5cjs.resolveAlgorithmVersion.call(void 0, ctx.algorithmVersion);
556
556
  const supplied = ctx.rng;
557
557
  const instruments = ctx.instruments;
558
558
  const vocabulary = (_nullishCoalesce(ctx.vocabulary, () => ( []))).map(
@@ -568,12 +568,12 @@ function resolveContext(input) {
568
568
  algorithmVersion,
569
569
  instrument: (part) => _optionalChain([instruments, 'optionalAccess', _4 => _4[part]]),
570
570
  vocabulary,
571
- part: (name) => supplied ? drawsFrom(supplied, name, VERSION_SEGMENT, algorithmVersion) : drawsFrom(_chunkJ772DL3Bcjs.createPositionalRng.call(void 0, _chunkJ772DL3Bcjs.deriveSeed.call(void 0, seed, name, VERSION_SEGMENT, algorithmVersion)))
571
+ part: (name) => supplied ? drawsFrom(supplied, name, VERSION_SEGMENT, algorithmVersion) : drawsFrom(_chunkCGBADIO5cjs.createPositionalRng.call(void 0, _chunkCGBADIO5cjs.deriveSeed.call(void 0, seed, name, VERSION_SEGMENT, algorithmVersion)))
572
572
  };
573
573
  }
574
574
  function resolveContextWith(input, sugar) {
575
575
  const base = resolveContext(input);
576
- const supplied = sugar.ornament === void 0 ? void 0 : _chunkXKSO2V5Icjs.assertRange.call(void 0, sugar.ornament, 0, 1, "complexity ornament");
576
+ const supplied = sugar.ornament === void 0 ? void 0 : _chunkS5BKZZGMcjs.assertRange.call(void 0, sugar.ornament, 0, 1, "complexity ornament");
577
577
  const ornament2 = _nullishCoalesce(base.ornament, () => ( supplied));
578
578
  return { ...base, ornament: ornament2 };
579
579
  }
@@ -590,14 +590,14 @@ function placeAboveBass(pc, bassMidi) {
590
590
  return foldIntoBand(pc + 12 * Math.round((bassMidi - pc) / 12), bassMidi);
591
591
  }
592
592
  function placeRoot(pc, low) {
593
- return low + _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, pc - low);
593
+ return low + _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, pc - low);
594
594
  }
595
595
  function barTiles(startBeat, endBeat, ts) {
596
- const barBeats = _chunkXKSO2V5Icjs.beatsPerBar.call(void 0, ts);
596
+ const barBeats = _chunkS5BKZZGMcjs.beatsPerBar.call(void 0, ts);
597
597
  const tiles = [];
598
598
  for (let index = 0; ; index += 1) {
599
599
  const tileStart = startBeat + index * barBeats;
600
- if (tileStart >= endBeat - _chunkXKSO2V5Icjs.BEAT_EPS) {
600
+ if (tileStart >= endBeat - _chunkS5BKZZGMcjs.BEAT_EPS) {
601
601
  break;
602
602
  }
603
603
  tiles.push({ startBeat: tileStart, endBeat: Math.min(tileStart + barBeats, endBeat) });
@@ -605,8 +605,8 @@ function barTiles(startBeat, endBeat, ts) {
605
605
  return tiles;
606
606
  }
607
607
  function midBarPulse(barStart, ts) {
608
- const pulse2 = _chunkXKSO2V5Icjs.pulseBeats.call(void 0, ts);
609
- return barStart + Math.floor((_chunkXKSO2V5Icjs.beatsPerBar.call(void 0, ts) / 2 + _chunkXKSO2V5Icjs.BEAT_EPS) / pulse2) * pulse2;
608
+ const pulse2 = _chunkS5BKZZGMcjs.pulseBeats.call(void 0, ts);
609
+ return barStart + Math.floor((_chunkS5BKZZGMcjs.beatsPerBar.call(void 0, ts) / 2 + _chunkS5BKZZGMcjs.BEAT_EPS) / pulse2) * pulse2;
610
610
  }
611
611
  function assertBassSegments(segments) {
612
612
  for (let index = 0; index < segments.length; index += 1) {
@@ -614,14 +614,14 @@ function assertBassSegments(segments) {
614
614
  if (segment === void 0) {
615
615
  continue;
616
616
  }
617
- _chunkXKSO2V5Icjs.assertRange.call(void 0, segment.startBeat, 0, Number.MAX_SAFE_INTEGER, `segments[${index}].startBeat`);
618
- _chunkXKSO2V5Icjs.assertRange.call(void 0, segment.endBeat, 0, Number.MAX_SAFE_INTEGER, `segments[${index}].endBeat`);
617
+ _chunkS5BKZZGMcjs.assertRange.call(void 0, segment.startBeat, 0, Number.MAX_SAFE_INTEGER, `segments[${index}].startBeat`);
618
+ _chunkS5BKZZGMcjs.assertRange.call(void 0, segment.endBeat, 0, Number.MAX_SAFE_INTEGER, `segments[${index}].endBeat`);
619
619
  if (segment.endBeat <= segment.startBeat) {
620
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(`segments[${index}] must have a positive duration`);
620
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`segments[${index}] must have a positive duration`);
621
621
  }
622
622
  const previous = segments[index - 1];
623
- if (previous !== void 0 && segment.startBeat < previous.endBeat - _chunkXKSO2V5Icjs.BEAT_EPS) {
624
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(
623
+ if (previous !== void 0 && segment.startBeat < previous.endBeat - _chunkS5BKZZGMcjs.BEAT_EPS) {
624
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
625
625
  `bass segments must not overlap: segments ${index - 1} and ${index} overlap`
626
626
  );
627
627
  }
@@ -631,22 +631,22 @@ function chordTonePcs(chord) {
631
631
  const seen = /* @__PURE__ */ new Set();
632
632
  const pcs = [];
633
633
  for (const interval of chord.intervals) {
634
- const pc = _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, chord.rootPc + interval);
634
+ const pc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, chord.rootPc + interval);
635
635
  if (!seen.has(pc)) {
636
636
  seen.add(pc);
637
637
  pcs.push(pc);
638
638
  }
639
639
  }
640
640
  if (pcs.length === 0) {
641
- pcs.push(_chunkXKSO2V5Icjs.pitchClassOf.call(void 0, chord.rootPc));
641
+ pcs.push(_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, chord.rootPc));
642
642
  }
643
643
  return pcs;
644
644
  }
645
645
  function fifthPcOf2(chord) {
646
- return _nullishCoalesce(_chunkYPB3A3EYcjs.fifthPcOf.call(void 0, chord), () => ( _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, chord.rootPc)));
646
+ return _nullishCoalesce(_chunk3R3QVKY5cjs.fifthPcOf.call(void 0, chord), () => ( _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, chord.rootPc)));
647
647
  }
648
648
  function bassPcOf(chord) {
649
- return _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, _nullishCoalesce(chord.bassPc, () => ( chord.rootPc)));
649
+ return _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, _nullishCoalesce(chord.bassPc, () => ( chord.rootPc)));
650
650
  }
651
651
  function bassToneCycle(chord) {
652
652
  const bass = bassPcOf(chord);
@@ -656,19 +656,19 @@ function bassToneCycle(chord) {
656
656
  }
657
657
  function beatPositions(start, end, ts) {
658
658
  const positions = [];
659
- const barBeats = _chunkXKSO2V5Icjs.beatsPerBar.call(void 0, ts);
660
- const pulse2 = _chunkXKSO2V5Icjs.pulseBeats.call(void 0, ts);
659
+ const barBeats = _chunkS5BKZZGMcjs.beatsPerBar.call(void 0, ts);
660
+ const pulse2 = _chunkS5BKZZGMcjs.pulseBeats.call(void 0, ts);
661
661
  const firstBar = Math.floor(start / barBeats);
662
- const lastBar = Math.floor((end - _chunkXKSO2V5Icjs.BEAT_EPS) / barBeats);
662
+ const lastBar = Math.floor((end - _chunkS5BKZZGMcjs.BEAT_EPS) / barBeats);
663
663
  for (let bar2 = firstBar; bar2 <= lastBar; bar2 += 1) {
664
664
  const barStart = bar2 * barBeats;
665
- const firstPulse = Math.max(0, Math.ceil((start - barStart - _chunkXKSO2V5Icjs.BEAT_EPS) / pulse2));
665
+ const firstPulse = Math.max(0, Math.ceil((start - barStart - _chunkS5BKZZGMcjs.BEAT_EPS) / pulse2));
666
666
  for (let index = firstPulse; ; index += 1) {
667
667
  const position = barStart + index * pulse2;
668
- if (position >= barStart + barBeats - _chunkXKSO2V5Icjs.BEAT_EPS || position >= end - _chunkXKSO2V5Icjs.BEAT_EPS) {
668
+ if (position >= barStart + barBeats - _chunkS5BKZZGMcjs.BEAT_EPS || position >= end - _chunkS5BKZZGMcjs.BEAT_EPS) {
669
669
  break;
670
670
  }
671
- if (position >= start - _chunkXKSO2V5Icjs.BEAT_EPS) {
671
+ if (position >= start - _chunkS5BKZZGMcjs.BEAT_EPS) {
672
672
  positions.push(position);
673
673
  }
674
674
  }
@@ -686,7 +686,7 @@ function bandFloor(low, instrument) {
686
686
  if (!instrument) {
687
687
  return low;
688
688
  }
689
- const range = _chunkJ772DL3Bcjs.instrumentRange.call(void 0, instrument);
689
+ const range = _chunkCGBADIO5cjs.instrumentRange.call(void 0, instrument);
690
690
  const dropped = low - 12 * Math.max(0, Math.ceil((low + 12 - range.high) / 12));
691
691
  return dropped + 12 * Math.max(0, Math.ceil((range.low - dropped) / 12));
692
692
  }
@@ -705,12 +705,12 @@ function neighborOnSide(target, dir, key, chromatic) {
705
705
  if (chromatic) {
706
706
  return semitone;
707
707
  }
708
- const cand = _chunkYPB3A3EYcjs.nearestScaleTone.call(void 0, target + dir * 2, key);
708
+ const cand = _chunk3R3QVKY5cjs.nearestScaleTone.call(void 0, target + dir * 2, key);
709
709
  const step = Math.abs(cand - target);
710
710
  return step >= 1 && step <= 2 ? cand : semitone;
711
711
  }
712
712
  function bassRegister(named, given, octave) {
713
- const instrument = given === void 0 ? named !== void 0 && named.kind === "stringed" ? named : void 0 : _chunkJ772DL3Bcjs.toStringedProfile.call(void 0, given, "instrument");
713
+ const instrument = given === void 0 ? named !== void 0 && named.kind === "stringed" ? named : void 0 : _chunkCGBADIO5cjs.toStringedProfile.call(void 0, given, "instrument");
714
714
  return { instrument, low: bandFloor(octave * 12 + 12, instrument) };
715
715
  }
716
716
 
@@ -719,31 +719,31 @@ var BAR_STEPS = 16;
719
719
  var BEAT_STEPS = 4;
720
720
  var STEP_BEATS = 1 / BEAT_STEPS;
721
721
  function assertGridEvents(events) {
722
- _chunkXKSO2V5Icjs.assertArray.call(void 0, events, "figure events");
722
+ _chunkS5BKZZGMcjs.assertArray.call(void 0, events, "figure events");
723
723
  events.forEach((event, index) => {
724
- _chunkXKSO2V5Icjs.assertRecord.call(void 0, event, `figure events[${index}]`);
725
- _chunkXKSO2V5Icjs.assertFiniteNumber.call(void 0, event.step, `figure events[${index}].step`);
724
+ _chunkS5BKZZGMcjs.assertRecord.call(void 0, event, `figure events[${index}]`);
725
+ _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, event.step, `figure events[${index}].step`);
726
726
  });
727
727
  return events;
728
728
  }
729
729
  function assertSpanSteps(spanSteps) {
730
- return _chunkXKSO2V5Icjs.assertPositiveInt.call(void 0, spanSteps, "figure span steps");
730
+ return _chunkS5BKZZGMcjs.assertPositiveInt.call(void 0, spanSteps, "figure span steps");
731
731
  }
732
732
  function streamOf(event) {
733
733
  return _nullishCoalesce(_nullishCoalesce(event.limb, () => ( event.voice)), () => ( ""));
734
734
  }
735
735
  var FIGURE_TS = { numerator: 4, denominator: 4 };
736
736
  function subdivisionBeats(ts) {
737
- const pulse2 = _chunkXKSO2V5Icjs.pulseBeats.call(void 0, ts);
738
- return _chunkXKSO2V5Icjs.isCompound.call(void 0, ts) ? pulse2 / 3 : pulse2 / 2;
737
+ const pulse2 = _chunkS5BKZZGMcjs.pulseBeats.call(void 0, ts);
738
+ return _chunkS5BKZZGMcjs.isCompound.call(void 0, ts) ? pulse2 / 3 : pulse2 / 2;
739
739
  }
740
740
  function gridMetricWeight(step, ts) {
741
- _chunkXKSO2V5Icjs.assertFiniteNumber.call(void 0, step, "step");
742
- return stepWeight(step, _chunkXKSO2V5Icjs.meterAt.call(void 0, 0, _chunkXKSO2V5Icjs.toMeterData.call(void 0, ts, "ts")));
741
+ _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, step, "step");
742
+ return stepWeight(step, _chunkS5BKZZGMcjs.meterAt.call(void 0, 0, _chunkS5BKZZGMcjs.toMeterData.call(void 0, ts, "ts")));
743
743
  }
744
744
  function stepWeight(step, ts) {
745
745
  const beats = step * STEP_BEATS;
746
- const weight = _chunkXKSO2V5Icjs.metricWeight.call(void 0, beats, ts);
746
+ const weight = _chunkS5BKZZGMcjs.metricWeight.call(void 0, beats, ts);
747
747
  if (weight > 0) {
748
748
  return weight + 1;
749
749
  }
@@ -753,8 +753,8 @@ function stepWeight(step, ts) {
753
753
  }
754
754
  function thin(events, amount, ts) {
755
755
  const figure = assertGridEvents(events);
756
- _chunkXKSO2V5Icjs.assertRange.call(void 0, amount, 0, 1, "thin amount");
757
- const signature = _chunkXKSO2V5Icjs.meterAt.call(void 0, 0, _chunkXKSO2V5Icjs.toMeterData.call(void 0, ts, "ts"));
756
+ _chunkS5BKZZGMcjs.assertRange.call(void 0, amount, 0, 1, "thin amount");
757
+ const signature = _chunkS5BKZZGMcjs.meterAt.call(void 0, 0, _chunkS5BKZZGMcjs.toMeterData.call(void 0, ts, "ts"));
758
758
  const floor = Math.min(4, Math.floor(amount * 5));
759
759
  return figure.filter((event) => stepWeight(event.step, signature) >= floor);
760
760
  }
@@ -806,10 +806,10 @@ function syncopate(events, amount, draw, ...path) {
806
806
  const figure = assertGridEvents(events);
807
807
  const sampler = assertDraw(draw);
808
808
  assertSeedPath(path);
809
- const asked = typeof amount === "number" ? void 0 : _chunkXKSO2V5Icjs.assertRecord.call(void 0, amount, "amount");
809
+ const asked = typeof amount === "number" ? void 0 : _chunkS5BKZZGMcjs.assertRecord.call(void 0, amount, "amount");
810
810
  const dial = asked === void 0 ? amount : asked.amount;
811
- const signature = _chunkXKSO2V5Icjs.meterAt.call(void 0, 0, _chunkXKSO2V5Icjs.toMeterData.call(void 0, _nullishCoalesce(_optionalChain([asked, 'optionalAccess', _7 => _7.ts]), () => ( FIGURE_TS)), "ts"));
812
- _chunkXKSO2V5Icjs.assertRange.call(void 0, dial, 0, 1, "syncopate amount");
811
+ const signature = _chunkS5BKZZGMcjs.meterAt.call(void 0, 0, _chunkS5BKZZGMcjs.toMeterData.call(void 0, _nullishCoalesce(_optionalChain([asked, 'optionalAccess', _7 => _7.ts]), () => ( FIGURE_TS)), "ts"));
812
+ _chunkS5BKZZGMcjs.assertRange.call(void 0, dial, 0, 1, "syncopate amount");
813
813
  const occupied = new Set(figure.map((event) => `${streamOf(event)}@${event.step}`));
814
814
  const out = [...figure];
815
815
  for (const event of figure) {
@@ -826,10 +826,10 @@ function syncopate(events, amount, draw, ...path) {
826
826
  }
827
827
  function ornamentBy(events, isOrnament, amount, draw, ...path) {
828
828
  const figure = assertGridEvents(events);
829
- const marks = _chunkXKSO2V5Icjs.assertFunction.call(void 0, isOrnament, "isOrnament");
829
+ const marks = _chunkS5BKZZGMcjs.assertFunction.call(void 0, isOrnament, "isOrnament");
830
830
  const sampler = assertDraw(draw);
831
831
  assertSeedPath(path);
832
- _chunkXKSO2V5Icjs.assertRange.call(void 0, amount, 0, 1, "ornament amount");
832
+ _chunkS5BKZZGMcjs.assertRange.call(void 0, amount, 0, 1, "ornament amount");
833
833
  return figure.filter(
834
834
  (event) => !marks(event) || sampler.prob(amount, ...path, "ornament", event.step)
835
835
  );
@@ -837,14 +837,14 @@ function ornamentBy(events, isOrnament, amount, draw, ...path) {
837
837
  var NEUTRAL_RHYTHMIC = 0.5;
838
838
  function deform(events, opts, draw, ...path) {
839
839
  const figure = assertGridEvents(events);
840
- const asked = _chunkXKSO2V5Icjs.assertRecord.call(void 0, opts, "opts");
840
+ const asked = _chunkS5BKZZGMcjs.assertRecord.call(void 0, opts, "opts");
841
841
  assertDraw(draw);
842
842
  assertSeedPath(path);
843
843
  const spanSteps = assertSpanSteps(asked.spanSteps === void 0 ? BAR_STEPS : asked.spanSteps);
844
844
  const ts = _nullishCoalesce(asked.ts, () => ( FIGURE_TS));
845
845
  let out = asked.rate === "half" ? halfTime(figure, spanSteps) : asked.rate === "double" ? doubleTime(figure, spanSteps) : [...figure];
846
846
  if (asked.rhythmic !== void 0) {
847
- const rhythmic = _chunkXKSO2V5Icjs.assertRange.call(void 0, asked.rhythmic, 0, 1, "complexity rhythmic");
847
+ const rhythmic = _chunkS5BKZZGMcjs.assertRange.call(void 0, asked.rhythmic, 0, 1, "complexity rhythmic");
848
848
  if (rhythmic < NEUTRAL_RHYTHMIC) {
849
849
  out = thin(out, (NEUTRAL_RHYTHMIC - rhythmic) / NEUTRAL_RHYTHMIC, ts);
850
850
  } else if (rhythmic > NEUTRAL_RHYTHMIC) {
@@ -857,7 +857,7 @@ function deform(events, opts, draw, ...path) {
857
857
  }
858
858
  }
859
859
  if (asked.ornament !== void 0 && asked.isOrnament) {
860
- const isOrnament = _chunkXKSO2V5Icjs.assertFunction.call(void 0, asked.isOrnament, "opts.isOrnament");
860
+ const isOrnament = _chunkS5BKZZGMcjs.assertFunction.call(void 0, asked.isOrnament, "opts.isOrnament");
861
861
  out = ornamentBy(out, (event) => isOrnament(event), asked.ornament, draw, ...path);
862
862
  }
863
863
  return out.sort((a, b) => a.step - b.step);
@@ -867,7 +867,7 @@ function withinCeiling(events, bpm, difficulty) {
867
867
  if (difficulty === void 0 || bpm === void 0) {
868
868
  return true;
869
869
  }
870
- _chunkXKSO2V5Icjs.assertFiniteNumber.call(void 0, bpm, "bpm");
870
+ _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, bpm, "bpm");
871
871
  assertDifficulty(difficulty);
872
872
  if (figure.length < 2) {
873
873
  return true;
@@ -905,8 +905,8 @@ function impliedScaleTones(chord) {
905
905
  if (chordDegreeSemitone(7, chord) === void 0) {
906
906
  return void 0;
907
907
  }
908
- for (const match of _chunkR7B5N2JKcjs.chordScales.call(void 0, chord)) {
909
- const mask = _chunkYPB3A3EYcjs.namedScaleMask.call(void 0, match.name);
908
+ for (const match of _chunkPM4XJE2Ycjs.chordScales.call(void 0, chord)) {
909
+ const mask = _chunk3R3QVKY5cjs.namedScaleMask.call(void 0, match.name);
910
910
  if (mask === void 0) {
911
911
  continue;
912
912
  }
@@ -926,7 +926,7 @@ function replacedDegreeSemitone(degree, chord) {
926
926
  if (degree !== 3) {
927
927
  return void 0;
928
928
  }
929
- const sounds = (semitones) => chord.intervals.some((interval) => _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, interval) === semitones);
929
+ const sounds = (semitones) => chord.intervals.some((interval) => _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, interval) === semitones);
930
930
  if (sounds(3) || sounds(4)) {
931
931
  return void 0;
932
932
  }
@@ -938,12 +938,12 @@ function degreeSemitone(degree, alter, chord, key, implied) {
938
938
  const template = _nullishCoalesce(MAJOR_DEGREE_SEMITONES[within - 1], () => ( 0));
939
939
  const semitone = alter !== 0 ? template : _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(chordDegreeSemitone(within, chord), () => ( replacedDegreeSemitone(within, chord))), () => ( _optionalChain([implied, 'optionalAccess', _8 => _8[within - 1]]))), () => ( // A degree neither the chord nor its quality settles is a passing tone,
940
940
  // so the key decides it.
941
- _chunkYPB3A3EYcjs.nearestScaleTone.call(void 0, chord.rootPc + template, key) - chord.rootPc));
942
- return _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, semitone) + 12 * octaves + alter;
941
+ _chunk3R3QVKY5cjs.nearestScaleTone.call(void 0, chord.rootPc + template, key) - chord.rootPc));
942
+ return _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, semitone) + 12 * octaves + alter;
943
943
  }
944
944
  function chordDegreeSemitone(degree, chord) {
945
945
  for (const interval of chord.intervals) {
946
- if (_chunkYPB3A3EYcjs.degreeOfInterval.call(void 0, interval, chord) === degree) {
946
+ if (_chunk3R3QVKY5cjs.degreeOfInterval.call(void 0, interval, chord) === degree) {
947
947
  return interval;
948
948
  }
949
949
  }
@@ -1173,28 +1173,28 @@ var BASS_LICKS = deepFreeze([
1173
1173
  var DEFAULT_BPM = 120;
1174
1174
  var DEFAULT_LICK_DENSITY = 0.6;
1175
1175
  function placeLicks(timeline, key, opts) {
1176
- const asked = _chunkXKSO2V5Icjs.assertRecord.call(void 0, opts, "opts");
1177
- const placement = _chunkXKSO2V5Icjs.assertArray.call(void 0,
1176
+ const asked = _chunkS5BKZZGMcjs.assertRecord.call(void 0, opts, "opts");
1177
+ const placement = _chunkS5BKZZGMcjs.assertArray.call(void 0,
1178
1178
  timeline,
1179
1179
  "timeline"
1180
1180
  );
1181
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, placement.length, "lick segments", asked.budget);
1182
- const genre = _chunkXKSO2V5Icjs.assertOneOf.call(void 0, asked.genre, GENRES, "lick genre");
1183
- const ts = _chunkXKSO2V5Icjs.meterAt.call(void 0, 0, _chunkXKSO2V5Icjs.toMeterData.call(void 0, _nullishCoalesce(asked.ts, () => ( DEFAULT_TS)), "ts"));
1181
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, placement.length, "lick segments", asked.budget);
1182
+ const genre = _chunkS5BKZZGMcjs.assertOneOf.call(void 0, asked.genre, GENRES, "lick genre");
1183
+ const ts = _chunkS5BKZZGMcjs.meterAt.call(void 0, 0, _chunkS5BKZZGMcjs.toMeterData.call(void 0, _nullishCoalesce(asked.ts, () => ( DEFAULT_TS)), "ts"));
1184
1184
  const octave = _nullishCoalesce(asked.octave, () => ( DEFAULT_OCTAVE));
1185
- _chunkXKSO2V5Icjs.assertInteger.call(void 0, octave, "lick octave", -1, 8);
1186
- const scale = _chunkYPB3A3EYcjs.toKeyScale.call(void 0, key);
1187
- const segments = placement.map((segment) => ({ ...segment, chord: _chunkYPB3A3EYcjs.toChordData.call(void 0, segment.chord) })).sort((a, b) => a.startBeat - b.startBeat);
1185
+ _chunkS5BKZZGMcjs.assertInteger.call(void 0, octave, "lick octave", -1, 8);
1186
+ const scale = _chunk3R3QVKY5cjs.toKeyScale.call(void 0, key);
1187
+ const segments = placement.map((segment) => ({ ...segment, chord: _chunk3R3QVKY5cjs.toChordData.call(void 0, segment.chord) })).sort((a, b) => a.startBeat - b.startBeat);
1188
1188
  assertBassSegments(segments);
1189
1189
  if (segments.length === 0) {
1190
1190
  return [];
1191
1191
  }
1192
- const barBeats = _chunkXKSO2V5Icjs.beatsPerBar.call(void 0, ts);
1192
+ const barBeats = _chunkS5BKZZGMcjs.beatsPerBar.call(void 0, ts);
1193
1193
  const estimatedBars = segments.reduce(
1194
1194
  (count, segment) => count + Math.max(1, Math.ceil((segment.endBeat - segment.startBeat) / barBeats)),
1195
1195
  0
1196
1196
  );
1197
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, estimatedBars, "lick bars", asked.budget);
1197
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, estimatedBars, "lick bars", asked.budget);
1198
1198
  const resolved = resolveContext(asked.ctx);
1199
1199
  const draw = resolved.part("bass");
1200
1200
  const bpm = _nullishCoalesce(resolved.bpm, () => ( DEFAULT_BPM));
@@ -1254,7 +1254,7 @@ function placeLicks(timeline, key, opts) {
1254
1254
  }
1255
1255
  raw.push({ startBeat: rootAt, pitch: rootMidi, velocity: STRONG_VELOCITY });
1256
1256
  if (notes) {
1257
- const figureRoot = segment.chord.bassPc === void 0 ? placePc(_chunkXKSO2V5Icjs.pitchClassOf.call(void 0, segment.chord.rootPc), rootMidi, low) : placeAboveBass(_chunkXKSO2V5Icjs.pitchClassOf.call(void 0, segment.chord.rootPc), rootMidi);
1257
+ const figureRoot = segment.chord.bassPc === void 0 ? placePc(_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, segment.chord.rootPc), rootMidi, low) : placeAboveBass(_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, segment.chord.rootPc), rootMidi);
1258
1258
  for (const lickNote of notes) {
1259
1259
  const at2 = tileStart + lickNote.step * STEP_BEATS;
1260
1260
  const offset = degreeSemitone(
@@ -1264,12 +1264,12 @@ function placeLicks(timeline, key, opts) {
1264
1264
  scale,
1265
1265
  implied
1266
1266
  );
1267
- const pitch = Math.abs(at2 - rootAt) < _chunkXKSO2V5Icjs.BEAT_EPS && lickNote.degree === 1 && (_nullishCoalesce(lickNote.alter, () => ( 0))) === 0 ? rootMidi : figureRoot + offset;
1267
+ const pitch = Math.abs(at2 - rootAt) < _chunkS5BKZZGMcjs.BEAT_EPS && lickNote.degree === 1 && (_nullishCoalesce(lickNote.alter, () => ( 0))) === 0 ? rootMidi : figureRoot + offset;
1268
1268
  raw.push({
1269
1269
  startBeat: at2,
1270
1270
  pitch,
1271
1271
  velocity: Math.round(
1272
- (_chunkXKSO2V5Icjs.isStrongBeat.call(void 0, at2, ts) ? STRONG_VELOCITY : WEAK_VELOCITY) * lickNote.velocity
1272
+ (_chunkS5BKZZGMcjs.isStrongBeat.call(void 0, at2, ts) ? STRONG_VELOCITY : WEAK_VELOCITY) * lickNote.velocity
1273
1273
  ),
1274
1274
  note: lickNote
1275
1275
  });
@@ -1280,7 +1280,7 @@ function placeLicks(timeline, key, opts) {
1280
1280
  if (next && lastTilePlayed) {
1281
1281
  const lastBeat = next.startBeat - STEP_BEATS * BEAT_STEPS;
1282
1282
  const approachAt = _nullishCoalesce(materialOnsetIn(playedTile, lastBeat, next.startBeat), () => ( lastBeat));
1283
- if (approachAt > firstOnset + _chunkXKSO2V5Icjs.BEAT_EPS) {
1283
+ if (approachAt > firstOnset + _chunkS5BKZZGMcjs.BEAT_EPS) {
1284
1284
  const nextRoot = placeRoot(bassPcOf(next.chord), low);
1285
1285
  const occupied = soundingAt(raw, approachAt);
1286
1286
  const distance = occupied === void 0 ? 0 : Math.abs(occupied.pitch - nextRoot);
@@ -1310,12 +1310,12 @@ function placeLicks(timeline, key, opts) {
1310
1310
  nextStart - item.startBeat,
1311
1311
  written === void 0 ? Number.POSITIVE_INFINITY : written * STEP_BEATS
1312
1312
  );
1313
- if (durationBeat <= _chunkXKSO2V5Icjs.BEAT_EPS) {
1313
+ if (durationBeat <= _chunkS5BKZZGMcjs.BEAT_EPS) {
1314
1314
  continue;
1315
1315
  }
1316
- const placed = instrument ? _chunkJ772DL3Bcjs.foldIntoRange.call(void 0, item.pitch, instrument) : item.pitch;
1316
+ const placed = instrument ? _chunkCGBADIO5cjs.foldIntoRange.call(void 0, item.pitch, instrument) : item.pitch;
1317
1317
  const event = {
1318
- pitch: _chunkXKSO2V5Icjs.clampToMidi.call(void 0, placed, "generated bass pitch"),
1318
+ pitch: _chunkS5BKZZGMcjs.clampToMidi.call(void 0, placed, "generated bass pitch"),
1319
1319
  startBeat: item.startBeat,
1320
1320
  durationBeat,
1321
1321
  velocity: Math.max(1, Math.min(127, item.velocity))
@@ -1330,7 +1330,7 @@ function placeLicks(timeline, key, opts) {
1330
1330
  function soundingAt(raw, at2) {
1331
1331
  for (let index = raw.length - 1; index >= 0; index -= 1) {
1332
1332
  const item = raw[index];
1333
- if (item !== void 0 && Math.abs(item.startBeat - at2) < _chunkXKSO2V5Icjs.BEAT_EPS) {
1333
+ if (item !== void 0 && Math.abs(item.startBeat - at2) < _chunkS5BKZZGMcjs.BEAT_EPS) {
1334
1334
  return item;
1335
1335
  }
1336
1336
  }
@@ -1343,7 +1343,7 @@ function materialOnsetIn(played, from, to) {
1343
1343
  let last;
1344
1344
  for (const note2 of played.material.notes) {
1345
1345
  const at2 = played.tileStart + note2.step * STEP_BEATS;
1346
- if (at2 < from - _chunkXKSO2V5Icjs.BEAT_EPS || at2 > to - _chunkXKSO2V5Icjs.BEAT_EPS) {
1346
+ if (at2 < from - _chunkS5BKZZGMcjs.BEAT_EPS || at2 > to - _chunkS5BKZZGMcjs.BEAT_EPS) {
1347
1347
  continue;
1348
1348
  }
1349
1349
  last = last === void 0 ? at2 : Math.max(last, at2);
@@ -1353,7 +1353,7 @@ function materialOnsetIn(played, from, to) {
1353
1353
  function lastPitchBefore(raw, at2, fallback) {
1354
1354
  for (let index = raw.length - 1; index >= 0; index -= 1) {
1355
1355
  const item = raw[index];
1356
- if (item !== void 0 && item.startBeat < at2 - _chunkXKSO2V5Icjs.BEAT_EPS) {
1356
+ if (item !== void 0 && item.startBeat < at2 - _chunkS5BKZZGMcjs.BEAT_EPS) {
1357
1357
  return item.pitch;
1358
1358
  }
1359
1359
  }
@@ -1366,7 +1366,7 @@ function anchorStepOf(material, spanBeats) {
1366
1366
  first = note2.step;
1367
1367
  }
1368
1368
  }
1369
- if (first === void 0 || first < 0 || first * STEP_BEATS >= spanBeats - _chunkXKSO2V5Icjs.BEAT_EPS) {
1369
+ if (first === void 0 || first < 0 || first * STEP_BEATS >= spanBeats - _chunkS5BKZZGMcjs.BEAT_EPS) {
1370
1370
  return 0;
1371
1371
  }
1372
1372
  return first;
@@ -1393,7 +1393,7 @@ function fitToSegment(material, spanBeats, density, resolved, draw, path, bpm, d
1393
1393
  ...path
1394
1394
  );
1395
1395
  const spanSteps = spanBeats / STEP_BEATS;
1396
- const inside = deformed.filter((lickNote) => lickNote.step < spanSteps - _chunkXKSO2V5Icjs.BEAT_EPS);
1396
+ const inside = deformed.filter((lickNote) => lickNote.step < spanSteps - _chunkS5BKZZGMcjs.BEAT_EPS);
1397
1397
  if (inside.length === 0 || !withinCeiling(inside, bpm, difficulty)) {
1398
1398
  return void 0;
1399
1399
  }
@@ -1411,15 +1411,15 @@ var BASS_STYLES = Object.freeze([
1411
1411
  var DEFAULT_STYLE = "root";
1412
1412
  var DEFAULT_PICKUP_DENSITY = 0.35;
1413
1413
  function sounding(ctx, placed) {
1414
- return ctx.instrument ? _chunkJ772DL3Bcjs.foldIntoRange.call(void 0, placed, ctx.instrument) : placed;
1414
+ return ctx.instrument ? _chunkCGBADIO5cjs.foldIntoRange.call(void 0, placed, ctx.instrument) : placed;
1415
1415
  }
1416
1416
  function placeTone(ctx, pc) {
1417
1417
  return ctx.overBass ? placeAboveBass(pc, ctx.rootMidi) : placePc(pc, ctx.rootMidi, ctx.low);
1418
1418
  }
1419
1419
  function emit(ctx, pos, pc, midiOverride) {
1420
- const placed = _chunkXKSO2V5Icjs.clampToMidi.call(void 0, _nullishCoalesce(midiOverride, () => ( placeTone(ctx, pc))), "generated bass pitch");
1420
+ const placed = _chunkS5BKZZGMcjs.clampToMidi.call(void 0, _nullishCoalesce(midiOverride, () => ( placeTone(ctx, pc))), "generated bass pitch");
1421
1421
  const midi = sounding(ctx, placed);
1422
- const velocity = _chunkXKSO2V5Icjs.isStrongBeat.call(void 0, pos, ctx.ts) ? STRONG_VELOCITY : WEAK_VELOCITY;
1422
+ const velocity = _chunkS5BKZZGMcjs.isStrongBeat.call(void 0, pos, ctx.ts) ? STRONG_VELOCITY : WEAK_VELOCITY;
1423
1423
  ctx.notes.push({ startBeat: pos, pitch: midi, velocity });
1424
1424
  ctx.prevMidi = midi;
1425
1425
  return midi;
@@ -1431,7 +1431,7 @@ function buildRootFifth(ctx, seg) {
1431
1431
  for (const tile of barTiles(seg.startBeat, seg.endBeat, ctx.ts)) {
1432
1432
  emit(ctx, tile.startBeat, bassPcOf(seg.chord));
1433
1433
  const answer = midBarPulse(tile.startBeat, ctx.ts);
1434
- if (answer > tile.startBeat + _chunkXKSO2V5Icjs.BEAT_EPS && answer < tile.endBeat - _chunkXKSO2V5Icjs.BEAT_EPS) {
1434
+ if (answer > tile.startBeat + _chunkS5BKZZGMcjs.BEAT_EPS && answer < tile.endBeat - _chunkS5BKZZGMcjs.BEAT_EPS) {
1435
1435
  emit(ctx, answer, fifthPcOf2(seg.chord));
1436
1436
  }
1437
1437
  }
@@ -1441,7 +1441,7 @@ function buildPop(ctx, seg, index) {
1441
1441
  const rootPc = bassPcOf(seg.chord);
1442
1442
  let emitted = false;
1443
1443
  for (const pos of positions) {
1444
- if (_chunkXKSO2V5Icjs.isStrongBeat.call(void 0, pos, ctx.ts)) {
1444
+ if (_chunkS5BKZZGMcjs.isStrongBeat.call(void 0, pos, ctx.ts)) {
1445
1445
  emit(ctx, pos, rootPc);
1446
1446
  emitted = true;
1447
1447
  } else if (ctx.draw.prob(ctx.pickupDensity, "pickup", index, pos)) {
@@ -1502,7 +1502,7 @@ function buildWalking(ctx, seg, next, index) {
1502
1502
  if (next && count > 1 && i === count - 1) {
1503
1503
  const nextBass = placeRoot(bassPcOf(next.chord), ctx.low);
1504
1504
  const midi = approachNote2(ctx, nextBass, ctx.prevMidi, index);
1505
- emit(ctx, pos, _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, midi), midi);
1505
+ emit(ctx, pos, _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, midi), midi);
1506
1506
  return;
1507
1507
  }
1508
1508
  const pc = _nullishCoalesce(tones[i % tones.length], () => ( bassPcOf(seg.chord)));
@@ -1510,29 +1510,29 @@ function buildWalking(ctx, seg, next, index) {
1510
1510
  });
1511
1511
  }
1512
1512
  function generateBassLine(opts) {
1513
- _chunkXKSO2V5Icjs.assertRecord.call(void 0, opts, "bass line options");
1514
- _chunkXKSO2V5Icjs.assertArray.call(void 0, opts.segments, "bass segments");
1515
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, opts.segments.length, "bass segments", opts.budget);
1516
- const segments = opts.segments.map((segment) => ({ ...segment, chord: _chunkYPB3A3EYcjs.toChordData.call(void 0, segment.chord) })).sort((a, b) => a.startBeat - b.startBeat);
1513
+ _chunkS5BKZZGMcjs.assertRecord.call(void 0, opts, "bass line options");
1514
+ _chunkS5BKZZGMcjs.assertArray.call(void 0, opts.segments, "bass segments");
1515
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, opts.segments.length, "bass segments", opts.budget);
1516
+ const segments = opts.segments.map((segment) => ({ ...segment, chord: _chunk3R3QVKY5cjs.toChordData.call(void 0, segment.chord) })).sort((a, b) => a.startBeat - b.startBeat);
1517
1517
  assertBassSegments(segments);
1518
1518
  if (segments.length === 0) {
1519
1519
  return [];
1520
1520
  }
1521
- const ts = _chunkXKSO2V5Icjs.meterAt.call(void 0, 0, _chunkXKSO2V5Icjs.toMeterData.call(void 0, _nullishCoalesce(opts.ts, () => ( DEFAULT_TS)), "ts"));
1522
- const style = _chunkXKSO2V5Icjs.assertOneOf.call(void 0, _nullishCoalesce(opts.style, () => ( DEFAULT_STYLE)), BASS_STYLES, "bass style");
1521
+ const ts = _chunkS5BKZZGMcjs.meterAt.call(void 0, 0, _chunkS5BKZZGMcjs.toMeterData.call(void 0, _nullishCoalesce(opts.ts, () => ( DEFAULT_TS)), "ts"));
1522
+ const style = _chunkS5BKZZGMcjs.assertOneOf.call(void 0, _nullishCoalesce(opts.style, () => ( DEFAULT_STYLE)), BASS_STYLES, "bass style");
1523
1523
  const octave = _nullishCoalesce(opts.octave, () => ( DEFAULT_OCTAVE));
1524
- _chunkXKSO2V5Icjs.assertInteger.call(void 0, octave, "bass octave", -1, 8);
1524
+ _chunkS5BKZZGMcjs.assertInteger.call(void 0, octave, "bass octave", -1, 8);
1525
1525
  const estimatedNotes = segments.reduce(
1526
1526
  (count, segment) => count + Math.max(1, Math.ceil(segment.endBeat - segment.startBeat)),
1527
1527
  0
1528
1528
  );
1529
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, estimatedNotes, "bass notes", opts.budget);
1529
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, estimatedNotes, "bass notes", opts.budget);
1530
1530
  const resolved = resolveContext(opts.ctx);
1531
1531
  const { instrument, low } = bassRegister(resolved.instrument("bass"), opts.instrument, octave);
1532
1532
  const ctx = {
1533
1533
  ts,
1534
1534
  low,
1535
- key: _chunkYPB3A3EYcjs.toKeyScale.call(void 0, opts.key),
1535
+ key: _chunk3R3QVKY5cjs.toKeyScale.call(void 0, opts.key),
1536
1536
  draw: resolved.part("bass"),
1537
1537
  notes: [],
1538
1538
  rootMidi: low,
@@ -1578,11 +1578,11 @@ function generateBassLine(opts) {
1578
1578
  }
1579
1579
  const nextStart = _nullishCoalesce(_optionalChain([ctx, 'access', _17 => _17.notes, 'access', _18 => _18[i + 1], 'optionalAccess', _19 => _19.startBeat]), () => ( lastEnd));
1580
1580
  const durationBeat = nextStart - note2.startBeat;
1581
- if (durationBeat <= _chunkXKSO2V5Icjs.BEAT_EPS) {
1581
+ if (durationBeat <= _chunkS5BKZZGMcjs.BEAT_EPS) {
1582
1582
  continue;
1583
1583
  }
1584
1584
  out.push({
1585
- pitch: _chunkXKSO2V5Icjs.clampToMidi.call(void 0, note2.pitch, "generated bass pitch"),
1585
+ pitch: _chunkS5BKZZGMcjs.clampToMidi.call(void 0, note2.pitch, "generated bass pitch"),
1586
1586
  startBeat: note2.startBeat,
1587
1587
  durationBeat,
1588
1588
  velocity: note2.velocity
@@ -1599,31 +1599,31 @@ function degreesOf(interval) {
1599
1599
  }
1600
1600
  function assertPlayable(pitch) {
1601
1601
  if (pitch < 0 || pitch > 127) {
1602
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(`imitated pitch ${pitch} is outside the MIDI range 0..127`);
1602
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`imitated pitch ${pitch} is outside the MIDI range 0..127`);
1603
1603
  }
1604
1604
  return pitch;
1605
1605
  }
1606
1606
  function imitate(lead, opts) {
1607
- _chunkXKSO2V5Icjs.assertNoteEvents.call(void 0, lead, "imitate lead", { allowNonPositiveDuration: true });
1608
- _chunkXKSO2V5Icjs.assertRecord.call(void 0, opts, "opts");
1609
- _chunkXKSO2V5Icjs.assertFiniteNumber.call(void 0, opts.atBeat, "atBeat");
1610
- const interval = _chunkXKSO2V5Icjs.toSpelledInterval.call(void 0, opts.interval);
1611
- const key = _chunkYPB3A3EYcjs.toKeyScale.call(void 0, opts.key);
1607
+ _chunkS5BKZZGMcjs.assertNoteEvents.call(void 0, lead, "imitate lead", { allowNonPositiveDuration: true });
1608
+ _chunkS5BKZZGMcjs.assertRecord.call(void 0, opts, "opts");
1609
+ _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, opts.atBeat, "atBeat");
1610
+ const interval = _chunkS5BKZZGMcjs.toSpelledInterval.call(void 0, opts.interval);
1611
+ const key = _chunk3R3QVKY5cjs.toKeyScale.call(void 0, opts.key);
1612
1612
  const from = _nullishCoalesce(opts.from, () => ( Number.NEGATIVE_INFINITY));
1613
1613
  const to = _nullishCoalesce(opts.to, () => ( Number.POSITIVE_INFINITY));
1614
1614
  if (opts.from !== void 0) {
1615
- _chunkXKSO2V5Icjs.assertFiniteNumber.call(void 0, opts.from, "from");
1615
+ _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, opts.from, "from");
1616
1616
  }
1617
1617
  if (opts.to !== void 0) {
1618
- _chunkXKSO2V5Icjs.assertFiniteNumber.call(void 0, opts.to, "to");
1618
+ _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, opts.to, "to");
1619
1619
  }
1620
1620
  if (from > to) {
1621
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(`imitate needs from <= to; received ${from} > ${to}`);
1621
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`imitate needs from <= to; received ${from} > ${to}`);
1622
1622
  }
1623
1623
  const velocityScale = _nullishCoalesce(opts.velocityScale, () => ( 1));
1624
- _chunkXKSO2V5Icjs.assertFiniteNumber.call(void 0, velocityScale, "velocityScale");
1625
- const tonal = _chunkXKSO2V5Icjs.assertOneOf.call(void 0, _nullishCoalesce(opts.answer, () => ( "real")), IMITATION_ANSWERS, "imitate answer") === "tonal";
1626
- const subject = _chunkXKSO2V5Icjs.dropSilentNotes.call(void 0, lead).filter((note2) => note2.startBeat >= from && note2.startBeat < to).sort((a, b) => a.startBeat - b.startBeat);
1624
+ _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, velocityScale, "velocityScale");
1625
+ const tonal = _chunkS5BKZZGMcjs.assertOneOf.call(void 0, _nullishCoalesce(opts.answer, () => ( "real")), IMITATION_ANSWERS, "imitate answer") === "tonal";
1626
+ const subject = _chunkS5BKZZGMcjs.dropSilentNotes.call(void 0, lead).filter((note2) => note2.startBeat >= from && note2.startBeat < to).sort((a, b) => a.startBeat - b.startBeat);
1627
1627
  const origin = _optionalChain([subject, 'access', _20 => _20[0], 'optionalAccess', _21 => _21.startBeat]);
1628
1628
  const pivot = _optionalChain([subject, 'access', _22 => _22[0], 'optionalAccess', _23 => _23.pitch]);
1629
1629
  if (origin === void 0 || pivot === void 0) {
@@ -1637,14 +1637,14 @@ function imitate(lead, opts) {
1637
1637
  let offset = 0;
1638
1638
  if (invert) {
1639
1639
  if (tonal) {
1640
- const here = _chunkYPB3A3EYcjs.scaleLadderPosition.call(void 0, pitch, key);
1641
- pitch = _chunkYPB3A3EYcjs.scaleLadderPitch.call(void 0, 2 * _chunkYPB3A3EYcjs.scaleLadderPosition.call(void 0, pivot, key).rung - here.rung, key);
1640
+ const here = _chunk3R3QVKY5cjs.scaleLadderPosition.call(void 0, pitch, key);
1641
+ pitch = _chunk3R3QVKY5cjs.scaleLadderPitch.call(void 0, 2 * _chunk3R3QVKY5cjs.scaleLadderPosition.call(void 0, pivot, key).rung - here.rung, key);
1642
1642
  offset = -here.offset;
1643
1643
  } else {
1644
1644
  pitch = 2 * pivot - pitch;
1645
1645
  }
1646
1646
  }
1647
- pitch = tonal ? _chunkYPB3A3EYcjs.shiftByScaleDegrees.call(void 0, pitch, degrees, key) + offset : pitch + Math.round(interval.semitones);
1647
+ pitch = tonal ? _chunk3R3QVKY5cjs.shiftByScaleDegrees.call(void 0, pitch, degrees, key) + offset : pitch + Math.round(interval.semitones);
1648
1648
  const answer = {
1649
1649
  ...note2,
1650
1650
  pitch: assertPlayable(pitch),
@@ -1669,7 +1669,7 @@ var DEFAULT_MELODY_VELOCITY = 96;
1669
1669
  var VELOCITY_DROP = 16;
1670
1670
  var TIE_BREAK_JITTER = 1e-6;
1671
1671
  function isWholeBeat(beat) {
1672
- return Math.abs(beat - Math.round(beat)) < _chunkXKSO2V5Icjs.BEAT_EPS;
1672
+ return Math.abs(beat - Math.round(beat)) < _chunkS5BKZZGMcjs.BEAT_EPS;
1673
1673
  }
1674
1674
  function melodyNoteAt(melody, beat) {
1675
1675
  return _optionalChain([melody, 'access', _24 => _24.at, 'call', _25 => _25(beat), 'optionalAccess', _26 => _26.note]);
@@ -1682,8 +1682,8 @@ function melodySnapshotAt(melody, beat) {
1682
1682
  if (current === void 0) {
1683
1683
  return void 0;
1684
1684
  }
1685
- const attacked = Math.abs(current.startBeat - beat) < _chunkXKSO2V5Icjs.BEAT_EPS;
1686
- const previous = attacked ? melodyNoteAt(melody, beat - _chunkXKSO2V5Icjs.BEAT_EPS * 2) : current;
1685
+ const attacked = Math.abs(current.startBeat - beat) < _chunkS5BKZZGMcjs.BEAT_EPS;
1686
+ const previous = attacked ? melodyNoteAt(melody, beat - _chunkS5BKZZGMcjs.BEAT_EPS * 2) : current;
1687
1687
  const snapshot = { pitch: current.pitch };
1688
1688
  if (previous !== void 0) {
1689
1689
  snapshot.prevPitch = previous.pitch;
@@ -1699,7 +1699,7 @@ function complementOnsets(melody, ts, spanStart, spanEnd, draw) {
1699
1699
  const onsets = [];
1700
1700
  const gridStart = Math.floor(spanStart / GRID_STEP) * GRID_STEP;
1701
1701
  let last = Number.NEGATIVE_INFINITY;
1702
- for (let beat = gridStart; beat < spanEnd - _chunkXKSO2V5Icjs.BEAT_EPS; beat += GRID_STEP) {
1702
+ for (let beat = gridStart; beat < spanEnd - _chunkS5BKZZGMcjs.BEAT_EPS; beat += GRID_STEP) {
1703
1703
  const attacked = melodyAttacksAt(melody, beat);
1704
1704
  const sounding2 = melodyNoteAt(melody, beat) !== void 0;
1705
1705
  let place = false;
@@ -1707,10 +1707,10 @@ function complementOnsets(melody, ts, spanStart, spanEnd, draw) {
1707
1707
  place = isWholeBeat(beat);
1708
1708
  } else if (!attacked) {
1709
1709
  place = draw.prob(isWholeBeat(beat) ? HOLD_ON_BEAT_PROB : HOLD_OFF_BEAT_PROB, "hold", beat);
1710
- } else if (_chunkXKSO2V5Icjs.isStrongBeat.call(void 0, beat, ts)) {
1710
+ } else if (_chunkS5BKZZGMcjs.isStrongBeat.call(void 0, beat, ts)) {
1711
1711
  place = draw.prob(REINFORCE_PROB, "reinforce", beat);
1712
1712
  }
1713
- if (place && beat - last >= MIN_ONSET_GAP - _chunkXKSO2V5Icjs.BEAT_EPS) {
1713
+ if (place && beat - last >= MIN_ONSET_GAP - _chunkS5BKZZGMcjs.BEAT_EPS) {
1714
1714
  onsets.push(beat);
1715
1715
  last = beat;
1716
1716
  }
@@ -1731,12 +1731,12 @@ function assertWeightOverrides(overrides) {
1731
1731
  return;
1732
1732
  }
1733
1733
  if (typeof overrides !== "object" || overrides === null) {
1734
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(
1735
- `countermelody weights must be an object of weight overrides; received ${_chunkXKSO2V5Icjs.describeRejected.call(void 0, overrides)}`
1734
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
1735
+ `countermelody weights must be an object of weight overrides; received ${_chunkS5BKZZGMcjs.describeRejected.call(void 0, overrides)}`
1736
1736
  );
1737
1737
  }
1738
1738
  for (const [field, value] of Object.entries(overrides)) {
1739
- _chunkXKSO2V5Icjs.assertFiniteNumber.call(void 0, value, `countermelody weights.${field}`);
1739
+ _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, value, `countermelody weights.${field}`);
1740
1740
  }
1741
1741
  }
1742
1742
  function scoreCandidate(pitch, melPitch, melPrev, prevPitch, chord, center, weights) {
@@ -1751,7 +1751,7 @@ function scoreCandidate(pitch, melPitch, melPrev, prevPitch, chord, center, weig
1751
1751
  score += weights.dissonance;
1752
1752
  }
1753
1753
  }
1754
- if (chord && _chunkYPB3A3EYcjs.chordToneRole.call(void 0, pitch, chord) !== null) {
1754
+ if (chord && _chunk3R3QVKY5cjs.chordToneRole.call(void 0, pitch, chord) !== null) {
1755
1755
  score += weights.chordTone;
1756
1756
  }
1757
1757
  if (prevPitch !== void 0) {
@@ -1761,7 +1761,7 @@ function scoreCandidate(pitch, melPitch, melPrev, prevPitch, chord, center, weig
1761
1761
  if (dist > 0 && dist <= 2) {
1762
1762
  score += weights.stepwise;
1763
1763
  }
1764
- if (_chunkYPB3A3EYcjs.isForbiddenMelodicLeap.call(void 0, prevPitch, pitch)) {
1764
+ if (_chunk3R3QVKY5cjs.isForbiddenMelodicLeap.call(void 0, prevPitch, pitch)) {
1765
1765
  score += weights.forbiddenLeap;
1766
1766
  }
1767
1767
  if (melPitch !== void 0 && melPrev !== void 0 && ic !== void 0) {
@@ -1786,12 +1786,12 @@ function heldNoteBoundaries(melody, startBeat, endBeat, chordChangeBeats) {
1786
1786
  boundaries.add(onset);
1787
1787
  }
1788
1788
  for (const beat of chordChangeBeats) {
1789
- if (beat > startBeat + _chunkXKSO2V5Icjs.BEAT_EPS && beat < endBeat - _chunkXKSO2V5Icjs.BEAT_EPS) {
1789
+ if (beat > startBeat + _chunkS5BKZZGMcjs.BEAT_EPS && beat < endBeat - _chunkS5BKZZGMcjs.BEAT_EPS) {
1790
1790
  boundaries.add(beat);
1791
1791
  }
1792
1792
  }
1793
1793
  const firstGrid = Math.floor(startBeat / GRID_STEP + 1) * GRID_STEP;
1794
- for (let beat = firstGrid; beat < endBeat - _chunkXKSO2V5Icjs.BEAT_EPS; beat += GRID_STEP) {
1794
+ for (let beat = firstGrid; beat < endBeat - _chunkS5BKZZGMcjs.BEAT_EPS; beat += GRID_STEP) {
1795
1795
  boundaries.add(beat);
1796
1796
  }
1797
1797
  return [...boundaries].sort((a, b) => a - b);
@@ -1804,8 +1804,8 @@ function boundaryContexts(melody, harmony, startBeat, endBeat, ts) {
1804
1804
  melodyVoice,
1805
1805
  otherVoices: melodyVoice === void 0 ? [] : [melodyVoice],
1806
1806
  chord: harmony.chordAt(boundary),
1807
- strongBeat: _chunkXKSO2V5Icjs.isStrongBeat.call(void 0, boundary, ts),
1808
- atCounterOnset: Math.abs(boundary - startBeat) < _chunkXKSO2V5Icjs.BEAT_EPS
1807
+ strongBeat: _chunkS5BKZZGMcjs.isStrongBeat.call(void 0, boundary, ts),
1808
+ atCounterOnset: Math.abs(boundary - startBeat) < _chunkS5BKZZGMcjs.BEAT_EPS
1809
1809
  };
1810
1810
  });
1811
1811
  }
@@ -1816,7 +1816,7 @@ function heldPitchSafety(pitch, contexts, prevPitch, key, profile, register, low
1816
1816
  if (melodyVoice !== void 0 && (register === "below" && pitch >= melodyVoice.pitch || register === "above" && pitch <= melodyVoice.pitch)) {
1817
1817
  return null;
1818
1818
  }
1819
- const result = _chunkYPB3A3EYcjs.evaluateSafety.call(void 0,
1819
+ const result = _chunk3R3QVKY5cjs.evaluateSafety.call(void 0,
1820
1820
  {
1821
1821
  profile,
1822
1822
  candidatePitch: pitch,
@@ -1838,51 +1838,51 @@ function heldPitchSafety(pitch, contexts, prevPitch, key, profile, register, low
1838
1838
  return worst;
1839
1839
  }
1840
1840
  function generateCounterMelody(opts) {
1841
- _chunkXKSO2V5Icjs.assertRecord.call(void 0, opts, "countermelody options");
1841
+ _chunkS5BKZZGMcjs.assertRecord.call(void 0, opts, "countermelody options");
1842
1842
  const timeline = opts.timeline;
1843
1843
  const chordAt = timeline === void 0 ? opts.chordAt : (beat) => timeline.at(beat);
1844
1844
  if (chordAt === void 0) {
1845
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)("countermelody needs a timeline or a chordAt callback");
1845
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)("countermelody needs a timeline or a chordAt callback");
1846
1846
  }
1847
1847
  const chordChangeBeats = timeline === void 0 ? _nullishCoalesce(opts.chordChangeBeats, () => ( [])) : timeline.segments.flatMap((segment) => [segment.startBeat, segment.endBeat]);
1848
1848
  const register = _nullishCoalesce(opts.register, () => ( "below"));
1849
- _chunkXKSO2V5Icjs.assertNoteEvents.call(void 0, opts.melody, "countermelody melody", { allowNonPositiveDuration: true });
1850
- const melody = _chunkTT6PKMPRcjs.createNoteEventIndex.call(void 0, _chunkXKSO2V5Icjs.soundingNotesOnly.call(void 0, opts.melody), {
1849
+ _chunkS5BKZZGMcjs.assertNoteEvents.call(void 0, opts.melody, "countermelody melody", { allowNonPositiveDuration: true });
1850
+ const melody = _chunk35NBV2FTcjs.createNoteEventIndex.call(void 0, _chunkS5BKZZGMcjs.soundingNotesOnly.call(void 0, opts.melody), {
1851
1851
  tieBreak: register === "below" ? "highest" : "lowest"
1852
1852
  });
1853
- const ts = _chunkXKSO2V5Icjs.meterAt.call(void 0, 0, _chunkXKSO2V5Icjs.toMeterData.call(void 0, _nullishCoalesce(opts.ts, () => ( DEFAULT_TS2)), "ts"));
1854
- _chunkXKSO2V5Icjs.assertTimeSignature.call(void 0, ts);
1855
- const rhythm = _chunkXKSO2V5Icjs.assertOneOf.call(void 0, _nullishCoalesce(opts.rhythm, () => ( "complement")), ["complement", "follow"], "rhythm");
1856
- const profile = _chunkXKSO2V5Icjs.assertOneOf.call(void 0, _nullishCoalesce(opts.profile, () => ( "pop")), ["strict", "pop"], "safety profile");
1853
+ const ts = _chunkS5BKZZGMcjs.meterAt.call(void 0, 0, _chunkS5BKZZGMcjs.toMeterData.call(void 0, _nullishCoalesce(opts.ts, () => ( DEFAULT_TS2)), "ts"));
1854
+ _chunkS5BKZZGMcjs.assertTimeSignature.call(void 0, ts);
1855
+ const rhythm = _chunkS5BKZZGMcjs.assertOneOf.call(void 0, _nullishCoalesce(opts.rhythm, () => ( "complement")), ["complement", "follow"], "rhythm");
1856
+ const profile = _chunkS5BKZZGMcjs.assertOneOf.call(void 0, _nullishCoalesce(opts.profile, () => ( "pop")), ["strict", "pop"], "safety profile");
1857
1857
  assertWeightOverrides(opts.weights);
1858
- const weights = _chunkYPB3A3EYcjs.profileWeights.call(void 0, profile, opts.weights);
1859
- const key = _chunkYPB3A3EYcjs.toKeyScale.call(void 0, opts.key);
1858
+ const weights = _chunk3R3QVKY5cjs.profileWeights.call(void 0, profile, opts.weights);
1859
+ const key = _chunk3R3QVKY5cjs.toKeyScale.call(void 0, opts.key);
1860
1860
  const draw = resolveContext(opts.ctx).part("countermelody");
1861
1861
  if (melody.notes.length === 0) {
1862
1862
  return [];
1863
1863
  }
1864
1864
  const spanStart = _nullishCoalesce(_optionalChain([melody, 'access', _27 => _27.notes, 'access', _28 => _28[0], 'optionalAccess', _29 => _29.note, 'access', _30 => _30.startBeat]), () => ( 0));
1865
1865
  const spanEnd = melody.notes.reduce((end, n) => Math.max(end, n.endBeat), spanStart);
1866
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, Math.ceil((spanEnd - spanStart) / GRID_STEP), "countermelody grid");
1866
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, Math.ceil((spanEnd - spanStart) / GRID_STEP), "countermelody grid");
1867
1867
  const meanPitch = melody.notes.reduce((sum, n) => sum + n.note.pitch, 0) / melody.notes.length;
1868
1868
  const defaultCenter = register === "below" ? meanPitch - REGISTER_OFFSET : meanPitch + REGISTER_OFFSET;
1869
- const low = _chunkXKSO2V5Icjs.clampToMidi.call(void 0,
1869
+ const low = _chunkS5BKZZGMcjs.clampToMidi.call(void 0,
1870
1870
  _nullishCoalesce(opts.pitchLow, () => ( Math.round(defaultCenter) - DEFAULT_HALF_RANGE)),
1871
1871
  "countermelody pitchLow"
1872
1872
  );
1873
- const high = _chunkXKSO2V5Icjs.clampToMidi.call(void 0,
1873
+ const high = _chunkS5BKZZGMcjs.clampToMidi.call(void 0,
1874
1874
  _nullishCoalesce(opts.pitchHigh, () => ( Math.round(defaultCenter) + DEFAULT_HALF_RANGE)),
1875
1875
  "countermelody pitchHigh"
1876
1876
  );
1877
1877
  if (low > high) {
1878
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(
1878
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
1879
1879
  `countermelody pitchLow must not exceed pitchHigh; received ${low} > ${high}`
1880
1880
  );
1881
1881
  }
1882
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, high - low + 1, "countermelody pitch candidates");
1883
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, chordChangeBeats.length, "chord change beats");
1882
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, high - low + 1, "countermelody pitch candidates");
1883
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, chordChangeBeats.length, "chord change beats");
1884
1884
  for (let index = 0; index < chordChangeBeats.length; index += 1) {
1885
- _chunkXKSO2V5Icjs.assertRange.call(void 0,
1885
+ _chunkS5BKZZGMcjs.assertRange.call(void 0,
1886
1886
  _nullishCoalesce(chordChangeBeats[index], () => ( Number.NaN)),
1887
1887
  0,
1888
1888
  Number.MAX_SAFE_INTEGER,
@@ -1892,7 +1892,7 @@ function generateCounterMelody(opts) {
1892
1892
  const center = (low + high) / 2;
1893
1893
  const onsets = rhythm === "follow" ? followOnsets(melody) : complementOnsets(melody, ts, spanStart, spanEnd, draw);
1894
1894
  const boundaryEstimate = onsets.length + Math.ceil((spanEnd - spanStart) / GRID_STEP) + melody.notes.length + chordChangeBeats.length;
1895
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, boundaryEstimate * (high - low + 1), "countermelody search");
1895
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, boundaryEstimate * (high - low + 1), "countermelody search");
1896
1896
  const jitter = Array.from(
1897
1897
  { length: high - low + 1 },
1898
1898
  (_, index) => draw.at("jitter", index) * TIE_BREAK_JITTER
@@ -1913,14 +1913,14 @@ function generateCounterMelody(opts) {
1913
1913
  const contexts = boundaryContexts(melody, { chordAt, chordChangeBeats }, beat, endBeat, ts);
1914
1914
  const chord = _nullishCoalesce(_optionalChain([contexts, 'access', _33 => _33[0], 'optionalAccess', _34 => _34.chord]), () => ( chordAt(beat)));
1915
1915
  const otherVoices = melodyVoice !== void 0 ? [melodyVoice] : [];
1916
- const candidates = _chunkYPB3A3EYcjs.enumerateSafePitches.call(void 0,
1916
+ const candidates = _chunk3R3QVKY5cjs.enumerateSafePitches.call(void 0,
1917
1917
  {
1918
1918
  profile,
1919
1919
  prevPitch,
1920
1920
  chord,
1921
1921
  key,
1922
1922
  otherVoices,
1923
- strongBeat: _chunkXKSO2V5Icjs.isStrongBeat.call(void 0, beat, ts),
1923
+ strongBeat: _chunkS5BKZZGMcjs.isStrongBeat.call(void 0, beat, ts),
1924
1924
  vocalLow: low,
1925
1925
  vocalHigh: high
1926
1926
  },
@@ -1947,7 +1947,7 @@ function generateCounterMelody(opts) {
1947
1947
  if (melPitch !== void 0) {
1948
1948
  if (prevPitch !== void 0 && melPrev !== void 0 && // Parallel octaves are the perfect-class-zero case of this predicate,
1949
1949
  // so a single check covers both parallel fifths and octaves.
1950
- _chunkYPB3A3EYcjs.createsParallelPerfect.call(void 0, prevPitch, candidate, melPrev, melPitch)) {
1950
+ _chunk3R3QVKY5cjs.createsParallelPerfect.call(void 0, prevPitch, candidate, melPrev, melPitch)) {
1951
1951
  continue;
1952
1952
  }
1953
1953
  }
@@ -1969,7 +1969,7 @@ function generateCounterMelody(opts) {
1969
1969
  Math.min(127, Math.round((_nullishCoalesce(_optionalChain([melNote, 'optionalAccess', _35 => _35.velocity]), () => ( DEFAULT_MELODY_VELOCITY))) - VELOCITY_DROP))
1970
1970
  );
1971
1971
  out.push({
1972
- pitch: _chunkXKSO2V5Icjs.clampToMidi.call(void 0, pitch),
1972
+ pitch: _chunkS5BKZZGMcjs.clampToMidi.call(void 0, pitch),
1973
1973
  startBeat: beat,
1974
1974
  durationBeat: endBeat - beat,
1975
1975
  velocity
@@ -2566,10 +2566,10 @@ function generateHiHatForBeat(ctx, sec) {
2566
2566
 
2567
2567
  // src/generate/drums/euclid.ts
2568
2568
  function euclideanRhythm(pulses, steps, rotation = 0) {
2569
- _chunkXKSO2V5Icjs.assertPositiveInt.call(void 0, steps, "euclidean steps");
2570
- _chunkXKSO2V5Icjs.assertInteger.call(void 0, pulses, "euclidean pulses");
2571
- _chunkXKSO2V5Icjs.assertInteger.call(void 0, rotation, "euclidean rotation");
2572
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, steps, "euclidean pattern steps");
2569
+ _chunkS5BKZZGMcjs.assertPositiveInt.call(void 0, steps, "euclidean steps");
2570
+ _chunkS5BKZZGMcjs.assertInteger.call(void 0, pulses, "euclidean pulses");
2571
+ _chunkS5BKZZGMcjs.assertInteger.call(void 0, rotation, "euclidean rotation");
2572
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, steps, "euclidean pattern steps");
2573
2573
  const p = Math.max(0, Math.min(pulses, steps));
2574
2574
  const base = bjorklund(p, steps);
2575
2575
  const shift = (rotation % steps + steps) % steps;
@@ -2905,7 +2905,7 @@ function drumNoteOf(voice) {
2905
2905
  return Object.hasOwn(DRUM_NOTES, voice) ? DRUM_NOTES[voice] : void 0;
2906
2906
  }
2907
2907
  function drumVoiceOf(pitch) {
2908
- return VOICE_BY_NOTE.get(_chunkXKSO2V5Icjs.assertMidiPitch.call(void 0, pitch));
2908
+ return VOICE_BY_NOTE.get(_chunkS5BKZZGMcjs.assertMidiPitch.call(void 0, pitch));
2909
2909
  }
2910
2910
  var ONSET_KEY_SCALE = 128;
2911
2911
  var HitList = (_class = class {constructor() { _class.prototype.__init.call(this); }
@@ -3216,12 +3216,12 @@ var KIT_ARTICULATIONS = Object.freeze([
3216
3216
  var DRUM_KIT = Object.freeze({
3217
3217
  kind: "percussion",
3218
3218
  name: "drum kit",
3219
- limbs: _chunkJ772DL3Bcjs.LIMBS,
3219
+ limbs: _chunkCGBADIO5cjs.LIMBS,
3220
3220
  reach: deepFreeze(reachByNote()),
3221
3221
  overdub: deepFreeze(OVERDUB_VOICES.map((voice) => DRUM_NOTES[voice])),
3222
3222
  articulations: KIT_ARTICULATIONS,
3223
3223
  // One stroke per limb, and one more per voice dubbed over them.
3224
- polyphony: _chunkJ772DL3Bcjs.LIMBS.length + OVERDUB_VOICES.length
3224
+ polyphony: _chunkCGBADIO5cjs.LIMBS.length + OVERDUB_VOICES.length
3225
3225
  });
3226
3226
 
3227
3227
  // src/generate/drums/vocabulary.ts
@@ -3232,8 +3232,8 @@ function isDrumPattern(material) {
3232
3232
  function assertDrumPattern(material, label) {
3233
3233
  material.strokes.forEach((stroke, index) => {
3234
3234
  if (typeof stroke !== "object" || stroke === null || typeof stroke.voice !== "string" || drumNoteOf(stroke.voice) === void 0) {
3235
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(
3236
- `${label} strokes[${index}].voice must name a drum voice; received ${_chunkXKSO2V5Icjs.describeRejected.call(void 0, _optionalChain([stroke, 'optionalAccess', _44 => _44.voice]))}`
3235
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
3236
+ `${label} strokes[${index}].voice must name a drum voice; received ${_chunkS5BKZZGMcjs.describeRejected.call(void 0, _optionalChain([stroke, 'optionalAccess', _44 => _44.voice]))}`
3237
3237
  );
3238
3238
  }
3239
3239
  });
@@ -3425,21 +3425,21 @@ var DEFAULT_VELOCITY = 100;
3425
3425
  var DEFAULT_BPM2 = 120;
3426
3426
  var MAX_STROKES_PER_BAR = 64;
3427
3427
  function placeDrumPattern(opts) {
3428
- _chunkXKSO2V5Icjs.assertRecord.call(void 0, opts, "drum pattern options");
3429
- _chunkXKSO2V5Icjs.assertPositiveInt.call(void 0, opts.bars, "drum pattern bars");
3430
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, opts.bars * MAX_STROKES_PER_BAR, "drum pattern hits", opts.budget);
3431
- const genre = _chunkXKSO2V5Icjs.assertOneOf.call(void 0, opts.genre, GENRES, "drum pattern genre");
3432
- const section = opts.section === void 0 ? void 0 : _chunkXKSO2V5Icjs.assertOneOf.call(void 0, opts.section, PUBLIC_SECTIONS, "drum pattern section");
3433
- const ts = _chunkXKSO2V5Icjs.meterAt.call(void 0, 0, _chunkXKSO2V5Icjs.toMeterData.call(void 0, _nullishCoalesce(opts.ts, () => ( FOUR_FOUR2)), "ts"));
3428
+ _chunkS5BKZZGMcjs.assertRecord.call(void 0, opts, "drum pattern options");
3429
+ _chunkS5BKZZGMcjs.assertPositiveInt.call(void 0, opts.bars, "drum pattern bars");
3430
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, opts.bars * MAX_STROKES_PER_BAR, "drum pattern hits", opts.budget);
3431
+ const genre = _chunkS5BKZZGMcjs.assertOneOf.call(void 0, opts.genre, GENRES, "drum pattern genre");
3432
+ const section = opts.section === void 0 ? void 0 : _chunkS5BKZZGMcjs.assertOneOf.call(void 0, opts.section, PUBLIC_SECTIONS, "drum pattern section");
3433
+ const ts = _chunkS5BKZZGMcjs.meterAt.call(void 0, 0, _chunkS5BKZZGMcjs.toMeterData.call(void 0, _nullishCoalesce(opts.ts, () => ( FOUR_FOUR2)), "ts"));
3434
3434
  if (opts.velocity !== void 0) {
3435
- _chunkXKSO2V5Icjs.assertRange.call(void 0, opts.velocity, 1, 127, "drum pattern velocity");
3435
+ _chunkS5BKZZGMcjs.assertRange.call(void 0, opts.velocity, 1, 127, "drum pattern velocity");
3436
3436
  }
3437
- const feel = opts.feel === void 0 ? "straight" : _chunkXKSO2V5Icjs.assertOneOf.call(void 0, opts.feel, DRUM_FEELS, "feel");
3437
+ const feel = opts.feel === void 0 ? "straight" : _chunkS5BKZZGMcjs.assertOneOf.call(void 0, opts.feel, DRUM_FEELS, "feel");
3438
3438
  const resolved = resolveContext(opts.ctx);
3439
3439
  const bpm = _nullishCoalesce(resolved.bpm, () => ( DEFAULT_BPM2));
3440
3440
  const draw = resolved.part("drums");
3441
3441
  const baseVelocity = _nullishCoalesce(opts.velocity, () => ( DEFAULT_VELOCITY));
3442
- const barBeats = _chunkXKSO2V5Icjs.beatsPerBar.call(void 0, ts);
3442
+ const barBeats = _chunkS5BKZZGMcjs.beatsPerBar.call(void 0, ts);
3443
3443
  const kit = resolved.instrument("drums");
3444
3444
  const swing = effectiveSwing(feel, feelSwingAmount(feel));
3445
3445
  const supplied = vocabularyOfKind(resolved.vocabulary, isDrumPattern);
@@ -3448,8 +3448,8 @@ function placeDrumPattern(opts) {
3448
3448
  });
3449
3449
  const dictionary = mergeVocabulary(DRUM_PATTERNS, supplied);
3450
3450
  if (selectVocabulary(dictionary, { ts }).length === 0) {
3451
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(
3452
- `drum pattern ts names a meter no figure is written in: ${_chunkXKSO2V5Icjs.formatTimeSignature.call(void 0, ts)}. The built-in figures are written in 4/4; supply vocabulary in another meter through the context.`
3451
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
3452
+ `drum pattern ts names a meter no figure is written in: ${_chunkS5BKZZGMcjs.formatTimeSignature.call(void 0, ts)}. The built-in figures are written in 4/4; supply vocabulary in another meter through the context.`
3453
3453
  );
3454
3454
  }
3455
3455
  const track = new HitList();
@@ -3514,26 +3514,26 @@ function placeDrumPattern(opts) {
3514
3514
  }
3515
3515
  }
3516
3516
  const endBeat = opts.bars * barBeats;
3517
- return track.hits.filter((h) => h.startBeat < endBeat && (kit === void 0 || _chunkJ772DL3Bcjs.canSound.call(void 0, kit, h.pitch))).sort((a, b) => a.startBeat - b.startBeat || a.pitch - b.pitch);
3517
+ return track.hits.filter((h) => h.startBeat < endBeat && (kit === void 0 || _chunkCGBADIO5cjs.canSound.call(void 0, kit, h.pitch))).sort((a, b) => a.startBeat - b.startBeat || a.pitch - b.pitch);
3518
3518
  }
3519
3519
 
3520
3520
  // src/generate/drums/index.ts
3521
3521
  var MAX_HITS_PER_BAR = 128;
3522
3522
  var DEFAULT_BPM3 = 120;
3523
3523
  function generateDrums(opts) {
3524
- _chunkXKSO2V5Icjs.assertRecord.call(void 0, opts, "drum options");
3525
- _chunkXKSO2V5Icjs.assertPositiveInt.call(void 0, opts.bars, "drum bars");
3526
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, opts.bars * MAX_HITS_PER_BAR, "drum hits", opts.budget);
3524
+ _chunkS5BKZZGMcjs.assertRecord.call(void 0, opts, "drum options");
3525
+ _chunkS5BKZZGMcjs.assertPositiveInt.call(void 0, opts.bars, "drum bars");
3526
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, opts.bars * MAX_HITS_PER_BAR, "drum hits", opts.budget);
3527
3527
  if (opts.euclideanKick) {
3528
3528
  const steps = _nullishCoalesce(opts.euclideanKick.steps, () => ( 16));
3529
- _chunkXKSO2V5Icjs.assertInteger.call(void 0, steps, "euclidean steps", 1, 16);
3530
- _chunkXKSO2V5Icjs.assertInteger.call(void 0, opts.euclideanKick.pulses, "euclidean pulses");
3531
- _chunkXKSO2V5Icjs.assertInteger.call(void 0, _nullishCoalesce(opts.euclideanKick.rotation, () => ( 0)), "euclidean rotation");
3529
+ _chunkS5BKZZGMcjs.assertInteger.call(void 0, steps, "euclidean steps", 1, 16);
3530
+ _chunkS5BKZZGMcjs.assertInteger.call(void 0, opts.euclideanKick.pulses, "euclidean pulses");
3531
+ _chunkS5BKZZGMcjs.assertInteger.call(void 0, _nullishCoalesce(opts.euclideanKick.rotation, () => ( 0)), "euclidean rotation");
3532
3532
  }
3533
- const publicStyle = _chunkXKSO2V5Icjs.assertOneOf.call(void 0, opts.style, GROOVE_STYLES, "drum style");
3534
- const publicSection = _chunkXKSO2V5Icjs.assertOneOf.call(void 0, opts.section, PUBLIC_SECTIONS, "drum section");
3533
+ const publicStyle = _chunkS5BKZZGMcjs.assertOneOf.call(void 0, opts.style, GROOVE_STYLES, "drum style");
3534
+ const publicSection = _chunkS5BKZZGMcjs.assertOneOf.call(void 0, opts.section, PUBLIC_SECTIONS, "drum section");
3535
3535
  if (opts.nextSection !== void 0) {
3536
- _chunkXKSO2V5Icjs.assertOneOf.call(void 0, opts.nextSection, PUBLIC_SECTIONS, "drum nextSection");
3536
+ _chunkS5BKZZGMcjs.assertOneOf.call(void 0, opts.nextSection, PUBLIC_SECTIONS, "drum nextSection");
3537
3537
  }
3538
3538
  const track = new HitList();
3539
3539
  const resolved = resolveContext(opts.ctx);
@@ -3544,18 +3544,18 @@ function generateDrums(opts) {
3544
3544
  const difficulty = resolved.difficulty;
3545
3545
  const mapping = mapStyle(publicStyle);
3546
3546
  const style = mapping.style;
3547
- const feel = opts.feel === void 0 ? mapping.feel : _chunkXKSO2V5Icjs.assertOneOf.call(void 0, opts.feel, DRUM_FEELS, "drum feel");
3548
- const role = opts.role === void 0 ? "full" : _chunkXKSO2V5Icjs.assertOneOf.call(void 0, opts.role, DRUM_ROLES, "drum role");
3549
- const meters = _chunkXKSO2V5Icjs.resolveMeters.call(void 0, { ts: opts.ts }, "ts");
3547
+ const feel = opts.feel === void 0 ? mapping.feel : _chunkS5BKZZGMcjs.assertOneOf.call(void 0, opts.feel, DRUM_FEELS, "drum feel");
3548
+ const role = opts.role === void 0 ? "full" : _chunkS5BKZZGMcjs.assertOneOf.call(void 0, opts.role, DRUM_ROLES, "drum role");
3549
+ const meters = _chunkS5BKZZGMcjs.resolveMeters.call(void 0, { ts: opts.ts }, "ts");
3550
3550
  for (const change of meters) {
3551
3551
  if (change.ts.numerator !== 4 || change.ts.denominator !== 4) {
3552
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(
3552
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
3553
3553
  `drum time signature must be 4/4 throughout; received ${change.ts.numerator}/${change.ts.denominator} at beat ${change.startBeat}`
3554
3554
  );
3555
3555
  }
3556
3556
  }
3557
- const ts = _chunkXKSO2V5Icjs.meterAt.call(void 0, 0, meters);
3558
- const barBeats = _chunkXKSO2V5Icjs.beatsPerBar.call(void 0, ts);
3557
+ const ts = _chunkS5BKZZGMcjs.meterAt.call(void 0, 0, meters);
3558
+ const barBeats = _chunkS5BKZZGMcjs.beatsPerBar.call(void 0, ts);
3559
3559
  const playMainVoices = role !== "fxOnly";
3560
3560
  const section = mapSection(publicSection);
3561
3561
  const swingAmount = feelSwingAmount(feel);
@@ -3748,7 +3748,7 @@ function underCeiling(hits, bpm, difficulty, exempt) {
3748
3748
  return kept;
3749
3749
  }
3750
3750
  function playableOn(kit, pitch) {
3751
- return kit === void 0 || _chunkJ772DL3Bcjs.canSound.call(void 0, kit, pitch);
3751
+ return kit === void 0 || _chunkCGBADIO5cjs.canSound.call(void 0, kit, pitch);
3752
3752
  }
3753
3753
 
3754
3754
  // src/generate/groove/index.ts
@@ -3763,24 +3763,24 @@ var MAX_METRIC_WEIGHT = 3;
3763
3763
  var MIN_VELOCITY = 1;
3764
3764
  var MAX_VELOCITY = 127;
3765
3765
  function humanize(events, opts = {}) {
3766
- const asked = _chunkXKSO2V5Icjs.assertOptions.call(void 0, opts, "opts");
3767
- const ts = _chunkXKSO2V5Icjs.meterAt.call(void 0, 0, _chunkXKSO2V5Icjs.toMeterData.call(void 0, _nullishCoalesce(asked.ts, () => ( DEFAULT_TS3)), "ts"));
3768
- _chunkXKSO2V5Icjs.assertNoteEvents.call(void 0, events, "humanize events", { allowNonPositiveDuration: true });
3769
- const sounding2 = _chunkXKSO2V5Icjs.dropSilentNotes.call(void 0, events);
3766
+ const asked = _chunkS5BKZZGMcjs.assertOptions.call(void 0, opts, "opts");
3767
+ const ts = _chunkS5BKZZGMcjs.meterAt.call(void 0, 0, _chunkS5BKZZGMcjs.toMeterData.call(void 0, _nullishCoalesce(asked.ts, () => ( DEFAULT_TS3)), "ts"));
3768
+ _chunkS5BKZZGMcjs.assertNoteEvents.call(void 0, events, "humanize events", { allowNonPositiveDuration: true });
3769
+ const sounding2 = _chunkS5BKZZGMcjs.dropSilentNotes.call(void 0, events);
3770
3770
  const timing = _nullishCoalesce(asked.timing, () => ( DEFAULT_TIMING));
3771
3771
  const velocityJitter = _nullishCoalesce(asked.velocity, () => ( DEFAULT_VELOCITY_JITTER));
3772
3772
  const accent2 = _nullishCoalesce(asked.accent, () => ( DEFAULT_ACCENT));
3773
3773
  const baseVelocity = _nullishCoalesce(asked.baseVelocity, () => ( DEFAULT_BASE_VELOCITY));
3774
- _chunkXKSO2V5Icjs.assertRange.call(void 0, timing, 0, Number.MAX_SAFE_INTEGER, "humanize timing");
3775
- _chunkXKSO2V5Icjs.assertRange.call(void 0, velocityJitter, 0, 127, "humanize velocity jitter");
3776
- _chunkXKSO2V5Icjs.assertRange.call(void 0, accent2, 0, 127, "humanize accent");
3777
- _chunkXKSO2V5Icjs.assertRange.call(void 0, baseVelocity, 0, 127, "humanize base velocity");
3774
+ _chunkS5BKZZGMcjs.assertRange.call(void 0, timing, 0, Number.MAX_SAFE_INTEGER, "humanize timing");
3775
+ _chunkS5BKZZGMcjs.assertRange.call(void 0, velocityJitter, 0, 127, "humanize velocity jitter");
3776
+ _chunkS5BKZZGMcjs.assertRange.call(void 0, accent2, 0, 127, "humanize accent");
3777
+ _chunkS5BKZZGMcjs.assertRange.call(void 0, baseVelocity, 0, 127, "humanize base velocity");
3778
3778
  const ctx = resolveContext(asked.ctx);
3779
3779
  const draw = ctx.part(_nullishCoalesce(asked.part, () => ( DEFAULT_PART)));
3780
3780
  return sounding2.map((event) => {
3781
3781
  const timingOffset = draw.float(-timing, timing, "timing", event.startBeat, event.pitch);
3782
3782
  const startBeat = event.startBeat + timingOffset;
3783
- const weight = _chunkXKSO2V5Icjs.metricWeight.call(void 0, event.startBeat, ts);
3783
+ const weight = _chunkS5BKZZGMcjs.metricWeight.call(void 0, event.startBeat, ts);
3784
3784
  const accentBoost = weight / MAX_METRIC_WEIGHT * accent2;
3785
3785
  const velocityOffset = draw.float(
3786
3786
  -velocityJitter,
@@ -3809,18 +3809,18 @@ function quantizeToGrid(beat, barBeats, subdivision, slotsPerBar) {
3809
3809
  };
3810
3810
  }
3811
3811
  function extractGrooveTemplate(events, ts, subdivision = DEFAULT_GROOVE_SUBDIVISION) {
3812
- const meter = _chunkXKSO2V5Icjs.meterAt.call(void 0, 0, _chunkXKSO2V5Icjs.toMeterData.call(void 0, ts, "ts"));
3813
- _chunkXKSO2V5Icjs.assertNoteEvents.call(void 0, events, "groove source events", { allowNonPositiveDuration: true });
3814
- _chunkXKSO2V5Icjs.assertPositiveInt.call(void 0, subdivision, "groove subdivision");
3815
- const barBeats = _chunkXKSO2V5Icjs.beatsPerBar.call(void 0, meter);
3812
+ const meter = _chunkS5BKZZGMcjs.meterAt.call(void 0, 0, _chunkS5BKZZGMcjs.toMeterData.call(void 0, ts, "ts"));
3813
+ _chunkS5BKZZGMcjs.assertNoteEvents.call(void 0, events, "groove source events", { allowNonPositiveDuration: true });
3814
+ _chunkS5BKZZGMcjs.assertPositiveInt.call(void 0, subdivision, "groove subdivision");
3815
+ const barBeats = _chunkS5BKZZGMcjs.beatsPerBar.call(void 0, meter);
3816
3816
  const slotsPerBar = Math.ceil(barBeats * subdivision);
3817
- _chunkXKSO2V5Icjs.assertPositiveInt.call(void 0, slotsPerBar, "groove template slots");
3818
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, slotsPerBar, "groove template slots");
3817
+ _chunkS5BKZZGMcjs.assertPositiveInt.call(void 0, slotsPerBar, "groove template slots");
3818
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, slotsPerBar, "groove template slots");
3819
3819
  const offsetSums = new Array(slotsPerBar).fill(0);
3820
3820
  const velocitySums = new Array(slotsPerBar).fill(0);
3821
3821
  const counts = new Array(slotsPerBar).fill(0);
3822
3822
  const velocityCounts = new Array(slotsPerBar).fill(0);
3823
- for (const event of _chunkXKSO2V5Icjs.dropSilentNotes.call(void 0, events)) {
3823
+ for (const event of _chunkS5BKZZGMcjs.dropSilentNotes.call(void 0, events)) {
3824
3824
  const { quantizedBeat, slotIndex } = quantizeToGrid(
3825
3825
  event.startBeat,
3826
3826
  barBeats,
@@ -3850,24 +3850,24 @@ function extractGrooveTemplate(events, ts, subdivision = DEFAULT_GROOVE_SUBDIVIS
3850
3850
  return { subdivision, slotsPerBar, slots, ts: meter };
3851
3851
  }
3852
3852
  function applyGrooveTemplate(events, template, ts) {
3853
- const meter = _chunkXKSO2V5Icjs.meterAt.call(void 0, 0, _chunkXKSO2V5Icjs.toMeterData.call(void 0, ts, "ts"));
3854
- _chunkXKSO2V5Icjs.assertNoteEvents.call(void 0, events, "groove target events", { allowNonPositiveDuration: true });
3855
- _chunkXKSO2V5Icjs.assertPositiveInt.call(void 0, template.subdivision, "template subdivision");
3856
- _chunkXKSO2V5Icjs.assertPositiveInt.call(void 0, template.slotsPerBar, "template slotsPerBar");
3857
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, template.slots.length, "template slots");
3853
+ const meter = _chunkS5BKZZGMcjs.meterAt.call(void 0, 0, _chunkS5BKZZGMcjs.toMeterData.call(void 0, ts, "ts"));
3854
+ _chunkS5BKZZGMcjs.assertNoteEvents.call(void 0, events, "groove target events", { allowNonPositiveDuration: true });
3855
+ _chunkS5BKZZGMcjs.assertPositiveInt.call(void 0, template.subdivision, "template subdivision");
3856
+ _chunkS5BKZZGMcjs.assertPositiveInt.call(void 0, template.slotsPerBar, "template slotsPerBar");
3857
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, template.slots.length, "template slots");
3858
3858
  if (template.slots.length !== template.slotsPerBar) {
3859
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)("template slots length must equal slotsPerBar");
3859
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)("template slots length must equal slotsPerBar");
3860
3860
  }
3861
3861
  if (template.ts && (template.ts.numerator !== meter.numerator || template.ts.denominator !== meter.denominator)) {
3862
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(
3863
- `Groove template meter ${_chunkXKSO2V5Icjs.formatTimeSignature.call(void 0, template.ts)} does not match apply-time meter ${_chunkXKSO2V5Icjs.formatTimeSignature.call(void 0, meter)}`
3862
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
3863
+ `Groove template meter ${_chunkS5BKZZGMcjs.formatTimeSignature.call(void 0, template.ts)} does not match apply-time meter ${_chunkS5BKZZGMcjs.formatTimeSignature.call(void 0, meter)}`
3864
3864
  );
3865
3865
  }
3866
- const barBeats = _chunkXKSO2V5Icjs.beatsPerBar.call(void 0, meter);
3866
+ const barBeats = _chunkS5BKZZGMcjs.beatsPerBar.call(void 0, meter);
3867
3867
  const expectedSlots = Math.ceil(barBeats * template.subdivision);
3868
3868
  if (template.slotsPerBar !== expectedSlots) {
3869
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(
3870
- `Groove template slotsPerBar ${template.slotsPerBar} does not match ${expectedSlots} slots per bar of ${_chunkXKSO2V5Icjs.formatTimeSignature.call(void 0, meter)} at subdivision ${template.subdivision}`
3869
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
3870
+ `Groove template slotsPerBar ${template.slotsPerBar} does not match ${expectedSlots} slots per bar of ${_chunkS5BKZZGMcjs.formatTimeSignature.call(void 0, meter)} at subdivision ${template.subdivision}`
3871
3871
  );
3872
3872
  }
3873
3873
  for (let index = 0; index < template.slots.length; index += 1) {
@@ -3875,12 +3875,12 @@ function applyGrooveTemplate(events, template, ts) {
3875
3875
  if (slot === void 0) {
3876
3876
  continue;
3877
3877
  }
3878
- _chunkXKSO2V5Icjs.assertFiniteNumber.call(void 0, slot.timingOffset, `template slots[${index}].timingOffset`);
3878
+ _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, slot.timingOffset, `template slots[${index}].timingOffset`);
3879
3879
  if (slot.velocity !== null && slot.velocity !== void 0) {
3880
- _chunkXKSO2V5Icjs.assertRange.call(void 0, slot.velocity, 0, 127, `template slots[${index}].velocity`);
3880
+ _chunkS5BKZZGMcjs.assertRange.call(void 0, slot.velocity, 0, 127, `template slots[${index}].velocity`);
3881
3881
  }
3882
3882
  }
3883
- return _chunkXKSO2V5Icjs.dropSilentNotes.call(void 0, events).map((event) => {
3883
+ return _chunkS5BKZZGMcjs.dropSilentNotes.call(void 0, events).map((event) => {
3884
3884
  const { quantizedBeat, slotIndex } = quantizeToGrid(
3885
3885
  event.startBeat,
3886
3886
  barBeats,
@@ -3897,7 +3897,7 @@ function applyGrooveTemplate(events, template, ts) {
3897
3897
  // src/generate/harmonize/nct.ts
3898
3898
  function snapToPulse(beat, pulse2) {
3899
3899
  const snapped = Math.round(beat / pulse2) * pulse2;
3900
- return Math.abs(snapped - beat) <= _chunkQ6R3QAZDcjs.HUMANIZE_ADJACENCY ? snapped : beat;
3900
+ return Math.abs(snapped - beat) <= _chunkSGLEQVJHcjs.HUMANIZE_ADJACENCY ? snapped : beat;
3901
3901
  }
3902
3902
  var STEP_SEMITONES = 2;
3903
3903
  function isStep(a, b) {
@@ -3911,9 +3911,9 @@ function sameDirection(prev, note2, next) {
3911
3911
  return prev !== note2 && next !== note2 && note2 - prev > 0 === next - note2 > 0;
3912
3912
  }
3913
3913
  function classifyMelodyTones(melody, ts) {
3914
- const meter = _chunkXKSO2V5Icjs.meterAt.call(void 0, 0, _chunkXKSO2V5Icjs.toMeterData.call(void 0, ts, "ts"));
3915
- _chunkXKSO2V5Icjs.assertNoteEvents.call(void 0, melody, "melody notes", { allowNonPositiveDuration: true });
3916
- const pulse2 = _chunkXKSO2V5Icjs.pulseBeats.call(void 0, meter);
3914
+ const meter = _chunkS5BKZZGMcjs.meterAt.call(void 0, 0, _chunkS5BKZZGMcjs.toMeterData.call(void 0, ts, "ts"));
3915
+ _chunkS5BKZZGMcjs.assertNoteEvents.call(void 0, melody, "melody notes", { allowNonPositiveDuration: true });
3916
+ const pulse2 = _chunkS5BKZZGMcjs.pulseBeats.call(void 0, meter);
3917
3917
  return melody.map((_, index) => {
3918
3918
  const role = roleOfNote(melody, index, meter, pulse2);
3919
3919
  return { noteIndex: index, role, ornamental: role !== "structural" };
@@ -3928,12 +3928,12 @@ function roleOfNote(melody, index, ts, pulse2) {
3928
3928
  }
3929
3929
  const intoNote = Math.abs(prev.startBeat + prev.durationBeat - note2.startBeat);
3930
3930
  const outOfNote = Math.abs(note2.startBeat + note2.durationBeat - next.startBeat);
3931
- if (intoNote > _chunkQ6R3QAZDcjs.HUMANIZE_ADJACENCY || outOfNote > _chunkQ6R3QAZDcjs.HUMANIZE_ADJACENCY) {
3931
+ if (intoNote > _chunkSGLEQVJHcjs.HUMANIZE_ADJACENCY || outOfNote > _chunkSGLEQVJHcjs.HUMANIZE_ADJACENCY) {
3932
3932
  return "structural";
3933
3933
  }
3934
- const weight = _chunkXKSO2V5Icjs.metricWeight.call(void 0, snapToPulse(note2.startBeat, pulse2), ts);
3935
- const weightPrev = _chunkXKSO2V5Icjs.metricWeight.call(void 0, snapToPulse(prev.startBeat, pulse2), ts);
3936
- const weightNext = _chunkXKSO2V5Icjs.metricWeight.call(void 0, snapToPulse(next.startBeat, pulse2), ts);
3934
+ const weight = _chunkS5BKZZGMcjs.metricWeight.call(void 0, snapToPulse(note2.startBeat, pulse2), ts);
3935
+ const weightPrev = _chunkS5BKZZGMcjs.metricWeight.call(void 0, snapToPulse(prev.startBeat, pulse2), ts);
3936
+ const weightNext = _chunkS5BKZZGMcjs.metricWeight.call(void 0, snapToPulse(next.startBeat, pulse2), ts);
3937
3937
  const subordinate = weight <= weightPrev && weight <= weightNext && note2.durationBeat <= prev.durationBeat && note2.durationBeat <= next.durationBeat;
3938
3938
  const leaning = weight > weightPrev && weight >= weightNext;
3939
3939
  if (leaning && prev.pitch === note2.pitch && note2.pitch - next.pitch >= 1 && isStep(note2.pitch, next.pitch)) {
@@ -3965,12 +3965,12 @@ var FALLBACK = {
3965
3965
  quality: "maj",
3966
3966
  secondaryDominant: false,
3967
3967
  base: 0,
3968
- pcs: _chunkYPB3A3EYcjs.chordPitchClasses.call(void 0, _chunkYPB3A3EYcjs.makeChord.call(void 0, 0, "maj"))
3968
+ pcs: _chunk3R3QVKY5cjs.chordPitchClasses.call(void 0, _chunk3R3QVKY5cjs.makeChord.call(void 0, 0, "maj"))
3969
3969
  };
3970
3970
  function defaultHarmonicRhythm(ts) {
3971
- const bar2 = _chunkXKSO2V5Icjs.beatsPerBar.call(void 0, ts);
3971
+ const bar2 = _chunkS5BKZZGMcjs.beatsPerBar.call(void 0, ts);
3972
3972
  const half = bar2 / 2;
3973
- return half % _chunkXKSO2V5Icjs.pulseBeats.call(void 0, ts) === 0 ? half : bar2;
3973
+ return half % _chunkS5BKZZGMcjs.pulseBeats.call(void 0, ts) === 0 ? half : bar2;
3974
3974
  }
3975
3975
  var DEFAULT_PLACEMENT = {
3976
3976
  transposeSearch: false,
@@ -3979,24 +3979,24 @@ var DEFAULT_PLACEMENT = {
3979
3979
  var DEFAULT_METER = { numerator: 4, denominator: 4 };
3980
3980
  var TIE_BREAK_JITTER2 = 1e-6;
3981
3981
  function cadencesThroughRaisedSeventh(key) {
3982
- return _chunkQ6R3QAZDcjs.isMinorKey.call(void 0, key) && _chunkYPB3A3EYcjs.scaleSystemOf.call(void 0, key) === "common-practice";
3982
+ return _chunkSGLEQVJHcjs.isMinorKey.call(void 0, key) && _chunk3R3QVKY5cjs.scaleSystemOf.call(void 0, key) === "common-practice";
3983
3983
  }
3984
3984
  function isKeyTone(pitch, key) {
3985
- return _chunkYPB3A3EYcjs.isScaleTone.call(void 0, pitch, key) || cadencesThroughRaisedSeventh(key) && _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, pitch) === _chunkYPB3A3EYcjs.leadingTonePcOf.call(void 0, key);
3985
+ return _chunk3R3QVKY5cjs.isScaleTone.call(void 0, pitch, key) || cadencesThroughRaisedSeventh(key) && _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, pitch) === _chunk3R3QVKY5cjs.leadingTonePcOf.call(void 0, key);
3986
3986
  }
3987
3987
  function inferKey(melody) {
3988
- let best = _chunkYPB3A3EYcjs.majorKey.call(void 0, 0);
3988
+ let best = _chunk3R3QVKY5cjs.majorKey.call(void 0, 0);
3989
3989
  let bestScore = Number.NEGATIVE_INFINITY;
3990
3990
  const candidates = [];
3991
3991
  for (let tonic = 0; tonic < 12; tonic += 1) {
3992
- candidates.push(_chunkYPB3A3EYcjs.majorKey.call(void 0, tonic), _chunkYPB3A3EYcjs.minorKey.call(void 0, tonic));
3992
+ candidates.push(_chunk3R3QVKY5cjs.majorKey.call(void 0, tonic), _chunk3R3QVKY5cjs.minorKey.call(void 0, tonic));
3993
3993
  }
3994
3994
  for (const key of candidates) {
3995
- const tonic = _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, key.rootPc);
3995
+ const tonic = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, key.rootPc);
3996
3996
  let score = 0;
3997
3997
  for (const n of melody) {
3998
3998
  const w = Math.max(0.25, n.durationBeat);
3999
- const pc = _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, n.pitch);
3999
+ const pc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, n.pitch);
4000
4000
  if (isKeyTone(n.pitch, key)) {
4001
4001
  score += w;
4002
4002
  }
@@ -4031,7 +4031,7 @@ function emissionCost(seg, cand, melody, key) {
4031
4031
  let cost = cand.base * seg.weight;
4032
4032
  for (const { index, weight, strong } of seg.costNotes) {
4033
4033
  const note2 = melody[index];
4034
- if (!note2 || pcs.includes(_chunkXKSO2V5Icjs.pitchClassOf.call(void 0, note2.pitch))) {
4034
+ if (!note2 || pcs.includes(_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, note2.pitch))) {
4035
4035
  continue;
4036
4036
  }
4037
4037
  cost += (strong ? NON_CHORD_TONE_STRONG : NON_CHORD_TONE_WEAK) * weight;
@@ -4070,7 +4070,7 @@ function phraseEndBonus(prev, cur, tonicPc, seg, melody) {
4070
4070
  return 0;
4071
4071
  }
4072
4072
  const closing = melody[seg.closingIndex];
4073
- if (!closing || _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, closing.pitch) !== tonicPc) {
4073
+ if (!closing || _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, closing.pitch) !== tonicPc) {
4074
4074
  return 0;
4075
4075
  }
4076
4076
  const weight = Math.max(seg.weight, seg.beats);
@@ -4107,7 +4107,7 @@ function sameHarmony(a, b) {
4107
4107
  return a.rootPc === b.rootPc && a.quality === b.quality;
4108
4108
  }
4109
4109
  function harmonizeOnce(melody, key, candidates, segments, jitter, phraseEnds, articulated) {
4110
- const tonicPc = _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, key.rootPc);
4110
+ const tonicPc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, key.rootPc);
4111
4111
  const n = candidates.length;
4112
4112
  const candAt = (i) => _nullishCoalesce(candidates[i], () => ( FALLBACK));
4113
4113
  const seg0 = segments[0];
@@ -4169,13 +4169,13 @@ function gridBounds(segmentStart, hr, gridCount, ends) {
4169
4169
  }
4170
4170
  const last = segmentStart + gridCount * hr;
4171
4171
  for (const end of ends) {
4172
- if (end > segmentStart + _chunkXKSO2V5Icjs.BEAT_EPS && end < last - _chunkXKSO2V5Icjs.BEAT_EPS) {
4172
+ if (end > segmentStart + _chunkS5BKZZGMcjs.BEAT_EPS && end < last - _chunkS5BKZZGMcjs.BEAT_EPS) {
4173
4173
  bounds.push(end);
4174
4174
  }
4175
4175
  }
4176
4176
  bounds.sort((a, b) => a - b);
4177
4177
  return bounds.filter(
4178
- (beat, index) => index === 0 || beat - (_nullishCoalesce(bounds[index - 1], () => ( beat))) > _chunkXKSO2V5Icjs.BEAT_EPS
4178
+ (beat, index) => index === 0 || beat - (_nullishCoalesce(bounds[index - 1], () => ( beat))) > _chunkS5BKZZGMcjs.BEAT_EPS
4179
4179
  );
4180
4180
  }
4181
4181
  function closingNoteIndices(spans, ends) {
@@ -4184,7 +4184,7 @@ function closingNoteIndices(spans, ends) {
4184
4184
  let index = -1;
4185
4185
  let start = Number.NEGATIVE_INFINITY;
4186
4186
  for (const [i, span] of spans.entries()) {
4187
- if (span.startBeat < end - _chunkXKSO2V5Icjs.BEAT_EPS && span.startBeat >= start) {
4187
+ if (span.startBeat < end - _chunkS5BKZZGMcjs.BEAT_EPS && span.startBeat >= start) {
4188
4188
  start = span.startBeat;
4189
4189
  index = i;
4190
4190
  }
@@ -4227,7 +4227,7 @@ function phraseEndSegments(segments, ends) {
4227
4227
  for (const end of ends) {
4228
4228
  let index = -1;
4229
4229
  for (let s = 0; s < segments.length; s += 1) {
4230
- if ((_nullishCoalesce(_optionalChain([segments, 'access', _48 => _48[s], 'optionalAccess', _49 => _49.startBeat]), () => ( 0))) < end - _chunkXKSO2V5Icjs.BEAT_EPS) {
4230
+ if ((_nullishCoalesce(_optionalChain([segments, 'access', _48 => _48[s], 'optionalAccess', _49 => _49.startBeat]), () => ( 0))) < end - _chunkS5BKZZGMcjs.BEAT_EPS) {
4231
4231
  index = s;
4232
4232
  }
4233
4233
  }
@@ -4244,13 +4244,13 @@ function buildSegments(spans, melody, ts, grid, phraseEnds, budget) {
4244
4244
  const hr = grid.harmonicRhythm;
4245
4245
  const segmentStart = Math.floor(melodyStart / hr) * hr;
4246
4246
  const gridCount = Math.max(1, Math.ceil((melodyEnd - segmentStart) / hr));
4247
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, gridCount, "harmonic segments", budget);
4247
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, gridCount, "harmonic segments", budget);
4248
4248
  const innerEnds = phraseEnds.filter(
4249
- (end) => end > segmentStart + _chunkXKSO2V5Icjs.BEAT_EPS && end < melodyEnd - _chunkXKSO2V5Icjs.BEAT_EPS
4249
+ (end) => end > segmentStart + _chunkS5BKZZGMcjs.BEAT_EPS && end < melodyEnd - _chunkS5BKZZGMcjs.BEAT_EPS
4250
4250
  );
4251
4251
  const bounds = gridBounds(segmentStart, hr, gridCount, innerEnds);
4252
4252
  const segCount = bounds.length - 1;
4253
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, segCount, "harmonic segments", budget);
4253
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, segCount, "harmonic segments", budget);
4254
4254
  const segments = Array.from({ length: segCount }, (_, s) => {
4255
4255
  const startBeat = _nullishCoalesce(bounds[s], () => ( segmentStart));
4256
4256
  const endBeat = _nullishCoalesce(bounds[s + 1], () => ( startBeat + hr));
@@ -4271,7 +4271,7 @@ function buildSegments(spans, melody, ts, grid, phraseEnds, budget) {
4271
4271
  lastExclusive += 1;
4272
4272
  }
4273
4273
  memberships += Math.max(0, lastExclusive - first);
4274
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, memberships, "note-to-segment memberships", budget);
4274
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, memberships, "note-to-segment memberships", budget);
4275
4275
  for (let segment = first; segment < lastExclusive; segment += 1) {
4276
4276
  _optionalChain([segments, 'access', _50 => _50[segment], 'optionalAccess', _51 => _51.noteIndices, 'access', _52 => _52.push, 'call', _53 => _53(index)]);
4277
4277
  }
@@ -4295,7 +4295,7 @@ function buildSegments(spans, melody, ts, grid, phraseEnds, budget) {
4295
4295
  continue;
4296
4296
  }
4297
4297
  const weight = Math.max(0.25, overlap);
4298
- segment.costNotes.push({ index, weight, strong: _chunkXKSO2V5Icjs.isStrongBeat.call(void 0, overlapStart, ts) });
4298
+ segment.costNotes.push({ index, weight, strong: _chunkS5BKZZGMcjs.isStrongBeat.call(void 0, overlapStart, ts) });
4299
4299
  segment.weight += weight;
4300
4300
  if (span.startBeat >= closingStart) {
4301
4301
  closingStart = span.startBeat;
@@ -4317,7 +4317,7 @@ var UNSTABLE_QUALITIES = /* @__PURE__ */ new Set([
4317
4317
  "aug7"
4318
4318
  ]);
4319
4319
  function vocabularyBase(rootPc, quality, tonicPc) {
4320
- const above = (_chunkXKSO2V5Icjs.pitchClassOf.call(void 0, rootPc) - tonicPc + 12) % 12;
4320
+ const above = (_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, rootPc) - tonicPc + 12) % 12;
4321
4321
  const root = _nullishCoalesce(ROOT_WEIGHT_BY_SEMITONE[above], () => ( UNSTABLE_TRIAD));
4322
4322
  return UNSTABLE_QUALITIES.has(quality) ? Math.max(root, UNSTABLE_TRIAD) : root;
4323
4323
  }
@@ -4326,7 +4326,7 @@ var BORROWED_BASE = 0.5;
4326
4326
  var SECONDARY_DOMINANT_TARGETS = [2, 4, 5, 6];
4327
4327
  function secondaryDominantTargets(key) {
4328
4328
  const tonicizable = new Map(
4329
- _chunkYPB3A3EYcjs.tonicizableDegrees.call(void 0, key).map((degree) => [degree.degreeNumber, degree])
4329
+ _chunk3R3QVKY5cjs.tonicizableDegrees.call(void 0, key).map((degree) => [degree.degreeNumber, degree])
4330
4330
  );
4331
4331
  return SECONDARY_DOMINANT_TARGETS.map((degree) => tonicizable.get(degree)).filter(
4332
4332
  (degree) => degree !== void 0
@@ -4345,19 +4345,19 @@ function admittedCount(fraction, size) {
4345
4345
  return Math.max(0, Math.min(size, Math.ceil(fraction * size)));
4346
4346
  }
4347
4347
  function buildCandidates(key, harmonic) {
4348
- const tonicPc = _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, key.rootPc);
4349
- const frame = _chunkYPB3A3EYcjs.heptatonicFrameOf.call(void 0, key);
4350
- const tones = _chunkYPB3A3EYcjs.scaleTonesInDegreeOrder.call(void 0, frame);
4348
+ const tonicPc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, key.rootPc);
4349
+ const frame = _chunk3R3QVKY5cjs.heptatonicFrameOf.call(void 0, key);
4350
+ const tones = _chunk3R3QVKY5cjs.scaleTonesInDegreeOrder.call(void 0, frame);
4351
4351
  const candidates = tones.map((rootPc, index) => {
4352
4352
  const degree = index + 1;
4353
- const quality = _chunkYPB3A3EYcjs.diatonicTriad.call(void 0, degree, frame).quality;
4353
+ const quality = _chunk3R3QVKY5cjs.diatonicTriad.call(void 0, degree, frame).quality;
4354
4354
  return {
4355
4355
  rootPc,
4356
4356
  quality,
4357
4357
  degree,
4358
4358
  secondaryDominant: false,
4359
4359
  base: vocabularyBase(rootPc, quality, tonicPc),
4360
- pcs: _chunkYPB3A3EYcjs.chordPitchClasses.call(void 0, _chunkYPB3A3EYcjs.makeChord.call(void 0, rootPc, quality))
4360
+ pcs: _chunk3R3QVKY5cjs.chordPitchClasses.call(void 0, _chunk3R3QVKY5cjs.makeChord.call(void 0, rootPc, quality))
4361
4361
  };
4362
4362
  });
4363
4363
  if (cadencesThroughRaisedSeventh(key)) {
@@ -4368,7 +4368,7 @@ function buildCandidates(key, harmonic) {
4368
4368
  degree: 5,
4369
4369
  secondaryDominant: false,
4370
4370
  base: vocabularyBase(rootPc, "maj", tonicPc),
4371
- pcs: _chunkYPB3A3EYcjs.chordPitchClasses.call(void 0, _chunkYPB3A3EYcjs.makeChord.call(void 0, rootPc, "maj"))
4371
+ pcs: _chunk3R3QVKY5cjs.chordPitchClasses.call(void 0, _chunk3R3QVKY5cjs.makeChord.call(void 0, rootPc, "maj"))
4372
4372
  });
4373
4373
  }
4374
4374
  const targets = secondaryDominantTargets(key);
@@ -4387,20 +4387,20 @@ function buildCandidates(key, harmonic) {
4387
4387
  secondaryDominant: true,
4388
4388
  targetDegree: target.degreeNumber,
4389
4389
  base: SECONDARY_DOMINANT_BASE,
4390
- pcs: _chunkYPB3A3EYcjs.chordPitchClasses.call(void 0, _chunkYPB3A3EYcjs.makeChord.call(void 0, rootPc, "dom7"))
4390
+ pcs: _chunk3R3QVKY5cjs.chordPitchClasses.call(void 0, _chunk3R3QVKY5cjs.makeChord.call(void 0, rootPc, "dom7"))
4391
4391
  });
4392
4392
  }
4393
- const parallel = _chunkQ6R3QAZDcjs.parallelKey.call(void 0, key);
4394
- const parallelTones = _chunkYPB3A3EYcjs.scaleTonesInDegreeOrder.call(void 0, parallel);
4393
+ const parallel = _chunkSGLEQVJHcjs.parallelKey.call(void 0, key);
4394
+ const parallelTones = _chunk3R3QVKY5cjs.scaleTonesInDegreeOrder.call(void 0, parallel);
4395
4395
  const borrowed = [];
4396
4396
  for (let degree = 1; degree <= parallelTones.length; degree += 1) {
4397
- const chord = _chunkYPB3A3EYcjs.diatonicTriad.call(void 0, degree, parallel);
4398
- if (!_chunkQ6R3QAZDcjs.isDiatonic.call(void 0, chord, key)) {
4397
+ const chord = _chunk3R3QVKY5cjs.diatonicTriad.call(void 0, degree, parallel);
4398
+ if (!_chunkSGLEQVJHcjs.isDiatonic.call(void 0, chord, key)) {
4399
4399
  borrowed.push(chord);
4400
4400
  }
4401
4401
  }
4402
4402
  const borrowedRank = (chord) => {
4403
- const offset = BORROWED_ENTRY_ORDER.indexOf(_chunkXKSO2V5Icjs.pitchClassOf.call(void 0, chord.rootPc - tonicPc));
4403
+ const offset = BORROWED_ENTRY_ORDER.indexOf(_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, chord.rootPc - tonicPc));
4404
4404
  return offset < 0 ? BORROWED_ENTRY_ORDER.length : offset;
4405
4405
  };
4406
4406
  borrowed.sort((a, b) => borrowedRank(a) - borrowedRank(b));
@@ -4419,7 +4419,7 @@ function buildCandidates(key, harmonic) {
4419
4419
  // which of the two a phrase took was decided by the tie-break jitter
4420
4420
  // rather than by the melody.
4421
4421
  base: UNSTABLE_QUALITIES.has(chord.quality) ? Math.max(BORROWED_BASE, UNSTABLE_TRIAD) : BORROWED_BASE,
4422
- pcs: _chunkYPB3A3EYcjs.chordPitchClasses.call(void 0, chord)
4422
+ pcs: _chunk3R3QVKY5cjs.chordPitchClasses.call(void 0, chord)
4423
4423
  });
4424
4424
  }
4425
4425
  const seen = /* @__PURE__ */ new Set();
@@ -4435,26 +4435,26 @@ function buildCandidates(key, harmonic) {
4435
4435
 
4436
4436
  // src/generate/harmonize/index.ts
4437
4437
  function harmonizeMelody(opts) {
4438
- _chunkXKSO2V5Icjs.assertRecord.call(void 0, opts, "harmonize options");
4439
- _chunkXKSO2V5Icjs.assertNoteEvents.call(void 0, opts.melody, "harmonize melody", {
4438
+ _chunkS5BKZZGMcjs.assertRecord.call(void 0, opts, "harmonize options");
4439
+ _chunkS5BKZZGMcjs.assertNoteEvents.call(void 0, opts.melody, "harmonize melody", {
4440
4440
  allowNonPositiveDuration: true,
4441
4441
  budget: opts.budget
4442
4442
  });
4443
4443
  const phraseEnds = _nullishCoalesce(opts.phraseEnds, () => ( []));
4444
4444
  for (const end of phraseEnds) {
4445
- _chunkXKSO2V5Icjs.assertFiniteNumber.call(void 0, end, "harmonize phrase end");
4445
+ _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, end, "harmonize phrase end");
4446
4446
  }
4447
- const soundingMelody = _chunkXKSO2V5Icjs.soundingNotesOnly.call(void 0, opts.melody);
4448
- const ts = _chunkXKSO2V5Icjs.meterAt.call(void 0, 0, _chunkXKSO2V5Icjs.toMeterData.call(void 0, _nullishCoalesce(opts.ts, () => ( DEFAULT_METER)), "ts"));
4449
- _chunkXKSO2V5Icjs.assertTimeSignature.call(void 0, ts);
4447
+ const soundingMelody = _chunkS5BKZZGMcjs.soundingNotesOnly.call(void 0, opts.melody);
4448
+ const ts = _chunkS5BKZZGMcjs.meterAt.call(void 0, 0, _chunkS5BKZZGMcjs.toMeterData.call(void 0, _nullishCoalesce(opts.ts, () => ( DEFAULT_METER)), "ts"));
4449
+ _chunkS5BKZZGMcjs.assertTimeSignature.call(void 0, ts);
4450
4450
  const requestedKey = _nullishCoalesce(opts.key, () => ( "infer"));
4451
- const resolvedKey = _chunkYPB3A3EYcjs.resolveKey.call(void 0,
4451
+ const resolvedKey = _chunk3R3QVKY5cjs.resolveKey.call(void 0,
4452
4452
  requestedKey === "infer" ? inferKey(soundingMelody) : requestedKey
4453
4453
  );
4454
4454
  const key = resolvedKey.scale;
4455
4455
  const placement = _nullishCoalesce(opts.placement, () => ( DEFAULT_PLACEMENT));
4456
4456
  const ctx = resolveContext(opts.ctx);
4457
- const reharmonize = _chunkXKSO2V5Icjs.assertOneOf.call(void 0,
4457
+ const reharmonize = _chunkS5BKZZGMcjs.assertOneOf.call(void 0,
4458
4458
  _nullishCoalesce(opts.reharmonize, () => ( "diatonic")),
4459
4459
  REHARMONIZE_STRENGTHS,
4460
4460
  "reharmonize"
@@ -4467,7 +4467,7 @@ function harmonizeMelody(opts) {
4467
4467
  const candAt = (i) => _nullishCoalesce(candidates[i], () => ( FALLBACK));
4468
4468
  const draw = ctx.part("harmony");
4469
4469
  const jitter = candidates.map((_, index) => draw.at("jitter", index) * TIE_BREAK_JITTER2);
4470
- const pulse2 = _chunkXKSO2V5Icjs.pulseBeats.call(void 0, ts);
4470
+ const pulse2 = _chunkS5BKZZGMcjs.pulseBeats.call(void 0, ts);
4471
4471
  const spans = soundingMelody.map((note2) => ({
4472
4472
  startBeat: snapToPulse(note2.startBeat, pulse2),
4473
4473
  endBeat: snapToPulse(note2.startBeat + note2.durationBeat, pulse2)
@@ -4480,7 +4480,7 @@ function harmonizeMelody(opts) {
4480
4480
  (end, span) => Math.max(end, span.endBeat),
4481
4481
  Number.NEGATIVE_INFINITY
4482
4482
  );
4483
- const hr = _chunkXKSO2V5Icjs.assertRange.call(void 0,
4483
+ const hr = _chunkS5BKZZGMcjs.assertRange.call(void 0,
4484
4484
  _nullishCoalesce(opts.harmonicRhythm, () => ( defaultHarmonicRhythm(ts))),
4485
4485
  Number.MIN_VALUE,
4486
4486
  Number.MAX_SAFE_INTEGER,
@@ -4509,7 +4509,7 @@ function harmonizeMelody(opts) {
4509
4509
  }
4510
4510
  const octaveShifts = placement.octaveSearch ? [0, -12, 12] : [0];
4511
4511
  const transposes = semitoneShifts.flatMap((s) => octaveShifts.map((o) => s + o));
4512
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0,
4512
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0,
4513
4513
  transposes.length * segments.length * candidates.length * candidates.length,
4514
4514
  "harmonization placement search",
4515
4515
  opts.budget
@@ -4555,8 +4555,8 @@ function harmonizeMelody(opts) {
4555
4555
  const melodyRoles = opts.melody.map((note2, noteIndex) => {
4556
4556
  const segIdx = segmentIndexAt(bounds, snapToPulse(note2.startBeat, pulse2));
4557
4557
  const cand = candAt(_nullishCoalesce(bestPath[segIdx], () => ( 0)));
4558
- const chord = _chunkYPB3A3EYcjs.makeChord.call(void 0, cand.rootPc, cand.quality);
4559
- return { noteIndex, role: _chunkR7B5N2JKcjs.roleOf.call(void 0, note2.pitch + bestTs, chord).role };
4558
+ const chord = _chunk3R3QVKY5cjs.makeChord.call(void 0, cand.rootPc, cand.quality);
4559
+ return { noteIndex, role: _chunkPM4XJE2Ycjs.roleOf.call(void 0, note2.pitch + bestTs, chord).role };
4560
4560
  });
4561
4561
  return { transposeSemitones: bestTs, key: resolvedKey, chords, melodyRoles };
4562
4562
  }
@@ -4575,15 +4575,15 @@ var MIN_TILE_SPAN = 1 / 256;
4575
4575
  var DEFAULT_TS4 = { numerator: 4, denominator: 4 };
4576
4576
  function isDownbeat(startBeat, barBeats) {
4577
4577
  const bar2 = startBeat / barBeats;
4578
- return Math.abs(bar2 - Math.round(bar2)) < _chunkXKSO2V5Icjs.BEAT_EPS;
4578
+ return Math.abs(bar2 - Math.round(bar2)) < _chunkS5BKZZGMcjs.BEAT_EPS;
4579
4579
  }
4580
4580
  function nearestChordTone(pitch, chord) {
4581
- const pcs = _chunkYPB3A3EYcjs.chordPitchClasses.call(void 0, chord);
4581
+ const pcs = _chunk3R3QVKY5cjs.chordPitchClasses.call(void 0, chord);
4582
4582
  for (let d = 0; d <= 12; d += 1) {
4583
- if (pcs.includes(_chunkXKSO2V5Icjs.pitchClassOf.call(void 0, pitch - d))) {
4583
+ if (pcs.includes(_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, pitch - d))) {
4584
4584
  return pitch - d;
4585
4585
  }
4586
- if (pcs.includes(_chunkXKSO2V5Icjs.pitchClassOf.call(void 0, pitch + d))) {
4586
+ if (pcs.includes(_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, pitch + d))) {
4587
4587
  return pitch + d;
4588
4588
  }
4589
4589
  }
@@ -4663,20 +4663,20 @@ function contourOffsets(contour, count) {
4663
4663
  return offsets;
4664
4664
  }
4665
4665
  function generateMotif(opts) {
4666
- _chunkXKSO2V5Icjs.assertRecord.call(void 0, opts, "motif options");
4666
+ _chunkS5BKZZGMcjs.assertRecord.call(void 0, opts, "motif options");
4667
4667
  const contour = _nullishCoalesce(opts.contour, () => ( "arch"));
4668
- const bars = _chunkXKSO2V5Icjs.assertPositiveInt.call(void 0, opts.bars, "motif bars");
4669
- const barBeats = _chunkXKSO2V5Icjs.beatsPerBar.call(void 0, _chunkXKSO2V5Icjs.meterAt.call(void 0, 0, _chunkXKSO2V5Icjs.toMeterData.call(void 0, _nullishCoalesce(opts.ts, () => ( DEFAULT_TS4)), "ts")));
4668
+ const bars = _chunkS5BKZZGMcjs.assertPositiveInt.call(void 0, opts.bars, "motif bars");
4669
+ const barBeats = _chunkS5BKZZGMcjs.beatsPerBar.call(void 0, _chunkS5BKZZGMcjs.meterAt.call(void 0, 0, _chunkS5BKZZGMcjs.toMeterData.call(void 0, _nullishCoalesce(opts.ts, () => ( DEFAULT_TS4)), "ts")));
4670
4670
  const totalBeats = bars * barBeats;
4671
4671
  const noteCount = Math.max(3, bars * 2);
4672
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, noteCount, "motif notes");
4672
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, noteCount, "motif notes");
4673
4673
  const beatsPerNote = totalBeats / noteCount;
4674
4674
  const ctx = resolveContextWith(opts.ctx, { ornament: opts.jitter });
4675
4675
  const jitterProb = _nullishCoalesce(ctx.ornament, () => ( 0));
4676
4676
  const draw = ctx.part("motif");
4677
- const key = _chunkYPB3A3EYcjs.toKeyScale.call(void 0, opts.key);
4678
- const chord = opts.chord ? _chunkYPB3A3EYcjs.toChordData.call(void 0, opts.chord) : null;
4679
- const tonic = _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, key.rootPc) + 60;
4677
+ const key = _chunk3R3QVKY5cjs.toKeyScale.call(void 0, opts.key);
4678
+ const chord = opts.chord ? _chunk3R3QVKY5cjs.toChordData.call(void 0, opts.chord) : null;
4679
+ const tonic = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, key.rootPc) + 60;
4680
4680
  const offsets = contourOffsets(contour, noteCount);
4681
4681
  const notes = [];
4682
4682
  for (let i = 0; i < noteCount; i += 1) {
@@ -4684,13 +4684,13 @@ function generateMotif(opts) {
4684
4684
  if (draw.prob(jitterProb, "jitter", i)) {
4685
4685
  jitter = draw.prob(0.5, "direction", i) ? 1 : -1;
4686
4686
  }
4687
- let pitch = _chunkYPB3A3EYcjs.shiftByScaleDegrees.call(void 0, tonic, (_nullishCoalesce(offsets[i], () => ( 0))) + jitter, key);
4687
+ let pitch = _chunk3R3QVKY5cjs.shiftByScaleDegrees.call(void 0, tonic, (_nullishCoalesce(offsets[i], () => ( 0))) + jitter, key);
4688
4688
  const startBeat = i * beatsPerNote;
4689
4689
  if (chord && isDownbeat(startBeat, barBeats)) {
4690
4690
  pitch = nearestChordTone(pitch, chord);
4691
4691
  }
4692
4692
  notes.push({
4693
- pitch: _chunkXKSO2V5Icjs.clampToMidi.call(void 0, pitch, "generated motif pitch"),
4693
+ pitch: _chunkS5BKZZGMcjs.clampToMidi.call(void 0, pitch, "generated motif pitch"),
4694
4694
  startBeat,
4695
4695
  durationBeat: beatsPerNote
4696
4696
  });
@@ -4701,12 +4701,12 @@ function motifToNoteEvents(cell) {
4701
4701
  return assertCellNotes(cell, "motif cell notes").map((note2) => ({ ...note2 }));
4702
4702
  }
4703
4703
  function assertCellNotes(cell, name) {
4704
- const read = _chunkXKSO2V5Icjs.assertRecord.call(void 0, cell, "motif cell");
4705
- _chunkXKSO2V5Icjs.assertNoteEvents.call(void 0, read.notes, name);
4704
+ const read = _chunkS5BKZZGMcjs.assertRecord.call(void 0, cell, "motif cell");
4705
+ _chunkS5BKZZGMcjs.assertNoteEvents.call(void 0, read.notes, name);
4706
4706
  return read.notes;
4707
4707
  }
4708
4708
  function transformMotif(cell, t, amount, key) {
4709
- return transformCell(cell, t, amount, key === void 0 ? void 0 : _chunkYPB3A3EYcjs.toKeyScale.call(void 0, key));
4709
+ return transformCell(cell, t, amount, key === void 0 ? void 0 : _chunk3R3QVKY5cjs.toKeyScale.call(void 0, key));
4710
4710
  }
4711
4711
  function transformCell(cell, t, amount, key) {
4712
4712
  return assertInRange(inTimeOrder(transformUnchecked(cell, t, amount, key)));
@@ -4714,7 +4714,7 @@ function transformCell(cell, t, amount, key) {
4714
4714
  function assertInRange(cell) {
4715
4715
  for (const note2 of cell.notes) {
4716
4716
  if (note2.pitch < 0 || note2.pitch > 127) {
4717
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(
4717
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
4718
4718
  `transformed motif pitch ${note2.pitch} is outside the MIDI range 0..127`
4719
4719
  );
4720
4720
  }
@@ -4723,18 +4723,18 @@ function assertInRange(cell) {
4723
4723
  }
4724
4724
  function transformUnchecked(cell, t, amount, key) {
4725
4725
  const notes = assertCellNotes(cell, "motif notes");
4726
- _chunkXKSO2V5Icjs.assertOneOf.call(void 0, t, MOTIF_TRANSFORMS, "motif transform");
4726
+ _chunkS5BKZZGMcjs.assertOneOf.call(void 0, t, MOTIF_TRANSFORMS, "motif transform");
4727
4727
  if (amount !== void 0) {
4728
- _chunkXKSO2V5Icjs.assertFiniteNumber.call(void 0, amount, "motif transform amount");
4728
+ _chunkS5BKZZGMcjs.assertFiniteNumber.call(void 0, amount, "motif transform amount");
4729
4729
  }
4730
4730
  if ((t === "transposeChromatic" || t === "transposeDiatonic" || t === "sequence") && amount !== void 0) {
4731
- _chunkXKSO2V5Icjs.assertInteger.call(void 0,
4731
+ _chunkS5BKZZGMcjs.assertInteger.call(void 0,
4732
4732
  amount,
4733
4733
  `${t === "transposeChromatic" ? "chromatic" : "diatonic"} transform amount`
4734
4734
  );
4735
4735
  }
4736
4736
  if ((t === "augment" || t === "diminish") && amount !== void 0 && amount <= 0) {
4737
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)("time transform amount must be positive");
4737
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)("time transform amount must be positive");
4738
4738
  }
4739
4739
  switch (t) {
4740
4740
  case "transposeChromatic": {
@@ -4752,7 +4752,7 @@ function transformUnchecked(cell, t, amount, key) {
4752
4752
  // notes a motif is written with — a blues lick, a semitone neighbour —
4753
4753
  // come through as themselves, and shifting by no degrees returns the
4754
4754
  // cell it was given.
4755
- pitch: key ? _chunkYPB3A3EYcjs.shiftByScaleDegrees.call(void 0, n.pitch, degrees, key) : n.pitch + degrees
4755
+ pitch: key ? _chunk3R3QVKY5cjs.shiftByScaleDegrees.call(void 0, n.pitch, degrees, key) : n.pitch + degrees
4756
4756
  }))
4757
4757
  };
4758
4758
  }
@@ -4798,13 +4798,13 @@ function scaleTime(cell, factor) {
4798
4798
  };
4799
4799
  }
4800
4800
  function developMotif(cell, timeline, key, bars, ts) {
4801
- const meter = _chunkXKSO2V5Icjs.meterAt.call(void 0, 0, _chunkXKSO2V5Icjs.toMeterData.call(void 0, ts, "ts"));
4802
- _chunkQ6R3QAZDcjs.assertChordTimeline.call(void 0, timeline);
4803
- _chunkXKSO2V5Icjs.assertPositiveInt.call(void 0, bars, "development bars");
4801
+ const meter = _chunkS5BKZZGMcjs.meterAt.call(void 0, 0, _chunkS5BKZZGMcjs.toMeterData.call(void 0, ts, "ts"));
4802
+ _chunkSGLEQVJHcjs.assertChordTimeline.call(void 0, timeline);
4803
+ _chunkS5BKZZGMcjs.assertPositiveInt.call(void 0, bars, "development bars");
4804
4804
  const cellNotes = assertCellNotes(cell, "motif notes");
4805
- const scale = _chunkYPB3A3EYcjs.toKeyScale.call(void 0, key);
4805
+ const scale = _chunk3R3QVKY5cjs.toKeyScale.call(void 0, key);
4806
4806
  const span = cellSpan(cell);
4807
- const barBeats = _chunkXKSO2V5Icjs.beatsPerBar.call(void 0, meter);
4807
+ const barBeats = _chunkS5BKZZGMcjs.beatsPerBar.call(void 0, meter);
4808
4808
  const totalBeats = bars * barBeats;
4809
4809
  const origin = cellOrigin(cellNotes);
4810
4810
  const out = [];
@@ -4813,7 +4813,7 @@ function developMotif(cell, timeline, key, bars, ts) {
4813
4813
  }
4814
4814
  const tileSpan = Math.max(span, MIN_TILE_SPAN);
4815
4815
  const tileCount = Math.ceil(totalBeats / tileSpan);
4816
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, tileCount * cellNotes.length, "developed motif notes");
4816
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, tileCount * cellNotes.length, "developed motif notes");
4817
4817
  for (let k = 0; k < tileCount; k += 1) {
4818
4818
  const offset = k * tileSpan;
4819
4819
  const taken = /* @__PURE__ */ new Map();
@@ -4825,8 +4825,8 @@ function developMotif(cell, timeline, key, bars, ts) {
4825
4825
  }
4826
4826
  const chord = timeline.at(startBeat);
4827
4827
  const structural = n.startBeat === origin || isDownbeat(startBeat, barBeats);
4828
- const chordTones = chord && structural ? _chunkYPB3A3EYcjs.chordPitchClasses.call(void 0, chord) : null;
4829
- const allows = chordTones ? (candidate) => chordTones.includes(_chunkXKSO2V5Icjs.pitchClassOf.call(void 0, candidate)) : (candidate) => _chunkYPB3A3EYcjs.isScaleTone.call(void 0, candidate, scale);
4828
+ const chordTones = chord && structural ? _chunk3R3QVKY5cjs.chordPitchClasses.call(void 0, chord) : null;
4829
+ const allows = chordTones ? (candidate) => chordTones.includes(_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, candidate)) : (candidate) => _chunk3R3QVKY5cjs.isScaleTone.call(void 0, candidate, scale);
4830
4830
  const direction = previous === void 0 ? 0 : n.pitch - previous;
4831
4831
  const pitch = developedPitch(n.pitch, allows, direction, taken);
4832
4832
  taken.set(pitch, n.pitch);
@@ -4849,7 +4849,7 @@ var MIN_VELOCITY2 = 1;
4849
4849
  var MAX_VELOCITY2 = 127;
4850
4850
  var SLIDE_MIN_SEMITONES = 1;
4851
4851
  function eligible(style, note2, previous, next, ts) {
4852
- const strong = _chunkXKSO2V5Icjs.isStrongBeat.call(void 0, note2.startBeat, ts);
4852
+ const strong = _chunkS5BKZZGMcjs.isStrongBeat.call(void 0, note2.startBeat, ts);
4853
4853
  switch (style) {
4854
4854
  case "ghost":
4855
4855
  return !strong;
@@ -4857,7 +4857,7 @@ function eligible(style, note2, previous, next, ts) {
4857
4857
  case "accent":
4858
4858
  return strong;
4859
4859
  case "drag":
4860
- return !strong && next !== void 0 && _chunkXKSO2V5Icjs.isStrongBeat.call(void 0, next.startBeat, ts);
4860
+ return !strong && next !== void 0 && _chunkS5BKZZGMcjs.isStrongBeat.call(void 0, next.startBeat, ts);
4861
4861
  case "slide":
4862
4862
  return previous !== void 0 && Math.abs(note2.pitch - previous.pitch) >= SLIDE_MIN_SEMITONES;
4863
4863
  }
@@ -4882,18 +4882,18 @@ function clampVelocity(velocity) {
4882
4882
  return Math.min(MAX_VELOCITY2, Math.max(MIN_VELOCITY2, Math.round(velocity)));
4883
4883
  }
4884
4884
  function ornament(notes, opts = {}) {
4885
- const asked = _chunkXKSO2V5Icjs.assertOptions.call(void 0, opts, "opts");
4886
- _chunkXKSO2V5Icjs.assertNoteEvents.call(void 0, notes, "ornament notes", { allowNonPositiveDuration: true });
4887
- const style = _chunkXKSO2V5Icjs.assertOneOf.call(void 0, _nullishCoalesce(asked.style, () => ( DEFAULT_STYLE2)), ORNAMENT_STYLES, "ornament style");
4888
- const ts = _chunkXKSO2V5Icjs.meterAt.call(void 0, 0, _chunkXKSO2V5Icjs.toMeterData.call(void 0, _nullishCoalesce(asked.ts, () => ( DEFAULT_TS5)), "ts"));
4889
- _chunkXKSO2V5Icjs.assertTimeSignature.call(void 0, ts);
4885
+ const asked = _chunkS5BKZZGMcjs.assertOptions.call(void 0, opts, "opts");
4886
+ _chunkS5BKZZGMcjs.assertNoteEvents.call(void 0, notes, "ornament notes", { allowNonPositiveDuration: true });
4887
+ const style = _chunkS5BKZZGMcjs.assertOneOf.call(void 0, _nullishCoalesce(asked.style, () => ( DEFAULT_STYLE2)), ORNAMENT_STYLES, "ornament style");
4888
+ const ts = _chunkS5BKZZGMcjs.meterAt.call(void 0, 0, _chunkS5BKZZGMcjs.toMeterData.call(void 0, _nullishCoalesce(asked.ts, () => ( DEFAULT_TS5)), "ts"));
4889
+ _chunkS5BKZZGMcjs.assertTimeSignature.call(void 0, ts);
4890
4890
  if (asked.amount !== void 0) {
4891
- _chunkXKSO2V5Icjs.assertRange.call(void 0, asked.amount, 0, 1, "ornament amount");
4891
+ _chunkS5BKZZGMcjs.assertRange.call(void 0, asked.amount, 0, 1, "ornament amount");
4892
4892
  }
4893
4893
  const ctx = resolveContextWith(asked.ctx, { ornament: asked.amount });
4894
4894
  const amount = _nullishCoalesce(ctx.ornament, () => ( DEFAULT_AMOUNT));
4895
4895
  const draw = ctx.part("ornament");
4896
- const sounding2 = _chunkXKSO2V5Icjs.dropSilentNotes.call(void 0, notes);
4896
+ const sounding2 = _chunkS5BKZZGMcjs.dropSilentNotes.call(void 0, notes);
4897
4897
  const ordered = [...sounding2].sort((a, b) => a.startBeat - b.startBeat || a.pitch - b.pitch);
4898
4898
  const previousOf = previousOnsets(ordered);
4899
4899
  const nextOf = nextOnsets(ordered);
@@ -5147,12 +5147,12 @@ function progressions() {
5147
5147
  return PRESETS.map((p) => ({ ...p, degrees: [...p.degrees], styles: [...p.styles] }));
5148
5148
  }
5149
5149
  function progressionsByStyle(style) {
5150
- const named = _chunkXKSO2V5Icjs.assertOneOf.call(void 0, style, PROG_STYLES, "style");
5150
+ const named = _chunkS5BKZZGMcjs.assertOneOf.call(void 0, style, PROG_STYLES, "style");
5151
5151
  return progressions().filter((p) => p.styles.includes(named));
5152
5152
  }
5153
5153
  function degreeToRootPc(degree, key) {
5154
5154
  if (degree >= 1 && degree <= 7) {
5155
- const tones = _chunkYPB3A3EYcjs.scaleTonesInDegreeOrder.call(void 0, _chunkYPB3A3EYcjs.heptatonicFrameOf.call(void 0, key));
5155
+ const tones = _chunk3R3QVKY5cjs.scaleTonesInDegreeOrder.call(void 0, _chunk3R3QVKY5cjs.heptatonicFrameOf.call(void 0, key));
5156
5156
  return _nullishCoalesce(tones[degree - 1], () => ( key.rootPc % 12));
5157
5157
  }
5158
5158
  const offset = _nullishCoalesce(BORROWED_OFFSET[degree], () => ( 0));
@@ -5160,10 +5160,10 @@ function degreeToRootPc(degree, key) {
5160
5160
  }
5161
5161
  function autoQuality(degree, key, harmonicDominant) {
5162
5162
  if (degree >= 1 && degree <= 7) {
5163
- if (harmonicDominant && _chunkQ6R3QAZDcjs.isMinorKey.call(void 0, key) && degree === 5) {
5163
+ if (harmonicDominant && _chunkSGLEQVJHcjs.isMinorKey.call(void 0, key) && degree === 5) {
5164
5164
  return "maj";
5165
5165
  }
5166
- return _chunkYPB3A3EYcjs.diatonicTriad.call(void 0, degree, _chunkYPB3A3EYcjs.heptatonicFrameOf.call(void 0, key)).quality;
5166
+ return _chunk3R3QVKY5cjs.diatonicTriad.call(void 0, degree, _chunk3R3QVKY5cjs.heptatonicFrameOf.call(void 0, key)).quality;
5167
5167
  }
5168
5168
  if (degree === 14) {
5169
5169
  return "dim";
@@ -5192,39 +5192,39 @@ function pickProgressionPreset(style, ctx = 0) {
5192
5192
  function presetFor(style, ctx) {
5193
5193
  const pool = PRESETS.filter((preset) => preset.styles.includes(style));
5194
5194
  if (pool.length === 0) {
5195
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(`Unknown progression style: ${style}`);
5195
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`Unknown progression style: ${style}`);
5196
5196
  }
5197
5197
  const index = ctx.part("progression").range(0, pool.length - 1, "preset");
5198
5198
  return _nullishCoalesce(pool[index], () => ( PRESETS[0]));
5199
5199
  }
5200
5200
  function tonicizableRootPcs(key) {
5201
- return new Set(_chunkYPB3A3EYcjs.tonicizableDegrees.call(void 0, key).map((degree) => degree.rootPc));
5201
+ return new Set(_chunk3R3QVKY5cjs.tonicizableDegrees.call(void 0, key).map((degree) => degree.rootPc));
5202
5202
  }
5203
5203
  function canBeTonicized(span, tonicizable) {
5204
5204
  if (!tonicizable.has(span.rootPc)) {
5205
5205
  return false;
5206
5206
  }
5207
- return _chunkYPB3A3EYcjs.fifthPcOf.call(void 0, _chunkYPB3A3EYcjs.makeChord.call(void 0, span.rootPc, span.quality)) === (span.rootPc + 7) % 12;
5207
+ return _chunk3R3QVKY5cjs.fifthPcOf.call(void 0, _chunk3R3QVKY5cjs.makeChord.call(void 0, span.rootPc, span.quality)) === (span.rootPc + 7) % 12;
5208
5208
  }
5209
5209
  function generateProgression(opts) {
5210
- _chunkXKSO2V5Icjs.assertRecord.call(void 0, opts, "progression options");
5211
- _chunkXKSO2V5Icjs.assertPositiveInt.call(void 0, opts.bars, "progression bars");
5212
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, opts.bars, "progression chords");
5213
- const key = _chunkYPB3A3EYcjs.toKeyScale.call(void 0, opts.key);
5210
+ _chunkS5BKZZGMcjs.assertRecord.call(void 0, opts, "progression options");
5211
+ _chunkS5BKZZGMcjs.assertPositiveInt.call(void 0, opts.bars, "progression bars");
5212
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, opts.bars, "progression chords");
5213
+ const key = _chunk3R3QVKY5cjs.toKeyScale.call(void 0, opts.key);
5214
5214
  const ctx = resolveContext(opts.ctx);
5215
5215
  let preset;
5216
5216
  if (opts.preset !== void 0) {
5217
5217
  if (opts.preset.degrees.length === 0) {
5218
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)("progression preset must name at least one degree");
5218
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)("progression preset must name at least one degree");
5219
5219
  }
5220
5220
  preset = {
5221
5221
  id: _nullishCoalesce(opts.preset.id, () => ( "custom")),
5222
5222
  name: _nullishCoalesce(opts.preset.name, () => ( "Custom")),
5223
5223
  degrees: opts.preset.degrees.map((degree, index) => {
5224
- _chunkXKSO2V5Icjs.assertDegree.call(void 0, degree, `progression preset degrees[${index}]`);
5224
+ _chunkS5BKZZGMcjs.assertDegree.call(void 0, degree, `progression preset degrees[${index}]`);
5225
5225
  const supported = degree >= 1 && degree <= 7 || Object.values(BORROWED_DEGREES).includes(degree);
5226
5226
  if (!supported) {
5227
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(
5227
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(
5228
5228
  `progression preset degrees[${index}] is not a supported progression degree; received ${degree}`
5229
5229
  );
5230
5230
  }
@@ -5237,18 +5237,18 @@ function generateProgression(opts) {
5237
5237
  if (preset === void 0 && opts.presetId !== void 0) {
5238
5238
  preset = PRESETS.find((p) => p.id === opts.presetId);
5239
5239
  if (preset === void 0) {
5240
- throw new (0, _chunkXKSO2V5Icjs.InvalidInputError)(`Unknown progression preset: ${opts.presetId}`);
5240
+ throw new (0, _chunkS5BKZZGMcjs.InvalidInputError)(`Unknown progression preset: ${opts.presetId}`);
5241
5241
  }
5242
5242
  }
5243
5243
  preset ??= presetFor(opts.style, ctx);
5244
- const ext = opts.ext === void 0 ? "auto" : _chunkXKSO2V5Icjs.assertOneOf.call(void 0, opts.ext, ["auto", ..._chunkYPB3A3EYcjs.chordQualities.call(void 0, )], "progression extension");
5244
+ const ext = opts.ext === void 0 ? "auto" : _chunkS5BKZZGMcjs.assertOneOf.call(void 0, opts.ext, ["auto", ..._chunk3R3QVKY5cjs.chordQualities.call(void 0, )], "progression extension");
5245
5245
  const cycle = resolveCycle(
5246
5246
  _nullishCoalesce(_optionalChain([preset, 'optionalAccess', _59 => _59.degrees]), () => ( [0])),
5247
5247
  key,
5248
5248
  ext,
5249
5249
  _optionalChain([preset, 'optionalAccess', _60 => _60.functional]) === "cadenceStrong"
5250
5250
  );
5251
- const barBeats = _chunkXKSO2V5Icjs.beatsPerBar.call(void 0, _nullishCoalesce(opts.ts, () => ( DEFAULT_TS6)));
5251
+ const barBeats = _chunkS5BKZZGMcjs.beatsPerBar.call(void 0, _nullishCoalesce(opts.ts, () => ( DEFAULT_TS6)));
5252
5252
  const chords = [];
5253
5253
  for (let bar2 = 0; bar2 < opts.bars; bar2 += 1) {
5254
5254
  const step = cycle[bar2 % cycle.length];
@@ -5305,7 +5305,7 @@ function commonToneCount(a, b) {
5305
5305
  return a.filter((pc) => set.has(pc)).length;
5306
5306
  }
5307
5307
  function triadQualityOf(chord) {
5308
- const semis = new Set(chord.intervals.map((interval) => _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, interval)));
5308
+ const semis = new Set(chord.intervals.map((interval) => _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, interval)));
5309
5309
  const hasThird = semis.has(4) ? "maj" : semis.has(3) ? "min" : void 0;
5310
5310
  if (hasThird === void 0) {
5311
5311
  return chord.quality;
@@ -5319,15 +5319,15 @@ function triadQualityOf(chord) {
5319
5319
  return hasThird;
5320
5320
  }
5321
5321
  function diatonicTriadsOf(key) {
5322
- const degrees = _chunkYPB3A3EYcjs.scaleTonesInDegreeOrder.call(void 0, key).length;
5322
+ const degrees = _chunk3R3QVKY5cjs.scaleTonesInDegreeOrder.call(void 0, key).length;
5323
5323
  const triads = [];
5324
5324
  for (let degree = 1; degree <= degrees; degree += 1) {
5325
- triads.push(_chunkYPB3A3EYcjs.diatonicTriad.call(void 0, degree, key));
5325
+ triads.push(_chunk3R3QVKY5cjs.diatonicTriad.call(void 0, degree, key));
5326
5326
  }
5327
5327
  return triads;
5328
5328
  }
5329
5329
  function sameChord(a, b) {
5330
- return _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, a.rootPc) === _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, b.rootPc) && a.quality === b.quality;
5330
+ return _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, a.rootPc) === _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, b.rootPc) && a.quality === b.quality;
5331
5331
  }
5332
5332
  var THIRD_OFFSETS = [3, 4, 8, 9];
5333
5333
  var MAX_HINT_ALTER = 2;
@@ -5335,75 +5335,75 @@ function bareSpelling(note2) {
5335
5335
  return { letter: note2.letter, alter: note2.alter };
5336
5336
  }
5337
5337
  function spelledOnRoot(chord, root, tonic, key) {
5338
- const usable = _chunkXKSO2V5Icjs.noteToPitchClass.call(void 0, root) === _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, chord.rootPc) && Math.abs(root.alter) <= MAX_HINT_ALTER;
5338
+ const usable = _chunkS5BKZZGMcjs.noteToPitchClass.call(void 0, root) === _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, chord.rootPc) && Math.abs(root.alter) <= MAX_HINT_ALTER;
5339
5339
  const spelled = {
5340
5340
  ...chord,
5341
- rootSpelling: bareSpelling(usable ? root : _chunkYPB3A3EYcjs.spellPitchClass.call(void 0, chord.rootPc, tonic, key))
5341
+ rootSpelling: bareSpelling(usable ? root : _chunk3R3QVKY5cjs.spellPitchClass.call(void 0, chord.rootPc, tonic, key))
5342
5342
  };
5343
5343
  if (chord.bassPc !== void 0) {
5344
- spelled.bassSpelling = bareSpelling(_chunkYPB3A3EYcjs.spellPitchClass.call(void 0, chord.bassPc, tonic, key));
5344
+ spelled.bassSpelling = bareSpelling(_chunk3R3QVKY5cjs.spellPitchClass.call(void 0, chord.bassPc, tonic, key));
5345
5345
  }
5346
5346
  return spelled;
5347
5347
  }
5348
5348
  function spelledInKey(chord, tonic, key) {
5349
- return spelledOnRoot(chord, _chunkYPB3A3EYcjs.spellPitchClass.call(void 0, chord.rootPc, tonic, key), tonic, key);
5349
+ return spelledOnRoot(chord, _chunk3R3QVKY5cjs.spellPitchClass.call(void 0, chord.rootPc, tonic, key), tonic, key);
5350
5350
  }
5351
5351
  function tritoneSubstituteRoot(dominant, tonic, key) {
5352
- const substituteRootPc = _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, dominant.rootPc + 6);
5353
- if (_chunkYPB3A3EYcjs.isScaleTone.call(void 0, substituteRootPc, key)) {
5354
- return _chunkYPB3A3EYcjs.spellPitchClass.call(void 0, substituteRootPc, tonic, key);
5352
+ const substituteRootPc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, dominant.rootPc + 6);
5353
+ if (_chunk3R3QVKY5cjs.isScaleTone.call(void 0, substituteRootPc, key)) {
5354
+ return _chunk3R3QVKY5cjs.spellPitchClass.call(void 0, substituteRootPc, tonic, key);
5355
5355
  }
5356
- const resolution = _chunkYPB3A3EYcjs.spellPitchClass.call(void 0, _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, dominant.rootPc + 5), tonic, key);
5357
- return _chunkXKSO2V5Icjs.transposeNote.call(void 0, resolution, 1);
5356
+ const resolution = _chunk3R3QVKY5cjs.spellPitchClass.call(void 0, _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, dominant.rootPc + 5), tonic, key);
5357
+ return _chunkS5BKZZGMcjs.transposeNote.call(void 0, resolution, 1);
5358
5358
  }
5359
5359
  function substituteChord(chord, key, opts) {
5360
- _chunkXKSO2V5Icjs.assertOptions.call(void 0, opts, "opts");
5361
- const source = _chunkYPB3A3EYcjs.toChordData.call(void 0, chord);
5362
- const { scale, tonic } = _chunkYPB3A3EYcjs.resolveKey.call(void 0, key);
5363
- const originalTriad = _chunkYPB3A3EYcjs.chordPitchClasses.call(void 0, _chunkYPB3A3EYcjs.makeChord.call(void 0, source.rootPc, triadQualityOf(source)));
5360
+ _chunkS5BKZZGMcjs.assertOptions.call(void 0, opts, "opts");
5361
+ const source = _chunk3R3QVKY5cjs.toChordData.call(void 0, chord);
5362
+ const { scale, tonic } = _chunk3R3QVKY5cjs.resolveKey.call(void 0, key);
5363
+ const originalTriad = _chunk3R3QVKY5cjs.chordPitchClasses.call(void 0, _chunk3R3QVKY5cjs.makeChord.call(void 0, source.rootPc, triadQualityOf(source)));
5364
5364
  const candidates = [];
5365
- if (_chunkYPB3A3EYcjs.soundsDominantSeventh.call(void 0, source)) {
5366
- const substitute = _chunkYPB3A3EYcjs.makeChord.call(void 0, _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, source.rootPc + 6), "dom7");
5365
+ if (_chunk3R3QVKY5cjs.soundsDominantSeventh.call(void 0, source)) {
5366
+ const substitute = _chunk3R3QVKY5cjs.makeChord.call(void 0, _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, source.rootPc + 6), "dom7");
5367
5367
  candidates.push({
5368
5368
  chord: spelledOnRoot(substitute, tritoneSubstituteRoot(source, tonic, scale), tonic, scale),
5369
5369
  type: "tritone"
5370
5370
  });
5371
5371
  }
5372
5372
  for (const triad of diatonicTriadsOf(scale)) {
5373
- const offset = _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, triad.rootPc - source.rootPc);
5374
- if (THIRD_OFFSETS.includes(offset) && commonToneCount(originalTriad, _chunkYPB3A3EYcjs.chordPitchClasses.call(void 0, triad)) === 2) {
5373
+ const offset = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, triad.rootPc - source.rootPc);
5374
+ if (THIRD_OFFSETS.includes(offset) && commonToneCount(originalTriad, _chunk3R3QVKY5cjs.chordPitchClasses.call(void 0, triad)) === 2) {
5375
5375
  candidates.push({ chord: spelledInKey(triad, tonic, scale), type: "relative" });
5376
5376
  }
5377
5377
  }
5378
- const targetFunction = _chunkQ6R3QAZDcjs.functionOf.call(void 0, source, scale);
5379
- const parallel = _chunkQ6R3QAZDcjs.parallelKey.call(void 0, scale);
5378
+ const targetFunction = _chunkSGLEQVJHcjs.functionOf.call(void 0, source, scale);
5379
+ const parallel = _chunkSGLEQVJHcjs.parallelKey.call(void 0, scale);
5380
5380
  for (const triad of diatonicTriadsOf(parallel)) {
5381
- if (_chunkQ6R3QAZDcjs.functionOf.call(void 0, triad, scale) === targetFunction && !_chunkQ6R3QAZDcjs.isDiatonic.call(void 0, triad, scale)) {
5381
+ if (_chunkSGLEQVJHcjs.functionOf.call(void 0, triad, scale) === targetFunction && !_chunkSGLEQVJHcjs.isDiatonic.call(void 0, triad, scale)) {
5382
5382
  candidates.push({ chord: spelledInKey(triad, tonic, parallel), type: "borrowed" });
5383
5383
  }
5384
5384
  }
5385
5385
  for (const offset of THIRD_OFFSETS) {
5386
5386
  for (const quality of ["maj", "min"]) {
5387
- const mediant = _chunkYPB3A3EYcjs.makeChord.call(void 0, _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, source.rootPc + offset), quality);
5388
- if (commonToneCount(originalTriad, _chunkYPB3A3EYcjs.chordPitchClasses.call(void 0, mediant)) === 1 && !_chunkQ6R3QAZDcjs.isDiatonic.call(void 0, mediant, scale)) {
5387
+ const mediant = _chunk3R3QVKY5cjs.makeChord.call(void 0, _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, source.rootPc + offset), quality);
5388
+ if (commonToneCount(originalTriad, _chunk3R3QVKY5cjs.chordPitchClasses.call(void 0, mediant)) === 1 && !_chunkSGLEQVJHcjs.isDiatonic.call(void 0, mediant, scale)) {
5389
5389
  candidates.push({ chord: spelledInKey(mediant, tonic, scale), type: "chromaticMediant" });
5390
5390
  }
5391
5391
  }
5392
5392
  }
5393
- const melodyPcs = _optionalChain([opts, 'optionalAccess', _66 => _66.melodyPcs, 'optionalAccess', _67 => _67.map, 'call', _68 => _68(_chunkXKSO2V5Icjs.pitchClassOf)]);
5393
+ const melodyPcs = _optionalChain([opts, 'optionalAccess', _66 => _66.melodyPcs, 'optionalAccess', _67 => _67.map, 'call', _68 => _68(_chunkS5BKZZGMcjs.pitchClassOf)]);
5394
5394
  const seen = /* @__PURE__ */ new Set();
5395
5395
  const results = [];
5396
5396
  for (const candidate of candidates) {
5397
5397
  if (sameChord(candidate.chord, source)) {
5398
5398
  continue;
5399
5399
  }
5400
- const dedupeKey = `${_chunkXKSO2V5Icjs.pitchClassOf.call(void 0, candidate.chord.rootPc)}:${candidate.chord.quality}`;
5400
+ const dedupeKey = `${_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, candidate.chord.rootPc)}:${candidate.chord.quality}`;
5401
5401
  if (seen.has(dedupeKey)) {
5402
5402
  continue;
5403
5403
  }
5404
5404
  seen.add(dedupeKey);
5405
5405
  if (melodyPcs !== void 0) {
5406
- const pcs = new Set(_chunkYPB3A3EYcjs.chordPitchClasses.call(void 0, candidate.chord));
5406
+ const pcs = new Set(_chunk3R3QVKY5cjs.chordPitchClasses.call(void 0, candidate.chord));
5407
5407
  if (!melodyPcs.every((pc) => pcs.has(pc))) {
5408
5408
  continue;
5409
5409
  }
@@ -5411,65 +5411,65 @@ function substituteChord(chord, key, opts) {
5411
5411
  results.push({
5412
5412
  chord: candidate.chord,
5413
5413
  type: candidate.type,
5414
- roman: _chunkQ6R3QAZDcjs.chordToRoman.call(void 0, candidate.chord, scale),
5415
- function: _chunkQ6R3QAZDcjs.functionOf.call(void 0, candidate.chord, scale)
5414
+ roman: _chunkSGLEQVJHcjs.chordToRoman.call(void 0, candidate.chord, scale),
5415
+ function: _chunkSGLEQVJHcjs.functionOf.call(void 0, candidate.chord, scale)
5416
5416
  });
5417
5417
  }
5418
5418
  return results;
5419
5419
  }
5420
5420
  function modalInterchangePalette(key) {
5421
- const { scale, tonic } = _chunkYPB3A3EYcjs.resolveKey.call(void 0, key);
5421
+ const { scale, tonic } = _chunk3R3QVKY5cjs.resolveKey.call(void 0, key);
5422
5422
  const palette = [];
5423
5423
  const seen = /* @__PURE__ */ new Set();
5424
5424
  const add = (chord) => {
5425
- const dedupeKey = `${_chunkXKSO2V5Icjs.pitchClassOf.call(void 0, chord.rootPc)}:${chord.quality}`;
5425
+ const dedupeKey = `${_chunkS5BKZZGMcjs.pitchClassOf.call(void 0, chord.rootPc)}:${chord.quality}`;
5426
5426
  if (seen.has(dedupeKey)) {
5427
5427
  return;
5428
5428
  }
5429
5429
  seen.add(dedupeKey);
5430
5430
  palette.push({
5431
5431
  chord,
5432
- roman: _chunkQ6R3QAZDcjs.chordToRoman.call(void 0, chord, scale),
5433
- source: _chunkQ6R3QAZDcjs.borrowedSource.call(void 0, chord, scale)
5432
+ roman: _chunkSGLEQVJHcjs.chordToRoman.call(void 0, chord, scale),
5433
+ source: _chunkSGLEQVJHcjs.borrowedSource.call(void 0, chord, scale)
5434
5434
  });
5435
5435
  };
5436
- const parallel = _chunkQ6R3QAZDcjs.parallelKey.call(void 0, scale);
5436
+ const parallel = _chunkSGLEQVJHcjs.parallelKey.call(void 0, scale);
5437
5437
  for (const triad of diatonicTriadsOf(parallel)) {
5438
- if (!_chunkQ6R3QAZDcjs.isDiatonic.call(void 0, triad, scale) && _chunkQ6R3QAZDcjs.borrowedSource.call(void 0, triad, scale) !== null) {
5438
+ if (!_chunkSGLEQVJHcjs.isDiatonic.call(void 0, triad, scale) && _chunkSGLEQVJHcjs.borrowedSource.call(void 0, triad, scale) !== null) {
5439
5439
  add(spelledInKey(triad, tonic, parallel));
5440
5440
  }
5441
5441
  }
5442
- const neapolitan = _chunkYPB3A3EYcjs.makeChord.call(void 0, _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, scale.rootPc + 1), "maj");
5443
- if (!_chunkQ6R3QAZDcjs.isDiatonic.call(void 0, neapolitan, scale)) {
5444
- add(spelledOnRoot(neapolitan, _chunkXKSO2V5Icjs.transposeNote.call(void 0, tonic, 1), tonic, scale));
5442
+ const neapolitan = _chunk3R3QVKY5cjs.makeChord.call(void 0, _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, scale.rootPc + 1), "maj");
5443
+ if (!_chunkSGLEQVJHcjs.isDiatonic.call(void 0, neapolitan, scale)) {
5444
+ add(spelledOnRoot(neapolitan, _chunkS5BKZZGMcjs.transposeNote.call(void 0, tonic, 1), tonic, scale));
5445
5445
  }
5446
5446
  return palette;
5447
5447
  }
5448
5448
  function negativeHarmonyMirror(chord, key) {
5449
- const source = _chunkYPB3A3EYcjs.toChordData.call(void 0, chord);
5450
- const { scale, tonic } = _chunkYPB3A3EYcjs.resolveKey.call(void 0, key);
5451
- const tonicPc = _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, scale.rootPc);
5452
- const mirror = (p) => _chunkXKSO2V5Icjs.pitchClassOf.call(void 0, 2 * tonicPc + 7 - p);
5453
- const pcs = _chunkYPB3A3EYcjs.chordPitchClasses.call(void 0, source).map(mirror);
5449
+ const source = _chunk3R3QVKY5cjs.toChordData.call(void 0, chord);
5450
+ const { scale, tonic } = _chunk3R3QVKY5cjs.resolveKey.call(void 0, key);
5451
+ const tonicPc = _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, scale.rootPc);
5452
+ const mirror = (p) => _chunkS5BKZZGMcjs.pitchClassOf.call(void 0, 2 * tonicPc + 7 - p);
5453
+ const pcs = _chunk3R3QVKY5cjs.chordPitchClasses.call(void 0, source).map(mirror);
5454
5454
  const bassPc = source.bassPc !== void 0 ? mirror(source.bassPc) : void 0;
5455
5455
  const pitches = bassPc !== void 0 ? [bassPc, ...pcs.map((pc) => pc + 12)] : pcs;
5456
- const detected = _chunkQ6R3QAZDcjs.detectChordBest.call(void 0, pitches);
5456
+ const detected = _chunkSGLEQVJHcjs.detectChordBest.call(void 0, pitches);
5457
5457
  if (detected) {
5458
5458
  if (bassPc === void 0 && detected.bassPc !== void 0) {
5459
- return spelledInKey(_chunkYPB3A3EYcjs.makeChord.call(void 0, detected.rootPc, detected.quality), tonic, scale);
5459
+ return spelledInKey(_chunk3R3QVKY5cjs.makeChord.call(void 0, detected.rootPc, detected.quality), tonic, scale);
5460
5460
  }
5461
5461
  return spelledInKey(detected, tonic, scale);
5462
5462
  }
5463
5463
  const quality = source.quality;
5464
- return spelledInKey(_chunkYPB3A3EYcjs.makeChord.call(void 0, mirror(source.rootPc), quality, bassPc), tonic, scale);
5464
+ return spelledInKey(_chunk3R3QVKY5cjs.makeChord.call(void 0, mirror(source.rootPc), quality, bassPc), tonic, scale);
5465
5465
  }
5466
5466
 
5467
5467
  // src/generate/rhythm/index.ts
5468
5468
  var DEFAULT_RHYTHM_VELOCITY = 96;
5469
5469
  function rhythmToNoteEvents(events, pitch, velocity = DEFAULT_RHYTHM_VELOCITY) {
5470
- _chunkXKSO2V5Icjs.assertMidiPitch.call(void 0, pitch, "pitch");
5471
- _chunkXKSO2V5Icjs.assertInteger.call(void 0, velocity, "velocity", 0, 127);
5472
- return _chunkXKSO2V5Icjs.assertArray.call(void 0, events, "events").map((event) => ({
5470
+ _chunkS5BKZZGMcjs.assertMidiPitch.call(void 0, pitch, "pitch");
5471
+ _chunkS5BKZZGMcjs.assertInteger.call(void 0, velocity, "velocity", 0, 127);
5472
+ return _chunkS5BKZZGMcjs.assertArray.call(void 0, events, "events").map((event) => ({
5473
5473
  pitch,
5474
5474
  startBeat: event.position,
5475
5475
  durationBeat: event.duration,
@@ -5480,7 +5480,7 @@ var DEFAULT_SUBDIVISION = 2;
5480
5480
  var DEFAULT_DENSITY = 0.5;
5481
5481
  var DEFAULT_BARS = 1;
5482
5482
  function onsetWeightCurve(weight) {
5483
- _chunkXKSO2V5Icjs.assertInteger.call(void 0, weight, "weight", 0, 3);
5483
+ _chunkS5BKZZGMcjs.assertInteger.call(void 0, weight, "weight", 0, 3);
5484
5484
  switch (weight) {
5485
5485
  case 3:
5486
5486
  return 1;
@@ -5493,20 +5493,20 @@ function onsetWeightCurve(weight) {
5493
5493
  }
5494
5494
  }
5495
5495
  function generateRhythm(ts, opts = {}) {
5496
- const asked = _chunkXKSO2V5Icjs.assertOptions.call(void 0, opts, "opts");
5497
- const meter = _chunkXKSO2V5Icjs.meterAt.call(void 0, 0, _chunkXKSO2V5Icjs.toMeterData.call(void 0, ts, "ts"));
5496
+ const asked = _chunkS5BKZZGMcjs.assertOptions.call(void 0, opts, "opts");
5497
+ const meter = _chunkS5BKZZGMcjs.meterAt.call(void 0, 0, _chunkS5BKZZGMcjs.toMeterData.call(void 0, ts, "ts"));
5498
5498
  const bars = _nullishCoalesce(asked.bars, () => ( DEFAULT_BARS));
5499
5499
  const subdivision = _nullishCoalesce(asked.subdivision, () => ( DEFAULT_SUBDIVISION));
5500
5500
  const ctx = resolveContext(asked.ctx);
5501
5501
  const density = _nullishCoalesce(ctx.rhythmic, () => ( DEFAULT_DENSITY));
5502
- _chunkXKSO2V5Icjs.assertPositiveInt.call(void 0, bars, "rhythm bars");
5503
- _chunkXKSO2V5Icjs.assertPositiveInt.call(void 0, subdivision, "rhythm subdivision");
5504
- const barBeats = _chunkXKSO2V5Icjs.beatsPerBar.call(void 0, meter);
5502
+ _chunkS5BKZZGMcjs.assertPositiveInt.call(void 0, bars, "rhythm bars");
5503
+ _chunkS5BKZZGMcjs.assertPositiveInt.call(void 0, subdivision, "rhythm subdivision");
5504
+ const barBeats = _chunkS5BKZZGMcjs.beatsPerBar.call(void 0, meter);
5505
5505
  const spanBeats = barBeats * bars;
5506
5506
  const step = 1 / subdivision;
5507
5507
  const slotsPerBar = Math.ceil(barBeats * subdivision);
5508
5508
  const slotCount = slotsPerBar * bars;
5509
- _chunkXKSO2V5Icjs.assertGenerationBudget.call(void 0, slotCount, "rhythm grid slots");
5509
+ _chunkS5BKZZGMcjs.assertGenerationBudget.call(void 0, slotCount, "rhythm grid slots");
5510
5510
  const draw = ctx.part("rhythm");
5511
5511
  const positions = [];
5512
5512
  for (let bar2 = 0; bar2 < bars; bar2 += 1) {
@@ -5521,7 +5521,7 @@ function generateRhythm(ts, opts = {}) {
5521
5521
  positions.push(position);
5522
5522
  continue;
5523
5523
  }
5524
- const weight = _chunkXKSO2V5Icjs.metricWeight.call(void 0, position, meter);
5524
+ const weight = _chunkS5BKZZGMcjs.metricWeight.call(void 0, position, meter);
5525
5525
  const probability = onsetWeightCurve(weight) * density;
5526
5526
  if (draw.prob(probability, "onset", bar2, slot)) {
5527
5527
  positions.push(position);
@@ -5537,8 +5537,8 @@ function generateRhythm(ts, opts = {}) {
5537
5537
  return events;
5538
5538
  }
5539
5539
  function rhythmDensity(events, ts) {
5540
- _chunkXKSO2V5Icjs.assertArray.call(void 0, events, "events");
5541
- const barBeats = _chunkXKSO2V5Icjs.beatsPerBar.call(void 0, ts);
5540
+ _chunkS5BKZZGMcjs.assertArray.call(void 0, events, "events");
5541
+ const barBeats = _chunkS5BKZZGMcjs.beatsPerBar.call(void 0, ts);
5542
5542
  if (events.length === 0) {
5543
5543
  return 0;
5544
5544
  }
@@ -5618,4 +5618,4 @@ function rhythmDensity(events, ts) {
5618
5618
 
5619
5619
 
5620
5620
  exports.GENRES = GENRES; exports.PROVENANCE_BASES = PROVENANCE_BASES; exports.fitsQuery = fitsQuery; exports.selectVocabulary = selectVocabulary; exports.pickVocabulary = pickVocabulary; exports.mergeVocabulary = mergeVocabulary; exports.vocabularyOfKind = vocabularyOfKind; exports.assertVocabulary = assertVocabulary; exports.MIN_DIFFICULTY = MIN_DIFFICULTY; exports.MAX_DIFFICULTY = MAX_DIFFICULTY; exports.sustainsStrokes = sustainsStrokes; exports.sustainsShift = sustainsShift; exports.resolveContext = resolveContext; exports.BAR_STEPS = BAR_STEPS; exports.BEAT_STEPS = BEAT_STEPS; exports.STEP_BEATS = STEP_BEATS; exports.gridMetricWeight = gridMetricWeight; exports.thin = thin; exports.double = double; exports.halfTime = halfTime; exports.doubleTime = doubleTime; exports.syncopate = syncopate; exports.ornamentBy = ornamentBy; exports.deform = deform; exports.withinCeiling = withinCeiling; exports.isLickMaterial = isLickMaterial; exports.BASS_LICKS = BASS_LICKS; exports.placeLicks = placeLicks; exports.BASS_STYLES = BASS_STYLES; exports.generateBassLine = generateBassLine; exports.imitate = imitate; exports.generateCounterMelody = generateCounterMelody; exports.FILL_TYPES = FILL_TYPES; exports.FILL_ARCHETYPES = FILL_ARCHETYPES; exports.isFillArchetype = isFillArchetype; exports.DRUM_NOTES = DRUM_NOTES; exports.drumVoiceOf = drumVoiceOf; exports.KICK_STEPS = KICK_STEPS; exports.KICK_FIGURES = KICK_FIGURES; exports.DRUM_KIT = DRUM_KIT; exports.isDrumPattern = isDrumPattern; exports.DRUM_PATTERNS = DRUM_PATTERNS; exports.placeDrumPattern = placeDrumPattern; exports.generateDrums = generateDrums; exports.humanize = humanize; exports.extractGrooveTemplate = extractGrooveTemplate; exports.applyGrooveTemplate = applyGrooveTemplate; exports.classifyMelodyTones = classifyMelodyTones; exports.harmonizeMelody = harmonizeMelody; exports.cellSpan = cellSpan; exports.generateMotif = generateMotif; exports.motifToNoteEvents = motifToNoteEvents; exports.transformMotif = transformMotif; exports.developMotif = developMotif; exports.ORNAMENT_STYLES = ORNAMENT_STYLES; exports.ornament = ornament; exports.BORROWED_DEGREES = BORROWED_DEGREES; exports.progressions = progressions; exports.progressionsByStyle = progressionsByStyle; exports.pickProgressionPreset = pickProgressionPreset; exports.generateProgression = generateProgression; exports.substituteChord = substituteChord; exports.modalInterchangePalette = modalInterchangePalette; exports.negativeHarmonyMirror = negativeHarmonyMirror; exports.rhythmToNoteEvents = rhythmToNoteEvents; exports.onsetWeightCurve = onsetWeightCurve; exports.generateRhythm = generateRhythm; exports.rhythmDensity = rhythmDensity;
5621
- //# sourceMappingURL=chunk-5KW7DNCJ.cjs.map
5621
+ //# sourceMappingURL=chunk-J7FHVZII.cjs.map