@libraz/libcantus 0.9.1 → 0.9.2
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 +15 -0
- package/dist/analyze/index.cjs +1697 -0
- package/dist/analyze/index.cjs.map +1 -0
- package/dist/analyze/index.d.cts +429 -0
- package/dist/analyze/index.d.ts +429 -0
- package/dist/analyze/index.js +51 -0
- package/dist/analyze/index.js.map +1 -0
- package/dist/chunk-5HTNMQW4.js +653 -0
- package/dist/chunk-5HTNMQW4.js.map +1 -0
- package/dist/chunk-7Y7WF64D.js +410 -0
- package/dist/chunk-7Y7WF64D.js.map +1 -0
- package/dist/chunk-A4532ZFR.js +259 -0
- package/dist/chunk-A4532ZFR.js.map +1 -0
- package/dist/chunk-BHUT2S5G.js +22 -0
- package/dist/chunk-BHUT2S5G.js.map +1 -0
- package/dist/chunk-CCBLVAPK.js +42 -0
- package/dist/chunk-CCBLVAPK.js.map +1 -0
- package/dist/chunk-COKTX2G5.js +907 -0
- package/dist/chunk-COKTX2G5.js.map +1 -0
- package/dist/chunk-DYWFNC4A.js +152 -0
- package/dist/chunk-DYWFNC4A.js.map +1 -0
- package/dist/chunk-GQKN5KDT.js +159 -0
- package/dist/chunk-GQKN5KDT.js.map +1 -0
- package/dist/chunk-LN7ZZMD2.js +530 -0
- package/dist/chunk-LN7ZZMD2.js.map +1 -0
- package/dist/chunk-MSWFZF7J.js +118 -0
- package/dist/chunk-MSWFZF7J.js.map +1 -0
- package/dist/chunk-R3S2LUBH.js +2722 -0
- package/dist/chunk-R3S2LUBH.js.map +1 -0
- package/dist/chunk-SDM3VJJ5.js +41 -0
- package/dist/chunk-SDM3VJJ5.js.map +1 -0
- package/dist/chunk-XTC3X6MS.js +816 -0
- package/dist/chunk-XTC3X6MS.js.map +1 -0
- package/dist/chunk-ZXW5YIWK.js +55 -0
- package/dist/chunk-ZXW5YIWK.js.map +1 -0
- package/dist/core/index.cjs +432 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +210 -0
- package/dist/core/index.d.ts +210 -0
- package/dist/core/index.js +73 -0
- package/dist/core/index.js.map +1 -0
- package/dist/function-2bJW1Zp_.d.ts +187 -0
- package/dist/function-r2sh-jOO.d.cts +187 -0
- package/dist/generate/index.cjs +3787 -0
- package/dist/generate/index.cjs.map +1 -0
- package/dist/generate/index.d.cts +980 -0
- package/dist/generate/index.d.ts +980 -0
- package/dist/generate/index.js +52 -0
- package/dist/generate/index.js.map +1 -0
- package/dist/index-BMPxwjwV.d.ts +151 -0
- package/dist/index-BOBXBNwP.d.cts +157 -0
- package/dist/index-BdeQ1r_p.d.cts +56 -0
- package/dist/index-BreoJRw0.d.ts +127 -0
- package/dist/index-CGMZNCx6.d.cts +140 -0
- package/dist/index-CGMZNCx6.d.ts +140 -0
- package/dist/index-CM5W4rcm.d.ts +157 -0
- package/dist/index-CP3wAfEH.d.ts +56 -0
- package/dist/index-Cl7mhOFM.d.cts +164 -0
- package/dist/index-Cl7mhOFM.d.ts +164 -0
- package/dist/index-DZ1M21do.d.cts +127 -0
- package/dist/index-D_ZTUNKp.d.cts +151 -0
- package/dist/index.cjs +3016 -2984
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -3982
- package/dist/index.d.ts +14 -3982
- package/dist/index.js +170 -6504
- package/dist/index.js.map +1 -1
- package/dist/model/index.cjs +2435 -0
- package/dist/model/index.cjs.map +1 -0
- package/dist/model/index.d.cts +630 -0
- package/dist/model/index.d.ts +630 -0
- package/dist/model/index.js +21 -0
- package/dist/model/index.js.map +1 -0
- package/dist/styled-BjXtOFNk.d.cts +282 -0
- package/dist/styled-D7BAx3S3.d.ts +282 -0
- package/dist/theory/index.cjs +1677 -0
- package/dist/theory/index.cjs.map +1 -0
- package/dist/theory/index.d.cts +535 -0
- package/dist/theory/index.d.ts +535 -0
- package/dist/theory/index.js +149 -0
- package/dist/theory/index.js.map +1 -0
- package/dist/types-MGP29r3t.d.cts +30 -0
- package/dist/types-MGP29r3t.d.ts +30 -0
- package/package.json +27 -2
- package/src/analyze/arrange/index.ts +21 -0
- package/src/analyze/arrange/internal.ts +125 -0
- package/src/analyze/arrange/tension.ts +187 -0
- package/src/analyze/arrange/tracks.ts +279 -0
- package/src/{detect → analyze/detect}/index.ts +4 -4
- package/src/analyze/functional/borrowed.ts +84 -0
- package/src/analyze/functional/cadence.ts +66 -0
- package/src/analyze/functional/function.ts +184 -0
- package/src/analyze/functional/index.ts +23 -0
- package/src/analyze/functional/internal.ts +29 -0
- package/src/{functional/index.ts → analyze/functional/roman.ts} +9 -327
- package/src/analyze/index.ts +49 -0
- package/src/{timeline → analyze/timeline}/index.ts +7 -11
- package/src/{analysis → analyze/voice}/index.ts +8 -5
- package/src/core/index.ts +47 -0
- package/src/{bass → generate/bass}/index.ts +5 -5
- package/src/{countermelody → generate/countermelody}/index.ts +11 -11
- package/src/{drums → generate/drums}/index.ts +2 -2
- package/src/{drums → generate/drums}/rng.ts +2 -2
- package/src/{groove → generate/groove}/index.ts +3 -3
- package/src/{harmonize → generate/harmonize}/index.ts +13 -13
- package/src/generate/index.ts +59 -0
- package/src/{motif → generate/motif}/index.ts +7 -7
- package/src/{progression → generate/progression}/index.ts +11 -25
- package/src/{reharmony → generate/reharmony}/index.ts +11 -11
- package/src/{rhythm → generate/rhythm}/index.ts +2 -2
- package/src/index.ts +130 -117
- package/src/model/chord.ts +423 -0
- package/src/model/index.ts +5 -1096
- package/src/model/interval.ts +82 -0
- package/src/model/key.ts +266 -0
- package/src/model/note.ts +176 -0
- package/src/model/progression.ts +161 -0
- package/src/model/shared.ts +12 -0
- package/src/{chord → theory/chord}/index.ts +19 -1
- package/src/{counterpoint → theory/counterpoint}/index.ts +2 -2
- package/src/theory/index.ts +107 -0
- package/src/{safety → theory/safety}/index.ts +1 -1
- package/src/theory/scale/degrees.ts +123 -0
- package/src/theory/scale/index.ts +28 -0
- package/src/theory/scale/key.ts +56 -0
- package/src/theory/scale/masks.ts +153 -0
- package/src/{spelling → theory/spelling}/index.ts +3 -3
- package/src/{symbol → theory/symbol}/index.ts +8 -1
- package/src/theory/voicing/index.ts +5 -0
- package/src/theory/voicing/internal.ts +168 -0
- package/src/theory/voicing/leading.ts +112 -0
- package/src/theory/voicing/satb.ts +195 -0
- package/src/theory/voicing/styled.ts +176 -0
- package/src/arrange/index.ts +0 -571
- package/src/scale/index.ts +0 -331
- package/src/voicing/index.ts +0 -623
- /package/src/{interval → core/interval}/index.ts +0 -0
- /package/src/{meter → core/meter}/index.ts +0 -0
- /package/src/{pitch → core/pitch}/index.ts +0 -0
- /package/src/{random → core/random}/index.ts +0 -0
- /package/src/{tuning → core/tuning}/index.ts +0 -0
- /package/src/{types.ts → core/types.ts} +0 -0
- /package/src/{drums → generate/drums}/beat.ts +0 -0
- /package/src/{drums → generate/drums}/euclid.ts +0 -0
- /package/src/{drums → generate/drums}/fills.ts +0 -0
- /package/src/{drums → generate/drums}/ghost.ts +0 -0
- /package/src/{drums → generate/drums}/hihat.ts +0 -0
- /package/src/{drums → generate/drums}/hit.ts +0 -0
- /package/src/{drums → generate/drums}/internal.ts +0 -0
- /package/src/{drums → generate/drums}/kick.ts +0 -0
- /package/src/{drums → generate/drums}/percussion.ts +0 -0
- /package/src/{drums → generate/drums}/swing.ts +0 -0
- /package/src/{chordscale → theory/chordscale}/index.ts +0 -0
- /package/src/{harmony → theory/harmony}/index.ts +0 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { K as KeyScale } from './types-MGP29r3t.js';
|
|
2
|
+
import { C as Chord } from './index-CM5W4rcm.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 = 'parallel-minor' | 'parallel-major' | '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, from its root's offset above the
|
|
111
|
+
* tonic. The mapping follows common-practice major-key function and is a useful
|
|
112
|
+
* approximation in minor and for borrowed chords.
|
|
113
|
+
*
|
|
114
|
+
* @param chord The chord.
|
|
115
|
+
* @param key The prevailing key.
|
|
116
|
+
* @returns The harmonic function.
|
|
117
|
+
* @category Functional Harmony
|
|
118
|
+
*/
|
|
119
|
+
declare function functionOf(chord: Chord, key: KeyScale): HarmonicFunction;
|
|
120
|
+
/**
|
|
121
|
+
* The result of {@link analyzeChord}: function, borrowing, and Roman numeral.
|
|
122
|
+
*
|
|
123
|
+
* @category Functional Harmony
|
|
124
|
+
*/
|
|
125
|
+
type ChordAnalysis = {
|
|
126
|
+
function: HarmonicFunction;
|
|
127
|
+
borrowed: boolean;
|
|
128
|
+
source: BorrowedSource;
|
|
129
|
+
roman: string;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Whether every pitch class of a chord belongs to the key's scale.
|
|
133
|
+
*
|
|
134
|
+
* The test is strict against the key's own mode mask: in a natural-minor key
|
|
135
|
+
* the harmonic-minor dominant (major V) is *not* diatonic, since the raised
|
|
136
|
+
* leading tone lies outside the mask. Borrowing predicates treat that case as
|
|
137
|
+
* an in-key alteration separately (see {@link isBorrowedChord}).
|
|
138
|
+
*
|
|
139
|
+
* @param chord The chord to test.
|
|
140
|
+
* @param key The prevailing key.
|
|
141
|
+
* @returns True if all chord pitch classes are scale tones.
|
|
142
|
+
* @category Functional Harmony
|
|
143
|
+
*/
|
|
144
|
+
declare function isDiatonic(chord: Chord, key: KeyScale): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* The parallel key: same tonic, opposite mode.
|
|
147
|
+
*
|
|
148
|
+
* A key with a minor third (natural/harmonic/melodic minor, dorian, phrygian)
|
|
149
|
+
* maps to the parallel major; any other key maps to the parallel natural minor.
|
|
150
|
+
*
|
|
151
|
+
* @param key The key to mirror.
|
|
152
|
+
* @returns The parallel major or natural-minor key on the same tonic.
|
|
153
|
+
* @category Functional Harmony
|
|
154
|
+
*/
|
|
155
|
+
declare function parallelKey(key: KeyScale): KeyScale;
|
|
156
|
+
/**
|
|
157
|
+
* Analyze a chord in a key: harmonic function, borrowing, and Roman numeral.
|
|
158
|
+
*
|
|
159
|
+
* The function is quality-aware (see the predicates behind it), the source
|
|
160
|
+
* follows {@link borrowedSource}, and the numeral comes from
|
|
161
|
+
* {@link chordToRoman}. `borrowed` is true whenever a source is identified —
|
|
162
|
+
* including the Neapolitan, which the stricter parallel-mode predicate
|
|
163
|
+
* {@link isBorrowedChord} does not count.
|
|
164
|
+
*
|
|
165
|
+
* @param chord The chord to analyze.
|
|
166
|
+
* @param key The prevailing key.
|
|
167
|
+
* @returns The chord analysis.
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* import { analyzeChord, makeChord, majorKey } from '@libraz/libcantus';
|
|
171
|
+
* analyzeChord(makeChord(7, 'dom7'), majorKey(0));
|
|
172
|
+
* // { function: 'dominant', borrowed: false, source: null, roman: 'V7' }
|
|
173
|
+
* ```
|
|
174
|
+
* @category Functional Harmony
|
|
175
|
+
*/
|
|
176
|
+
declare function analyzeChord(chord: Chord, key: KeyScale): ChordAnalysis;
|
|
177
|
+
/**
|
|
178
|
+
* The secondary dominant (V7) that tonicizes a scale degree.
|
|
179
|
+
*
|
|
180
|
+
* @param targetDegree 0-based scale degree to tonicize.
|
|
181
|
+
* @param key The prevailing key.
|
|
182
|
+
* @returns A dominant-seventh chord a fifth above the target's root.
|
|
183
|
+
* @category Functional Harmony
|
|
184
|
+
*/
|
|
185
|
+
declare function secondaryDominant(targetDegree: number, key: KeyScale): Chord;
|
|
186
|
+
|
|
187
|
+
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 };
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { K as KeyScale } from './types-MGP29r3t.cjs';
|
|
2
|
+
import { C as Chord } from './index-BOBXBNwP.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 = 'parallel-minor' | 'parallel-major' | '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, from its root's offset above the
|
|
111
|
+
* tonic. The mapping follows common-practice major-key function and is a useful
|
|
112
|
+
* approximation in minor and for borrowed chords.
|
|
113
|
+
*
|
|
114
|
+
* @param chord The chord.
|
|
115
|
+
* @param key The prevailing key.
|
|
116
|
+
* @returns The harmonic function.
|
|
117
|
+
* @category Functional Harmony
|
|
118
|
+
*/
|
|
119
|
+
declare function functionOf(chord: Chord, key: KeyScale): HarmonicFunction;
|
|
120
|
+
/**
|
|
121
|
+
* The result of {@link analyzeChord}: function, borrowing, and Roman numeral.
|
|
122
|
+
*
|
|
123
|
+
* @category Functional Harmony
|
|
124
|
+
*/
|
|
125
|
+
type ChordAnalysis = {
|
|
126
|
+
function: HarmonicFunction;
|
|
127
|
+
borrowed: boolean;
|
|
128
|
+
source: BorrowedSource;
|
|
129
|
+
roman: string;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Whether every pitch class of a chord belongs to the key's scale.
|
|
133
|
+
*
|
|
134
|
+
* The test is strict against the key's own mode mask: in a natural-minor key
|
|
135
|
+
* the harmonic-minor dominant (major V) is *not* diatonic, since the raised
|
|
136
|
+
* leading tone lies outside the mask. Borrowing predicates treat that case as
|
|
137
|
+
* an in-key alteration separately (see {@link isBorrowedChord}).
|
|
138
|
+
*
|
|
139
|
+
* @param chord The chord to test.
|
|
140
|
+
* @param key The prevailing key.
|
|
141
|
+
* @returns True if all chord pitch classes are scale tones.
|
|
142
|
+
* @category Functional Harmony
|
|
143
|
+
*/
|
|
144
|
+
declare function isDiatonic(chord: Chord, key: KeyScale): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* The parallel key: same tonic, opposite mode.
|
|
147
|
+
*
|
|
148
|
+
* A key with a minor third (natural/harmonic/melodic minor, dorian, phrygian)
|
|
149
|
+
* maps to the parallel major; any other key maps to the parallel natural minor.
|
|
150
|
+
*
|
|
151
|
+
* @param key The key to mirror.
|
|
152
|
+
* @returns The parallel major or natural-minor key on the same tonic.
|
|
153
|
+
* @category Functional Harmony
|
|
154
|
+
*/
|
|
155
|
+
declare function parallelKey(key: KeyScale): KeyScale;
|
|
156
|
+
/**
|
|
157
|
+
* Analyze a chord in a key: harmonic function, borrowing, and Roman numeral.
|
|
158
|
+
*
|
|
159
|
+
* The function is quality-aware (see the predicates behind it), the source
|
|
160
|
+
* follows {@link borrowedSource}, and the numeral comes from
|
|
161
|
+
* {@link chordToRoman}. `borrowed` is true whenever a source is identified —
|
|
162
|
+
* including the Neapolitan, which the stricter parallel-mode predicate
|
|
163
|
+
* {@link isBorrowedChord} does not count.
|
|
164
|
+
*
|
|
165
|
+
* @param chord The chord to analyze.
|
|
166
|
+
* @param key The prevailing key.
|
|
167
|
+
* @returns The chord analysis.
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* import { analyzeChord, makeChord, majorKey } from '@libraz/libcantus';
|
|
171
|
+
* analyzeChord(makeChord(7, 'dom7'), majorKey(0));
|
|
172
|
+
* // { function: 'dominant', borrowed: false, source: null, roman: 'V7' }
|
|
173
|
+
* ```
|
|
174
|
+
* @category Functional Harmony
|
|
175
|
+
*/
|
|
176
|
+
declare function analyzeChord(chord: Chord, key: KeyScale): ChordAnalysis;
|
|
177
|
+
/**
|
|
178
|
+
* The secondary dominant (V7) that tonicizes a scale degree.
|
|
179
|
+
*
|
|
180
|
+
* @param targetDegree 0-based scale degree to tonicize.
|
|
181
|
+
* @param key The prevailing key.
|
|
182
|
+
* @returns A dominant-seventh chord a fifth above the target's root.
|
|
183
|
+
* @category Functional Harmony
|
|
184
|
+
*/
|
|
185
|
+
declare function secondaryDominant(targetDegree: number, key: KeyScale): Chord;
|
|
186
|
+
|
|
187
|
+
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 };
|