@libraz/libcantus 0.9.1 → 0.9.3

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 (160) hide show
  1. package/README.md +19 -3
  2. package/dist/analyze/index.cjs +1970 -0
  3. package/dist/analyze/index.cjs.map +1 -0
  4. package/dist/analyze/index.d.cts +341 -0
  5. package/dist/analyze/index.d.ts +341 -0
  6. package/dist/analyze/index.js +51 -0
  7. package/dist/analyze/index.js.map +1 -0
  8. package/dist/chunk-2ZWMSJH6.js +30 -0
  9. package/dist/chunk-2ZWMSJH6.js.map +1 -0
  10. package/dist/chunk-4MHA432G.js +2854 -0
  11. package/dist/chunk-4MHA432G.js.map +1 -0
  12. package/dist/chunk-62QZKCJQ.js +49 -0
  13. package/dist/chunk-62QZKCJQ.js.map +1 -0
  14. package/dist/chunk-AKLYPWIN.js +83 -0
  15. package/dist/chunk-AKLYPWIN.js.map +1 -0
  16. package/dist/chunk-C5XYKUVG.js +904 -0
  17. package/dist/chunk-C5XYKUVG.js.map +1 -0
  18. package/dist/chunk-CHMXELDS.js +549 -0
  19. package/dist/chunk-CHMXELDS.js.map +1 -0
  20. package/dist/chunk-DYWFNC4A.js +152 -0
  21. package/dist/chunk-DYWFNC4A.js.map +1 -0
  22. package/dist/chunk-EH6EM37U.js +315 -0
  23. package/dist/chunk-EH6EM37U.js.map +1 -0
  24. package/dist/chunk-FBQK3ZQN.js +131 -0
  25. package/dist/chunk-FBQK3ZQN.js.map +1 -0
  26. package/dist/chunk-GOAW4VYL.js +719 -0
  27. package/dist/chunk-GOAW4VYL.js.map +1 -0
  28. package/dist/chunk-I5R7ZBJS.js +202 -0
  29. package/dist/chunk-I5R7ZBJS.js.map +1 -0
  30. package/dist/chunk-IT2O4XFE.js +154 -0
  31. package/dist/chunk-IT2O4XFE.js.map +1 -0
  32. package/dist/chunk-MIWO425M.js +412 -0
  33. package/dist/chunk-MIWO425M.js.map +1 -0
  34. package/dist/chunk-N6IHQUOX.js +1 -0
  35. package/dist/chunk-N6IHQUOX.js.map +1 -0
  36. package/dist/chunk-SGU7SPLK.js +924 -0
  37. package/dist/chunk-SGU7SPLK.js.map +1 -0
  38. package/dist/core/index.cjs +648 -0
  39. package/dist/core/index.cjs.map +1 -0
  40. package/dist/core/index.d.cts +262 -0
  41. package/dist/core/index.d.ts +262 -0
  42. package/dist/core/index.js +93 -0
  43. package/dist/core/index.js.map +1 -0
  44. package/dist/function-DVH4Eusr.d.ts +187 -0
  45. package/dist/function-DYt4iKsn.d.cts +187 -0
  46. package/dist/generate/index.cjs +4123 -0
  47. package/dist/generate/index.cjs.map +1 -0
  48. package/dist/generate/index.d.cts +986 -0
  49. package/dist/generate/index.d.ts +986 -0
  50. package/dist/generate/index.js +52 -0
  51. package/dist/generate/index.js.map +1 -0
  52. package/dist/index-BNlGP86A.d.cts +157 -0
  53. package/dist/index-Bg5dYMmZ.d.ts +56 -0
  54. package/dist/index-Bt4tOUD9.d.ts +157 -0
  55. package/dist/index-CGMZNCx6.d.cts +140 -0
  56. package/dist/index-CGMZNCx6.d.ts +140 -0
  57. package/dist/index-Cl7mhOFM.d.cts +164 -0
  58. package/dist/index-Cl7mhOFM.d.ts +164 -0
  59. package/dist/index-CnZCo29u.d.cts +108 -0
  60. package/dist/index-CpOsP1y9.d.cts +151 -0
  61. package/dist/index-CxqBQtH1.d.cts +128 -0
  62. package/dist/index-Dikst44v.d.cts +56 -0
  63. package/dist/index-DxvARIP2.d.ts +151 -0
  64. package/dist/index-Jc0Ryi79.d.ts +128 -0
  65. package/dist/index-JnF4v9bx.d.ts +108 -0
  66. package/dist/index.cjs +3710 -3143
  67. package/dist/index.cjs.map +1 -1
  68. package/dist/index.d.cts +15 -3982
  69. package/dist/index.d.ts +15 -3982
  70. package/dist/index.js +191 -6504
  71. package/dist/index.js.map +1 -1
  72. package/dist/model/index.cjs +2574 -0
  73. package/dist/model/index.cjs.map +1 -0
  74. package/dist/model/index.d.cts +631 -0
  75. package/dist/model/index.d.ts +631 -0
  76. package/dist/model/index.js +21 -0
  77. package/dist/model/index.js.map +1 -0
  78. package/dist/styled-DZ7GjShb.d.ts +282 -0
  79. package/dist/styled-ZTbdaVFM.d.cts +282 -0
  80. package/dist/theory/index.cjs +1823 -0
  81. package/dist/theory/index.cjs.map +1 -0
  82. package/dist/theory/index.d.cts +535 -0
  83. package/dist/theory/index.d.ts +535 -0
  84. package/dist/theory/index.js +150 -0
  85. package/dist/theory/index.js.map +1 -0
  86. package/dist/types-MGP29r3t.d.cts +30 -0
  87. package/dist/types-MGP29r3t.d.ts +30 -0
  88. package/package.json +61 -5
  89. package/src/analyze/arrange/index.ts +21 -0
  90. package/src/analyze/arrange/internal.ts +127 -0
  91. package/src/analyze/arrange/tension.ts +199 -0
  92. package/src/analyze/arrange/tracks.ts +312 -0
  93. package/src/{detect → analyze/detect}/index.ts +50 -13
  94. package/src/analyze/functional/borrowed.ts +84 -0
  95. package/src/analyze/functional/cadence.ts +66 -0
  96. package/src/analyze/functional/function.ts +184 -0
  97. package/src/analyze/functional/index.ts +23 -0
  98. package/src/analyze/functional/internal.ts +29 -0
  99. package/src/{functional/index.ts → analyze/functional/roman.ts} +23 -332
  100. package/src/analyze/index.ts +49 -0
  101. package/src/{timeline → analyze/timeline}/index.ts +50 -18
  102. package/src/{analysis → analyze/voice}/index.ts +19 -7
  103. package/src/core/event-index/index.ts +104 -0
  104. package/src/core/index.ts +61 -0
  105. package/src/{meter → core/meter}/index.ts +24 -4
  106. package/src/{random → core/random}/index.ts +26 -3
  107. package/src/{tuning → core/tuning}/index.ts +36 -6
  108. package/src/core/validation/index.ts +119 -0
  109. package/src/{bass → generate/bass}/index.ts +28 -5
  110. package/src/{countermelody → generate/countermelody}/index.ts +176 -85
  111. package/src/{drums → generate/drums}/euclid.ts +10 -3
  112. package/src/{drums → generate/drums}/index.ts +58 -26
  113. package/src/{drums → generate/drums}/percussion.ts +1 -1
  114. package/src/{drums → generate/drums}/rng.ts +2 -2
  115. package/src/{groove → generate/groove}/index.ts +28 -3
  116. package/src/{harmonize → generate/harmonize}/index.ts +68 -57
  117. package/src/generate/index.ts +58 -0
  118. package/src/{motif → generate/motif}/index.ts +52 -28
  119. package/src/{progression → generate/progression}/index.ts +19 -41
  120. package/src/{reharmony → generate/reharmony}/index.ts +12 -19
  121. package/src/{rhythm → generate/rhythm}/index.ts +13 -3
  122. package/src/index.ts +13 -234
  123. package/src/model/chord.ts +442 -0
  124. package/src/model/index.ts +5 -1096
  125. package/src/model/interval.ts +82 -0
  126. package/src/model/key.ts +266 -0
  127. package/src/model/note.ts +176 -0
  128. package/src/model/progression.ts +161 -0
  129. package/src/model/shared.ts +12 -0
  130. package/src/{chord → theory/chord}/index.ts +23 -3
  131. package/src/{counterpoint → theory/counterpoint}/index.ts +2 -2
  132. package/src/{harmony → theory/harmony}/index.ts +6 -21
  133. package/src/theory/index.ts +112 -0
  134. package/src/{safety → theory/safety}/index.ts +72 -3
  135. package/src/theory/scale/degrees.ts +123 -0
  136. package/src/theory/scale/index.ts +28 -0
  137. package/src/theory/scale/key.ts +56 -0
  138. package/src/theory/scale/masks.ts +153 -0
  139. package/src/{spelling → theory/spelling}/index.ts +73 -6
  140. package/src/{symbol → theory/symbol}/index.ts +8 -1
  141. package/src/theory/voicing/index.ts +5 -0
  142. package/src/theory/voicing/internal.ts +168 -0
  143. package/src/theory/voicing/leading.ts +112 -0
  144. package/src/theory/voicing/satb.ts +216 -0
  145. package/src/theory/voicing/styled.ts +199 -0
  146. package/src/arrange/index.ts +0 -571
  147. package/src/scale/index.ts +0 -331
  148. package/src/voicing/index.ts +0 -623
  149. /package/src/{interval → core/interval}/index.ts +0 -0
  150. /package/src/{pitch → core/pitch}/index.ts +0 -0
  151. /package/src/{types.ts → core/types.ts} +0 -0
  152. /package/src/{drums → generate/drums}/beat.ts +0 -0
  153. /package/src/{drums → generate/drums}/fills.ts +0 -0
  154. /package/src/{drums → generate/drums}/ghost.ts +0 -0
  155. /package/src/{drums → generate/drums}/hihat.ts +0 -0
  156. /package/src/{drums → generate/drums}/hit.ts +0 -0
  157. /package/src/{drums → generate/drums}/internal.ts +0 -0
  158. /package/src/{drums → generate/drums}/kick.ts +0 -0
  159. /package/src/{drums → generate/drums}/swing.ts +0 -0
  160. /package/src/{chordscale → theory/chordscale}/index.ts +0 -0
