@libraz/libcantus 1.0.0 → 1.1.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-TTCLJX6D.js → chunk-57WB2EDF.js} +10 -8
  9. package/dist/chunk-57WB2EDF.js.map +1 -0
  10. package/dist/chunk-5JJ6EHEZ.cjs +457 -0
  11. package/dist/chunk-5JJ6EHEZ.cjs.map +1 -0
  12. package/dist/{chunk-AFM2ULJH.cjs → chunk-5KW7DNCJ.cjs} +1567 -1067
  13. package/dist/chunk-5KW7DNCJ.cjs.map +1 -0
  14. package/dist/chunk-7GOKQJTQ.js +145 -0
  15. package/dist/chunk-7GOKQJTQ.js.map +1 -0
  16. package/dist/{chunk-H3VORETI.js → chunk-AWEMD747.js} +487 -592
  17. package/dist/chunk-AWEMD747.js.map +1 -0
  18. package/dist/{chunk-4A2RMUCC.js → chunk-DKICR7AN.js} +1216 -611
  19. package/dist/chunk-DKICR7AN.js.map +1 -0
  20. package/dist/{chunk-INHVXP6Z.js → chunk-FPBZFNCD.js} +1159 -415
  21. package/dist/chunk-FPBZFNCD.js.map +1 -0
  22. package/dist/{chunk-M4CWTJWJ.cjs → chunk-GDKE6RQW.cjs} +1453 -848
  23. package/dist/chunk-GDKE6RQW.cjs.map +1 -0
  24. package/dist/chunk-H66ARFU5.js +363 -0
  25. package/dist/chunk-H66ARFU5.js.map +1 -0
  26. package/dist/{chunk-YH3BIKHH.js → chunk-HOHFYGKW.js} +146 -49
  27. package/dist/chunk-HOHFYGKW.js.map +1 -0
  28. package/dist/chunk-HSY2VQXZ.js +2272 -0
  29. package/dist/chunk-HSY2VQXZ.js.map +1 -0
  30. package/dist/{chunk-E3F4AHAH.cjs → chunk-J772DL3B.cjs} +221 -134
  31. package/dist/chunk-J772DL3B.cjs.map +1 -0
  32. package/dist/chunk-K6OZXIR6.js +1 -0
  33. package/dist/{chunk-VTI6FOLB.js → chunk-PQL7E5F6.js} +709 -133
  34. package/dist/chunk-PQL7E5F6.js.map +1 -0
  35. package/dist/chunk-Q6R3QAZD.cjs +3329 -0
  36. package/dist/chunk-Q6R3QAZD.cjs.map +1 -0
  37. package/dist/{chunk-MXO72PLY.cjs → chunk-QCXYKSZS.cjs} +21 -19
  38. package/dist/chunk-QCXYKSZS.cjs.map +1 -0
  39. package/dist/{chunk-VOHZB45S.js → chunk-R5VUXQMP.js} +1321 -821
  40. package/dist/chunk-R5VUXQMP.js.map +1 -0
  41. package/dist/chunk-R7B5N2JK.cjs +363 -0
  42. package/dist/chunk-R7B5N2JK.cjs.map +1 -0
  43. package/dist/{chunk-WWURE4XT.cjs → chunk-RVS4G4MR.cjs} +624 -729
  44. package/dist/chunk-RVS4G4MR.cjs.map +1 -0
  45. package/dist/chunk-TT6PKMPR.cjs +145 -0
  46. package/dist/chunk-TT6PKMPR.cjs.map +1 -0
  47. package/dist/chunk-UGLFDG7L.cjs +1 -0
  48. package/dist/chunk-UGLFDG7L.cjs.map +1 -0
  49. package/dist/chunk-VLE5R7PF.js +3329 -0
  50. package/dist/chunk-VLE5R7PF.js.map +1 -0
  51. package/dist/{chunk-FVSI36UV.js → chunk-X6RJAHII.js} +197 -110
  52. package/dist/chunk-X6RJAHII.js.map +1 -0
  53. package/dist/{chunk-Q2WGKJNN.cjs → chunk-XKSO2V5I.cjs} +699 -123
  54. package/dist/chunk-XKSO2V5I.cjs.map +1 -0
  55. package/dist/chunk-XVMJO3QF.cjs +2272 -0
  56. package/dist/chunk-XVMJO3QF.cjs.map +1 -0
  57. package/dist/{chunk-UADYAYAT.cjs → chunk-YPB3A3EY.cjs} +1309 -565
  58. package/dist/chunk-YPB3A3EY.cjs.map +1 -0
  59. package/dist/{index-C_8o--VE.d.cts → coerce-CJlgULrQ.d.cts} +210 -199
  60. package/dist/{index-szBv3496.d.ts → coerce-wwdELNYS.d.ts} +210 -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-Dzr13q3d.d.cts → index-B3WCj_Hm.d.cts} +135 -58
  72. package/dist/{index-BO6xE9YU.d.cts → index-BUtIf2go.d.ts} +460 -254
  73. package/dist/{index-CCNJRG-P.d.cts → index-BaoKVVhE.d.cts} +293 -56
  74. package/dist/{index-Chbst3Jx.d.ts → index-BpWOhkkE.d.ts} +135 -58
  75. package/dist/{index-BGFW-8P2.d.cts → index-BzLNkmA7.d.cts} +196 -114
  76. package/dist/{index-CunYKLiu.d.ts → index-CBCP84rv.d.cts} +1 -1
  77. package/dist/{index-BkGmlyI3.d.cts → index-Ci3xyows.d.ts} +60 -23
  78. package/dist/{index-9wcMhG73.d.ts → index-CnHQgqNh.d.ts} +293 -56
  79. package/dist/{index-B4o55NDr.d.cts → index-CnIdP4EZ.d.ts} +1 -1
  80. package/dist/{index-B9MNZboQ.d.ts → index-Cy15oTvh.d.cts} +52 -22
  81. package/dist/{index-B9MNZboQ.d.cts → index-Cy15oTvh.d.ts} +52 -22
  82. package/dist/{index-D57QRbVn.d.ts → index-DTsKaPaC.d.cts} +460 -254
  83. package/dist/{index-Cj49F892.d.ts → index-D_hzxD8w.d.cts} +60 -23
  84. package/dist/{index-CgHqxdps.d.ts → index-DpC-mDlV.d.ts} +196 -114
  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.ts → masks-C8TWLFIi.d.cts} +49 -2
  92. package/dist/{masks-DYbE485J.d.cts → masks-O73Rhj5d.d.ts} +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 +502 -181
  96. package/dist/model/index.d.ts +502 -181
  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 +6 -5
  106. package/dist/chunk-3JXCW6DX.cjs +0 -3220
  107. package/dist/chunk-3JXCW6DX.cjs.map +0 -1
  108. package/dist/chunk-4A2RMUCC.js.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-E3F4AHAH.cjs.map +0 -1
  113. package/dist/chunk-ELCTZUJJ.js +0 -379
  114. package/dist/chunk-ELCTZUJJ.js.map +0 -1
  115. package/dist/chunk-FVSI36UV.js.map +0 -1
  116. package/dist/chunk-GOZG57ER.js +0 -3220
  117. package/dist/chunk-GOZG57ER.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-M4CWTJWJ.cjs.map +0 -1
  128. package/dist/chunk-MXO72PLY.cjs.map +0 -1
  129. package/dist/chunk-NLEU4QSE.cjs +0 -360
  130. package/dist/chunk-NLEU4QSE.cjs.map +0 -1
  131. package/dist/chunk-OE6WK2Y2.cjs +0 -1577
  132. package/dist/chunk-OE6WK2Y2.cjs.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-CJlgULrQ.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.cjs';
