@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,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { d as ChordQuality, e as ChordSegment, c as ChordLike, K as KeyLike, b as Chord, m as ProfileWeights, g as ChordSpan } from './
|
|
5
|
-
import { e as ChordTimeline, B as BorrowedSource, H as HarmonicFunction } from './index-
|
|
6
|
-
import { H as HarmonyRole } from './index-
|
|
1
|
+
import { T as TimeSignature, b as MeterLike } from './index-CL4b4gUQ.js';
|
|
2
|
+
import { a as Articulation, h as NoteEvent } from './index-Cy15oTvh.js';
|
|
3
|
+
import { S as SeedPath, d as PositionalRng, I as InstrumentProfile, f as StringedProfile } from './positional-DJgs6ltD.js';
|
|
4
|
+
import { d as ChordQuality, e as ChordSegment, c as ChordLike, K as KeyLike, b as Chord, m as ProfileWeights, g as ChordSpan, n as ResolvedKey, r as SpelledKeyLike } from './coerce-DP0vYu-x.js';
|
|
5
|
+
import { e as ChordTimeline, B as BorrowedSource, H as HarmonicFunction } from './index-CJBBiAmU.js';
|
|
6
|
+
import { H as HarmonyRole } from './index-Dw2DP7vm.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* The samplers a generator needs, each addressed by the position it is drawing
|
|
@@ -98,11 +98,17 @@ type Section = (typeof PUBLIC_SECTIONS)[number];
|
|
|
98
98
|
*/
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
|
-
* Every genre
|
|
101
|
+
* Every genre name a vocabulary entry may carry, in declaration order.
|
|
102
|
+
*
|
|
103
|
+
* Each built-in dictionary stocks part of the list, not all of it: the drum
|
|
104
|
+
* patterns carry `motown`, `funk`, `blues`, `bossa`, `samba`, `gospel` and
|
|
105
|
+
* `dnb`; the bass licks carry `motown`, `soul`, `funk`, `blues`, `jazz`,
|
|
106
|
+
* `bossa`, `gospel`, `country` and `reggae`. Asking a dictionary for a genre it
|
|
107
|
+
* has nothing for selects nothing rather than failing.
|
|
102
108
|
*
|
|
103
109
|
* The list is open in spirit even though the type is closed: a caller with a
|
|
104
|
-
* genre of its own
|
|
105
|
-
* waiting for this list to grow.
|
|
110
|
+
* genre of its own — or one the built-ins do not stock — supplies entries
|
|
111
|
+
* through the generation context rather than waiting for this list to grow.
|
|
106
112
|
*
|
|
107
113
|
* @category Composition
|
|
108
114
|
*/
|
|
@@ -201,7 +207,8 @@ type VocabularyQuery = {
|
|
|
201
207
|
section?: Section;
|
|
202
208
|
/** Tempo in BPM, matched against each entry's band. */
|
|
203
209
|
bpm?: number;
|
|
204
|
-
|
|
210
|
+
/** The meter in force, matched against each entry's own signature. */
|
|
211
|
+
ts?: MeterLike;
|
|
205
212
|
/** The difficulty ceiling: entries above it are rejected. */
|
|
206
213
|
difficulty?: number;
|
|
207
214
|
/** The chord in force, matched against each entry's `fitsOver`. */
|
|
@@ -499,16 +506,24 @@ type GridEvent = {
|
|
|
499
506
|
*
|
|
500
507
|
* This is the ranking the thinning rule works down: the notes a player drops
|
|
501
508
|
* first when asked for something easier are the ones carrying the least of the
|
|
502
|
-
* metre.
|
|
503
|
-
*
|
|
504
|
-
* two
|
|
505
|
-
*
|
|
506
|
-
*
|
|
509
|
+
* metre. The ranking is the meter's own — {@link metricWeight} says which
|
|
510
|
+
* positions are the downbeat, a secondary strong pulse, and a plain main pulse,
|
|
511
|
+
* and the two ranks below them are the pulse's first subdivision and everything
|
|
512
|
+
* off it. In 4/4 that is the downbeat, the half bar, the other quarters, the
|
|
513
|
+
* quavers and the semiquavers; in 6/8 it is the two dotted-quarter pulses, then
|
|
514
|
+
* the quavers, and the quarter-note positions a 4/4 reading would rank above
|
|
515
|
+
* them fall where they belong, between the beats.
|
|
516
|
+
*
|
|
517
|
+
* @param step Sixteenth index from the start of the figure.
|
|
518
|
+
* @param ts The meter the figure is counted in, in any form that names one.
|
|
519
|
+
* Asked for rather than defaulted: the built-in figures are written on a 4/4
|
|
520
|
+
* grid, but a caller working in 7/8 who leaves it out has no way to hear that
|
|
521
|
+
* the ranking they got was somebody else's bar.
|
|
507
522
|
* @returns The weight, 0 to 4.
|
|
508
523
|
*
|
|
509
524
|
* @category Composition
|
|
510
525
|
*/
|
|
511
|
-
declare function gridMetricWeight(step: number): number;
|
|
526
|
+
declare function gridMetricWeight(step: number, ts: MeterLike): number;
|
|
512
527
|
/**
|
|
513
528
|
* Drop the notes carrying the least of the metre.
|
|
514
529
|
*
|
|
@@ -519,11 +534,15 @@ declare function gridMetricWeight(step: number): number;
|
|
|
519
534
|
*
|
|
520
535
|
* @param events The figure.
|
|
521
536
|
* @param amount How much to thin, in [0, 1].
|
|
537
|
+
* @param ts The meter the figure is counted in, in any form that names one.
|
|
538
|
+
* The ranks are the meter's, so a full turn of the dial leaves the downbeats
|
|
539
|
+
* of the bar the figure is actually in — which is why it is asked for rather
|
|
540
|
+
* than assumed.
|
|
522
541
|
* @returns The surviving events, in the order given.
|
|
523
542
|
*
|
|
524
543
|
* @category Composition
|
|
525
544
|
*/
|
|
526
|
-
declare function thin<T extends GridEvent>(events: readonly T[], amount: number): T[];
|
|
545
|
+
declare function thin<T extends GridEvent>(events: readonly T[], amount: number, ts: MeterLike): T[];
|
|
527
546
|
/**
|
|
528
547
|
* Fill in the gaps of a figure, one note per gap.
|
|
529
548
|
*
|
|
@@ -555,13 +574,35 @@ declare function halfTime<T extends GridEvent>(events: readonly T[], spanSteps?:
|
|
|
555
574
|
* The repeat is what makes this the mirror of {@link halfTime} rather than a
|
|
556
575
|
* figure with a hole in it: the bar stays full.
|
|
557
576
|
*
|
|
577
|
+
* Halving brings positions together, and two onsets of one stream landing on
|
|
578
|
+
* the same step are one stroke played louder rather than two: a drum struck
|
|
579
|
+
* twice at the same instant is a pair of note-ons a reader turns into a hung or
|
|
580
|
+
* cut note, so the pair is merged and the louder of the two is what sounds.
|
|
581
|
+
* Streams stay apart, since two limbs striking together is a chord and not a
|
|
582
|
+
* repeat.
|
|
583
|
+
*
|
|
558
584
|
* @param events The figure.
|
|
559
585
|
* @param spanSteps Length of the figure in sixteenths.
|
|
560
|
-
* @returns The compressed figure, repeated to fill the span
|
|
586
|
+
* @returns The compressed figure, repeated to fill the span, at most one event
|
|
587
|
+
* per stream and step.
|
|
561
588
|
*
|
|
562
589
|
* @category Composition
|
|
563
590
|
*/
|
|
564
591
|
declare function doubleTime<T extends GridEvent>(events: readonly T[], spanSteps?: number): T[];
|
|
592
|
+
/**
|
|
593
|
+
* How much a figure is syncopated, and the meter it is felt in.
|
|
594
|
+
*
|
|
595
|
+
* @category Composition
|
|
596
|
+
*/
|
|
597
|
+
type SyncopateOptions = {
|
|
598
|
+
/** How much syncopation, in [0, 1]. */
|
|
599
|
+
amount: number;
|
|
600
|
+
/**
|
|
601
|
+
* The meter the figure is counted in, in any form that names one; 4/4 when
|
|
602
|
+
* none is named.
|
|
603
|
+
*/
|
|
604
|
+
ts?: MeterLike;
|
|
605
|
+
};
|
|
565
606
|
/**
|
|
566
607
|
* Anticipate beats, one sixteenth early.
|
|
567
608
|
*
|
|
@@ -583,14 +624,17 @@ declare function doubleTime<T extends GridEvent>(events: readonly T[], spanSteps
|
|
|
583
624
|
* than this one's.
|
|
584
625
|
*
|
|
585
626
|
* @param events The figure.
|
|
586
|
-
* @param amount How much syncopation, in [0, 1]
|
|
627
|
+
* @param amount How much syncopation, in [0, 1], or the amount together with
|
|
628
|
+
* the meter the figure is counted in. The path is variadic, so the meter is
|
|
629
|
+
* named here rather than after it; naming none reads the figure in 4/4, as
|
|
630
|
+
* every built-in figure is written.
|
|
587
631
|
* @param draw The position-addressed sampler.
|
|
588
632
|
* @param path Where the figure sits, so the same bar always syncopates alike.
|
|
589
633
|
* @returns The figure with its anticipations, sorted by position.
|
|
590
634
|
*
|
|
591
635
|
* @category Composition
|
|
592
636
|
*/
|
|
593
|
-
declare function syncopate<T extends GridEvent>(events: readonly T[], amount: number, draw: Draw, ...path: readonly (string | number)[]): T[];
|
|
637
|
+
declare function syncopate<T extends GridEvent>(events: readonly T[], amount: number | SyncopateOptions, draw: Draw, ...path: readonly (string | number)[]): T[];
|
|
594
638
|
/**
|
|
595
639
|
* How much decoration a figure keeps.
|
|
596
640
|
*
|
|
@@ -634,6 +678,15 @@ type DeformOptions = {
|
|
|
634
678
|
rate?: 'straight' | 'half' | 'double';
|
|
635
679
|
/** Length of the figure in sixteenths. */
|
|
636
680
|
spanSteps?: number;
|
|
681
|
+
/**
|
|
682
|
+
* The meter the figure is counted in, in any form that names one; 4/4 when
|
|
683
|
+
* none is named, which is the bar every built-in figure is written on.
|
|
684
|
+
*
|
|
685
|
+
* The dials rank a figure's positions by how much of the metre each carries,
|
|
686
|
+
* so a figure written in another meter has to name it or it is thinned and
|
|
687
|
+
* syncopated against accents its own bar does not have.
|
|
688
|
+
*/
|
|
689
|
+
ts?: MeterLike;
|
|
637
690
|
};
|
|
638
691
|
/**
|
|
639
692
|
* Apply the complexity dials to a figure.
|
|
@@ -746,7 +799,7 @@ type BassLineOptions = {
|
|
|
746
799
|
*
|
|
747
800
|
* @defaultValue `{ numerator: 4, denominator: 4 }`
|
|
748
801
|
*/
|
|
749
|
-
ts?:
|
|
802
|
+
ts?: MeterLike;
|
|
750
803
|
/**
|
|
751
804
|
* Bass-line idiom.
|
|
752
805
|
*
|
|
@@ -756,7 +809,8 @@ type BassLineOptions = {
|
|
|
756
809
|
/**
|
|
757
810
|
* Target register as a base MIDI octave; roots land around `octave*12+12`.
|
|
758
811
|
* An octave pickup in the `pop` style may drop a note into the octave below
|
|
759
|
-
* that band, which is where such a pickup belongs
|
|
812
|
+
* that band, which is where such a pickup belongs, or take the octave above
|
|
813
|
+
* instead on an instrument with nothing below the band to drop into.
|
|
760
814
|
*
|
|
761
815
|
* @defaultValue 2
|
|
762
816
|
*/
|
|
@@ -859,11 +913,11 @@ type CounterMelodyOptions = {
|
|
|
859
913
|
*/
|
|
860
914
|
key: KeyLike;
|
|
861
915
|
/**
|
|
862
|
-
* Meter used for strong-beat decisions.
|
|
916
|
+
* Meter used for strong-beat decisions, in any form that names one.
|
|
863
917
|
*
|
|
864
918
|
* @defaultValue 4/4
|
|
865
919
|
*/
|
|
866
|
-
ts?:
|
|
920
|
+
ts?: MeterLike;
|
|
867
921
|
/**
|
|
868
922
|
* Which side of the melody the counter line occupies.
|
|
869
923
|
*
|
|
@@ -890,7 +944,8 @@ type CounterMelodyOptions = {
|
|
|
890
944
|
/**
|
|
891
945
|
* Per-field overrides of the profile's ranking weights, for a preference the
|
|
892
946
|
* two stock profiles do not express — a line that should leap more freely, or
|
|
893
|
-
* one that should hold a pedal wherever it can.
|
|
947
|
+
* one that should hold a pedal wherever it can. Every field named must be a
|
|
948
|
+
* finite number.
|
|
894
949
|
*/
|
|
895
950
|
weights?: Partial<ProfileWeights>;
|
|
896
951
|
/** Lowest MIDI pitch the counter line may use (default derived from `register`). */
|
|
@@ -931,6 +986,9 @@ type CounterMelodyOptions = {
|
|
|
931
986
|
*
|
|
932
987
|
* @param opts The lead line, chord context callback, key, and generation knobs.
|
|
933
988
|
* @returns The counter line as note events sorted by onset; `[]` for an empty melody.
|
|
989
|
+
* @throws If an option names a value outside its range — including a weight
|
|
990
|
+
* override that is not a finite number, which is rejected before any
|
|
991
|
+
* candidate is scored rather than absorbed into the ranking.
|
|
934
992
|
* @example
|
|
935
993
|
* ```ts
|
|
936
994
|
* import { generateCounterMelody, majorKey, parseChordSymbol } from '@libraz/libcantus';
|
|
@@ -1056,12 +1114,14 @@ type DrumsOptions = {
|
|
|
1056
1114
|
* hi-hat subdivisions, the open-hat and crash beats, the beat a fill starts on
|
|
1057
1115
|
* — is written against a four-beat bar, so another meter would come back with
|
|
1058
1116
|
* 4/4 accents in a bar of the wrong length and no sign that anything was
|
|
1059
|
-
* wrong. A meter it cannot place is refused rather than mis-placed
|
|
1060
|
-
*
|
|
1117
|
+
* wrong. A meter it cannot place is refused rather than mis-placed, and a
|
|
1118
|
+
* meter map is read whole: one that opens in 4/4 and changes later is refused
|
|
1119
|
+
* for the change, not accepted for the opening. Use {@link generateRhythm} or
|
|
1120
|
+
* {@link placeDrumPattern} for other meters.
|
|
1061
1121
|
*
|
|
1062
1122
|
* @defaultValue `{ numerator: 4, denominator: 4 }`
|
|
1063
1123
|
*/
|
|
1064
|
-
ts?:
|
|
1124
|
+
ts?: MeterLike;
|
|
1065
1125
|
/**
|
|
1066
1126
|
* Replace the final bar with a fill.
|
|
1067
1127
|
*
|
|
@@ -1186,11 +1246,11 @@ declare function generateDrums(opts: DrumsOptions): DrumHit[];
|
|
|
1186
1246
|
*/
|
|
1187
1247
|
type HumanizeOptions = {
|
|
1188
1248
|
/**
|
|
1189
|
-
* Time signature used to derive metric accents.
|
|
1249
|
+
* Time signature used to derive metric accents, in any form that names one.
|
|
1190
1250
|
*
|
|
1191
1251
|
* @defaultValue 4/4
|
|
1192
1252
|
*/
|
|
1193
|
-
ts?:
|
|
1253
|
+
ts?: MeterLike;
|
|
1194
1254
|
/**
|
|
1195
1255
|
* Maximum timing jitter in quarter-note beats, applied as ±this value.
|
|
1196
1256
|
*
|
|
@@ -1321,7 +1381,7 @@ type GrooveTemplate = {
|
|
|
1321
1381
|
* @returns The extracted groove template.
|
|
1322
1382
|
* @category Rhythm & Meter
|
|
1323
1383
|
*/
|
|
1324
|
-
declare function extractGrooveTemplate(events: readonly NoteEvent[], ts:
|
|
1384
|
+
declare function extractGrooveTemplate(events: readonly NoteEvent[], ts: MeterLike, subdivision?: number): GrooveTemplate;
|
|
1325
1385
|
/**
|
|
1326
1386
|
* Apply a groove template to a set of (typically quantized) note events: each
|
|
1327
1387
|
* event is snapped to its grid slot and then offset by that slot's recorded
|
|
@@ -1335,13 +1395,19 @@ declare function extractGrooveTemplate(events: readonly NoteEvent[], ts: TimeSig
|
|
|
1335
1395
|
* If the template carries a time signature (see {@link GrooveTemplate.ts}) it
|
|
1336
1396
|
* must match `ts`, since a differing bar length would misalign the per-bar
|
|
1337
1397
|
* grid and drift the feel; a mismatch throws rather than corrupting timing
|
|
1338
|
-
* silently.
|
|
1398
|
+
* silently. `slotsPerBar` is held to the same standard, since it is what the
|
|
1399
|
+
* grid is read through: a template built by hand whose count does not match the
|
|
1400
|
+
* bar would send a note past the end of the grid and land it on the next bar's
|
|
1401
|
+
* downbeat. What the slots carry is checked too, so nothing this returns is a
|
|
1402
|
+
* note event the rest of the library would refuse.
|
|
1339
1403
|
*
|
|
1340
1404
|
* @param events The events to reshape.
|
|
1341
1405
|
* @param template The groove template, from {@link extractGrooveTemplate}.
|
|
1342
1406
|
* @param ts The time signature, used to compute the bar length.
|
|
1343
1407
|
* @returns Reshaped copies of `events`, in input order.
|
|
1344
|
-
* @throws If `template.ts` is set and does not match `ts
|
|
1408
|
+
* @throws If `template.ts` is set and does not match `ts`, if `slotsPerBar` is
|
|
1409
|
+
* not the number of slots a bar of `ts` holds at the template's subdivision,
|
|
1410
|
+
* or if a slot carries a non-finite offset or a velocity outside [0, 127].
|
|
1345
1411
|
* @example
|
|
1346
1412
|
* ```ts
|
|
1347
1413
|
* import { extractGrooveTemplate, applyGrooveTemplate, parseTimeSignature } from '@libraz/libcantus';
|
|
@@ -1358,14 +1424,22 @@ declare function extractGrooveTemplate(events: readonly NoteEvent[], ts: TimeSig
|
|
|
1358
1424
|
* ```
|
|
1359
1425
|
* @category Rhythm & Meter
|
|
1360
1426
|
*/
|
|
1361
|
-
declare function applyGrooveTemplate(events: readonly NoteEvent[], template: GrooveTemplate, ts:
|
|
1427
|
+
declare function applyGrooveTemplate(events: readonly NoteEvent[], template: GrooveTemplate, ts: MeterLike): NoteEvent[];
|
|
1362
1428
|
|
|
1429
|
+
/**
|
|
1430
|
+
* Every production style a preset may suit, in declaration order.
|
|
1431
|
+
*
|
|
1432
|
+
* Written as a table rather than only as a union so the names exist at run time:
|
|
1433
|
+
* a union is checked when the caller compiles, and a style arriving from a
|
|
1434
|
+
* config file or a JavaScript caller is checked against this.
|
|
1435
|
+
*/
|
|
1436
|
+
declare const PROG_STYLES: readonly ["minimal", "dance", "idol", "rock"];
|
|
1363
1437
|
/**
|
|
1364
1438
|
* Broad production style a progression preset suits.
|
|
1365
1439
|
*
|
|
1366
1440
|
* @category Composition
|
|
1367
1441
|
*/
|
|
1368
|
-
type ProgStyle =
|
|
1442
|
+
type ProgStyle = (typeof PROG_STYLES)[number];
|
|
1369
1443
|
/**
|
|
1370
1444
|
* Harmonic-function role of a progression as a whole.
|
|
1371
1445
|
*
|
|
@@ -1381,8 +1455,9 @@ type ProgressionPreset = {
|
|
|
1381
1455
|
id: string;
|
|
1382
1456
|
name: string;
|
|
1383
1457
|
/**
|
|
1384
|
-
* The chord roots, in order, as {@link ProgressionDegree} codes:
|
|
1385
|
-
* key's own scale degrees
|
|
1458
|
+
* The chord roots, in order, as {@link ProgressionDegree} codes: 1..7 for the
|
|
1459
|
+
* key's own scale degrees, counted as a musician counts them, and
|
|
1460
|
+
* {@link BORROWED_DEGREES} for the borrowed ones.
|
|
1386
1461
|
*/
|
|
1387
1462
|
degrees: ProgressionDegree[];
|
|
1388
1463
|
functional: ProgFunction;
|
|
@@ -1447,6 +1522,16 @@ type ProgressionOptions = {
|
|
|
1447
1522
|
*/
|
|
1448
1523
|
style: ProgStyle;
|
|
1449
1524
|
bars: number;
|
|
1525
|
+
/**
|
|
1526
|
+
* The meter the bars are counted in, in any form that names one; a meter map
|
|
1527
|
+
* is read as the signature it opens in. One chord is laid out per bar, so this
|
|
1528
|
+
* is what the chords are spaced by — a chord every three beats in 3/4, every
|
|
1529
|
+
* three in 6/8 — and a progression written against another bar length drifts
|
|
1530
|
+
* off the bar lines of the part it is played under.
|
|
1531
|
+
*
|
|
1532
|
+
* @defaultValue `4/4`
|
|
1533
|
+
*/
|
|
1534
|
+
ts?: MeterLike;
|
|
1450
1535
|
/** Pick a specific built-in preset by id instead of choosing one by style. */
|
|
1451
1536
|
presetId?: string;
|
|
1452
1537
|
/**
|
|
@@ -1490,8 +1575,8 @@ declare function progressionsByStyle(style: ProgStyle): ProgressionPreset[];
|
|
|
1490
1575
|
* no way to name it.
|
|
1491
1576
|
*
|
|
1492
1577
|
* @param style The style pool to choose from.
|
|
1493
|
-
* @param
|
|
1494
|
-
* @returns The preset that
|
|
1578
|
+
* @param ctx The same context the generator would be given, or the seed alone.
|
|
1579
|
+
* @returns The preset that context selects.
|
|
1495
1580
|
* @throws If no preset claims the style.
|
|
1496
1581
|
* @example
|
|
1497
1582
|
* ```ts
|
|
@@ -1500,7 +1585,7 @@ declare function progressionsByStyle(style: ProgStyle): ProgressionPreset[];
|
|
|
1500
1585
|
* ```
|
|
1501
1586
|
* @category Composition
|
|
1502
1587
|
*/
|
|
1503
|
-
declare function pickProgressionPreset(style: ProgStyle,
|
|
1588
|
+
declare function pickProgressionPreset(style: ProgStyle, ctx?: GenerationContextInput): ProgressionPreset;
|
|
1504
1589
|
/**
|
|
1505
1590
|
* Generate a chord progression laid out one chord per bar.
|
|
1506
1591
|
*
|
|
@@ -1508,14 +1593,17 @@ declare function pickProgressionPreset(style: ProgStyle, seed?: number): Progres
|
|
|
1508
1593
|
* the presets matching `style`, seeded by the context's `seed`. An unknown
|
|
1509
1594
|
* `presetId`, or a `style` no preset claims, is a caller error and throws rather
|
|
1510
1595
|
* than silently falling back to a random preset. The preset's degrees cycle to
|
|
1511
|
-
* fill `bars`;
|
|
1596
|
+
* fill `bars`; a bar is one bar of `ts`, so `startBeat` is `barIndex` bars of
|
|
1597
|
+
* it — four beats apart in 4/4, three in 3/4 and in 6/8 alike. Chord
|
|
1512
1598
|
* roots come from the key's diatonic scale-degree mapping. When `ext` is
|
|
1513
1599
|
* omitted or `'auto'`, each chord takes its diatonic triad quality; otherwise
|
|
1514
1600
|
* `ext` is forced on every chord — except a reharmonized chord, which is a
|
|
1515
1601
|
* secondary dominant and is therefore always a `dom7`. With
|
|
1516
1602
|
* `complexity.harmonic` above 0, some chords are deterministically replaced with
|
|
1517
1603
|
* the secondary dominant (V7) of the following chord, flagged with
|
|
1518
|
-
* `secondaryDominant`.
|
|
1604
|
+
* `secondaryDominant`. Only a chord the key can make a local tonic is given one:
|
|
1605
|
+
* nothing tonicizes a diminished triad, so the supertonic of a minor key takes
|
|
1606
|
+
* no dominant of its own.
|
|
1519
1607
|
*
|
|
1520
1608
|
* @param opts Generation options.
|
|
1521
1609
|
* @returns One chord per bar in timeline order.
|
|
@@ -1539,6 +1627,12 @@ declare function pickProgressionPreset(style: ProgStyle, seed?: number): Progres
|
|
|
1539
1627
|
*/
|
|
1540
1628
|
declare function generateProgression(opts: ProgressionOptions): ChordSpan[];
|
|
1541
1629
|
|
|
1630
|
+
/**
|
|
1631
|
+
* What the stages of the harmonizer share: the shapes they pass between them,
|
|
1632
|
+
* the defaults they fall back on, and the two questions about a key that more
|
|
1633
|
+
* than one of them asks.
|
|
1634
|
+
*/
|
|
1635
|
+
|
|
1542
1636
|
/**
|
|
1543
1637
|
* A melody note supplied to the harmonizer: a {@link NoteEvent}.
|
|
1544
1638
|
*
|
|
@@ -1612,7 +1706,7 @@ type HarmonizeOptions = {
|
|
|
1612
1706
|
*
|
|
1613
1707
|
* @defaultValue `4/4`
|
|
1614
1708
|
*/
|
|
1615
|
-
ts?:
|
|
1709
|
+
ts?: MeterLike;
|
|
1616
1710
|
/**
|
|
1617
1711
|
* How far beyond the key's own triads the chord vocabulary reaches:
|
|
1618
1712
|
* `'diatonic'` uses only them, `'secondaryDominant'` adds the dominants that
|
|
@@ -1672,6 +1766,14 @@ type HarmonizeOptions = {
|
|
|
1672
1766
|
* @defaultValue `{ seed: 0 }`
|
|
1673
1767
|
*/
|
|
1674
1768
|
ctx?: GenerationContextInput;
|
|
1769
|
+
/**
|
|
1770
|
+
* Upper bound on the work this call may do. The search is one pass per
|
|
1771
|
+
* placement over every pair of candidate chords in every slot, so a long line
|
|
1772
|
+
* harmonized with `placement.transposeSearch` on is what needs this raised.
|
|
1773
|
+
*
|
|
1774
|
+
* @defaultValue {@link DEFAULT_GENERATION_BUDGET}
|
|
1775
|
+
*/
|
|
1776
|
+
budget?: number;
|
|
1675
1777
|
};
|
|
1676
1778
|
/**
|
|
1677
1779
|
* The chosen transpose, key, chord path, and per-note roles.
|
|
@@ -1684,7 +1786,16 @@ type HarmonizeResult = {
|
|
|
1684
1786
|
* much puts it in `key`, which is the key the chords are in.
|
|
1685
1787
|
*/
|
|
1686
1788
|
transposeSemitones: number;
|
|
1687
|
-
|
|
1789
|
+
/**
|
|
1790
|
+
* The key the chords are in, whole.
|
|
1791
|
+
*
|
|
1792
|
+
* A key/scale alone says nothing about how it is written, so a result
|
|
1793
|
+
* carrying one would report whichever spelling its pitch classes read best
|
|
1794
|
+
* from, and an Ab minor handed in would come back out a G# minor. It matters
|
|
1795
|
+
* most under `key: 'infer'`, where this is the only account of which key was
|
|
1796
|
+
* chosen and a caller has nothing else to spell the chord spans from.
|
|
1797
|
+
*/
|
|
1798
|
+
key: ResolvedKey;
|
|
1688
1799
|
/** One span per chord change, each starting on a harmonic-rhythm boundary. */
|
|
1689
1800
|
chords: ChordSpan[];
|
|
1690
1801
|
/** Each melody note's role in the chord sounding under it, once chosen. */
|
|
@@ -1693,60 +1804,22 @@ type HarmonizeResult = {
|
|
|
1693
1804
|
role: HarmonyRole;
|
|
1694
1805
|
}[];
|
|
1695
1806
|
};
|
|
1696
|
-
/**
|
|
1697
|
-
* Harmonize a melody with a min-cost chord progression.
|
|
1698
|
-
*
|
|
1699
|
-
* The melody's ornaments are classified first, from the melody and the metre
|
|
1700
|
-
* alone (see {@link classifyMelodyTones}); the chords then have to explain the
|
|
1701
|
-
* structural tones only, so a passing tone no longer buys itself a chord. The
|
|
1702
|
-
* melody is segmented by `harmonicRhythm`; each segment is scored against the
|
|
1703
|
-
* candidate chords the harmonic dial opens — the key's own triads, then the
|
|
1704
|
-
* secondary dominants, then the parallel mode's chords, one at a time as
|
|
1705
|
-
* `ctx.complexity.harmonic` rises from 0 to 1 — by the fit of those structural
|
|
1706
|
-
* tones, and a Viterbi search picks the lowest-cost path using a
|
|
1707
|
-
* functional-flow transition cost and a cadence bonus at the end of the melody
|
|
1708
|
-
* it is given — one cadence, at the close, unless `phraseEnds` names the closes
|
|
1709
|
-
* inside a longer line, and then one at each of them as well. Runs of the same
|
|
1710
|
-
* chord are reported once, so the chord count follows the harmony rather than
|
|
1711
|
-
* the grid.
|
|
1712
|
-
*
|
|
1713
|
-
* With `placement.transposeSearch` the melody is moved into the key it is
|
|
1714
|
-
* harmonized in, and `transposeSemitones` reports how far; with
|
|
1715
|
-
* `placement.octaveSearch` it is moved by octaves into a comfortable register,
|
|
1716
|
-
* which leaves the key and the chords untouched. Both may be set, and the
|
|
1717
|
-
* reported shift is their sum.
|
|
1718
|
-
*
|
|
1719
|
-
* The `seed` drives a deterministic tie-break only: it perturbs candidates by a
|
|
1720
|
-
* magnitude far below any real cost difference (see `TIE_BREAK_JITTER`),
|
|
1721
|
-
* so it can decide between chords or paths of otherwise-equal cost but never
|
|
1722
|
-
* overrides melody fit or functional flow. For a well-determined melody the
|
|
1723
|
-
* result is identical across seeds; the same seed always yields the same result.
|
|
1724
|
-
*
|
|
1725
|
-
* @param opts The melody and, optionally, the generation context, key, harmonic
|
|
1726
|
-
* rhythm, reharmonization strength, placement search, meter, and seed. Only
|
|
1727
|
-
* `melody` is required.
|
|
1728
|
-
* @returns The chosen transpose, key, chord path, and per-note roles.
|
|
1729
|
-
* @example
|
|
1730
|
-
* ```ts
|
|
1731
|
-
* import { harmonizeMelody } from '@libraz/libcantus';
|
|
1732
|
-
* const result = harmonizeMelody({
|
|
1733
|
-
* melody: [
|
|
1734
|
-
* { pitch: 60, startBeat: 0, durationBeat: 1 },
|
|
1735
|
-
* { pitch: 64, startBeat: 1, durationBeat: 1 },
|
|
1736
|
-
* ],
|
|
1737
|
-
* });
|
|
1738
|
-
* result.chords; // one ChordSpan per chord change, on the harmonic-rhythm grid
|
|
1739
|
-
* ```
|
|
1740
|
-
* @category Reharmonization
|
|
1741
|
-
*/
|
|
1742
|
-
declare function harmonizeMelody(opts: HarmonizeOptions): HarmonizeResult;
|
|
1743
1807
|
|
|
1744
1808
|
/**
|
|
1745
1809
|
* A transformation applicable to a motif cell.
|
|
1746
1810
|
*
|
|
1747
1811
|
* @category Composition
|
|
1748
1812
|
*/
|
|
1749
|
-
|
|
1813
|
+
declare const MOTIF_TRANSFORMS: readonly ["transposeDiatonic", "transposeChromatic", "invert", "retrograde", "augment", "diminish", "sequence"];
|
|
1814
|
+
/**
|
|
1815
|
+
* The name of a transformation {@link transformMotif} can apply to a cell.
|
|
1816
|
+
*
|
|
1817
|
+
* Derived from the table the transforms are dispatched from, so a transform
|
|
1818
|
+
* added to one is named by the other on the same commit.
|
|
1819
|
+
*
|
|
1820
|
+
* @category Composition
|
|
1821
|
+
*/
|
|
1822
|
+
type MotifTransform = (typeof MOTIF_TRANSFORMS)[number];
|
|
1750
1823
|
/**
|
|
1751
1824
|
* A single note within a motif cell.
|
|
1752
1825
|
*
|
|
@@ -1792,7 +1865,7 @@ type MotifOptions = {
|
|
|
1792
1865
|
*
|
|
1793
1866
|
* @defaultValue 4/4
|
|
1794
1867
|
*/
|
|
1795
|
-
ts?:
|
|
1868
|
+
ts?: MeterLike;
|
|
1796
1869
|
/**
|
|
1797
1870
|
* Melodic contour shape the line follows.
|
|
1798
1871
|
*
|
|
@@ -1864,7 +1937,10 @@ declare function motifToNoteEvents(cell: MotifCell): NoteEvent[];
|
|
|
1864
1937
|
/**
|
|
1865
1938
|
* Apply a transformation to a motif cell.
|
|
1866
1939
|
*
|
|
1867
|
-
*
|
|
1940
|
+
* Every transform hands the cell back in onset order, so the note a later
|
|
1941
|
+
* transform reads as the first one is the note that sounds first.
|
|
1942
|
+
*
|
|
1943
|
+
* `invert` reflects pitches about the earliest note (chromatic, self-inverse);
|
|
1868
1944
|
* `retrograde` mirrors onsets about the cell span, preserving rests (self-inverse);
|
|
1869
1945
|
* `augment`/`diminish` scale time by `amount ?? 2` and its reciprocal;
|
|
1870
1946
|
* `transposeChromatic` adds `amount` semitones; `transposeDiatonic` shifts by
|
|
@@ -1879,7 +1955,8 @@ declare function motifToNoteEvents(cell: MotifCell): NoteEvent[];
|
|
|
1879
1955
|
* @param key Key context for the diatonic transforms, as a key name such as
|
|
1880
1956
|
* `'C major'` or as a key/scale; without it, `transposeDiatonic` and
|
|
1881
1957
|
* `sequence` shift chromatically by semitones.
|
|
1882
|
-
* @returns The transformed cell
|
|
1958
|
+
* @returns The transformed cell, its notes in time order whatever order the
|
|
1959
|
+
* source cell was written in, so it can be read as a line.
|
|
1883
1960
|
* @throws If a transformed pitch would fall outside the MIDI range 0..127.
|
|
1884
1961
|
*
|
|
1885
1962
|
* @example
|
|
@@ -1908,21 +1985,23 @@ declare function transformMotif(cell: MotifCell, t: MotifTransform, amount?: num
|
|
|
1908
1985
|
* @param key Key context, as a key name such as `'C major'` or as a key/scale;
|
|
1909
1986
|
* the notes off the structural positions are kept in it.
|
|
1910
1987
|
* @param bars Number of bars to fill.
|
|
1911
|
-
* @param ts Meter the bars are counted in
|
|
1912
|
-
*
|
|
1988
|
+
* @param ts Meter the bars are counted in. Asked for rather than defaulted: a
|
|
1989
|
+
* development laid on the wrong bar length drifts off the part it plays
|
|
1990
|
+
* under, and a caller who leaves it out has no way to hear that.
|
|
1991
|
+
* @returns The developed, harmony-aware cell, its notes in time order.
|
|
1913
1992
|
*
|
|
1914
1993
|
* @example
|
|
1915
1994
|
* ```ts
|
|
1916
1995
|
* import { chordTimelineFromChords, developMotif, generateMotif, majorKey } from '@libraz/libcantus';
|
|
1917
1996
|
* const key = majorKey(0);
|
|
1918
1997
|
* const timeline = chordTimelineFromChords([{ rootPc: 0, quality: 'maj', startBeat: 0 }], 8);
|
|
1919
|
-
* const developed = developMotif(generateMotif({ key, bars: 1 }), timeline, key, 2);
|
|
1998
|
+
* const developed = developMotif(generateMotif({ key, bars: 1 }), timeline, key, 2, '4/4');
|
|
1920
1999
|
* developed.notes.map((n) => n.pitch); // [60, 62, 60, 60, 62, 60] — the C-D-C cell, twice
|
|
1921
2000
|
* ```
|
|
1922
2001
|
*
|
|
1923
2002
|
* @category Composition
|
|
1924
2003
|
*/
|
|
1925
|
-
declare function developMotif(cell: MotifCell, timeline: ChordTimeline, key: KeyLike, bars: number, ts
|
|
2004
|
+
declare function developMotif(cell: MotifCell, timeline: ChordTimeline, key: KeyLike, bars: number, ts: MeterLike): MotifCell;
|
|
1926
2005
|
|
|
1927
2006
|
/**
|
|
1928
2007
|
* Ornaments applied to material that already exists.
|
|
@@ -1952,7 +2031,8 @@ declare const ORNAMENT_STYLES: readonly ["ghost", "flam", "drag", "slide", "acce
|
|
|
1952
2031
|
* also takes, voiced as a grace stroke instead of a velocity lift.
|
|
1953
2032
|
* - `'drag'`: mark notes leading into a strong position as dragged. A weak-position
|
|
1954
2033
|
* note qualifies only when the next onset in the material falls on a strong one.
|
|
1955
|
-
* - `'slide'`: mark a note reached by a step or a leap as slid into.
|
|
2034
|
+
* - `'slide'`: mark a note reached by a step or a leap as slid into. A repeated
|
|
2035
|
+
* pitch is not: a slide is the move between two pitches, and there is none.
|
|
1956
2036
|
* - `'accent'`: mark strong-position notes as accented, and lift their velocity.
|
|
1957
2037
|
*
|
|
1958
2038
|
* @category Composition
|
|
@@ -1977,11 +2057,12 @@ type OrnamentOptions = {
|
|
|
1977
2057
|
*/
|
|
1978
2058
|
amount?: number;
|
|
1979
2059
|
/**
|
|
1980
|
-
* Time signature, used to tell strong positions
|
|
2060
|
+
* Time signature, in any form that names one, used to tell strong positions
|
|
2061
|
+
* from weak ones.
|
|
1981
2062
|
*
|
|
1982
2063
|
* @defaultValue 4/4
|
|
1983
2064
|
*/
|
|
1984
|
-
ts?:
|
|
2065
|
+
ts?: MeterLike;
|
|
1985
2066
|
/**
|
|
1986
2067
|
* The generation context. Its `complexity.ornament` sets the amount, its
|
|
1987
2068
|
* `complexity.difficulty` — with a tempo — keeps ornaments off passages too
|
|
@@ -1996,7 +2077,8 @@ type OrnamentOptions = {
|
|
|
1996
2077
|
*
|
|
1997
2078
|
* Which notes are eligible follows from the style and the meter — ghosts fall on
|
|
1998
2079
|
* weak positions, drags on the weak position before a strong one, flams and
|
|
1999
|
-
* accents on strong ones, slides on notes
|
|
2080
|
+
* accents on strong ones, slides on notes the line moves to, by a step or by a
|
|
2081
|
+
* leap — and `amount`
|
|
2000
2082
|
* decides how many of those eligible notes are taken. The choice is addressed by
|
|
2001
2083
|
* each note's own position, so raising `amount` adds ornaments without moving the
|
|
2002
2084
|
* ones already there, and no onset is ever added or shifted: a decorated note is
|
|
@@ -2117,7 +2199,7 @@ type SubstituteOptions = {
|
|
|
2117
2199
|
* ```
|
|
2118
2200
|
* @category Reharmonization
|
|
2119
2201
|
*/
|
|
2120
|
-
declare function substituteChord(chord: ChordLike, key:
|
|
2202
|
+
declare function substituteChord(chord: ChordLike, key: SpelledKeyLike, opts?: SubstituteOptions): Substitution[];
|
|
2121
2203
|
/**
|
|
2122
2204
|
* A borrowed chord in the modal-interchange palette of a key.
|
|
2123
2205
|
*
|
|
@@ -2155,7 +2237,7 @@ type BorrowedChord = {
|
|
|
2155
2237
|
* ```
|
|
2156
2238
|
* @category Reharmonization
|
|
2157
2239
|
*/
|
|
2158
|
-
declare function modalInterchangePalette(key:
|
|
2240
|
+
declare function modalInterchangePalette(key: SpelledKeyLike): BorrowedChord[];
|
|
2159
2241
|
/**
|
|
2160
2242
|
* Reflect a chord across the tonic–dominant axis of a key (negative harmony).
|
|
2161
2243
|
*
|
|
@@ -2180,7 +2262,7 @@ declare function modalInterchangePalette(key: KeyLike): BorrowedChord[];
|
|
|
2180
2262
|
* ```
|
|
2181
2263
|
* @category Reharmonization
|
|
2182
2264
|
*/
|
|
2183
|
-
declare function negativeHarmonyMirror(chord: ChordLike, key:
|
|
2265
|
+
declare function negativeHarmonyMirror(chord: ChordLike, key: SpelledKeyLike): Chord;
|
|
2184
2266
|
|
|
2185
2267
|
/**
|
|
2186
2268
|
* Deterministic rhythm generation over a metric grid.
|
|
@@ -2218,6 +2300,7 @@ type RhythmEvent = {
|
|
|
2218
2300
|
* @param pitch The MIDI pitch to give every note.
|
|
2219
2301
|
* @param velocity Velocity for every note; defaults to a mezzo-forte 96.
|
|
2220
2302
|
* @returns The note events, in the order given.
|
|
2303
|
+
* @throws If the pitch or the velocity is not a whole MIDI value in [0, 127].
|
|
2221
2304
|
* @example
|
|
2222
2305
|
* ```ts
|
|
2223
2306
|
* import { generateRhythm, humanize, rhythmToNoteEvents } from '@libraz/libcantus';
|
|
@@ -2281,27 +2364,26 @@ declare function onsetWeightCurve(weight: number): number;
|
|
|
2281
2364
|
* seed. Each event's duration extends to the next onset, and the last event
|
|
2282
2365
|
* extends to the end of the span.
|
|
2283
2366
|
*
|
|
2284
|
-
* @param ts The time signature.
|
|
2367
|
+
* @param ts The time signature, in any form that names one.
|
|
2285
2368
|
* @param opts Generation options.
|
|
2286
2369
|
* @returns Onset events sorted by position, non-overlapping, covering the span.
|
|
2287
2370
|
* @example
|
|
2288
2371
|
* ```ts
|
|
2289
|
-
* import {
|
|
2290
|
-
*
|
|
2291
|
-
* generateRhythm(ts, { ctx: { seed: 42, complexity: { rhythmic: 0.6 } } });
|
|
2372
|
+
* import { generateRhythm } from '@libraz/libcantus';
|
|
2373
|
+
* generateRhythm('4/4', { ctx: { seed: 42, complexity: { rhythmic: 0.6 } } });
|
|
2292
2374
|
* // onset events over one bar
|
|
2293
2375
|
* ```
|
|
2294
2376
|
* @category Rhythm & Meter
|
|
2295
2377
|
*/
|
|
2296
|
-
declare function generateRhythm(ts:
|
|
2378
|
+
declare function generateRhythm(ts: MeterLike, opts?: RhythmOptions): RhythmEvent[];
|
|
2297
2379
|
/**
|
|
2298
2380
|
* Onset density of a generated pattern: the mean number of onsets per bar.
|
|
2299
2381
|
*
|
|
2300
2382
|
* @param events Events from {@link generateRhythm}.
|
|
2301
|
-
* @param ts The time signature.
|
|
2383
|
+
* @param ts The time signature, in any form that names one.
|
|
2302
2384
|
* @returns The onset count divided by the number of bars the events span.
|
|
2303
2385
|
* @category Rhythm & Meter
|
|
2304
2386
|
*/
|
|
2305
|
-
declare function rhythmDensity(events: RhythmEvent[], ts:
|
|
2387
|
+
declare function rhythmDensity(events: RhythmEvent[], ts: MeterLike): number;
|
|
2306
2388
|
|
|
2307
|
-
export { type Section as $, type MotifCell as A, BAR_STEPS as B, type Complexity as C, DRUM_NOTES as D, type EuclideanKick as E, type MotifContour as F, GENRES as G, type HarmonizeOptions as H, type MotifNote as I, type MotifOptions as J, type MotifTransform as K, type OrnamentOptions as L, type MelodyNote as M, type OrnamentStyle as N, ORNAMENT_STYLES as O, PROVENANCE_BASES as P, type ProgFunction as Q, type ProgStyle as R, type ProgressionDegree as S, type ProgressionOptions as T, type ProgressionPreset as U, type Provenance as V, type ProvenanceBasis as W, type ResolvedContext as X, type RhythmEvent as Y, type RhythmOptions as Z, STEP_BEATS as _, BASS_STYLES as a, type SubstituteOptions as a0, type Substitution as a1, type SubstitutionType as a2, type
|
|
2389
|
+
export { type Section as $, type MotifCell as A, BAR_STEPS as B, type Complexity as C, DRUM_NOTES as D, type EuclideanKick as E, type MotifContour as F, GENRES as G, type HarmonizeOptions as H, type MotifNote as I, type MotifOptions as J, type MotifTransform as K, type OrnamentOptions as L, type MelodyNote as M, type OrnamentStyle as N, ORNAMENT_STYLES as O, PROVENANCE_BASES as P, type ProgFunction as Q, type ProgStyle as R, type ProgressionDegree as S, type ProgressionOptions as T, type ProgressionPreset as U, type Provenance as V, type ProvenanceBasis as W, type ResolvedContext as X, type RhythmEvent as Y, type RhythmOptions as Z, STEP_BEATS as _, BASS_STYLES as a, type SubstituteOptions as a0, type Substitution as a1, type SubstitutionType as a2, type SyncopateOptions as a3, type Vocabulary as a4, type VocabularyQuery as a5, applyGrooveTemplate as a6, assertVocabulary as a7, deform as a8, developMotif as a9, rhythmDensity as aA, rhythmToNoteEvents as aB, selectVocabulary as aC, substituteChord as aD, syncopate as aE, thin as aF, transformMotif as aG, vocabularyOfKind as aH, withinCeiling as aI, double as aa, doubleTime as ab, drumVoiceOf as ac, extractGrooveTemplate as ad, fitsQuery as ae, generateBassLine as af, generateCounterMelody as ag, generateDrums as ah, generateMotif as ai, generateProgression as aj, generateRhythm as ak, gridMetricWeight as al, halfTime as am, humanize as an, mergeVocabulary as ao, modalInterchangePalette as ap, motifToNoteEvents as aq, negativeHarmonyMirror as ar, onsetWeightCurve as as, ornament as at, ornamentBy as au, pickProgressionPreset as av, pickVocabulary as aw, progressions as ax, progressionsByStyle as ay, resolveContext as az, BEAT_STEPS as b, BORROWED_DEGREES as c, type BassLineOptions as d, type BassSegment as e, type BassStyle as f, type BorrowedChord as g, type CounterMelodyOptions as h, type DeformOptions as i, type Draw as j, type DrumHit as k, type DrumRole as l, type DrumStyle as m, type DrumVoice as n, type DrumsOptions as o, type GenerationContext as p, type GenerationContextInput as q, type Genre as r, type GridEvent as s, type GrooveFeel as t, type GrooveSlot as u, type GrooveStyle as v, type GrooveTemplate as w, type HarmonizePlacement as x, type HarmonizeResult as y, type HumanizeOptions as z };
|