@libraz/libcantus 0.9.4 → 1.0.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 (186) hide show
  1. package/README.md +61 -261
  2. package/README_ja.md +115 -0
  3. package/dist/analyze/index.cjs +54 -7
  4. package/dist/analyze/index.cjs.map +1 -1
  5. package/dist/analyze/index.d.cts +213 -456
  6. package/dist/analyze/index.d.ts +213 -456
  7. package/dist/analyze/index.js +56 -9
  8. package/dist/chunk-3JXCW6DX.cjs +3220 -0
  9. package/dist/chunk-3JXCW6DX.cjs.map +1 -0
  10. package/dist/chunk-4A2RMUCC.js +7647 -0
  11. package/dist/chunk-4A2RMUCC.js.map +1 -0
  12. package/dist/chunk-6XPTBE7Y.cjs +49 -0
  13. package/dist/chunk-6XPTBE7Y.cjs.map +1 -0
  14. package/dist/chunk-AFM2ULJH.cjs +5121 -0
  15. package/dist/chunk-AFM2ULJH.cjs.map +1 -0
  16. package/dist/chunk-E3F4AHAH.cjs +690 -0
  17. package/dist/chunk-E3F4AHAH.cjs.map +1 -0
  18. package/dist/chunk-ELCTZUJJ.js +379 -0
  19. package/dist/chunk-ELCTZUJJ.js.map +1 -0
  20. package/dist/chunk-FVSI36UV.js +690 -0
  21. package/dist/chunk-FVSI36UV.js.map +1 -0
  22. package/dist/chunk-GEDTJHAC.cjs +1 -0
  23. package/dist/chunk-GEDTJHAC.cjs.map +1 -0
  24. package/dist/chunk-GOZG57ER.js +3220 -0
  25. package/dist/chunk-GOZG57ER.js.map +1 -0
  26. package/dist/chunk-H3VORETI.js +2243 -0
  27. package/dist/chunk-H3VORETI.js.map +1 -0
  28. package/dist/chunk-H42UHPYW.js +1577 -0
  29. package/dist/chunk-H42UHPYW.js.map +1 -0
  30. package/dist/chunk-HFPS7JFD.js +1 -0
  31. package/dist/chunk-INHVXP6Z.js +3053 -0
  32. package/dist/chunk-INHVXP6Z.js.map +1 -0
  33. package/dist/chunk-K4ZJUGF4.cjs +379 -0
  34. package/dist/chunk-K4ZJUGF4.cjs.map +1 -0
  35. package/dist/chunk-KNJEKLKV.js +49 -0
  36. package/dist/chunk-KNJEKLKV.js.map +1 -0
  37. package/dist/chunk-M4CWTJWJ.cjs +7647 -0
  38. package/dist/chunk-M4CWTJWJ.cjs.map +1 -0
  39. package/dist/chunk-MXO72PLY.cjs +211 -0
  40. package/dist/chunk-MXO72PLY.cjs.map +1 -0
  41. package/dist/chunk-NLEU4QSE.cjs +360 -0
  42. package/dist/chunk-NLEU4QSE.cjs.map +1 -0
  43. package/dist/chunk-OE6WK2Y2.cjs +1577 -0
  44. package/dist/chunk-OE6WK2Y2.cjs.map +1 -0
  45. package/dist/chunk-Q2WGKJNN.cjs +1064 -0
  46. package/dist/chunk-Q2WGKJNN.cjs.map +1 -0
  47. package/dist/chunk-QYQQ5J6E.js +1 -0
  48. package/dist/chunk-QYQQ5J6E.js.map +1 -0
  49. package/dist/chunk-RHIJ3S4I.cjs +1 -0
  50. package/dist/chunk-RHIJ3S4I.cjs.map +1 -0
  51. package/dist/chunk-TTCLJX6D.js +211 -0
  52. package/dist/chunk-TTCLJX6D.js.map +1 -0
  53. package/dist/chunk-UADYAYAT.cjs +3053 -0
  54. package/dist/chunk-UADYAYAT.cjs.map +1 -0
  55. package/dist/chunk-VOHZB45S.js +5121 -0
  56. package/dist/chunk-VOHZB45S.js.map +1 -0
  57. package/dist/chunk-VTI6FOLB.js +1064 -0
  58. package/dist/chunk-VTI6FOLB.js.map +1 -0
  59. package/dist/chunk-WWURE4XT.cjs +2243 -0
  60. package/dist/chunk-WWURE4XT.cjs.map +1 -0
  61. package/dist/chunk-YH3BIKHH.js +360 -0
  62. package/dist/chunk-YH3BIKHH.js.map +1 -0
  63. package/dist/core/index.cjs +103 -6
  64. package/dist/core/index.cjs.map +1 -1
  65. package/dist/core/index.d.cts +96 -345
  66. package/dist/core/index.d.ts +96 -345
  67. package/dist/core/index.js +104 -7
  68. package/dist/generate/index.cjs +89 -10
  69. package/dist/generate/index.cjs.map +1 -1
  70. package/dist/generate/index.d.cts +437 -1095
  71. package/dist/generate/index.d.ts +437 -1095
  72. package/dist/generate/index.js +94 -15
  73. package/dist/index-9wcMhG73.d.ts +1095 -0
  74. package/dist/{index-D6b6na69.d.cts → index-B4o55NDr.d.cts} +13 -9
  75. package/dist/index-B9MNZboQ.d.cts +770 -0
  76. package/dist/index-B9MNZboQ.d.ts +770 -0
  77. package/dist/index-BGFW-8P2.d.cts +2307 -0
  78. package/dist/index-BO6xE9YU.d.cts +1804 -0
  79. package/dist/index-BkGmlyI3.d.cts +470 -0
  80. package/dist/index-CCNJRG-P.d.cts +1095 -0
  81. package/dist/index-CGpRv5sl.d.cts +643 -0
  82. package/dist/index-C_8o--VE.d.cts +1242 -0
  83. package/dist/index-CgHqxdps.d.ts +2307 -0
  84. package/dist/index-Chbst3Jx.d.ts +1343 -0
  85. package/dist/index-Cj49F892.d.ts +470 -0
  86. package/dist/{index-tSQh-xwY.d.ts → index-CunYKLiu.d.ts} +13 -9
  87. package/dist/index-D57QRbVn.d.ts +1804 -0
  88. package/dist/index-DInQqT8Q.d.cts +66 -0
  89. package/dist/index-DInQqT8Q.d.ts +66 -0
  90. package/dist/index-Dzr13q3d.d.cts +1343 -0
  91. package/dist/index-G1uwGGWQ.d.ts +643 -0
  92. package/dist/index-szBv3496.d.ts +1242 -0
  93. package/dist/index.cjs +358 -15
  94. package/dist/index.cjs.map +1 -1
  95. package/dist/index.d.cts +17 -15
  96. package/dist/index.d.ts +17 -15
  97. package/dist/index.js +407 -64
  98. package/dist/masks-DYbE485J.d.cts +445 -0
  99. package/dist/masks-DYbE485J.d.ts +445 -0
  100. package/dist/model/index.cjs +39 -7
  101. package/dist/model/index.cjs.map +1 -1
  102. package/dist/model/index.d.cts +4685 -243
  103. package/dist/model/index.d.ts +4685 -243
  104. package/dist/model/index.js +40 -8
  105. package/dist/positional-Cptlj-xs.d.ts +287 -0
  106. package/dist/positional-DvH_sd8u.d.cts +287 -0
  107. package/dist/theory/index.cjs +101 -7
  108. package/dist/theory/index.cjs.map +1 -1
  109. package/dist/theory/index.d.cts +513 -173
  110. package/dist/theory/index.d.ts +513 -173
  111. package/dist/theory/index.js +118 -24
  112. package/package.json +16 -11
  113. package/dist/chunk-36N73KZ3.cjs +0 -246
  114. package/dist/chunk-36N73KZ3.cjs.map +0 -1
  115. package/dist/chunk-4HLLZPXT.cjs +0 -3077
  116. package/dist/chunk-4HLLZPXT.cjs.map +0 -1
  117. package/dist/chunk-7MGZ7D62.cjs +0 -498
  118. package/dist/chunk-7MGZ7D62.cjs.map +0 -1
  119. package/dist/chunk-7NKDPF74.js +0 -3077
  120. package/dist/chunk-7NKDPF74.js.map +0 -1
  121. package/dist/chunk-CAN76NCU.cjs +0 -679
  122. package/dist/chunk-CAN76NCU.cjs.map +0 -1
  123. package/dist/chunk-D2FAJBYL.js +0 -479
  124. package/dist/chunk-D2FAJBYL.js.map +0 -1
  125. package/dist/chunk-EHVEBWM5.js +0 -1449
  126. package/dist/chunk-EHVEBWM5.js.map +0 -1
  127. package/dist/chunk-FCANXBAT.cjs +0 -30
  128. package/dist/chunk-FCANXBAT.cjs.map +0 -1
  129. package/dist/chunk-FNDWXRRI.cjs +0 -479
  130. package/dist/chunk-FNDWXRRI.cjs.map +0 -1
  131. package/dist/chunk-GQSGS2N4.js +0 -173
  132. package/dist/chunk-GQSGS2N4.js.map +0 -1
  133. package/dist/chunk-HKGYCQ34.js +0 -53
  134. package/dist/chunk-HKGYCQ34.js.map +0 -1
  135. package/dist/chunk-I24MV65U.js +0 -106
  136. package/dist/chunk-I24MV65U.js.map +0 -1
  137. package/dist/chunk-KMHOICIY.js +0 -679
  138. package/dist/chunk-KMHOICIY.js.map +0 -1
  139. package/dist/chunk-LW53AHQU.cjs +0 -1117
  140. package/dist/chunk-LW53AHQU.cjs.map +0 -1
  141. package/dist/chunk-N6IHQUOX.js +0 -1
  142. package/dist/chunk-NKIBQ6PT.js +0 -30
  143. package/dist/chunk-NKIBQ6PT.js.map +0 -1
  144. package/dist/chunk-NP4NA2FB.cjs +0 -106
  145. package/dist/chunk-NP4NA2FB.cjs.map +0 -1
  146. package/dist/chunk-NVE34YGZ.cjs +0 -1449
  147. package/dist/chunk-NVE34YGZ.cjs.map +0 -1
  148. package/dist/chunk-NYYWMV2C.js +0 -327
  149. package/dist/chunk-NYYWMV2C.js.map +0 -1
  150. package/dist/chunk-Q2XUP227.js +0 -845
  151. package/dist/chunk-Q2XUP227.js.map +0 -1
  152. package/dist/chunk-Q6OP4U43.cjs +0 -327
  153. package/dist/chunk-Q6OP4U43.cjs.map +0 -1
  154. package/dist/chunk-RC6GBMCD.cjs +0 -845
  155. package/dist/chunk-RC6GBMCD.cjs.map +0 -1
  156. package/dist/chunk-RK35RIN7.js +0 -1117
  157. package/dist/chunk-RK35RIN7.js.map +0 -1
  158. package/dist/chunk-RUMU3UA6.cjs +0 -53
  159. package/dist/chunk-RUMU3UA6.cjs.map +0 -1
  160. package/dist/chunk-T64C7ZD7.cjs +0 -1
  161. package/dist/chunk-T64C7ZD7.cjs.map +0 -1
  162. package/dist/chunk-XEBG3G53.js +0 -498
  163. package/dist/chunk-XEBG3G53.js.map +0 -1
  164. package/dist/chunk-YLEMGEFH.js +0 -246
  165. package/dist/chunk-YLEMGEFH.js.map +0 -1
  166. package/dist/chunk-ZEJR4TKL.cjs +0 -173
  167. package/dist/chunk-ZEJR4TKL.cjs.map +0 -1
  168. package/dist/function-BtiZb9i9.d.ts +0 -208
  169. package/dist/function-DNugAOrt.d.cts +0 -208
  170. package/dist/index-6VR8-kit.d.ts +0 -143
  171. package/dist/index-70p168VM.d.ts +0 -192
  172. package/dist/index-Be74mcon.d.cts +0 -152
  173. package/dist/index-BtXT6UQ0.d.cts +0 -192
  174. package/dist/index-C5UBbQ4G.d.ts +0 -152
  175. package/dist/index-C83mZI1P.d.ts +0 -242
  176. package/dist/index-DXd9JikN.d.cts +0 -246
  177. package/dist/index-DXd9JikN.d.ts +0 -246
  178. package/dist/index-OG65ocOr.d.cts +0 -272
  179. package/dist/index-OG65ocOr.d.ts +0 -272
  180. package/dist/index-tJhkmQgE.d.cts +0 -143
  181. package/dist/index-y_ak9_Hi.d.cts +0 -242
  182. package/dist/styled-DIRkk9Uz.d.ts +0 -506
  183. package/dist/styled-DJbkJQfj.d.cts +0 -506
  184. package/dist/types-BN6_Q9Kl.d.cts +0 -39
  185. package/dist/types-BN6_Q9Kl.d.ts +0 -39
  186. /package/dist/{chunk-N6IHQUOX.js.map → chunk-HFPS7JFD.js.map} +0 -0