1
+ import { P as ParseResult } from './index-Cy15oTvh.js';
2
2
 
3
3
  /**
4
4
  * Meter arithmetic shared by the meter module and the validation guards.
@@ -83,6 +83,11 @@ 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
+ *
86
91
  * @category Rhythm & Meter
87
92
  */
88
93
  type MeterMap = MeterChange[];
@@ -123,7 +128,10 @@ type MeterLike = string | TimeSignature | MeterMap | {
123
128
  * value whose `toJSON` returns one of those.
124
129
  * @param name What the meter is called in an error message, so a caller that
125
130
  * holds several of them hears which one was malformed.
126
- * @returns The validated signature, or the validated map.
131
+ * @returns The validated signature, or the validated map, freshly allocated
132
+ * down to every grouping array — so a caller may keep and edit what it gets
133
+ * back without editing the meter it passed in, and without any two calls
134
+ * handing out the same object.
127
135
  * @throws If the value names no meter, or the meter it names is malformed.
128
136
  */
129
137
  declare function toMeterData(value: MeterLike, name?: string): MeterData;
@@ -186,17 +194,23 @@ declare function tryParseTimeSignature(text: string): ParseResult<TimeSignature>
186
194
  *
187
195
  * The additive form is what {@link parseTimeSignature} reads back, and it adds
188
196
  * 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.
197
+ * units can be rendered that way. A grouping counted in main pulses whose groups
198
+ * are all the same length (9/8 as `[1, 1, 1]`, 12/8 as `[2, 2]`) states the
199
+ * division the bare signature already has, so it falls back to the plain form at
200
+ * no cost. One whose groups differ (12/8 as `[1, 1, 2]`) states an accent no
201
+ * signature text can carry, and asking for the additive form of it is refused
202
+ * rather than answered with a bar that weighs its pulses differently.
193
203
  *
194
204
  * The plain form drops the grouping, so a round trip through it reads 7/8 as
195
205
  * flat rather than as 2+2+3; ask for the additive form to keep it.
196
206
  *
197
- * @param ts The time signature.
207
+ * @param ts The time signature, in any form that names one; a meter map is
208
+ * rendered as the signature it opens in.
198
209
  * @param opts Set `grouping: true` to render an additive grouping.
199
210
  * @returns The formatted signature.
211
+ * @throws If `grouping: true` is asked of a grouping that no signature text can
212
+ * spell: one counted in main pulses, on a compound numerator, whose groups are
213
+ * not all the same length.
200
214
  * @example
201
215
  * ```ts
202
216
  * import { formatTimeSignature } from '@libraz/libcantus';
@@ -206,7 +220,7 @@ declare function tryParseTimeSignature(text: string): ParseResult<TimeSignature>
206
220
  * ```
207
221
  * @category Rhythm & Meter
208
222
  */
209
- declare function formatTimeSignature(ts: TimeSignature, opts?: {
223
+ declare function formatTimeSignature(ts: MeterLike, opts?: {
210
224
  grouping?: boolean;
211
225
  }): string;
212
226
  /**
@@ -217,19 +231,27 @@ declare function formatTimeSignature(ts: TimeSignature, opts?: {
217
231
  * is a signature whose {@link TimeSignature.grouping} selects the additive
218
232
  * reading (9/8 as 2+2+2+3).
219
233
  *
220
- * @param ts The time signature.
234
+ * @param ts The time signature, in any form that names one; a meter map is read
235
+ * as the signature it opens in.
221
236
  * @returns True for compound meters.
222
237
  * @category Rhythm & Meter
223
238
  */
224
- declare function isCompound(ts: TimeSignature): boolean;
239
+ declare function isCompound(ts: MeterLike): boolean;
225
240
  /**
226
241
  * Length of a bar in quarter-note beats.
227
242
  *
228
- * @param ts The time signature.
243
+ * @param ts The time signature, in any form that names one; a meter map has no
244
+ * single bar length, so it is read as the signature it opens in. Ask
245
+ * {@link beatsPerBarAt} for the bar a given beat falls in.
229
246
  * @returns The bar length in quarter notes.
247
+ * @example
248
+ * ```ts
249
+ * import { beatsPerBar } from '@libraz/libcantus';
250
+ * beatsPerBar('6/8'); // 3
251
+ * ```
230
252
  * @category Rhythm & Meter
231
253
  */
232
- declare function beatsPerBar(ts: TimeSignature): number;
254
+ declare function beatsPerBar(ts: MeterLike): number;
233
255
  /**
234
256
  * The time signature in force at a beat.
235
257
  *
@@ -284,6 +306,12 @@ declare function barIndexAt(beatInQuarters: number, meter: MeterLike): number;
284
306
  * The meter-map counterpart of {@link beatsPerBar}, which answers for one
285
307
  * signature and so cannot be asked about a piece that changes meter.
286
308
  *
309
+ * The bar the beat is in, not the bar its signature nominally has: a change of
310
+ * meter starts a new bar, so a bar interrupted by one is shorter than its own
311
+ * signature says. Reading the signature's own length there would put the end of
312
+ * the bar past where the next one begins, and every span measured in bars from
313
+ * that point on would be counted against a bar length the music never had.
314
+ *
287
315
  * @param beatInQuarters Absolute position in quarter-note beats.
288
316
  * @param meter A single signature, or the piece's meter map.
289
317
  * @returns The bar length in quarter notes.
@@ -300,7 +328,9 @@ declare function beatsPerBarAt(beatInQuarters: number, meter: MeterLike): number
300
328
  *
301
329
  * @param opts The options carrying `ts`, `meters`, or neither.
302
330
  * @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.
331
+ * @returns The meter map to analyse against, freshly allocated down to every
332
+ * signature and grouping array, so writing to it changes nothing another
333
+ * caller reads; 4/4 throughout when neither `ts` nor `meters` is given.
304
334
  * @throws If both `ts` and `meters` are given, or the map is malformed.
305
335
  * @example
306
336
  * ```ts
@@ -311,8 +341,8 @@ declare function beatsPerBarAt(beatInQuarters: number, meter: MeterLike): number
311
341
  * @category Rhythm & Meter
312
342
  */
313
343
  declare function resolveMeters(opts: {
314
- ts?: TimeSignature;
315
- meters?: MeterMap;
344
+ ts?: MeterLike;
345
+ meters?: MeterLike;
316
346
  }, name?: string): MeterMap;
317
347
  /**
318
348
  * Number of main pulses (felt beats) per bar: the numerator for simple meters,
@@ -324,11 +354,12 @@ declare function resolveMeters(opts: {
324
354
  * {@link TimeSignature.grouping}; {@link metricWeight} then accents each
325
355
  * group's head pulse.
326
356
  *
327
- * @param ts The time signature.
357
+ * @param ts The time signature, in any form that names one; a meter map is read
358
+ * as the signature it opens in.
328
359
  * @returns The pulse count per bar.
329
360
  * @category Rhythm & Meter
330
361
  */
331
- declare function pulsesPerBar(ts: TimeSignature): number;
362
+ declare function pulsesPerBar(ts: MeterLike): number;
332
363
  /**
333
364
  * Convert an absolute quarter-note position to a bar index and in-bar offset.
334
365
  *
@@ -351,16 +382,17 @@ declare function beatToBarPosition(beatInQuarters: number, meter: MeterLike): Ba
351
382
  * denominator unit in an additive metre. Position displays, click tracks, and
352
383
  * score export are all written against this length.
353
384
  *
354
- * @param ts The time signature.
385
+ * @param ts The time signature, in any form that names one; a meter map is read
386
+ * as the signature it opens in.
355
387
  * @returns The pulse length in quarter-note beats.
356
388
  * @example
357
389
  * ```ts
358
- * import { parseTimeSignature, pulseBeats } from '@libraz/libcantus';
359
- * pulseBeats(parseTimeSignature('6/8')); // 1.5
390
+ * import { pulseBeats } from '@libraz/libcantus';
391
+ * pulseBeats('6/8'); // 1.5
360
392
  * ```
361
393
  * @category Rhythm & Meter
362
394
  */
363
- declare function pulseBeats(ts: TimeSignature): number;
395
+ declare function pulseBeats(ts: MeterLike): number;
364
396
  /**
365
397
  * The felt-beat number of a bar position, 1-based.
366
398
  *
@@ -391,11 +423,16 @@ declare function barPositionToPulse(pos: BarPosition, meter: MeterLike): number;
391
423
  * @param beatInQuarters Absolute position in quarter-note beats.
392
424
  * @param meter A single signature, or the piece's meter map.
393
425
  * @param decimals Digits of the fractional beat to keep.
394
- * @returns The formatted position, e.g. `'3.2'` for bar 3, felt beat 2.
426
+ * @returns The formatted position in one of two forms: `bar.beat` on a felt
427
+ * beat, e.g. `'3.2'` for bar 3, felt beat 2; and `bar.beat+fraction` between
428
+ * felt beats, e.g. `'3.2+0.5'` halfway from the second felt beat to the third.
429
+ * A reader of these strings has to take both, since most onsets of an ordinary
430
+ * piece fall between pulses.
395
431
  * @example
396
432
  * ```ts
397
433
  * import { formatBarPosition, parseTimeSignature } from '@libraz/libcantus';
398
434
  * formatBarPosition(7.5, parseTimeSignature('6/8')); // '3.2'
435
+ * formatBarPosition(8.25, parseTimeSignature('6/8')); // '3.2+0.5'
399
436
  * ```
400
437
  * @category Rhythm & Meter
401
438
  */
@@ -425,7 +462,7 @@ declare function barPositionToBeat(pos: BarPosition, meter: MeterLike): number;
425
462
  * an ungrouped bar rather than accenting every group head.
426
463
  *
427
464
  * 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.
465
+ * beat 2 of a piece is a mid-bar accent in 4/4 and a plain main pulse in 3/4.
429
466
  * The downbeat is beat 0 however much pickup precedes it, so a note in the
430
467
  * pickup weighs as the upbeat it is rather than as a downbeat.
431
468
  *