@@ -0,0 +1,108 @@
1
+ import { K as KeyScale } from './types-MGP29r3t.js';
2
+ import { a as ChordQuality, C as Chord } from './index-Bt4tOUD9.js';
3
+
4
+ /**
5
+ * Recognition: infer a chord name from a set of pitches, or a key from a set of
6
+ * pitch classes. This is the inverse direction of the chord/scale builders,
7
+ * which only go name -> notes.
8
+ */
9
+
10
+ /**
11
+ * A candidate chord interpretation of a pitch set.
12
+ *
13
+ * @category Recognition
14
+ */
15
+ type ChordMatch = {
16
+ rootPc: number;
17
+ quality: ChordQuality;
18
+ /** Chord tones absent from the input (an incomplete voicing). */
19
+ missingPcs: number[];
20
+ /** Input pitch classes not belonging to the chord. */
21
+ extraPcs: number[];
22
+ /** True when the input pitch-class set equals the chord exactly. */
23
+ exact: boolean;
24
+ /** Inversion implied by a known bass, or null for an unordered pitch-class set. */
25
+ inversion: number | null;
26
+ /** Bass pitch class when inverted (the lowest note is not the root). */
27
+ bassPc?: number;
28
+ };
29
+ /** Input interpretation for {@link detectChord} and {@link detectChordBest}. */
30
+ type DetectChordOptions = {
31
+ /**
32
+ * `midi` uses the numerically lowest pitch as bass; `pitchClass` treats the
33
+ * input as unordered. `auto` (default) selects pitch-class mode only when all
34
+ * values lie in 0..11.
35
+ */
36
+ input?: 'auto' | 'midi' | 'pitchClass';
37
+ /** Explicit bass pitch class, including for an unordered pitch-class set. */
38
+ bassPc?: number;
39
+ };
40
+ /**
41
+ * A candidate key interpretation of a pitch-class set.
42
+ *
43
+ * @category Recognition
44
+ */
45
+ type KeyMatch = {
46
+ key: KeyScale;
47
+ mode: 'major' | 'minor';
48
+ /** Fraction of input pitch classes that are in the scale, in [0, 1]. */
49
+ fit: number;
50
+ };
51
+ /**
52
+ * Identify chords matching a set of pitches.
53
+ *
54
+ * Every input pitch class is tried as a root against every known chord quality.
55
+ * A match is reported when all of the chord's tones are present in the input, or
56
+ * when the only absent tone is the perfect fifth (a common omission in shell
57
+ * voicings); matches are ranked best-first by fewest extra notes, then fewest
58
+ * missing notes, then most specific (largest) chord. An exact match (no extras,
59
+ * no missing) is flagged and ranked first.
60
+ *
61
+ * @param pitches MIDI pitches or bare pitch classes (octave-agnostic).
62
+ * @returns Ranked chord interpretations (may be empty).
63
+ * @example
64
+ * ```ts
65
+ * import { detectChord } from '@libraz/libcantus';
66
+ * const matches = detectChord([60, 64, 67]); // C E G
67
+ * matches[0]; // { rootPc: 0, quality: 'maj', exact: true, ... }
68
+ * ```
69
+ * @category Recognition
70
+ */
71
+ declare function detectChord(pitches: number[], opts?: DetectChordOptions): ChordMatch[];
72
+ /**
73
+ * The single best chord interpretation of a pitch set, or null if none.
74
+ *
75
+ * @param pitches MIDI pitches or bare pitch classes.
76
+ * @returns The top-ranked chord, or null when nothing matches.
77
+ * @example
78
+ * ```ts
79
+ * import { detectChordBest } from '@libraz/libcantus';
80
+ * detectChordBest([60, 64, 67]); // C major triad: { rootPc: 0, quality: 'maj', ... }
81
+ * ```
82
+ * @category Recognition
83
+ */
84
+ declare function detectChordBest(pitches: number[], opts?: DetectChordOptions): Chord | null;
85
+ /**
86
+ * Rank major and minor keys by how well they contain a set of pitch classes.
87
+ *
88
+ * The tonic is weighted so that, among equally-fitting keys, the one whose root
89
+ * appears in the input is preferred. Minor candidates are scored against the
90
+ * natural, harmonic, and melodic minor variants and keep the best of the three,
91
+ * so a minor cadence containing the leading tone still resolves to its own
92
+ * tonic; the returned key is always the natural-minor scale. Returns all 24
93
+ * keys ranked best-first, or an empty array for an empty input (mirroring
94
+ * {@link detectChord}).
95
+ *
96
+ * @param pitches MIDI pitches or bare pitch classes.
97
+ * @returns Ranked key interpretations (empty for an empty input).
98
+ * @example
99
+ * ```ts
100
+ * import { detectKey } from '@libraz/libcantus';
101
+ * const keys = detectKey([60, 62, 64, 65, 67, 69, 71]); // C major scale
102
+ * keys[0].mode; // 'major', with keys[0].key.rootPc === 0
103
+ * ```
104
+ * @category Recognition
105
+ */
106
+ declare function detectKey(pitches: number[]): KeyMatch[];
107
+
108
+ export { type ChordMatch as C, type DetectChordOptions as D, type KeyMatch as K, detectChordBest as a, detectKey as b, detectChord as d };