@libraz/libcantus 0.9.0 → 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 +25 -2
- 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 +5277 -4893
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -2621
- package/dist/index.d.ts +14 -2621
- package/dist/index.js +170 -6152
- 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 +31 -1
- 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 +82 -23
- 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/analyze/functional/roman.ts +393 -0
- package/src/analyze/index.ts +49 -0
- package/src/{timeline → analyze/timeline}/index.ts +87 -24
- package/src/{analysis → analyze/voice}/index.ts +81 -12
- package/src/core/index.ts +47 -0
- package/src/{interval → core/interval}/index.ts +15 -1
- package/src/{meter → core/meter}/index.ts +108 -5
- package/src/{pitch → core/pitch}/index.ts +58 -3
- package/src/{random → core/random}/index.ts +13 -1
- package/src/{tuning → core/tuning}/index.ts +28 -1
- package/src/{bass → generate/bass}/index.ts +66 -17
- package/src/{countermelody → generate/countermelody}/index.ts +54 -24
- package/src/{drums → generate/drums}/fills.ts +31 -20
- package/src/{drums → generate/drums}/index.ts +127 -9
- package/src/{drums → generate/drums}/internal.ts +7 -1
- package/src/{drums → generate/drums}/rng.ts +2 -2
- package/src/{drums → generate/drums}/swing.ts +7 -2
- package/src/{groove → generate/groove}/index.ts +118 -22
- package/src/{harmonize → generate/harmonize}/index.ts +96 -23
- package/src/generate/index.ts +59 -0
- package/src/{motif → generate/motif}/index.ts +94 -17
- package/src/{progression → generate/progression}/index.ts +61 -27
- package/src/{reharmony → generate/reharmony}/index.ts +46 -15
- package/src/{rhythm → generate/rhythm}/index.ts +47 -13
- package/src/index.ts +130 -116
- package/src/model/chord.ts +423 -0
- package/src/model/index.ts +5 -947
- 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 +85 -4
- package/src/{chordscale → theory/chordscale}/index.ts +67 -9
- package/src/{counterpoint → theory/counterpoint}/index.ts +23 -2
- package/src/{harmony → theory/harmony}/index.ts +19 -2
- package/src/theory/index.ts +107 -0
- package/src/{safety → theory/safety}/index.ts +59 -12
- 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 +21 -3
- package/src/{symbol → theory/symbol}/index.ts +91 -36
- 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 -409
- package/src/functional/index.ts +0 -602
- package/src/scale/index.ts +0 -215
- package/src/voicing/index.ts +0 -523
- /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}/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}/kick.ts +0 -0
- /package/src/{drums → generate/drums}/percussion.ts +0 -0
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
import { C as Chord } from '../index-BOBXBNwP.cjs';
|
|
2
|
+
export { a as ChordQuality, c as chordFromDegree, d as chordPitchClasses, e as chordQualities, f as chordToneRole, g as diatonicSeventh, h as diatonicTriad, m as makeChord } from '../index-BOBXBNwP.cjs';
|
|
3
|
+
import { d as VoicingOptions } from '../styled-BjXtOFNk.cjs';
|
|
4
|
+
export { C as ChordScaleMatch, a as ChordScaleReportEntry, S as SATB_RANGES, b as ScaleChoice, c as StyledVoicingOptions, V as VoiceRange, e as VoicingStyle, f as availableTensions, g as avoidNotes, h as chordScaleReport, i as chordScales, s as scaleMatchesChord, j as scalesForChanges, v as voiceChord, k as voiceChordStyled, l as voiceProgression } from '../styled-BjXtOFNk.cjs';
|
|
5
|
+
import { K as KeyScale } from '../types-MGP29r3t.cjs';
|
|
6
|
+
export { H as HarmonyRole, L as LockLevel, V as VoicedRole, r as roleOf } from '../index-BdeQ1r_p.cjs';
|
|
7
|
+
export { N as NoteSafety, R as ReasonFlag, S as SafetyProfile, a as SafetyQuery, b as SafetyResult, V as VoiceSnapshot, e as enumerateSafePitches, c as evaluateSafety } from '../index-DZ1M21do.cjs';
|
|
8
|
+
import { N as Note } from '../index-CGMZNCx6.cjs';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Total voice-leading cost between two voicings: the sum of absolute semitone
|
|
12
|
+
* motion across voices, plus a moderate {@link HIDDEN_PERFECT_PENALTY} when the
|
|
13
|
+
* outer-voice (bass–soprano) pair reaches a hidden/direct perfect fifth or
|
|
14
|
+
* octave by similar motion. The arrays must be the same length; when they
|
|
15
|
+
* differ the voicings are not comparable and the cost is `Infinity`.
|
|
16
|
+
*
|
|
17
|
+
* @param from The previous voicing, one MIDI pitch per voice.
|
|
18
|
+
* @param to The next voicing, one MIDI pitch per voice.
|
|
19
|
+
* @returns The summed absolute motion (plus any hidden-perfect penalty), or
|
|
20
|
+
* `Infinity` when lengths differ.
|
|
21
|
+
* @category Voicing & Counterpoint
|
|
22
|
+
*/
|
|
23
|
+
declare function voiceLeadingCost(from: number[], to: number[]): number;
|
|
24
|
+
/**
|
|
25
|
+
* Voice a single chord to follow smoothly from an arbitrary current voicing.
|
|
26
|
+
*
|
|
27
|
+
* Candidate voicings of `chord` are enumerated within ranges taken from `opts`,
|
|
28
|
+
* or — when neither `voices` nor `ranges` is given — from a one-octave window
|
|
29
|
+
* around each pitch of `current` (so the result matches `current`'s voice
|
|
30
|
+
* count). Each candidate is scored by structural quality, voice-leading motion
|
|
31
|
+
* from `current`, and a large penalty per counterpoint violation; the lowest
|
|
32
|
+
* scoring candidate is returned, ascending.
|
|
33
|
+
*
|
|
34
|
+
* @param current The current voicing to lead from, ascending (index 0 = lowest).
|
|
35
|
+
* @param chord The next chord to voice.
|
|
36
|
+
* @param opts Voicing options; when omitted, ranges follow `current`'s span.
|
|
37
|
+
* @returns The chosen voicing, ascending with one MIDI pitch per voice.
|
|
38
|
+
* @throws If no voicing fits the derived ranges.
|
|
39
|
+
* @category Voicing & Counterpoint
|
|
40
|
+
*/
|
|
41
|
+
declare function nextVoicing(current: number[], chord: Chord, opts?: VoicingOptions): number[];
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Whether an upper voice has crossed below a lower voice.
|
|
45
|
+
*
|
|
46
|
+
* @param upperPitch Pitch of the nominally higher voice.
|
|
47
|
+
* @param lowerPitch Pitch of the nominally lower voice.
|
|
48
|
+
* @returns True when the upper voice sits below the lower voice.
|
|
49
|
+
* @category Voicing & Counterpoint
|
|
50
|
+
*/
|
|
51
|
+
declare function createsVoiceCrossing(upperPitch: number, lowerPitch: number): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Whether two simultaneous pitches form a dissonance.
|
|
54
|
+
*
|
|
55
|
+
* @param a First pitch.
|
|
56
|
+
* @param b Second pitch.
|
|
57
|
+
* @param twoVoice When true, the perfect fourth counts as dissonant.
|
|
58
|
+
* @returns True when the vertical interval is dissonant.
|
|
59
|
+
* @category Voicing & Counterpoint
|
|
60
|
+
*/
|
|
61
|
+
declare function createsVerticalDissonance(a: number, b: number, twoVoice: boolean): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Whether a melodic move is a forbidden leap: a tritone, either seventh (minor
|
|
64
|
+
* or major), or any leap wider than an octave.
|
|
65
|
+
*
|
|
66
|
+
* Operates on the raw absolute distance, so compound leaps are not reduced to
|
|
67
|
+
* their simple class before the octave check.
|
|
68
|
+
*
|
|
69
|
+
* @param prev Starting pitch.
|
|
70
|
+
* @param cur Ending pitch.
|
|
71
|
+
* @returns True when the leap is forbidden in strict counterpoint.
|
|
72
|
+
* @category Voicing & Counterpoint
|
|
73
|
+
*/
|
|
74
|
+
declare function isForbiddenMelodicLeap(prev: number, cur: number): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Whether two voices move into consecutive perfect intervals of the same kind
|
|
77
|
+
* (fifth-to-fifth, octave-to-octave, unison-to-unison).
|
|
78
|
+
*
|
|
79
|
+
* Both true parallels (similar motion) and anti-parallels — the same perfect
|
|
80
|
+
* class reached by contrary motion, e.g. octave to octave with the voices moving
|
|
81
|
+
* in opposite directions — are flagged, as both are forbidden in strict two-voice
|
|
82
|
+
* counterpoint. The rule requires that both voices actually move: oblique motion
|
|
83
|
+
* (either voice stationary) and the no-change case (identical pitches) are excluded.
|
|
84
|
+
*
|
|
85
|
+
* A fifth expanding to a twelfth counts (same perfect class); a fifth moving to
|
|
86
|
+
* an octave does not (different perfect kinds — the direct/hidden case owned by
|
|
87
|
+
* {@link createsHiddenParallelPerfect}).
|
|
88
|
+
*
|
|
89
|
+
* @category Voicing & Counterpoint
|
|
90
|
+
*/
|
|
91
|
+
declare function createsParallelPerfect(aPrev: number, aCur: number, bPrev: number, bCur: number): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Whether two voices move in consecutive parallel octaves (or unisons) by
|
|
94
|
+
* similar motion.
|
|
95
|
+
*
|
|
96
|
+
* This is a strict subset of {@link createsParallelPerfect}: a similar-motion
|
|
97
|
+
* octave-to-octave is the perfect-class-zero case that predicate already flags
|
|
98
|
+
* (and it additionally catches the contrary-motion anti-parallel). Callers that
|
|
99
|
+
* tally parallel violations should therefore use {@link createsParallelPerfect}
|
|
100
|
+
* alone to avoid double counting; this predicate remains for callers wanting a
|
|
101
|
+
* dedicated similar-motion octave test.
|
|
102
|
+
*
|
|
103
|
+
* @category Voicing & Counterpoint
|
|
104
|
+
*/
|
|
105
|
+
declare function createsParallelOctave(aPrev: number, aCur: number, bPrev: number, bCur: number): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Whether two voices move in consecutive parallel unisons — both landing on the
|
|
108
|
+
* same pitch, having shared a pitch on the previous move.
|
|
109
|
+
*
|
|
110
|
+
* @category Voicing & Counterpoint
|
|
111
|
+
*/
|
|
112
|
+
declare function createsParallelUnison(aPrev: number, aCur: number, bPrev: number, bCur: number): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Whether two voices reach a perfect interval by similar motion from an
|
|
115
|
+
* imperfect one (a hidden/direct fifth or octave).
|
|
116
|
+
*
|
|
117
|
+
* The traditional step exception is applied: the approach is allowed when the
|
|
118
|
+
* upper of the two voices moves by step, so only leaps into the perfect
|
|
119
|
+
* interval are flagged.
|
|
120
|
+
*
|
|
121
|
+
* @category Voicing & Counterpoint
|
|
122
|
+
*/
|
|
123
|
+
declare function createsHiddenParallelPerfect(aPrev: number, aCur: number, bPrev: number, bCur: number): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Whether two voices overlap: the upper voice descends below where the lower
|
|
126
|
+
* voice just was, or the lower voice rises above where the upper voice just was.
|
|
127
|
+
* Distinct from a simultaneous voice crossing.
|
|
128
|
+
*
|
|
129
|
+
* @param upperPrev Previous pitch of the upper voice.
|
|
130
|
+
* @param upperCur Current pitch of the upper voice.
|
|
131
|
+
* @param lowerPrev Previous pitch of the lower voice.
|
|
132
|
+
* @param lowerCur Current pitch of the lower voice.
|
|
133
|
+
* @category Voicing & Counterpoint
|
|
134
|
+
*/
|
|
135
|
+
declare function createsVoiceOverlap(upperPrev: number, upperCur: number, lowerPrev: number, lowerCur: number): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Whether two adjacent upper voices are spaced more than a maximum apart
|
|
138
|
+
* (commonly an octave). Bass-to-tenor spacing is conventionally exempt, so this
|
|
139
|
+
* is meant for the upper voice pairs.
|
|
140
|
+
*
|
|
141
|
+
* @param upperPitch Pitch of the higher voice.
|
|
142
|
+
* @param lowerPitch Pitch of the lower voice.
|
|
143
|
+
* @param maxSemitones Maximum allowed spacing in semitones (default an octave).
|
|
144
|
+
* @category Voicing & Counterpoint
|
|
145
|
+
*/
|
|
146
|
+
declare function exceedsSpacing(upperPitch: number, lowerPitch: number, maxSemitones?: number): boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Whether a leading tone resolves correctly upward to the tonic.
|
|
149
|
+
*
|
|
150
|
+
* @param prev The leading-tone pitch.
|
|
151
|
+
* @param cur The following pitch.
|
|
152
|
+
* @param key Key context supplying the tonic.
|
|
153
|
+
* @returns True when `prev` is the leading tone and `cur` is the tonic a step above.
|
|
154
|
+
* @category Voicing & Counterpoint
|
|
155
|
+
*/
|
|
156
|
+
declare function isLeadingToneResolution(prev: number, cur: number, key: KeyScale): boolean;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Test whether a pitch belongs to the scale.
|
|
160
|
+
*
|
|
161
|
+
* @param pitch MIDI pitch or bare pitch class.
|
|
162
|
+
* @param key The key/scale to test against.
|
|
163
|
+
* @returns True if the pitch class is a member of the scale.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```ts
|
|
167
|
+
* import { majorKey, isScaleTone } from '@libraz/libcantus';
|
|
168
|
+
* const key = majorKey(0); // C major
|
|
169
|
+
* isScaleTone(64, key); // true — E is in C major
|
|
170
|
+
* isScaleTone(61, key); // false — C# is not
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* @category Scales
|
|
174
|
+
*/
|
|
175
|
+
declare function isScaleTone(pitch: number, key: KeyScale): boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Find the nearest MIDI pitch whose pitch class is in the scale.
|
|
178
|
+
*
|
|
179
|
+
* The search expands symmetrically outward from `pitch`. On a tie (equal
|
|
180
|
+
* distance above and below) the lower pitch is returned.
|
|
181
|
+
*
|
|
182
|
+
* @param pitch MIDI pitch to snap.
|
|
183
|
+
* @param key The key/scale to snap to.
|
|
184
|
+
* @returns The nearest in-scale MIDI pitch.
|
|
185
|
+
*
|
|
186
|
+
* @category Scales
|
|
187
|
+
*/
|
|
188
|
+
declare function nearestScaleTone(pitch: number, key: KeyScale): number;
|
|
189
|
+
/**
|
|
190
|
+
* Get the 0-based scale degree of a pitch.
|
|
191
|
+
*
|
|
192
|
+
* @param pitch MIDI pitch or bare pitch class.
|
|
193
|
+
* @param key The key/scale to measure against.
|
|
194
|
+
* @returns The 0-based degree, or -1 if the pitch is not in the scale.
|
|
195
|
+
*
|
|
196
|
+
* @category Scales
|
|
197
|
+
*/
|
|
198
|
+
declare function pitchToScaleDegree(pitch: number, key: KeyScale): number;
|
|
199
|
+
/**
|
|
200
|
+
* List the pitch classes of a key's scale.
|
|
201
|
+
*
|
|
202
|
+
* @param key The key/scale to enumerate.
|
|
203
|
+
* @returns The member pitch classes, sorted ascending in [0, 11].
|
|
204
|
+
*
|
|
205
|
+
* @category Scales
|
|
206
|
+
*/
|
|
207
|
+
declare function diatonicPitchClasses(key: KeyScale): number[];
|
|
208
|
+
/**
|
|
209
|
+
* List the pitch classes of a key's scale in ascending scale-degree order.
|
|
210
|
+
*
|
|
211
|
+
* Degree 0 is the root; degrees follow the mask bits in offset order rather
|
|
212
|
+
* than sorted pitch-class order.
|
|
213
|
+
*
|
|
214
|
+
* @param key The key/scale to enumerate.
|
|
215
|
+
* @returns The member pitch classes ordered by scale degree.
|
|
216
|
+
*
|
|
217
|
+
* @category Scales
|
|
218
|
+
*/
|
|
219
|
+
declare function scaleTonesInDegreeOrder(key: KeyScale): number[];
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Build a `KeyScale` for a major key on the given root pitch class.
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```ts
|
|
226
|
+
* import { majorKey } from '@libraz/libcantus';
|
|
227
|
+
* const cMajor = majorKey(0); // C major: { rootPc: 0, modeMask12: MAJOR_MASK }
|
|
228
|
+
* ```
|
|
229
|
+
*
|
|
230
|
+
* @category Scales
|
|
231
|
+
*/
|
|
232
|
+
declare function majorKey(rootPc: number): KeyScale;
|
|
233
|
+
/**
|
|
234
|
+
* Build a `KeyScale` for a natural-minor key on the given root pitch class.
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```ts
|
|
238
|
+
* import { minorKey } from '@libraz/libcantus';
|
|
239
|
+
* const aMinor = minorKey(9); // A natural minor: { rootPc: 9, modeMask12: NATURAL_MINOR_MASK }
|
|
240
|
+
* ```
|
|
241
|
+
*
|
|
242
|
+
* @category Scales
|
|
243
|
+
*/
|
|
244
|
+
declare function minorKey(rootPc: number): KeyScale;
|
|
245
|
+
/**
|
|
246
|
+
* Build a `KeyScale` from a named scale (see {@link NAMED_SCALES}).
|
|
247
|
+
*
|
|
248
|
+
* @param name The scale name, e.g. `'dorian'` or `'harmonicMinor'`.
|
|
249
|
+
* @param rootPc The root pitch class.
|
|
250
|
+
* @returns The key/scale.
|
|
251
|
+
* @throws If the name is not a known scale.
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```ts
|
|
255
|
+
* import { scaleByName } from '@libraz/libcantus';
|
|
256
|
+
* const dDorian = scaleByName('dorian', 2); // D Dorian, rootPc 2
|
|
257
|
+
* ```
|
|
258
|
+
*
|
|
259
|
+
* @category Scales
|
|
260
|
+
*/
|
|
261
|
+
declare function scaleByName(name: string, rootPc: number): KeyScale;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Build a 12-bit mode mask from a list of semitone offsets above the root.
|
|
265
|
+
*
|
|
266
|
+
* Bit 0 (the root) is always set, enforcing the `KeyScale` invariant that the
|
|
267
|
+
* root is a scale tone even when the offset list omits 0.
|
|
268
|
+
*
|
|
269
|
+
* @category Scales
|
|
270
|
+
*/
|
|
271
|
+
declare function maskFromOffsets(offsets: readonly number[]): number;
|
|
272
|
+
/**
|
|
273
|
+
* Mode mask for the major (Ionian) scale: offsets {0, 2, 4, 5, 7, 9, 11}.
|
|
274
|
+
*
|
|
275
|
+
* @category Scales
|
|
276
|
+
*/
|
|
277
|
+
declare const MAJOR_MASK = 2741;
|
|
278
|
+
/**
|
|
279
|
+
* Mode mask for the natural minor (Aeolian) scale: offsets {0, 2, 3, 5, 7, 8, 10}.
|
|
280
|
+
*
|
|
281
|
+
* @category Scales
|
|
282
|
+
*/
|
|
283
|
+
declare const NATURAL_MINOR_MASK = 1453;
|
|
284
|
+
/**
|
|
285
|
+
* Harmonic minor: natural minor with a raised seventh — offsets {0,2,3,5,7,8,11}.
|
|
286
|
+
*
|
|
287
|
+
* @category Scales
|
|
288
|
+
*/
|
|
289
|
+
declare const HARMONIC_MINOR_MASK: number;
|
|
290
|
+
/**
|
|
291
|
+
* Ascending melodic minor: offsets {0,2,3,5,7,9,11}.
|
|
292
|
+
*
|
|
293
|
+
* @category Scales
|
|
294
|
+
*/
|
|
295
|
+
declare const MELODIC_MINOR_MASK: number;
|
|
296
|
+
/**
|
|
297
|
+
* Dorian mode: offsets {0,2,3,5,7,9,10}.
|
|
298
|
+
*
|
|
299
|
+
* @category Scales
|
|
300
|
+
*/
|
|
301
|
+
declare const DORIAN_MASK: number;
|
|
302
|
+
/**
|
|
303
|
+
* Phrygian mode: offsets {0,1,3,5,7,8,10}.
|
|
304
|
+
*
|
|
305
|
+
* @category Scales
|
|
306
|
+
*/
|
|
307
|
+
declare const PHRYGIAN_MASK: number;
|
|
308
|
+
/**
|
|
309
|
+
* Lydian mode: offsets {0,2,4,6,7,9,11}.
|
|
310
|
+
*
|
|
311
|
+
* @category Scales
|
|
312
|
+
*/
|
|
313
|
+
declare const LYDIAN_MASK: number;
|
|
314
|
+
/**
|
|
315
|
+
* Mixolydian mode: offsets {0,2,4,5,7,9,10}.
|
|
316
|
+
*
|
|
317
|
+
* @category Scales
|
|
318
|
+
*/
|
|
319
|
+
declare const MIXOLYDIAN_MASK: number;
|
|
320
|
+
/**
|
|
321
|
+
* Locrian mode: offsets {0,1,3,5,6,8,10}.
|
|
322
|
+
*
|
|
323
|
+
* @category Scales
|
|
324
|
+
*/
|
|
325
|
+
declare const LOCRIAN_MASK: number;
|
|
326
|
+
/**
|
|
327
|
+
* Major pentatonic: offsets {0,2,4,7,9}.
|
|
328
|
+
*
|
|
329
|
+
* @category Scales
|
|
330
|
+
*/
|
|
331
|
+
declare const MAJOR_PENTATONIC_MASK: number;
|
|
332
|
+
/**
|
|
333
|
+
* Minor pentatonic: offsets {0,3,5,7,10}.
|
|
334
|
+
*
|
|
335
|
+
* @category Scales
|
|
336
|
+
*/
|
|
337
|
+
declare const MINOR_PENTATONIC_MASK: number;
|
|
338
|
+
/**
|
|
339
|
+
* Hexatonic blues scale: minor pentatonic plus the flat-fifth — {0,3,5,6,7,10}.
|
|
340
|
+
*
|
|
341
|
+
* @category Scales
|
|
342
|
+
*/
|
|
343
|
+
declare const BLUES_MASK: number;
|
|
344
|
+
/**
|
|
345
|
+
* Whole-tone scale: offsets {0,2,4,6,8,10}.
|
|
346
|
+
*
|
|
347
|
+
* @category Scales
|
|
348
|
+
*/
|
|
349
|
+
declare const WHOLE_TONE_MASK: number;
|
|
350
|
+
/**
|
|
351
|
+
* Octatonic (half-step first): offsets {0,1,3,4,6,7,9,10}.
|
|
352
|
+
*
|
|
353
|
+
* @category Scales
|
|
354
|
+
*/
|
|
355
|
+
declare const OCTATONIC_HALF_WHOLE_MASK: number;
|
|
356
|
+
/**
|
|
357
|
+
* Octatonic (whole-step first): offsets {0,2,3,5,6,8,9,11}.
|
|
358
|
+
*
|
|
359
|
+
* @category Scales
|
|
360
|
+
*/
|
|
361
|
+
declare const OCTATONIC_WHOLE_HALF_MASK: number;
|
|
362
|
+
/**
|
|
363
|
+
* Chromatic scale: all twelve pitch classes.
|
|
364
|
+
*
|
|
365
|
+
* @category Scales
|
|
366
|
+
*/
|
|
367
|
+
declare const CHROMATIC_MASK = 4095;
|
|
368
|
+
/**
|
|
369
|
+
* Named scale masks addressable by {@link scaleByName}.
|
|
370
|
+
*
|
|
371
|
+
* @category Scales
|
|
372
|
+
*/
|
|
373
|
+
declare const NAMED_SCALES: Record<string, number>;
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Spelling: derive letter-name notes for scales and chords from a spelled tonic.
|
|
377
|
+
*
|
|
378
|
+
* The theory core works in pitch classes, which cannot choose between (say) a
|
|
379
|
+
* G# and an Ab. Given a spelled tonic, this module assigns diatonic letters to
|
|
380
|
+
* scale degrees and chord tones so a C major scale spells as C D E F G A B and
|
|
381
|
+
* A harmonic minor spells its seventh as G#.
|
|
382
|
+
*/
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Spell a single pitch class relative to a spelled tonic and key.
|
|
386
|
+
*
|
|
387
|
+
* Diatonic pitch classes take the scale's letter for their degree; the common
|
|
388
|
+
* chromatic tones (b2, b3, #4, b6, b7) and a minor key's raised degrees (#6, #7)
|
|
389
|
+
* take their conventional, key-correct accidental spelling; anything else falls
|
|
390
|
+
* back to a sharp spelling of the nearest natural.
|
|
391
|
+
*
|
|
392
|
+
* @param pc The pitch class to spell.
|
|
393
|
+
* @param tonic The spelled tonic (its letter anchors the spelling).
|
|
394
|
+
* @param key The key/scale.
|
|
395
|
+
* @returns The spelled note (without octave).
|
|
396
|
+
* @category Pitch & Intervals
|
|
397
|
+
*/
|
|
398
|
+
declare function spellPitchClass(pc: number, tonic: Note, key: KeyScale): Note;
|
|
399
|
+
/**
|
|
400
|
+
* Spell every pitch class of a scale, in ascending scale-degree order.
|
|
401
|
+
*
|
|
402
|
+
* Correct for heptatonic scales (each degree gets the next letter). Non-standard
|
|
403
|
+
* scales are spelled tone-by-tone with a sharp preference.
|
|
404
|
+
*
|
|
405
|
+
* @param tonic The spelled tonic.
|
|
406
|
+
* @param key The key/scale.
|
|
407
|
+
* @returns Spelled notes, one per scale degree.
|
|
408
|
+
* @example
|
|
409
|
+
* ```ts
|
|
410
|
+
* import { spellScale, noteNames, parseNote, majorKey } from '@libraz/libcantus';
|
|
411
|
+
* noteNames(spellScale(parseNote('C'), majorKey(0)));
|
|
412
|
+
* // ['C', 'D', 'E', 'F', 'G', 'A', 'B']
|
|
413
|
+
* ```
|
|
414
|
+
* @category Pitch & Intervals
|
|
415
|
+
*/
|
|
416
|
+
declare function spellScale(tonic: Note, key: KeyScale): Note[];
|
|
417
|
+
/**
|
|
418
|
+
* Spell an arbitrary list of pitch classes relative to a key.
|
|
419
|
+
*
|
|
420
|
+
* @param pcs The pitch classes.
|
|
421
|
+
* @param tonic The spelled tonic.
|
|
422
|
+
* @param key The key/scale.
|
|
423
|
+
* @returns Spelled notes, in input order.
|
|
424
|
+
* @category Pitch & Intervals
|
|
425
|
+
*/
|
|
426
|
+
declare function spellPitchClasses(pcs: number[], tonic: Note, key: KeyScale): Note[];
|
|
427
|
+
/**
|
|
428
|
+
* Spell a chord's tones, in the chord's own (tertian) order, relative to a key.
|
|
429
|
+
*
|
|
430
|
+
* Diatonic chords spell exactly (e.g. G7 in C major -> G B D F). Chromatic chord
|
|
431
|
+
* tones take their conventional spelling; enharmonically ambiguous altered
|
|
432
|
+
* tensions may be spelled by the general convention rather than by chord
|
|
433
|
+
* function.
|
|
434
|
+
*
|
|
435
|
+
* @param chord The chord.
|
|
436
|
+
* @param tonic The spelled tonic of the key.
|
|
437
|
+
* @param key The key/scale.
|
|
438
|
+
* @returns Spelled chord tones, root first.
|
|
439
|
+
* @example
|
|
440
|
+
* ```ts
|
|
441
|
+
* import { spellChord, noteNames, parseNote, majorKey, makeChord } from '@libraz/libcantus';
|
|
442
|
+
* // G7 in C major
|
|
443
|
+
* noteNames(spellChord(makeChord(7, 'dom7'), parseNote('C'), majorKey(0)));
|
|
444
|
+
* // ['G', 'B', 'D', 'F']
|
|
445
|
+
* ```
|
|
446
|
+
* @category Pitch & Intervals
|
|
447
|
+
*/
|
|
448
|
+
declare function spellChord(chord: Chord, tonic: Note, key: KeyScale): Note[];
|
|
449
|
+
/**
|
|
450
|
+
* Convenience: render spelled notes as letter-name strings.
|
|
451
|
+
*
|
|
452
|
+
* @param notes The notes.
|
|
453
|
+
* @returns Their formatted names.
|
|
454
|
+
* @category Pitch & Intervals
|
|
455
|
+
*/
|
|
456
|
+
declare function noteNames(notes: Note[]): string[];
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Lead-sheet chord symbol parsing and formatting.
|
|
460
|
+
*
|
|
461
|
+
* Bridges the informal `<root><quality>[/<bass>]` notation musicians write
|
|
462
|
+
* (`Cmaj7`, `F#m7b5`, `Bb7`, `C/G`) and the library's structured {@link Chord}
|
|
463
|
+
* type, so callers can accept/emit plain text at the edges of the API.
|
|
464
|
+
*/
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Parse a lead-sheet chord symbol into a {@link Chord}.
|
|
468
|
+
*
|
|
469
|
+
* Accepts `<root><quality>[/<bass>]`, e.g. `Cmaj7`, `F#m7b5`, `Bb7`, `C/G`,
|
|
470
|
+
* `C6/9`, `C6/9/E`. Root and bass letters are case-insensitive, matching
|
|
471
|
+
* {@link parseNote}. A `/` is ambiguous between a slash bass and the `6/9`
|
|
472
|
+
* quality; the text splits at the last `/` whose right-hand side is a valid
|
|
473
|
+
* bare note preceded by a recognized quality, so `6/9` (with or without a
|
|
474
|
+
* further slash bass) parses as a quality.
|
|
475
|
+
*
|
|
476
|
+
* The parsed chord carries the root/bass spellings as enharmonic hints
|
|
477
|
+
* (`rootSpelling`/`bassSpelling`) so {@link formatChordSymbol} can reproduce
|
|
478
|
+
* flat spellings such as `Bbmaj7` instead of respelling them with sharps.
|
|
479
|
+
*
|
|
480
|
+
* @param text The chord symbol text.
|
|
481
|
+
* @returns The parsed chord.
|
|
482
|
+
* @throws If the root or quality is not recognized.
|
|
483
|
+
* @example
|
|
484
|
+
* ```ts
|
|
485
|
+
* import { parseChordSymbol, formatChordSymbol } from '@libraz/libcantus';
|
|
486
|
+
* const c = parseChordSymbol('Bbmaj7');
|
|
487
|
+
* formatChordSymbol(c); // 'Bbmaj7' — flat spelling is preserved on round-trip
|
|
488
|
+
* ```
|
|
489
|
+
* @category Chords
|
|
490
|
+
*/
|
|
491
|
+
declare function parseChordSymbol(text: string): Chord;
|
|
492
|
+
/**
|
|
493
|
+
* Format a {@link Chord} as a lead-sheet chord symbol.
|
|
494
|
+
*
|
|
495
|
+
* The inverse of {@link parseChordSymbol}: each quality maps to one canonical
|
|
496
|
+
* suffix spelling, and a slash bass is appended only when it differs from the
|
|
497
|
+
* root. When the chord carries `rootSpelling`/`bassSpelling` hints (as chords
|
|
498
|
+
* from {@link parseChordSymbol} do) and no explicit `flats` preference is
|
|
499
|
+
* given, the hints are reused so flat symbols round-trip unchanged.
|
|
500
|
+
*
|
|
501
|
+
* @param chord The chord to format.
|
|
502
|
+
* @param opts Formatting options.
|
|
503
|
+
* @param opts.flats Prefer flat spellings over sharps for altered roots/basses;
|
|
504
|
+
* passing either `true` or `false` overrides any spelling hints.
|
|
505
|
+
* @returns The chord symbol text.
|
|
506
|
+
* @example
|
|
507
|
+
* ```ts
|
|
508
|
+
* import { makeChord, formatChordSymbol } from '@libraz/libcantus';
|
|
509
|
+
* formatChordSymbol(makeChord(0, 'min7')); // 'Cm7'
|
|
510
|
+
* ```
|
|
511
|
+
* @category Chords
|
|
512
|
+
*/
|
|
513
|
+
declare function formatChordSymbol(chord: Chord, opts?: {
|
|
514
|
+
flats?: boolean;
|
|
515
|
+
}): string;
|
|
516
|
+
/**
|
|
517
|
+
* Transpose a chord symbol by a number of semitones.
|
|
518
|
+
*
|
|
519
|
+
* @param text The chord symbol text.
|
|
520
|
+
* @param semitones Signed semitone offset to apply to the root and bass.
|
|
521
|
+
* @param opts Formatting options for the result; see {@link formatChordSymbol}.
|
|
522
|
+
* @returns The transposed chord symbol text.
|
|
523
|
+
* @throws If `text` does not parse as a chord symbol.
|
|
524
|
+
* @example
|
|
525
|
+
* ```ts
|
|
526
|
+
* import { transposeChordSymbol } from '@libraz/libcantus';
|
|
527
|
+
* transposeChordSymbol('C/G', 2); // 'D/A'
|
|
528
|
+
* ```
|
|
529
|
+
* @category Chords
|
|
530
|
+
*/
|
|
531
|
+
declare function transposeChordSymbol(text: string, semitones: number, opts?: {
|
|
532
|
+
flats?: boolean;
|
|
533
|
+
}): string;
|
|
534
|
+
|
|
535
|
+
export { BLUES_MASK, CHROMATIC_MASK, Chord as ChordData, DORIAN_MASK, HARMONIC_MINOR_MASK, LOCRIAN_MASK, LYDIAN_MASK, MAJOR_MASK, MAJOR_PENTATONIC_MASK, MELODIC_MINOR_MASK, MINOR_PENTATONIC_MASK, MIXOLYDIAN_MASK, NAMED_SCALES, NATURAL_MINOR_MASK, OCTATONIC_HALF_WHOLE_MASK, OCTATONIC_WHOLE_HALF_MASK, PHRYGIAN_MASK, VoicingOptions, WHOLE_TONE_MASK, createsHiddenParallelPerfect, createsParallelOctave, createsParallelPerfect, createsParallelUnison, createsVerticalDissonance, createsVoiceCrossing, createsVoiceOverlap, diatonicPitchClasses, exceedsSpacing, formatChordSymbol, isForbiddenMelodicLeap, isLeadingToneResolution, isScaleTone, majorKey, maskFromOffsets, minorKey, nearestScaleTone, nextVoicing, noteNames, parseChordSymbol, pitchToScaleDegree, scaleByName, scaleTonesInDegreeOrder, spellChord, spellPitchClass, spellPitchClasses, spellScale, transposeChordSymbol, voiceLeadingCost };
|