@@ -1,208 +0,0 @@
1
- import { K as KeyScale } from './types-BN6_Q9Kl.js';
2
- import { C as Chord } from './index-C83mZI1P.js';
3
-
4
- /**
5
- * Borrowed chords (modal interchange) and the Neapolitan.
6
- *
7
- * Roots are pitch classes measured against the key tonic, so borrowed and
8
- * chromatic chords are handled by their semitone offset rather than requiring a
9
- * spelled key signature.
10
- */
11
-
12
- /**
13
- * The origin of a recognized non-diatonic chord, or null when none applies.
14
- *
15
- * @category Functional Harmony
16
- */
17
- type BorrowedSource = 'parallelMinor' | 'parallelMajor' | 'neapolitan' | null;
18
- /**
19
- * Whether a chord is borrowed from the parallel mode (modal interchange).
20
- *
21
- * True when the chord is not diatonic to `key` but is diatonic to its
22
- * {@link parallelKey} — e.g. iv, bVI, or bVII in a major key, or the Picardy
23
- * tonic and major IV in a minor key. Two non-diatonic families are excluded:
24
- * chords diatonic to neither mode (they are chromatic, not borrowed), and, in
25
- * a minor key, chords explained by the harmonic minor scale (the major
26
- * dominant and raised-leading-tone chords), which are in-key alterations
27
- * rather than interchange even though they happen to fit the parallel major.
28
- *
29
- * @param chord The chord to test.
30
- * @param key The prevailing key.
31
- * @returns True if the chord is borrowed from the parallel mode.
32
- * @category Functional Harmony
33
- */
34
- declare function isBorrowedChord(chord: Chord, key: KeyScale): boolean;
35
- /**
36
- * Identify where a non-diatonic chord comes from.
37
- *
38
- * The Neapolitan (major triad on b2) is recognized first, since it sits
39
- * outside both parallel modes; parallel-mode borrowing follows the
40
- * {@link isBorrowedChord} rules. Diatonic chords, harmonic-minor alterations,
41
- * and unrecognized chromatic chords all yield null.
42
- *
43
- * @param chord The chord to classify.
44
- * @param key The prevailing key.
45
- * @returns The borrowing source, or null.
46
- * @category Functional Harmony
47
- */
48
- declare function borrowedSource(chord: Chord, key: KeyScale): BorrowedSource;
49
-
50
- /**
51
- * Cadence detection between two successive chords.
52
- *
53
- * Roots are pitch classes measured against the key tonic, so borrowed and
54
- * chromatic chords are handled by their semitone offset rather than requiring a
55
- * spelled key signature.
56
- */
57
-
58
- /**
59
- * A recognized cadence type, or null when a chord pair forms none.
60
- *
61
- * @category Functional Harmony
62
- */
63
- type Cadence = 'authentic' | 'plagal' | 'half' | 'deceptive' | null;
64
- /**
65
- * Classify the cadence formed by moving from one chord to the next.
66
- *
67
- * - authentic: V (dominant a fifth above the tonic) to I
68
- * - plagal: IV (a fourth above the tonic) to I
69
- * - deceptive: V to the submediant (diatonic vi or borrowed bVI in major, VI in
70
- * minor)
71
- * - half: any chord other than the dominant itself to V
72
- *
73
- * A static V-to-V repeat with no root motion is not a cadence and yields null.
74
- *
75
- * @param from The penultimate chord.
76
- * @param to The final chord.
77
- * @param key The prevailing key.
78
- * @returns The cadence type, or null.
79
- * @example
80
- * ```ts
81
- * import { detectCadence, makeChord, majorKey } from '@libraz/libcantus';
82
- * detectCadence(makeChord(7, 'maj'), makeChord(0, 'maj'), majorKey(0)); // => 'authentic'
83
- * ```
84
- * @category Functional Harmony
85
- */
86
- declare function detectCadence(from: Chord, to: Chord, key: KeyScale): Cadence;
87
-
88
- /**
89
- * Harmonic function (tonic / subdominant / dominant), diatonicity, parallel-key
90
- * mirroring, and full chord analysis.
91
- *
92
- * Roots are pitch classes measured against the key tonic, so borrowed and
93
- * chromatic chords are handled by their semitone offset rather than requiring a
94
- * spelled key signature.
95
- */
96
-
97
- /**
98
- * The three broad harmonic functions of tonal music.
99
- *
100
- * @category Functional Harmony
101
- */
102
- type HarmonicFunction = 'tonic' | 'subdominant' | 'dominant';
103
- /**
104
- * Whether a key's scale has a minor third and no major third (a minor key).
105
- *
106
- * @category Functional Harmony
107
- */
108
- declare function isMinorKey(key: KeyScale): boolean;
109
- /**
110
- * The harmonic function of a chord in a key.
111
- *
112
- * The root's offset above the tonic gives the baseline mapping, which follows
113
- * common-practice major-key function and is a useful approximation in minor and
114
- * for borrowed chords. Chord quality then refines it where the sonority settles
115
- * an ambiguity the root offset cannot:
116
- *
117
- * - A chord that *sounds* like a dominant — a major third with a minor seventh,
118
- * or a diminished-family chord — and is not diatonic to the key has dominant
119
- * function when its root resolves down a fifth or by a semitone onto a
120
- * diatonic degree. This is what makes an applied dominant (`A7` in C, which
121
- * tonicizes ii) and its tritone substitute (`Db7`) read as dominant rather
122
- * than inheriting the function of the degree they happen to sit on.
123
- * - The Neapolitan is subdominant.
124
- * - A major triad on bVI or bVII of a major key is subdominant — the borrowed
125
- * pop cadence chord, distinct from the bVII7 above, which has a seventh and
126
- * is a dominant sonority.
127
- *
128
- * @param chord The chord.
129
- * @param key The prevailing key.
130
- * @returns The harmonic function.
131
- * @example
132
- * ```ts
133
- * import { functionOf, makeChord, majorKey } from '@libraz/libcantus';
134
- * functionOf(makeChord(9, 'dom7'), majorKey(0)); // 'dominant' — A7 tonicizes ii
135
- * functionOf(makeChord(10, 'maj'), majorKey(0)); // 'subdominant' — borrowed bVII
136
- * ```
137
- * @category Functional Harmony
138
- */
139
- declare function functionOf(chord: Chord, key: KeyScale): HarmonicFunction;
140
- /**
141
- * The result of {@link analyzeChord}: function, borrowing, and Roman numeral.
142
- *
143
- * @category Functional Harmony
144
- */
145
- type ChordAnalysis = {
146
- function: HarmonicFunction;
147
- borrowed: boolean;
148
- source: BorrowedSource;
149
- roman: string;
150
- };
151
- /**
152
- * Whether every pitch class of a chord belongs to the key's scale.
153
- *
154
- * The test is strict against the key's own mode mask: in a natural-minor key
155
- * the harmonic-minor dominant (major V) is *not* diatonic, since the raised
156
- * leading tone lies outside the mask. Borrowing predicates treat that case as
157
- * an in-key alteration separately (see {@link isBorrowedChord}).
158
- *
159
- * @param chord The chord to test.
160
- * @param key The prevailing key.
161
- * @returns True if all chord pitch classes are scale tones.
162
- * @category Functional Harmony
163
- */
164
- declare function isDiatonic(chord: Chord, key: KeyScale): boolean;
165
- /**
166
- * The parallel key: same tonic, opposite mode.
167
- *
168
- * A key with a minor third (natural/harmonic/melodic minor, dorian, phrygian)
169
- * maps to the parallel major; any other key maps to the parallel natural minor.
170
- *
171
- * @param key The key to mirror.
172
- * @returns The parallel major or natural-minor key on the same tonic.
173
- * @category Functional Harmony
174
- */
175
- declare function parallelKey(key: KeyScale): KeyScale;
176
- /**
177
- * Analyze a chord in a key: harmonic function, borrowing, and Roman numeral.
178
- *
179
- * The function is quality-aware (see the predicates behind it), the source
180
- * follows {@link borrowedSource}, and the numeral comes from
181
- * {@link chordToRoman}. `borrowed` is true whenever a source is identified —
182
- * including the Neapolitan, which the stricter parallel-mode predicate
183
- * {@link isBorrowedChord} does not count.
184
- *
185
- * @param chord The chord to analyze.
186
- * @param key The prevailing key.
187
- * @returns The chord analysis.
188
- * @example
189
- * ```ts
190
- * import { analyzeChord, makeChord, majorKey } from '@libraz/libcantus';
191
- * analyzeChord(makeChord(7, 'dom7'), majorKey(0));
192
- * // { function: 'dominant', borrowed: false, source: null, roman: 'V7' }
193
- * ```
194
- * @category Functional Harmony
195
- */
196
- declare function analyzeChord(chord: Chord, key: KeyScale): ChordAnalysis;
197
- /**
198
- * The secondary dominant (V7) that tonicizes a scale degree.
199
- *
200
- * @param targetDegree 0-based scale degree to tonicize, in 0..6.
201
- * @param key The prevailing key.
202
- * @returns A dominant-seventh chord a fifth above the target's root.
203
- * @throws If `targetDegree` is not an integer in 0..6.
204
- * @category Functional Harmony
205
- */
206
- declare function secondaryDominant(targetDegree: number, key: KeyScale): Chord;
207
-
208
- export { type BorrowedSource as B, type Cadence as C, type HarmonicFunction as H, type ChordAnalysis as a, analyzeChord as b, borrowedSource as c, detectCadence as d, isDiatonic as e, functionOf as f, isMinorKey as g, isBorrowedChord as i, parallelKey as p, secondaryDominant as s };
@@ -1,208 +0,0 @@
1
- import { K as KeyScale } from './types-BN6_Q9Kl.cjs';
2
- import { C as Chord } from './index-y_ak9_Hi.cjs';
3
-
4
- /**
5
- * Borrowed chords (modal interchange) and the Neapolitan.
6
- *
7
- * Roots are pitch classes measured against the key tonic, so borrowed and
8
- * chromatic chords are handled by their semitone offset rather than requiring a
9
- * spelled key signature.
10
- */
11
-
12
- /**
13
- * The origin of a recognized non-diatonic chord, or null when none applies.
14
- *
15
- * @category Functional Harmony
16
- */
17
- type BorrowedSource = 'parallelMinor' | 'parallelMajor' | 'neapolitan' | null;
18
- /**
19
- * Whether a chord is borrowed from the parallel mode (modal interchange).
20
- *
21
- * True when the chord is not diatonic to `key` but is diatonic to its
22
- * {@link parallelKey} — e.g. iv, bVI, or bVII in a major key, or the Picardy
23
- * tonic and major IV in a minor key. Two non-diatonic families are excluded:
24
- * chords diatonic to neither mode (they are chromatic, not borrowed), and, in
25
- * a minor key, chords explained by the harmonic minor scale (the major
26
- * dominant and raised-leading-tone chords), which are in-key alterations
27
- * rather than interchange even though they happen to fit the parallel major.
28
- *
29
- * @param chord The chord to test.
30
- * @param key The prevailing key.
31
- * @returns True if the chord is borrowed from the parallel mode.
32
- * @category Functional Harmony
33
- */
34
- declare function isBorrowedChord(chord: Chord, key: KeyScale): boolean;
35
- /**
36
- * Identify where a non-diatonic chord comes from.
37
- *
38
- * The Neapolitan (major triad on b2) is recognized first, since it sits
39
- * outside both parallel modes; parallel-mode borrowing follows the
40
- * {@link isBorrowedChord} rules. Diatonic chords, harmonic-minor alterations,
41
- * and unrecognized chromatic chords all yield null.
42
- *
43
- * @param chord The chord to classify.
44
- * @param key The prevailing key.
45
- * @returns The borrowing source, or null.
46
- * @category Functional Harmony
47
- */
48
- declare function borrowedSource(chord: Chord, key: KeyScale): BorrowedSource;
49
-
50
- /**
51
- * Cadence detection between two successive chords.
52
- *
53
- * Roots are pitch classes measured against the key tonic, so borrowed and
54
- * chromatic chords are handled by their semitone offset rather than requiring a
55
- * spelled key signature.
56
- */
57
-
58
- /**
59
- * A recognized cadence type, or null when a chord pair forms none.
60
- *
61
- * @category Functional Harmony
62
- */
63
- type Cadence = 'authentic' | 'plagal' | 'half' | 'deceptive' | null;
64
- /**
65
- * Classify the cadence formed by moving from one chord to the next.
66
- *
67
- * - authentic: V (dominant a fifth above the tonic) to I
68
- * - plagal: IV (a fourth above the tonic) to I
69
- * - deceptive: V to the submediant (diatonic vi or borrowed bVI in major, VI in
70
- * minor)
71
- * - half: any chord other than the dominant itself to V
72
- *
73
- * A static V-to-V repeat with no root motion is not a cadence and yields null.
74
- *
75
- * @param from The penultimate chord.
76
- * @param to The final chord.
77
- * @param key The prevailing key.
78
- * @returns The cadence type, or null.
79
- * @example
80
- * ```ts
81
- * import { detectCadence, makeChord, majorKey } from '@libraz/libcantus';
82
- * detectCadence(makeChord(7, 'maj'), makeChord(0, 'maj'), majorKey(0)); // => 'authentic'
83
- * ```
84
- * @category Functional Harmony
85
- */
86
- declare function detectCadence(from: Chord, to: Chord, key: KeyScale): Cadence;
87
-
88
- /**
89
- * Harmonic function (tonic / subdominant / dominant), diatonicity, parallel-key
90
- * mirroring, and full chord analysis.
91
- *
92
- * Roots are pitch classes measured against the key tonic, so borrowed and
93
- * chromatic chords are handled by their semitone offset rather than requiring a
94
- * spelled key signature.
95
- */
96
-
97
- /**
98
- * The three broad harmonic functions of tonal music.
99
- *
100
- * @category Functional Harmony
101
- */
102
- type HarmonicFunction = 'tonic' | 'subdominant' | 'dominant';
103
- /**
104
- * Whether a key's scale has a minor third and no major third (a minor key).
105
- *
106
- * @category Functional Harmony
107
- */
108
- declare function isMinorKey(key: KeyScale): boolean;
109
- /**
110
- * The harmonic function of a chord in a key.
111
- *
112
- * The root's offset above the tonic gives the baseline mapping, which follows
113
- * common-practice major-key function and is a useful approximation in minor and
114
- * for borrowed chords. Chord quality then refines it where the sonority settles
115
- * an ambiguity the root offset cannot:
116
- *
117
- * - A chord that *sounds* like a dominant — a major third with a minor seventh,
118
- * or a diminished-family chord — and is not diatonic to the key has dominant
119
- * function when its root resolves down a fifth or by a semitone onto a
120
- * diatonic degree. This is what makes an applied dominant (`A7` in C, which
121
- * tonicizes ii) and its tritone substitute (`Db7`) read as dominant rather
122
- * than inheriting the function of the degree they happen to sit on.
123
- * - The Neapolitan is subdominant.
124
- * - A major triad on bVI or bVII of a major key is subdominant — the borrowed
125
- * pop cadence chord, distinct from the bVII7 above, which has a seventh and
126
- * is a dominant sonority.
127
- *
128
- * @param chord The chord.
129
- * @param key The prevailing key.
130
- * @returns The harmonic function.
131
- * @example
132
- * ```ts
133
- * import { functionOf, makeChord, majorKey } from '@libraz/libcantus';
134
- * functionOf(makeChord(9, 'dom7'), majorKey(0)); // 'dominant' — A7 tonicizes ii
135
- * functionOf(makeChord(10, 'maj'), majorKey(0)); // 'subdominant' — borrowed bVII
136
- * ```
137
- * @category Functional Harmony
138
- */
139
- declare function functionOf(chord: Chord, key: KeyScale): HarmonicFunction;
140
- /**
141
- * The result of {@link analyzeChord}: function, borrowing, and Roman numeral.
142
- *
143
- * @category Functional Harmony
144
- */
145
- type ChordAnalysis = {
146
- function: HarmonicFunction;
147
- borrowed: boolean;
148
- source: BorrowedSource;
149
- roman: string;
150
- };
151
- /**
152
- * Whether every pitch class of a chord belongs to the key's scale.
153
- *
154
- * The test is strict against the key's own mode mask: in a natural-minor key
155
- * the harmonic-minor dominant (major V) is *not* diatonic, since the raised
156
- * leading tone lies outside the mask. Borrowing predicates treat that case as
157
- * an in-key alteration separately (see {@link isBorrowedChord}).
158
- *
159
- * @param chord The chord to test.
160
- * @param key The prevailing key.
161
- * @returns True if all chord pitch classes are scale tones.
162
- * @category Functional Harmony
163
- */
164
- declare function isDiatonic(chord: Chord, key: KeyScale): boolean;
165
- /**
166
- * The parallel key: same tonic, opposite mode.
167
- *
168
- * A key with a minor third (natural/harmonic/melodic minor, dorian, phrygian)
169
- * maps to the parallel major; any other key maps to the parallel natural minor.
170
- *
171
- * @param key The key to mirror.
172
- * @returns The parallel major or natural-minor key on the same tonic.
173
- * @category Functional Harmony
174
- */
175
- declare function parallelKey(key: KeyScale): KeyScale;
176
- /**
177
- * Analyze a chord in a key: harmonic function, borrowing, and Roman numeral.
178
- *
179
- * The function is quality-aware (see the predicates behind it), the source
180
- * follows {@link borrowedSource}, and the numeral comes from
181
- * {@link chordToRoman}. `borrowed` is true whenever a source is identified —
182
- * including the Neapolitan, which the stricter parallel-mode predicate
183
- * {@link isBorrowedChord} does not count.
184
- *
185
- * @param chord The chord to analyze.
186
- * @param key The prevailing key.
187
- * @returns The chord analysis.
188
- * @example
189
- * ```ts
190
- * import { analyzeChord, makeChord, majorKey } from '@libraz/libcantus';
191
- * analyzeChord(makeChord(7, 'dom7'), majorKey(0));
192
- * // { function: 'dominant', borrowed: false, source: null, roman: 'V7' }
193
- * ```
194
- * @category Functional Harmony
195
- */
196
- declare function analyzeChord(chord: Chord, key: KeyScale): ChordAnalysis;
197
- /**
198
- * The secondary dominant (V7) that tonicizes a scale degree.
199
- *
200
- * @param targetDegree 0-based scale degree to tonicize, in 0..6.
201
- * @param key The prevailing key.
202
- * @returns A dominant-seventh chord a fifth above the target's root.
203
- * @throws If `targetDegree` is not an integer in 0..6.
204
- * @category Functional Harmony
205
- */
206
- declare function secondaryDominant(targetDegree: number, key: KeyScale): Chord;
207
-
208
- export { type BorrowedSource as B, type Cadence as C, type HarmonicFunction as H, type ChordAnalysis as a, analyzeChord as b, borrowedSource as c, detectCadence as d, isDiatonic as e, functionOf as f, isMinorKey as g, isBorrowedChord as i, parallelKey as p, secondaryDominant as s };
@@ -1,143 +0,0 @@
1
- import { K as KeyScale } from './types-BN6_Q9Kl.js';
2
- import { C as Chord } from './index-C83mZI1P.js';
3
-
4
- /**
5
- * Severity policy: `strict` counterpoint vs. lenient `pop` voice-leading.
6
- *
7
- * @category Arrangement & Analysis
8
- */
9
- type SafetyProfile = 'strict' | 'pop';
10
- /**
11
- * Overall placeability verdict for a candidate pitch.
12
- *
13
- * @category Arrangement & Analysis
14
- */
15
- declare enum NoteSafety {
16
- Safe = 0,
17
- Warning = 1,
18
- Dissonant = 2
19
- }
20
- /**
21
- * Bit flags describing why a pitch received its verdict.
22
- *
23
- * @category Arrangement & Analysis
24
- */
25
- declare enum ReasonFlag {
26
- ChordTone = 1,
27
- Tension = 2,
28
- AvoidNote = 4,
29
- ScaleTone = 8,
30
- NonScale = 16,
31
- OutOfRange = 32,
32
- Tritone = 64,
33
- LargeLeap = 128,
34
- MinorSecond = 256,
35
- MajorSeventh = 512,
36
- VerticalDissonance = 1024,
37
- ParallelPerfect = 2048,
38
- HiddenParallel = 4096,
39
- VoiceCrossing = 8192,
40
- Suspension = 16384,
41
- NeedsResolution = 32768
42
- }
43
- /**
44
- * A neighbouring voice's current and previous pitch.
45
- *
46
- * @category Arrangement & Analysis
47
- */
48
- type VoiceSnapshot = {
49
- pitch: number;
50
- prevPitch?: number;
51
- };
52
- /**
53
- * Everything needed to evaluate one candidate pitch.
54
- *
55
- * @category Arrangement & Analysis
56
- */
57
- type SafetyQuery = {
58
- profile: SafetyProfile;
59
- candidatePitch: number;
60
- prevPitch?: number;
61
- chord: Chord | null;
62
- key: KeyScale;
63
- otherVoices: VoiceSnapshot[];
64
- strongBeat: boolean;
65
- vocalLow?: number;
66
- vocalHigh?: number;
67
- };
68
- /**
69
- * The verdict, reason flags, and optional resolution guidance.
70
- *
71
- * @category Arrangement & Analysis
72
- */
73
- type SafetyResult = {
74
- safety: NoteSafety;
75
- reasons: number;
76
- resolveTo?: number;
77
- suggestions?: number[];
78
- rationale?: string;
79
- };
80
- /**
81
- * Evaluate the safety of placing a candidate pitch in a voice.
82
- *
83
- * Reasons are merged from harmonic context (chord tone / tension / avoid / scale)
84
- * and counterpoint (vertical dissonance, parallels, voice crossing). The `strict`
85
- * profile treats avoid notes and parallels as dissonant; `pop` treats them as
86
- * warnings. The final verdict is the worst severity among the reasons.
87
- *
88
- * @param q The candidate and its harmonic/voice-leading context.
89
- * @returns The verdict, reason bitmask, and optional resolution guidance.
90
- * @example
91
- * ```ts
92
- * import { evaluateSafety, makeChord, majorKey, NoteSafety } from '@libraz/libcantus';
93
- * const result = evaluateSafety({
94
- * profile: 'pop',
95
- * candidatePitch: 60, // C over a C major chord
96
- * chord: makeChord(0, 'maj'),
97
- * key: majorKey(0),
98
- * otherVoices: [],
99
- * strongBeat: true,
100
- * });
101
- * result.safety === NoteSafety.Safe; // true — C is a chord tone
102
- * ```
103
- * @category Arrangement & Analysis
104
- */
105
- declare function evaluateSafety(q: SafetyQuery, opts?: EvaluateSafetyOptions): SafetyResult;
106
- /**
107
- * Options for {@link evaluateSafety}.
108
- *
109
- * @category Arrangement & Analysis
110
- */
111
- type EvaluateSafetyOptions = {
112
- /**
113
- * Whether to search for safe replacement pitches when the verdict is not
114
- * safe. Turning it off skips up to two dozen extra evaluations per rejected
115
- * pitch, which is worth doing when only the verdict is wanted.
116
- *
117
- * @defaultValue true
118
- */
119
- suggestions?: boolean;
120
- };
121
- /**
122
- * Enumerate placeable pitches in a range, chord tones first, descending.
123
- *
124
- * @param q The safety context minus the candidate pitch.
125
- * @param pitchLow Lowest MIDI pitch to consider (inclusive).
126
- * @param pitchHigh Highest MIDI pitch to consider (inclusive).
127
- * @returns Placeable pitches (non-dissonant), chord tones before others, each group descending.
128
- * @throws If either bound is non-finite/non-integral, reversed, or exceeds the generation budget.
129
- * @example
130
- * ```ts
131
- * import { enumerateSafePitches, makeChord, majorKey } from '@libraz/libcantus';
132
- * const pitches = enumerateSafePitches(
133
- * { profile: 'pop', chord: makeChord(0, 'maj'), key: majorKey(0), otherVoices: [], strongBeat: true },
134
- * 60,
135
- * 72,
136
- * );
137
- * pitches; // placeable pitches in [60, 72], chord tones first, each group descending
138
- * ```
139
- * @category Arrangement & Analysis
140
- */
141
- declare function enumerateSafePitches(q: Omit<SafetyQuery, 'candidatePitch'>, pitchLow: number, pitchHigh: number): number[];
142
-
143
- export { type EvaluateSafetyOptions as E, NoteSafety as N, ReasonFlag as R, type SafetyProfile as S, type VoiceSnapshot as V, type SafetyQuery as a, type SafetyResult as b, evaluateSafety as c, enumerateSafePitches as e };