@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.
- package/README.md +27 -65
- package/README_ja.md +28 -66
- package/dist/analyze/index.cjs +11 -7
- package/dist/analyze/index.cjs.map +1 -1
- package/dist/analyze/index.d.cts +79 -144
- package/dist/analyze/index.d.ts +79 -144
- package/dist/analyze/index.js +20 -16
- package/dist/chunk-35NBV2FT.cjs +145 -0
- package/dist/chunk-35NBV2FT.cjs.map +1 -0
- package/dist/{chunk-UADYAYAT.cjs → chunk-3R3QVKY5.cjs} +1353 -580
- package/dist/chunk-3R3QVKY5.cjs.map +1 -0
- package/dist/{chunk-WWURE4XT.cjs → chunk-76ZBTRG2.cjs} +624 -729
- package/dist/chunk-76ZBTRG2.cjs.map +1 -0
- package/dist/{chunk-FVSI36UV.js → chunk-7KG3RTYS.js} +197 -110
- package/dist/chunk-7KG3RTYS.js.map +1 -0
- package/dist/{chunk-VTI6FOLB.js → chunk-AGOVW7U6.js} +709 -133
- package/dist/chunk-AGOVW7U6.js.map +1 -0
- package/dist/{chunk-E3F4AHAH.cjs → chunk-CGBADIO5.cjs} +221 -134
- package/dist/chunk-CGBADIO5.cjs.map +1 -0
- package/dist/{chunk-6XH6QZYQ.cjs → chunk-DSMJRXCZ.cjs} +1455 -849
- package/dist/chunk-DSMJRXCZ.cjs.map +1 -0
- package/dist/{chunk-PKFNUHDY.js → chunk-FBH75DAY.js} +1218 -612
- package/dist/chunk-FBH75DAY.js.map +1 -0
- package/dist/chunk-H2KJHBW4.js +3329 -0
- package/dist/chunk-H2KJHBW4.js.map +1 -0
- package/dist/chunk-HPVSH7SF.cjs +2294 -0
- package/dist/chunk-HPVSH7SF.cjs.map +1 -0
- package/dist/{chunk-MXO72PLY.cjs → chunk-HWHGOVO6.cjs} +21 -19
- package/dist/chunk-HWHGOVO6.cjs.map +1 -0
- package/dist/chunk-HYJJ2V2I.js +2294 -0
- package/dist/chunk-HYJJ2V2I.js.map +1 -0
- package/dist/{chunk-AFM2ULJH.cjs → chunk-J7FHVZII.cjs} +1567 -1067
- package/dist/chunk-J7FHVZII.cjs.map +1 -0
- package/dist/chunk-K6OZXIR6.js +1 -0
- package/dist/{chunk-H3VORETI.js → chunk-M5RYMAFI.js} +487 -592
- package/dist/chunk-M5RYMAFI.js.map +1 -0
- package/dist/chunk-NB25P3EH.js +363 -0
- package/dist/chunk-NB25P3EH.js.map +1 -0
- package/dist/{chunk-TTCLJX6D.js → chunk-NFJ4P6ZZ.js} +10 -8
- package/dist/chunk-NFJ4P6ZZ.js.map +1 -0
- package/dist/chunk-NM7UAMC3.cjs +457 -0
- package/dist/chunk-NM7UAMC3.cjs.map +1 -0
- package/dist/chunk-PM4XJE2Y.cjs +363 -0
- package/dist/chunk-PM4XJE2Y.cjs.map +1 -0
- package/dist/chunk-PUKJP2Z5.js +145 -0
- package/dist/chunk-PUKJP2Z5.js.map +1 -0
- package/dist/{chunk-VOHZB45S.js → chunk-Q6LFSAKV.js} +1321 -821
- package/dist/chunk-Q6LFSAKV.js.map +1 -0
- package/dist/{chunk-INHVXP6Z.js → chunk-RFIBF2RR.js} +1203 -430
- package/dist/chunk-RFIBF2RR.js.map +1 -0
- package/dist/{chunk-Q2WGKJNN.cjs → chunk-S5BKZZGM.cjs} +699 -123
- package/dist/chunk-S5BKZZGM.cjs.map +1 -0
- package/dist/chunk-SGLEQVJH.cjs +3329 -0
- package/dist/chunk-SGLEQVJH.cjs.map +1 -0
- package/dist/chunk-UGLFDG7L.cjs +1 -0
- package/dist/chunk-UGLFDG7L.cjs.map +1 -0
- package/dist/{chunk-YH3BIKHH.js → chunk-UMWZ4ZET.js} +146 -49
- package/dist/chunk-UMWZ4ZET.js.map +1 -0
- package/dist/{index-szBv3496.d.ts → coerce-DP0vYu-x.d.ts} +286 -199
- package/dist/{index-C_8o--VE.d.cts → coerce-DRERzdve.d.cts} +286 -199
- package/dist/core/index.cjs +9 -5
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +122 -108
- package/dist/core/index.d.ts +122 -108
- package/dist/core/index.js +32 -28
- package/dist/generate/index.cjs +8 -8
- package/dist/generate/index.d.cts +168 -84
- package/dist/generate/index.d.ts +168 -84
- package/dist/generate/index.js +7 -7
- package/dist/{index-CGpRv5sl.d.cts → index-9eoQs2C1.d.ts} +34 -19
- package/dist/{index-CCNJRG-P.d.cts → index-B9QLziDe.d.cts} +293 -56
- package/dist/{index-Dzr13q3d.d.cts → index-BBWNZS0f.d.cts} +135 -58
- package/dist/{index-9wcMhG73.d.ts → index-BHIUyjhZ.d.ts} +293 -56
- package/dist/{index-BGFW-8P2.d.cts → index-BJgP97N1.d.ts} +196 -114
- package/dist/{index-CunYKLiu.d.ts → index-BL5N2Oyz.d.cts} +1 -1
- package/dist/{index-Cj49F892.d.ts → index-BMweUlm5.d.cts} +63 -23
- package/dist/{index-CgHqxdps.d.ts → index-BNSM-DSk.d.cts} +196 -114
- package/dist/{index-D57QRbVn.d.ts → index-BRMbPkHE.d.ts} +480 -254
- package/dist/{index-Chbst3Jx.d.ts → index-CJBBiAmU.d.ts} +135 -58
- package/dist/{index-BkGmlyI3.d.cts → index-CL4b4gUQ.d.ts} +63 -23
- package/dist/{index-B9MNZboQ.d.ts → index-Cy15oTvh.d.cts} +52 -22
- package/dist/{index-B9MNZboQ.d.cts → index-Cy15oTvh.d.ts} +52 -22
- package/dist/{index-BO6xE9YU.d.cts → index-DGCNKAUr.d.cts} +480 -254
- package/dist/{index-B4o55NDr.d.cts → index-Dw2DP7vm.d.ts} +1 -1
- package/dist/{index-G1uwGGWQ.d.ts → index-cHvbYgJI.d.cts} +34 -19
- package/dist/index.cjs +42 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -14
- package/dist/index.d.ts +14 -14
- package/dist/index.js +82 -54
- package/dist/{masks-DYbE485J.d.cts → masks-Cc7-MzzY.d.ts} +49 -2
- package/dist/{masks-DYbE485J.d.ts → masks-pADfTOiD.d.cts} +49 -2
- package/dist/model/index.cjs +19 -12
- package/dist/model/index.cjs.map +1 -1
- package/dist/model/index.d.cts +504 -182
- package/dist/model/index.d.ts +504 -182
- package/dist/model/index.js +18 -11
- package/dist/{positional-Cptlj-xs.d.ts → positional-DJgs6ltD.d.ts} +85 -8
- package/dist/{positional-DvH_sd8u.d.cts → positional-DMZer-FM.d.cts} +85 -8
- package/dist/theory/index.cjs +35 -6
- package/dist/theory/index.cjs.map +1 -1
- package/dist/theory/index.d.cts +257 -62
- package/dist/theory/index.d.ts +257 -62
- package/dist/theory/index.js +41 -12
- package/package.json +7 -5
- package/dist/chunk-2LCPM3EG.js +0 -3224
- package/dist/chunk-2LCPM3EG.js.map +0 -1
- package/dist/chunk-6XH6QZYQ.cjs.map +0 -1
- package/dist/chunk-6XPTBE7Y.cjs +0 -49
- package/dist/chunk-6XPTBE7Y.cjs.map +0 -1
- package/dist/chunk-AFM2ULJH.cjs.map +0 -1
- package/dist/chunk-B6XNKWZV.cjs +0 -3224
- package/dist/chunk-B6XNKWZV.cjs.map +0 -1
- package/dist/chunk-E3F4AHAH.cjs.map +0 -1
- package/dist/chunk-ELCTZUJJ.js +0 -379
- package/dist/chunk-ELCTZUJJ.js.map +0 -1
- package/dist/chunk-FVSI36UV.js.map +0 -1
- package/dist/chunk-H3VORETI.js.map +0 -1
- package/dist/chunk-H42UHPYW.js +0 -1577
- package/dist/chunk-H42UHPYW.js.map +0 -1
- package/dist/chunk-HFPS7JFD.js +0 -1
- package/dist/chunk-INHVXP6Z.js.map +0 -1
- package/dist/chunk-K4ZJUGF4.cjs +0 -379
- package/dist/chunk-K4ZJUGF4.cjs.map +0 -1
- package/dist/chunk-KNJEKLKV.js +0 -49
- package/dist/chunk-KNJEKLKV.js.map +0 -1
- package/dist/chunk-MXO72PLY.cjs.map +0 -1
- package/dist/chunk-NLEU4QSE.cjs +0 -360
- package/dist/chunk-NLEU4QSE.cjs.map +0 -1
- package/dist/chunk-OE6WK2Y2.cjs +0 -1577
- package/dist/chunk-OE6WK2Y2.cjs.map +0 -1
- package/dist/chunk-PKFNUHDY.js.map +0 -1
- package/dist/chunk-Q2WGKJNN.cjs.map +0 -1
- package/dist/chunk-RHIJ3S4I.cjs +0 -1
- package/dist/chunk-RHIJ3S4I.cjs.map +0 -1
- package/dist/chunk-TTCLJX6D.js.map +0 -1
- package/dist/chunk-UADYAYAT.cjs.map +0 -1
- package/dist/chunk-VOHZB45S.js.map +0 -1
- package/dist/chunk-VTI6FOLB.js.map +0 -1
- package/dist/chunk-WWURE4XT.cjs.map +0 -1
- package/dist/chunk-YH3BIKHH.js.map +0 -1
- /package/dist/{chunk-HFPS7JFD.js.map → chunk-K6OZXIR6.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as ParseResult } from './index-
|
|
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
|
|
190
|
-
* `[1, 1, 1]`, 12/8 as `[2, 2]`)
|
|
191
|
-
*
|
|
192
|
-
*
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
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?:
|
|
315
|
-
meters?:
|
|
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:
|
|
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 {
|
|
359
|
-
* pulseBeats(
|
|
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:
|
|
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
|
|
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
|
|
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
|
*
|