@libraz/libcantus 1.0.1 → 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 (142) hide show
  1. package/README.md +27 -65
  2. package/README_ja.md +28 -66
  3. package/dist/analyze/index.cjs +11 -7
  4. package/dist/analyze/index.cjs.map +1 -1
  5. package/dist/analyze/index.d.cts +79 -144
  6. package/dist/analyze/index.d.ts +79 -144
  7. package/dist/analyze/index.js +20 -16
  8. package/dist/chunk-35NBV2FT.cjs +145 -0
  9. package/dist/chunk-35NBV2FT.cjs.map +1 -0
  10. package/dist/{chunk-UADYAYAT.cjs → chunk-3R3QVKY5.cjs} +1353 -580
  11. package/dist/chunk-3R3QVKY5.cjs.map +1 -0
  12. package/dist/{chunk-WWURE4XT.cjs → chunk-76ZBTRG2.cjs} +624 -729
  13. package/dist/chunk-76ZBTRG2.cjs.map +1 -0
  14. package/dist/{chunk-FVSI36UV.js → chunk-7KG3RTYS.js} +197 -110
  15. package/dist/chunk-7KG3RTYS.js.map +1 -0
  16. package/dist/{chunk-VTI6FOLB.js → chunk-AGOVW7U6.js} +709 -133
  17. package/dist/chunk-AGOVW7U6.js.map +1 -0
  18. package/dist/{chunk-E3F4AHAH.cjs → chunk-CGBADIO5.cjs} +221 -134
  19. package/dist/chunk-CGBADIO5.cjs.map +1 -0
  20. package/dist/{chunk-6XH6QZYQ.cjs → chunk-DSMJRXCZ.cjs} +1455 -849
  21. package/dist/chunk-DSMJRXCZ.cjs.map +1 -0
  22. package/dist/{chunk-PKFNUHDY.js → chunk-FBH75DAY.js} +1218 -612
  23. package/dist/chunk-FBH75DAY.js.map +1 -0
  24. package/dist/chunk-H2KJHBW4.js +3329 -0
  25. package/dist/chunk-H2KJHBW4.js.map +1 -0
  26. package/dist/chunk-HPVSH7SF.cjs +2294 -0
  27. package/dist/chunk-HPVSH7SF.cjs.map +1 -0
  28. package/dist/{chunk-MXO72PLY.cjs → chunk-HWHGOVO6.cjs} +21 -19
  29. package/dist/chunk-HWHGOVO6.cjs.map +1 -0
  30. package/dist/chunk-HYJJ2V2I.js +2294 -0
  31. package/dist/chunk-HYJJ2V2I.js.map +1 -0
  32. package/dist/{chunk-AFM2ULJH.cjs → chunk-J7FHVZII.cjs} +1567 -1067
  33. package/dist/chunk-J7FHVZII.cjs.map +1 -0
  34. package/dist/chunk-K6OZXIR6.js +1 -0
  35. package/dist/{chunk-H3VORETI.js → chunk-M5RYMAFI.js} +487 -592
  36. package/dist/chunk-M5RYMAFI.js.map +1 -0
  37. package/dist/chunk-NB25P3EH.js +363 -0
  38. package/dist/chunk-NB25P3EH.js.map +1 -0
  39. package/dist/{chunk-TTCLJX6D.js → chunk-NFJ4P6ZZ.js} +10 -8
  40. package/dist/chunk-NFJ4P6ZZ.js.map +1 -0
  41. package/dist/chunk-NM7UAMC3.cjs +457 -0
  42. package/dist/chunk-NM7UAMC3.cjs.map +1 -0
  43. package/dist/chunk-PM4XJE2Y.cjs +363 -0
  44. package/dist/chunk-PM4XJE2Y.cjs.map +1 -0
  45. package/dist/chunk-PUKJP2Z5.js +145 -0
  46. package/dist/chunk-PUKJP2Z5.js.map +1 -0
  47. package/dist/{chunk-VOHZB45S.js → chunk-Q6LFSAKV.js} +1321 -821
  48. package/dist/chunk-Q6LFSAKV.js.map +1 -0
  49. package/dist/{chunk-INHVXP6Z.js → chunk-RFIBF2RR.js} +1203 -430
  50. package/dist/chunk-RFIBF2RR.js.map +1 -0
  51. package/dist/{chunk-Q2WGKJNN.cjs → chunk-S5BKZZGM.cjs} +699 -123
  52. package/dist/chunk-S5BKZZGM.cjs.map +1 -0
  53. package/dist/chunk-SGLEQVJH.cjs +3329 -0
  54. package/dist/chunk-SGLEQVJH.cjs.map +1 -0
  55. package/dist/chunk-UGLFDG7L.cjs +1 -0
  56. package/dist/chunk-UGLFDG7L.cjs.map +1 -0
  57. package/dist/{chunk-YH3BIKHH.js → chunk-UMWZ4ZET.js} +146 -49
  58. package/dist/chunk-UMWZ4ZET.js.map +1 -0
  59. package/dist/{index-szBv3496.d.ts → coerce-DP0vYu-x.d.ts} +286 -199
  60. package/dist/{index-C_8o--VE.d.cts → coerce-DRERzdve.d.cts} +286 -199
  61. package/dist/core/index.cjs +9 -5
  62. package/dist/core/index.cjs.map +1 -1
  63. package/dist/core/index.d.cts +122 -108
  64. package/dist/core/index.d.ts +122 -108
  65. package/dist/core/index.js +32 -28
  66. package/dist/generate/index.cjs +8 -8
  67. package/dist/generate/index.d.cts +168 -84
  68. package/dist/generate/index.d.ts +168 -84
  69. package/dist/generate/index.js +7 -7
  70. package/dist/{index-CGpRv5sl.d.cts → index-9eoQs2C1.d.ts} +34 -19
  71. package/dist/{index-CCNJRG-P.d.cts → index-B9QLziDe.d.cts} +293 -56
  72. package/dist/{index-Dzr13q3d.d.cts → index-BBWNZS0f.d.cts} +135 -58
  73. package/dist/{index-9wcMhG73.d.ts → index-BHIUyjhZ.d.ts} +293 -56
  74. package/dist/{index-BGFW-8P2.d.cts → index-BJgP97N1.d.ts} +196 -114
  75. package/dist/{index-CunYKLiu.d.ts → index-BL5N2Oyz.d.cts} +1 -1
  76. package/dist/{index-Cj49F892.d.ts → index-BMweUlm5.d.cts} +63 -23
  77. package/dist/{index-CgHqxdps.d.ts → index-BNSM-DSk.d.cts} +196 -114
  78. package/dist/{index-D57QRbVn.d.ts → index-BRMbPkHE.d.ts} +480 -254
  79. package/dist/{index-Chbst3Jx.d.ts → index-CJBBiAmU.d.ts} +135 -58
  80. package/dist/{index-BkGmlyI3.d.cts → index-CL4b4gUQ.d.ts} +63 -23
  81. package/dist/{index-B9MNZboQ.d.ts → index-Cy15oTvh.d.cts} +52 -22
  82. package/dist/{index-B9MNZboQ.d.cts → index-Cy15oTvh.d.ts} +52 -22
  83. package/dist/{index-BO6xE9YU.d.cts → index-DGCNKAUr.d.cts} +480 -254
  84. package/dist/{index-B4o55NDr.d.cts → index-Dw2DP7vm.d.ts} +1 -1
  85. package/dist/{index-G1uwGGWQ.d.ts → index-cHvbYgJI.d.cts} +34 -19
  86. package/dist/index.cjs +42 -14
  87. package/dist/index.cjs.map +1 -1
  88. package/dist/index.d.cts +14 -14
  89. package/dist/index.d.ts +14 -14
  90. package/dist/index.js +82 -54
  91. package/dist/{masks-DYbE485J.d.cts → masks-Cc7-MzzY.d.ts} +49 -2
  92. package/dist/{masks-DYbE485J.d.ts → masks-pADfTOiD.d.cts} +49 -2
  93. package/dist/model/index.cjs +19 -12
  94. package/dist/model/index.cjs.map +1 -1
  95. package/dist/model/index.d.cts +504 -182
  96. package/dist/model/index.d.ts +504 -182
  97. package/dist/model/index.js +18 -11
  98. package/dist/{positional-Cptlj-xs.d.ts → positional-DJgs6ltD.d.ts} +85 -8
  99. package/dist/{positional-DvH_sd8u.d.cts → positional-DMZer-FM.d.cts} +85 -8
  100. package/dist/theory/index.cjs +35 -6
  101. package/dist/theory/index.cjs.map +1 -1
  102. package/dist/theory/index.d.cts +257 -62
  103. package/dist/theory/index.d.ts +257 -62
  104. package/dist/theory/index.js +41 -12
  105. package/package.json +7 -5
  106. package/dist/chunk-2LCPM3EG.js +0 -3224
  107. package/dist/chunk-2LCPM3EG.js.map +0 -1
  108. package/dist/chunk-6XH6QZYQ.cjs.map +0 -1
  109. package/dist/chunk-6XPTBE7Y.cjs +0 -49
  110. package/dist/chunk-6XPTBE7Y.cjs.map +0 -1
  111. package/dist/chunk-AFM2ULJH.cjs.map +0 -1
  112. package/dist/chunk-B6XNKWZV.cjs +0 -3224
  113. package/dist/chunk-B6XNKWZV.cjs.map +0 -1
  114. package/dist/chunk-E3F4AHAH.cjs.map +0 -1
  115. package/dist/chunk-ELCTZUJJ.js +0 -379
  116. package/dist/chunk-ELCTZUJJ.js.map +0 -1
  117. package/dist/chunk-FVSI36UV.js.map +0 -1
  118. package/dist/chunk-H3VORETI.js.map +0 -1
  119. package/dist/chunk-H42UHPYW.js +0 -1577
  120. package/dist/chunk-H42UHPYW.js.map +0 -1
  121. package/dist/chunk-HFPS7JFD.js +0 -1
  122. package/dist/chunk-INHVXP6Z.js.map +0 -1
  123. package/dist/chunk-K4ZJUGF4.cjs +0 -379
  124. package/dist/chunk-K4ZJUGF4.cjs.map +0 -1
  125. package/dist/chunk-KNJEKLKV.js +0 -49
  126. package/dist/chunk-KNJEKLKV.js.map +0 -1
  127. package/dist/chunk-MXO72PLY.cjs.map +0 -1
  128. package/dist/chunk-NLEU4QSE.cjs +0 -360
  129. package/dist/chunk-NLEU4QSE.cjs.map +0 -1
  130. package/dist/chunk-OE6WK2Y2.cjs +0 -1577
  131. package/dist/chunk-OE6WK2Y2.cjs.map +0 -1
  132. package/dist/chunk-PKFNUHDY.js.map +0 -1
  133. package/dist/chunk-Q2WGKJNN.cjs.map +0 -1
  134. package/dist/chunk-RHIJ3S4I.cjs +0 -1
  135. package/dist/chunk-RHIJ3S4I.cjs.map +0 -1
  136. package/dist/chunk-TTCLJX6D.js.map +0 -1
  137. package/dist/chunk-UADYAYAT.cjs.map +0 -1
  138. package/dist/chunk-VOHZB45S.js.map +0 -1
  139. package/dist/chunk-VTI6FOLB.js.map +0 -1
  140. package/dist/chunk-WWURE4XT.cjs.map +0 -1
  141. package/dist/chunk-YH3BIKHH.js.map +0 -1
  142. /package/dist/{chunk-HFPS7JFD.js.map → chunk-K6OZXIR6.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import { j as ChordToneRole, c as ChordLike } from './index-szBv3496.js';
1
+ import { i as ChordToneRole, c as ChordLike } from './coerce-DRERzdve.cjs';
2
2
 
3
3
  /**
4
4
  * Harmonic role a pitch plays within a chord.
@@ -1,4 +1,4 @@
1
- import { P as ParseResult } from './index-B9MNZboQ.js';
1
+ import { P as ParseResult } from './index-Cy15oTvh.cjs';
2
2
 
3
3
  /**
4
4
  * Meter arithmetic shared by the meter module and the validation guards.
@@ -83,6 +83,14 @@ type MeterChange = {
83
83
  * The first entry also governs everything before it, which is what reads a
84
84
  * pickup written at negative beats in the signature the piece opens in.
85
85
  *
86
+ * Beat 0 is the first downbeat here as everywhere else: the opening signature
87
+ * lays its bar lines from beat 0 whatever beat the first entry is written at, so
88
+ * a map opening at the pickup it covers numbers its bars exactly as the bare
89
+ * signature does. Every later entry starts a bar at the beat it takes effect.
90
+ *
91
+ * Pass the whole piece with its map rather than one call per meter span: a
92
+ * split call cannot see a voice move or a key region that crosses the change.
93
+ *
86
94
  * @category Rhythm & Meter
87
95
  */
88
96
  type MeterMap = MeterChange[];
@@ -123,7 +131,10 @@ type MeterLike = string | TimeSignature | MeterMap | {
123
131
  * value whose `toJSON` returns one of those.
124
132
  * @param name What the meter is called in an error message, so a caller that
125
133
  * holds several of them hears which one was malformed.
126
- * @returns The validated signature, or the validated map.
134
+ * @returns The validated signature, or the validated map, freshly allocated
135
+ * down to every grouping array — so a caller may keep and edit what it gets
136
+ * back without editing the meter it passed in, and without any two calls
137
+ * handing out the same object.
127
138
  * @throws If the value names no meter, or the meter it names is malformed.
128
139
  */
129
140
  declare function toMeterData(value: MeterLike, name?: string): MeterData;
@@ -186,17 +197,23 @@ declare function tryParseTimeSignature(text: string): ParseResult<TimeSignature>
186
197
  *
187
198
  * The additive form is what {@link parseTimeSignature} reads back, and it adds
188
199
  * its terms to get the numerator — so only a grouping written in denominator
189
- * units can be rendered that way. A grouping counted in main pulses (9/8 as
190
- * `[1, 1, 1]`, 12/8 as `[2, 2]`) would come back as a different bar, so it
191
- * falls back to the plain form, which those groupings cost nothing: they select
192
- * the same reading the bare signature does.
200
+ * units can be rendered that way. A grouping counted in main pulses whose groups
201
+ * are all the same length (9/8 as `[1, 1, 1]`, 12/8 as `[2, 2]`) states the
202
+ * division the bare signature already has, so it falls back to the plain form at
203
+ * no cost. One whose groups differ (12/8 as `[1, 1, 2]`) states an accent no
204
+ * signature text can carry, and asking for the additive form of it is refused
205
+ * rather than answered with a bar that weighs its pulses differently.
193
206
  *
194
207
  * The plain form drops the grouping, so a round trip through it reads 7/8 as
195
208
  * flat rather than as 2+2+3; ask for the additive form to keep it.
196
209
  *
197
- * @param ts The time signature.
210
+ * @param ts The time signature, in any form that names one; a meter map is
211
+ * rendered as the signature it opens in.
198
212
  * @param opts Set `grouping: true` to render an additive grouping.
199
213
  * @returns The formatted signature.
214
+ * @throws If `grouping: true` is asked of a grouping that no signature text can
215
+ * spell: one counted in main pulses, on a compound numerator, whose groups are
216
+ * not all the same length.
200
217
  * @example
201
218
  * ```ts
202
219
  * import { formatTimeSignature } from '@libraz/libcantus';
@@ -206,7 +223,7 @@ declare function tryParseTimeSignature(text: string): ParseResult<TimeSignature>
206
223
  * ```
207
224
  * @category Rhythm & Meter
208
225
  */
209
- declare function formatTimeSignature(ts: TimeSignature, opts?: {
226
+ declare function formatTimeSignature(ts: MeterLike, opts?: {
210
227
  grouping?: boolean;
211
228
  }): string;
212
229
  /**
@@ -217,19 +234,27 @@ declare function formatTimeSignature(ts: TimeSignature, opts?: {
217
234
  * is a signature whose {@link TimeSignature.grouping} selects the additive
218
235
  * reading (9/8 as 2+2+2+3).
219
236
  *
220
- * @param ts The time signature.
237
+ * @param ts The time signature, in any form that names one; a meter map is read
238
+ * as the signature it opens in.
221
239
  * @returns True for compound meters.
222
240
  * @category Rhythm & Meter
223
241
  */
224
- declare function isCompound(ts: TimeSignature): boolean;
242
+ declare function isCompound(ts: MeterLike): boolean;
225
243
  /**
226
244
  * Length of a bar in quarter-note beats.
227
245
  *
228
- * @param ts The time signature.
246
+ * @param ts The time signature, in any form that names one; a meter map has no
247
+ * single bar length, so it is read as the signature it opens in. Ask
248
+ * {@link beatsPerBarAt} for the bar a given beat falls in.
229
249
  * @returns The bar length in quarter notes.
250
+ * @example
251
+ * ```ts
252
+ * import { beatsPerBar } from '@libraz/libcantus';
253
+ * beatsPerBar('6/8'); // 3
254
+ * ```
230
255
  * @category Rhythm & Meter
231
256
  */
232
- declare function beatsPerBar(ts: TimeSignature): number;
257
+ declare function beatsPerBar(ts: MeterLike): number;
233
258
  /**
234
259
  * The time signature in force at a beat.
235
260
  *
@@ -284,6 +309,12 @@ declare function barIndexAt(beatInQuarters: number, meter: MeterLike): number;
284
309
  * The meter-map counterpart of {@link beatsPerBar}, which answers for one
285
310
  * signature and so cannot be asked about a piece that changes meter.
286
311
  *
312
+ * The bar the beat is in, not the bar its signature nominally has: a change of
313
+ * meter starts a new bar, so a bar interrupted by one is shorter than its own
314
+ * signature says. Reading the signature's own length there would put the end of
315
+ * the bar past where the next one begins, and every span measured in bars from
316
+ * that point on would be counted against a bar length the music never had.
317
+ *
287
318
  * @param beatInQuarters Absolute position in quarter-note beats.
288
319
  * @param meter A single signature, or the piece's meter map.
289
320
  * @returns The bar length in quarter notes.
@@ -300,7 +331,9 @@ declare function beatsPerBarAt(beatInQuarters: number, meter: MeterLike): number
300
331
  *
301
332
  * @param opts The options carrying `ts`, `meters`, or neither.
302
333
  * @param name What the options belong to, for the error message.
303
- * @returns The meter map to analyse against; 4/4 throughout when neither is given.
334
+ * @returns The meter map to analyse against, freshly allocated down to every
335
+ * signature and grouping array, so writing to it changes nothing another
336
+ * caller reads; 4/4 throughout when neither `ts` nor `meters` is given.
304
337
  * @throws If both `ts` and `meters` are given, or the map is malformed.
305
338
  * @example
306
339
  * ```ts
@@ -311,8 +344,8 @@ declare function beatsPerBarAt(beatInQuarters: number, meter: MeterLike): number
311
344
  * @category Rhythm & Meter
312
345
  */
313
346
  declare function resolveMeters(opts: {
314
- ts?: TimeSignature;
315
- meters?: MeterMap;
347
+ ts?: MeterLike;
348
+ meters?: MeterLike;
316
349
  }, name?: string): MeterMap;
317
350
  /**
318
351
  * Number of main pulses (felt beats) per bar: the numerator for simple meters,
@@ -324,11 +357,12 @@ declare function resolveMeters(opts: {
324
357
  * {@link TimeSignature.grouping}; {@link metricWeight} then accents each
325
358
  * group's head pulse.
326
359
  *
327
- * @param ts The time signature.
360
+ * @param ts The time signature, in any form that names one; a meter map is read
361
+ * as the signature it opens in.
328
362
  * @returns The pulse count per bar.
329
363
  * @category Rhythm & Meter
330
364
  */
331
- declare function pulsesPerBar(ts: TimeSignature): number;
365
+ declare function pulsesPerBar(ts: MeterLike): number;
332
366
  /**
333
367
  * Convert an absolute quarter-note position to a bar index and in-bar offset.
334
368
  *
@@ -351,16 +385,17 @@ declare function beatToBarPosition(beatInQuarters: number, meter: MeterLike): Ba
351
385
  * denominator unit in an additive metre. Position displays, click tracks, and
352
386
  * score export are all written against this length.
353
387
  *
354
- * @param ts The time signature.
388
+ * @param ts The time signature, in any form that names one; a meter map is read
389
+ * as the signature it opens in.
355
390
  * @returns The pulse length in quarter-note beats.
356
391
  * @example
357
392
  * ```ts
358
- * import { parseTimeSignature, pulseBeats } from '@libraz/libcantus';
359
- * pulseBeats(parseTimeSignature('6/8')); // 1.5
393
+ * import { pulseBeats } from '@libraz/libcantus';
394
+ * pulseBeats('6/8'); // 1.5
360
395
  * ```
361
396
  * @category Rhythm & Meter
362
397
  */
363
- declare function pulseBeats(ts: TimeSignature): number;
398
+ declare function pulseBeats(ts: MeterLike): number;
364
399
  /**
365
400
  * The felt-beat number of a bar position, 1-based.
366
401
  *
@@ -391,11 +426,16 @@ declare function barPositionToPulse(pos: BarPosition, meter: MeterLike): number;
391
426
  * @param beatInQuarters Absolute position in quarter-note beats.
392
427
  * @param meter A single signature, or the piece's meter map.
393
428
  * @param decimals Digits of the fractional beat to keep.
394
- * @returns The formatted position, e.g. `'3.2'` for bar 3, felt beat 2.
429
+ * @returns The formatted position in one of two forms: `bar.beat` on a felt
430
+ * beat, e.g. `'3.2'` for bar 3, felt beat 2; and `bar.beat+fraction` between
431
+ * felt beats, e.g. `'3.2+0.5'` halfway from the second felt beat to the third.
432
+ * A reader of these strings has to take both, since most onsets of an ordinary
433
+ * piece fall between pulses.
395
434
  * @example
396
435
  * ```ts
397
436
  * import { formatBarPosition, parseTimeSignature } from '@libraz/libcantus';
398
437
  * formatBarPosition(7.5, parseTimeSignature('6/8')); // '3.2'
438
+ * formatBarPosition(8.25, parseTimeSignature('6/8')); // '3.2+0.5'
399
439
  * ```
400
440
  * @category Rhythm & Meter
401
441
  */
@@ -425,7 +465,7 @@ declare function barPositionToBeat(pos: BarPosition, meter: MeterLike): number;
425
465
  * an ungrouped bar rather than accenting every group head.
426
466
  *
427
467
  * Given a meter map, the weight follows the signature in force at that beat, so
428
- * beat 5 of a piece is a mid-bar accent in 4/4 and a plain main pulse in 3/4.
468
+ * beat 2 of a piece is a mid-bar accent in 4/4 and a plain main pulse in 3/4.
429
469
  * The downbeat is beat 0 however much pickup precedes it, so a note in the
430
470
  * pickup weighs as the upbeat it is rather than as a downbeat.
431
471
  *