@libraz/libcantus 0.9.3 → 0.9.5
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 +29 -20
- package/README_ja.md +268 -0
- package/dist/analyze/index.cjs +39 -1947
- package/dist/analyze/index.cjs.map +1 -1
- package/dist/analyze/index.d.cts +161 -91
- package/dist/analyze/index.d.ts +161 -91
- package/dist/analyze/index.js +19 -8
- package/dist/chunk-2A2QMA74.cjs +261 -0
- package/dist/chunk-2A2QMA74.cjs.map +1 -0
- package/dist/chunk-2PTFGVD7.js +261 -0
- package/dist/chunk-2PTFGVD7.js.map +1 -0
- package/dist/chunk-357ZDPVU.cjs +162 -0
- package/dist/chunk-357ZDPVU.cjs.map +1 -0
- package/dist/chunk-3KX76RLG.js +1548 -0
- package/dist/chunk-3KX76RLG.js.map +1 -0
- package/dist/chunk-4VZ5MZAM.cjs +889 -0
- package/dist/chunk-4VZ5MZAM.cjs.map +1 -0
- package/dist/{chunk-C5XYKUVG.js → chunk-7EONYVI5.js} +471 -171
- package/dist/chunk-7EONYVI5.js.map +1 -0
- package/dist/{chunk-IT2O4XFE.js → chunk-7JEP3MFY.js} +42 -34
- package/dist/chunk-7JEP3MFY.js.map +1 -0
- package/dist/{chunk-4MHA432G.js → chunk-AID75RN3.js} +572 -250
- package/dist/chunk-AID75RN3.js.map +1 -0
- package/dist/chunk-BSLTLGM3.cjs +497 -0
- package/dist/chunk-BSLTLGM3.cjs.map +1 -0
- package/dist/chunk-CU6VG2YM.cjs +109 -0
- package/dist/chunk-CU6VG2YM.cjs.map +1 -0
- package/dist/{chunk-EH6EM37U.js → chunk-DZMHIGI4.js} +81 -59
- package/dist/chunk-DZMHIGI4.js.map +1 -0
- package/dist/{chunk-AKLYPWIN.js → chunk-EDOTEABK.js} +45 -19
- package/dist/chunk-EDOTEABK.js.map +1 -0
- package/dist/{chunk-2ZWMSJH6.js → chunk-HN2OEUN2.js} +7 -4
- package/dist/chunk-HN2OEUN2.js.map +1 -0
- package/dist/{chunk-MIWO425M.js → chunk-KBTTEX7Q.js} +128 -43
- package/dist/chunk-KBTTEX7Q.js.map +1 -0
- package/dist/chunk-KQN2ZYND.cjs +724 -0
- package/dist/chunk-KQN2ZYND.cjs.map +1 -0
- package/dist/chunk-MPTVJIVG.cjs +3176 -0
- package/dist/chunk-MPTVJIVG.cjs.map +1 -0
- package/dist/chunk-MTMZTMWM.cjs +53 -0
- package/dist/chunk-MTMZTMWM.cjs.map +1 -0
- package/dist/{chunk-CHMXELDS.js → chunk-NNB67XA2.js} +372 -197
- package/dist/chunk-NNB67XA2.js.map +1 -0
- package/dist/chunk-OL3IHHSJ.cjs +1204 -0
- package/dist/chunk-OL3IHHSJ.cjs.map +1 -0
- package/dist/chunk-PI3UXRWK.cjs +528 -0
- package/dist/chunk-PI3UXRWK.cjs.map +1 -0
- package/dist/chunk-R2VVFAIN.js +528 -0
- package/dist/chunk-R2VVFAIN.js.map +1 -0
- package/dist/chunk-T64C7ZD7.cjs +1 -0
- package/dist/chunk-T64C7ZD7.cjs.map +1 -0
- package/dist/chunk-WFDXOLUB.cjs +337 -0
- package/dist/chunk-WFDXOLUB.cjs.map +1 -0
- package/dist/chunk-WTAN4ACG.cjs +1548 -0
- package/dist/chunk-WTAN4ACG.cjs.map +1 -0
- package/dist/chunk-YFJXS3AU.cjs +33 -0
- package/dist/chunk-YFJXS3AU.cjs.map +1 -0
- package/dist/{chunk-GOAW4VYL.js → chunk-YUE6TJ4M.js} +315 -145
- package/dist/chunk-YUE6TJ4M.js.map +1 -0
- package/dist/{chunk-62QZKCJQ.js → chunk-ZGLJM4A4.js} +10 -6
- package/dist/chunk-ZGLJM4A4.js.map +1 -0
- package/dist/core/index.cjs +140 -647
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +313 -41
- package/dist/core/index.d.ts +313 -41
- package/dist/core/index.js +64 -16
- package/dist/{function-DVH4Eusr.d.ts → function-CxixTB02.d.cts} +122 -10
- package/dist/{function-DYt4iKsn.d.cts → function-DTCt675z.d.ts} +122 -10
- package/dist/generate/index.cjs +28 -4085
- package/dist/generate/index.cjs.map +1 -1
- package/dist/generate/index.d.cts +374 -66
- package/dist/generate/index.d.ts +374 -66
- package/dist/generate/index.js +23 -9
- package/dist/{index-Jc0Ryi79.d.ts → index-B2Ulxxpo.d.cts} +21 -5
- package/dist/{index-CpOsP1y9.d.cts → index-BkYJ0xMq.d.cts} +18 -17
- package/dist/{index-CxqBQtH1.d.cts → index-BuaB-ypt.d.ts} +21 -5
- package/dist/index-CAN7v-kw.d.ts +199 -0
- package/dist/{index-Bt4tOUD9.d.ts → index-COw1Ky9g.d.ts} +93 -8
- package/dist/{index-Dikst44v.d.cts → index-Cfx8xgH0.d.ts} +14 -11
- package/dist/{index-DxvARIP2.d.ts → index-DRtIhlJj.d.ts} +18 -17
- package/dist/{index-Cl7mhOFM.d.cts → index-DXd9JikN.d.cts} +92 -10
- package/dist/{index-Cl7mhOFM.d.ts → index-DXd9JikN.d.ts} +92 -10
- package/dist/index-alrRninU.d.cts +199 -0
- package/dist/{index-BNlGP86A.d.cts → index-oTQbYYIs.d.cts} +93 -8
- package/dist/index-tR9jTn26.d.cts +275 -0
- package/dist/index-tR9jTn26.d.ts +275 -0
- package/dist/{index-Bg5dYMmZ.d.ts → index-x2vcsduE.d.cts} +14 -11
- package/dist/index.cjs +429 -7383
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -15
- package/dist/index.d.ts +15 -15
- package/dist/index.js +121 -27
- package/dist/model/index.cjs +8 -2562
- package/dist/model/index.cjs.map +1 -1
- package/dist/model/index.d.cts +471 -81
- package/dist/model/index.d.ts +471 -81
- package/dist/model/index.js +6 -7
- package/dist/styled-Bl0ZK28h.d.ts +543 -0
- package/dist/styled-Crv6SA4S.d.cts +543 -0
- package/dist/theory/index.cjs +172 -1822
- package/dist/theory/index.cjs.map +1 -1
- package/dist/theory/index.d.cts +151 -233
- package/dist/theory/index.d.ts +151 -233
- package/dist/theory/index.js +30 -7
- package/dist/{types-MGP29r3t.d.cts → types-BN6_Q9Kl.d.cts} +11 -2
- package/dist/{types-MGP29r3t.d.ts → types-BN6_Q9Kl.d.ts} +11 -2
- package/package.json +34 -13
- package/dist/chunk-2ZWMSJH6.js.map +0 -1
- package/dist/chunk-4MHA432G.js.map +0 -1
- package/dist/chunk-62QZKCJQ.js.map +0 -1
- package/dist/chunk-AKLYPWIN.js.map +0 -1
- package/dist/chunk-C5XYKUVG.js.map +0 -1
- package/dist/chunk-CHMXELDS.js.map +0 -1
- package/dist/chunk-DYWFNC4A.js +0 -152
- package/dist/chunk-DYWFNC4A.js.map +0 -1
- package/dist/chunk-EH6EM37U.js.map +0 -1
- package/dist/chunk-FBQK3ZQN.js +0 -131
- package/dist/chunk-FBQK3ZQN.js.map +0 -1
- package/dist/chunk-GOAW4VYL.js.map +0 -1
- package/dist/chunk-I5R7ZBJS.js +0 -202
- package/dist/chunk-I5R7ZBJS.js.map +0 -1
- package/dist/chunk-IT2O4XFE.js.map +0 -1
- package/dist/chunk-MIWO425M.js.map +0 -1
- package/dist/chunk-SGU7SPLK.js +0 -924
- package/dist/chunk-SGU7SPLK.js.map +0 -1
- package/dist/index-CGMZNCx6.d.cts +0 -140
- package/dist/index-CGMZNCx6.d.ts +0 -140
- package/dist/index-CnZCo29u.d.cts +0 -108
- package/dist/index-JnF4v9bx.d.ts +0 -108
- package/dist/styled-DZ7GjShb.d.ts +0 -282
- package/dist/styled-ZTbdaVFM.d.cts +0 -282
- package/src/analyze/arrange/index.ts +0 -21
- package/src/analyze/arrange/internal.ts +0 -127
- package/src/analyze/arrange/tension.ts +0 -199
- package/src/analyze/arrange/tracks.ts +0 -312
- package/src/analyze/detect/index.ts +0 -272
- package/src/analyze/functional/borrowed.ts +0 -84
- package/src/analyze/functional/cadence.ts +0 -66
- package/src/analyze/functional/function.ts +0 -184
- package/src/analyze/functional/index.ts +0 -23
- package/src/analyze/functional/internal.ts +0 -29
- package/src/analyze/functional/roman.ts +0 -402
- package/src/analyze/index.ts +0 -49
- package/src/analyze/timeline/index.ts +0 -451
- package/src/analyze/voice/index.ts +0 -339
- package/src/core/event-index/index.ts +0 -104
- package/src/core/index.ts +0 -61
- package/src/core/interval/index.ts +0 -81
- package/src/core/meter/index.ts +0 -302
- package/src/core/pitch/index.ts +0 -311
- package/src/core/random/index.ts +0 -76
- package/src/core/tuning/index.ts +0 -186
- package/src/core/types.ts +0 -29
- package/src/core/validation/index.ts +0 -119
- package/src/generate/bass/index.ts +0 -373
- package/src/generate/countermelody/index.ts +0 -470
- package/src/generate/drums/beat.ts +0 -266
- package/src/generate/drums/euclid.ts +0 -65
- package/src/generate/drums/fills.ts +0 -356
- package/src/generate/drums/ghost.ts +0 -119
- package/src/generate/drums/hihat.ts +0 -285
- package/src/generate/drums/hit.ts +0 -31
- package/src/generate/drums/index.ts +0 -361
- package/src/generate/drums/internal.ts +0 -257
- package/src/generate/drums/kick.ts +0 -160
- package/src/generate/drums/percussion.ts +0 -121
- package/src/generate/drums/rng.ts +0 -7
- package/src/generate/drums/swing.ts +0 -71
- package/src/generate/groove/index.ts +0 -351
- package/src/generate/harmonize/index.ts +0 -451
- package/src/generate/index.ts +0 -58
- package/src/generate/motif/index.ts +0 -422
- package/src/generate/progression/index.ts +0 -362
- package/src/generate/reharmony/index.ts +0 -323
- package/src/generate/rhythm/index.ts +0 -175
- package/src/index.ts +0 -13
- package/src/model/chord.ts +0 -442
- package/src/model/index.ts +0 -15
- package/src/model/interval.ts +0 -82
- package/src/model/key.ts +0 -266
- package/src/model/note.ts +0 -176
- package/src/model/progression.ts +0 -161
- package/src/model/shared.ts +0 -12
- package/src/theory/chord/index.ts +0 -375
- package/src/theory/chordscale/index.ts +0 -374
- package/src/theory/counterpoint/index.ts +0 -230
- package/src/theory/harmony/index.ts +0 -77
- package/src/theory/index.ts +0 -112
- package/src/theory/safety/index.ts +0 -488
- package/src/theory/scale/degrees.ts +0 -123
- package/src/theory/scale/index.ts +0 -28
- package/src/theory/scale/key.ts +0 -56
- package/src/theory/scale/masks.ts +0 -153
- package/src/theory/spelling/index.ts +0 -249
- package/src/theory/symbol/index.ts +0 -268
- package/src/theory/voicing/index.ts +0 -5
- package/src/theory/voicing/internal.ts +0 -168
- package/src/theory/voicing/leading.ts +0 -112
- package/src/theory/voicing/satb.ts +0 -216
- package/src/theory/voicing/styled.ts +0 -199
- package/tsconfig.json +0 -23
package/dist/model/index.d.ts
CHANGED
|
@@ -1,9 +1,122 @@
|
|
|
1
|
-
import { D as DetectChordOptions } from '../index-
|
|
2
|
-
import { H as HarmonicFunction, a as ChordAnalysis, C as Cadence, B as BorrowedSource } from '../function-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { b as KeyVariant, a as DetectKeyOptions, K as KeyMatch, D as DetectChordOptions, C as ChordMatch } from '../index-CAN7v-kw.js';
|
|
2
|
+
import { b as ChordToRomanOptions, H as HarmonicFunction, a as ChordAnalysis, C as Cadence, B as BorrowedSource } from '../function-DTCt675z.js';
|
|
3
|
+
import { I as IntervalQualityLabel, S as SpelledInterval, N as Note$1 } from '../index-tR9jTn26.js';
|
|
4
|
+
import { K as KeyScale } from '../types-BN6_Q9Kl.js';
|
|
5
|
+
import { a as ChordQuality, c as ChordSpan, C as Chord$1 } from '../index-COw1Ky9g.js';
|
|
6
|
+
export { P as PitchSpelling } from '../index-COw1Ky9g.js';
|
|
7
|
+
import { p as ScaleNameInput, r as VoicingOptions, n as ScaleChoice, q as StyledVoicingOptions, a as ChordScaleMatch } from '../styled-Bl0ZK28h.js';
|
|
8
|
+
export { o as ScaleName, V as VoiceRange, s as VoicingStyle } from '../styled-Bl0ZK28h.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* An immutable spelled interval value: a diatonic number, a quality label, and
|
|
12
|
+
* a signed semitone span. A thin convenience wrapper over the pitch module's
|
|
13
|
+
* plain interval result.
|
|
14
|
+
*
|
|
15
|
+
* @category Class API
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { Interval, Note } from '@libraz/libcantus';
|
|
19
|
+
* Interval.between(Note.of('C4'), Note.of('G4')).name; // 'P5'
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare class Interval {
|
|
23
|
+
#private;
|
|
24
|
+
private constructor();
|
|
25
|
+
/**
|
|
26
|
+
* The spelled interval between two notes.
|
|
27
|
+
*
|
|
28
|
+
* @param a The first note.
|
|
29
|
+
* @param b The second note.
|
|
30
|
+
* @returns The interval from `a` to `b`.
|
|
31
|
+
*/
|
|
32
|
+
static between(a: Note, b: Note): Interval;
|
|
33
|
+
/**
|
|
34
|
+
* Build an interval from explicit components.
|
|
35
|
+
*
|
|
36
|
+
* @param numberValue Diatonic size: 1 = unison, 2 = second, ... 8 = octave.
|
|
37
|
+
* @param quality Quality label: `'P'`, `'M'`, `'m'`, or repeated `'A'`/`'d'`.
|
|
38
|
+
* @param semitones Signed semitone span; its magnitude must be the span the
|
|
39
|
+
* number and quality describe.
|
|
40
|
+
* @returns The interval.
|
|
41
|
+
* @throws If the three components do not describe the same interval — a
|
|
42
|
+
* `P5` spanning 8 semitones is not a value any other method can produce.
|
|
43
|
+
*/
|
|
44
|
+
static of(numberValue: number, quality: IntervalQualityLabel, semitones: number): Interval;
|
|
45
|
+
/**
|
|
46
|
+
* Wrap a plain spelled interval, as returned by the pitch module.
|
|
47
|
+
*
|
|
48
|
+
* @param data The plain interval.
|
|
49
|
+
* @returns The wrapped interval.
|
|
50
|
+
*/
|
|
51
|
+
static fromData(data: SpelledInterval): Interval;
|
|
52
|
+
/**
|
|
53
|
+
* Rebuild an interval from its {@link Interval.toJSON} output.
|
|
54
|
+
*
|
|
55
|
+
* @param data The serialized interval.
|
|
56
|
+
* @returns The wrapped interval.
|
|
57
|
+
*/
|
|
58
|
+
static fromJSON(data: SpelledInterval): Interval;
|
|
59
|
+
/**
|
|
60
|
+
* Parse an interval name such as `'P5'`, `'m3'`, or `'AA4'`.
|
|
61
|
+
*
|
|
62
|
+
* @param name The interval name.
|
|
63
|
+
* @returns The ascending interval of that name.
|
|
64
|
+
* @throws If the name is not a quality label followed by a diatonic number.
|
|
65
|
+
*/
|
|
66
|
+
static parse(name: string): Interval;
|
|
67
|
+
/** Diatonic size: 1 = unison, 2 = second, ... 8 = octave, and beyond. */
|
|
68
|
+
get number(): number;
|
|
69
|
+
/** Quality label: `'P'`, `'M'`, `'m'`, or repeated `'A'`/`'d'`. */
|
|
70
|
+
get quality(): IntervalQualityLabel;
|
|
71
|
+
/** Signed semitone span. */
|
|
72
|
+
get semitones(): number;
|
|
73
|
+
/** A readable label composed of quality and number, e.g. `'P5'` or `'M3'`. */
|
|
74
|
+
get name(): string;
|
|
75
|
+
/**
|
|
76
|
+
* The interval's inversion: the complement that completes the octave.
|
|
77
|
+
*
|
|
78
|
+
* A compound interval is reduced to its simple form first, and the result is
|
|
79
|
+
* always ascending — an inversion answers "what is left of the octave",
|
|
80
|
+
* which has no direction of its own.
|
|
81
|
+
*
|
|
82
|
+
* @returns The inverted interval, e.g. `M3` becomes `m6`.
|
|
83
|
+
*/
|
|
84
|
+
invert(): Interval;
|
|
85
|
+
/**
|
|
86
|
+
* Whether the interval is consonant.
|
|
87
|
+
*
|
|
88
|
+
* @param twoVoice When true, the perfect fourth counts as a dissonance,
|
|
89
|
+
* matching two-voice counterpoint.
|
|
90
|
+
* @returns True if the interval is consonant in that context.
|
|
91
|
+
*/
|
|
92
|
+
isConsonant(twoVoice?: boolean): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Whether another interval is spelled identically.
|
|
95
|
+
*
|
|
96
|
+
* Enharmonic equivalents are not equal: an augmented second and a minor
|
|
97
|
+
* third span the same distance but are different intervals.
|
|
98
|
+
*
|
|
99
|
+
* @param other The interval to compare with.
|
|
100
|
+
* @returns True when number, quality, and span all match.
|
|
101
|
+
*/
|
|
102
|
+
equals(other: Interval): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* The plain interval data, for JSON serialization.
|
|
105
|
+
*
|
|
106
|
+
* Private class fields do not serialize, so an explicit `toJSON` keeps
|
|
107
|
+
* `JSON.stringify(interval)` from collapsing to `{}`.
|
|
108
|
+
*
|
|
109
|
+
* @returns The diatonic number, quality, and semitone span.
|
|
110
|
+
*/
|
|
111
|
+
toJSON(): SpelledInterval;
|
|
112
|
+
/**
|
|
113
|
+
* The interval's name, so a template literal or a log line reads as the
|
|
114
|
+
* interval.
|
|
115
|
+
*
|
|
116
|
+
* @returns The name, e.g. `'M3'`.
|
|
117
|
+
*/
|
|
118
|
+
toString(): string;
|
|
119
|
+
}
|
|
7
120
|
|
|
8
121
|
/**
|
|
9
122
|
* An immutable spelled note: a diatonic letter plus a chromatic alteration and
|
|
@@ -23,6 +136,7 @@ declare class Note {
|
|
|
23
136
|
* Wrap a plain note object.
|
|
24
137
|
*
|
|
25
138
|
* @param data The spelled note; it is copied, never retained or mutated.
|
|
139
|
+
* @throws If `letter` is not an integer in 0..6.
|
|
26
140
|
*/
|
|
27
141
|
constructor(data: Note$1);
|
|
28
142
|
/**
|
|
@@ -46,6 +160,7 @@ declare class Note {
|
|
|
46
160
|
*
|
|
47
161
|
* @param data The plain note.
|
|
48
162
|
* @returns The wrapped note.
|
|
163
|
+
* @throws If `letter` is not an integer in 0..6.
|
|
49
164
|
*/
|
|
50
165
|
static fromData(data: Note$1): Note;
|
|
51
166
|
/** The note rendered as scientific pitch notation, e.g. `'G4'` or `'Bb'`. */
|
|
@@ -67,24 +182,59 @@ declare class Note {
|
|
|
67
182
|
/** A copy of the underlying plain note object. */
|
|
68
183
|
get data(): Note$1;
|
|
69
184
|
/**
|
|
70
|
-
* Transpose by a signed number of semitones.
|
|
185
|
+
* Transpose by a signed number of semitones, keeping the spelling.
|
|
71
186
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
187
|
+
* The letter moves by the diatonic distance of the conventional interval for
|
|
188
|
+
* that many semitones, so `Ab4` up a major second is `Bb4` rather than `A#4`
|
|
189
|
+
* and a flat key stays on the flat side. An octave-less note stays
|
|
74
190
|
* octave-less: only its pitch class is moved. Transposing by zero is the
|
|
75
191
|
* identity: the original spelling is preserved (no enharmonic respelling).
|
|
76
192
|
*
|
|
77
193
|
* @param semitones The signed semitone offset.
|
|
194
|
+
* @param opts `spelling` forces the result onto the sharp or flat side
|
|
195
|
+
* instead of following this note's letter.
|
|
78
196
|
* @returns The transposed note.
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* import { Note } from '@libraz/libcantus';
|
|
200
|
+
* Note.of('Ab4').transpose(2).name; // 'Bb4'
|
|
201
|
+
* Note.of('Ab4').transpose(2, { spelling: 'sharp' }).name; // 'A#4'
|
|
202
|
+
* ```
|
|
79
203
|
*/
|
|
80
|
-
transpose(semitones: number
|
|
204
|
+
transpose(semitones: number, opts?: {
|
|
205
|
+
spelling?: 'sharp' | 'flat';
|
|
206
|
+
}): Note;
|
|
81
207
|
/**
|
|
82
208
|
* The spelled interval from this note to another.
|
|
83
209
|
*
|
|
84
210
|
* @param other The second note.
|
|
85
|
-
* @returns The
|
|
211
|
+
* @returns The interval, which {@link Interval.toJSON} unwraps to plain data.
|
|
86
212
|
*/
|
|
87
|
-
intervalTo(other: Note):
|
|
213
|
+
intervalTo(other: Note): Interval;
|
|
214
|
+
/**
|
|
215
|
+
* Transpose by a spelled interval, keeping the spelling the interval names.
|
|
216
|
+
*
|
|
217
|
+
* Unlike {@link Note.transpose}, which picks a letter from the semitone
|
|
218
|
+
* count, the interval's diatonic number decides the letter: C up an
|
|
219
|
+
* augmented second is D#, not Eb.
|
|
220
|
+
*
|
|
221
|
+
* @param interval The interval to apply; a descending interval moves down.
|
|
222
|
+
* @returns The transposed note.
|
|
223
|
+
* @example
|
|
224
|
+
* ```ts
|
|
225
|
+
* import { Interval, Note } from '@libraz/libcantus';
|
|
226
|
+
* Note.of('C4').transposeBy(Interval.parse('A2')).name; // 'D#4'
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
transposeBy(interval: Interval): Note;
|
|
230
|
+
/**
|
|
231
|
+
* Rebuild a note from its {@link Note.toJSON} output.
|
|
232
|
+
*
|
|
233
|
+
* @param data The serialized note.
|
|
234
|
+
* @returns The wrapped note.
|
|
235
|
+
* @throws If `letter` is not an integer in 0..6.
|
|
236
|
+
*/
|
|
237
|
+
static fromJSON(data: Note$1): Note;
|
|
88
238
|
/**
|
|
89
239
|
* Whether another note has the same letter, alteration, and octave.
|
|
90
240
|
*
|
|
@@ -101,8 +251,18 @@ declare class Note {
|
|
|
101
251
|
* @returns A copy of the underlying plain note object.
|
|
102
252
|
*/
|
|
103
253
|
toJSON(): Note$1;
|
|
254
|
+
/**
|
|
255
|
+
* The note's name, so a template literal or a log line reads as the note.
|
|
256
|
+
*
|
|
257
|
+
* @returns The spelled name, e.g. `'Bb3'`.
|
|
258
|
+
*/
|
|
259
|
+
toString(): string;
|
|
104
260
|
}
|
|
105
261
|
|
|
262
|
+
/** A detected key paired with the score and scale form that produced it. */
|
|
263
|
+
type DetectedKeyMatch = Omit<KeyMatch, 'key'> & {
|
|
264
|
+
key: Key;
|
|
265
|
+
};
|
|
106
266
|
/**
|
|
107
267
|
* An immutable key/scale: a `KeyScale` (root pitch class plus mode mask) paired
|
|
108
268
|
* with a spelled tonic that anchors letter-name spelling. Acts as the factory
|
|
@@ -122,8 +282,9 @@ declare class Key {
|
|
|
122
282
|
*
|
|
123
283
|
* @param scale The key/scale; its root is normalized to a pitch class.
|
|
124
284
|
* @param tonic The spelled tonic anchoring letter-name spelling.
|
|
285
|
+
* @param variant Optional detected scale form retained for display.
|
|
125
286
|
*/
|
|
126
|
-
constructor(scale: KeyScale, tonic: Note);
|
|
287
|
+
constructor(scale: KeyScale, tonic: Note, variant?: KeyVariant);
|
|
127
288
|
/**
|
|
128
289
|
* A major key.
|
|
129
290
|
*
|
|
@@ -146,20 +307,79 @@ declare class Key {
|
|
|
146
307
|
* A key on a named scale (e.g. `'dorian'`, `'harmonicMinor'`).
|
|
147
308
|
*
|
|
148
309
|
* @param name The scale name, a key of the scale module's named-scale table.
|
|
149
|
-
* @param root Tonic as a note name or a pitch class
|
|
310
|
+
* @param root Tonic as a note name or a pitch class; a numeric root is
|
|
311
|
+
* spelled with whichever accidental side yields the fewest accidentals
|
|
312
|
+
* across the scale, exactly as {@link Key.major} does.
|
|
150
313
|
* @returns The key.
|
|
151
314
|
* @throws If the name is not a known scale.
|
|
152
315
|
*/
|
|
153
|
-
static named(name:
|
|
316
|
+
static named(name: ScaleNameInput, root: string | number): Key;
|
|
154
317
|
/**
|
|
155
318
|
* Wrap an existing `KeyScale`, synthesizing a spelled tonic when none is
|
|
156
|
-
* given
|
|
319
|
+
* given.
|
|
320
|
+
*
|
|
321
|
+
* The synthesized tonic is chosen the same way as for a numeric root
|
|
322
|
+
* elsewhere: whichever accidental side spells the scale with the fewest
|
|
323
|
+
* accidentals. This is what keeps `Key.of(detectKey(...).scale)` from handing
|
|
324
|
+
* every downstream chord a double-sharp spelling.
|
|
157
325
|
*
|
|
158
326
|
* @param scale The key/scale to wrap.
|
|
159
|
-
* @param tonic Optional spelled tonic.
|
|
327
|
+
* @param tonic Optional spelled tonic; must spell the scale's root pitch class.
|
|
160
328
|
* @returns The key.
|
|
329
|
+
* @throws If the given tonic is not the scale's root pitch class.
|
|
161
330
|
*/
|
|
162
331
|
static of(scale: KeyScale, tonic?: Note): Key;
|
|
332
|
+
/**
|
|
333
|
+
* Rebuild a key from its {@link Key.toJSON} output.
|
|
334
|
+
*
|
|
335
|
+
* @param data The serialized key and tonic.
|
|
336
|
+
* @returns The key.
|
|
337
|
+
*/
|
|
338
|
+
static fromJSON(data: {
|
|
339
|
+
scale: KeyScale;
|
|
340
|
+
tonic: Note$1;
|
|
341
|
+
}): Key;
|
|
342
|
+
/**
|
|
343
|
+
* Identify the keys a set of pitches fits, best interpretation first.
|
|
344
|
+
*
|
|
345
|
+
* The counterpart of {@link Chord.detect}.
|
|
346
|
+
*
|
|
347
|
+
* @param pitches MIDI pitches or bare pitch classes.
|
|
348
|
+
* @param opts How to weigh the input; see {@link DetectKeyOptions}.
|
|
349
|
+
* @returns Ranked keys (may be empty).
|
|
350
|
+
*/
|
|
351
|
+
static detect(pitches: readonly number[], opts?: DetectKeyOptions): Key[];
|
|
352
|
+
/**
|
|
353
|
+
* Identify keys while retaining each candidate's score, fit, and scale form.
|
|
354
|
+
*
|
|
355
|
+
* @param pitches MIDI pitches or bare pitch classes.
|
|
356
|
+
* @param opts How to weigh the input; see {@link DetectKeyOptions}.
|
|
357
|
+
* @returns Ranked key matches (may be empty).
|
|
358
|
+
*/
|
|
359
|
+
static detectMatches(pitches: readonly number[], opts?: DetectKeyOptions): DetectedKeyMatch[];
|
|
360
|
+
/**
|
|
361
|
+
* The single best key interpretation of a pitch set.
|
|
362
|
+
*
|
|
363
|
+
* @param pitches MIDI pitches or bare pitch classes.
|
|
364
|
+
* @param opts How to weigh the input; see {@link DetectKeyOptions}.
|
|
365
|
+
* @returns The top-ranked key, or null when nothing matches.
|
|
366
|
+
* @example
|
|
367
|
+
* ```ts
|
|
368
|
+
* import { Key } from '@libraz/libcantus';
|
|
369
|
+
* Key.detectBest([0, 2, 4, 5, 7, 9, 11])?.toString(); // 'C major'
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
static detectBest(pitches: readonly number[], opts?: DetectKeyOptions): Key | null;
|
|
373
|
+
/**
|
|
374
|
+
* Whether another key has the same tonic pitch class and mode.
|
|
375
|
+
*
|
|
376
|
+
* The spelled tonic is not compared: C# major and Db major are the same key
|
|
377
|
+
* written two ways.
|
|
378
|
+
*
|
|
379
|
+
* @param other The key to compare.
|
|
380
|
+
* @returns True when tonic and mode mask both match.
|
|
381
|
+
*/
|
|
382
|
+
equals(other: Key): boolean;
|
|
163
383
|
/** A copy of the underlying plain `KeyScale`. */
|
|
164
384
|
get scale(): KeyScale;
|
|
165
385
|
/** The spelled tonic. */
|
|
@@ -168,12 +388,30 @@ declare class Key {
|
|
|
168
388
|
get rootPc(): number;
|
|
169
389
|
/** Whether the scale has a minor third and no major third. */
|
|
170
390
|
get isMinor(): boolean;
|
|
391
|
+
/** The detected scale form, when this key came from key detection. */
|
|
392
|
+
get variant(): KeyVariant | undefined;
|
|
171
393
|
/**
|
|
172
394
|
* The scale's pitch classes in ascending scale-degree order (degree 0 first).
|
|
173
395
|
*
|
|
174
396
|
* @returns One pitch class per scale degree.
|
|
175
397
|
*/
|
|
176
398
|
pitchClasses(): number[];
|
|
399
|
+
/**
|
|
400
|
+
* Transpose the key by a number of semitones.
|
|
401
|
+
*
|
|
402
|
+
* The mode mask is unchanged, so the scale keeps its shape; only the tonic
|
|
403
|
+
* moves. The new tonic is spelled the way that key is conventionally written
|
|
404
|
+
* — D major, not C## major.
|
|
405
|
+
*
|
|
406
|
+
* @param semitones The signed semitone offset.
|
|
407
|
+
* @returns The transposed key.
|
|
408
|
+
* @example
|
|
409
|
+
* ```ts
|
|
410
|
+
* import { Key } from '@libraz/libcantus';
|
|
411
|
+
* Key.major('C').transpose(2).toString(); // 'D major'
|
|
412
|
+
* ```
|
|
413
|
+
*/
|
|
414
|
+
transpose(semitones: number): Key;
|
|
177
415
|
/**
|
|
178
416
|
* The spelled scale, one note per degree (e.g. C D E F G A B for C major).
|
|
179
417
|
*
|
|
@@ -202,6 +440,10 @@ declare class Key {
|
|
|
202
440
|
* @param degree 0-based scale degree of the chord root.
|
|
203
441
|
* @param quality Optional chord quality.
|
|
204
442
|
* @returns The chord, with this key attached.
|
|
443
|
+
* @throws Without a `quality`, if this key's scale is not heptatonic —
|
|
444
|
+
* stacking thirds needs seven degrees, so the pentatonic, blues,
|
|
445
|
+
* whole-tone, octatonic and chromatic scales have no diatonic triad. Pass
|
|
446
|
+
* an explicit `quality` for those.
|
|
205
447
|
*/
|
|
206
448
|
chord(degree: number, quality?: ChordQuality): Chord;
|
|
207
449
|
/**
|
|
@@ -209,6 +451,8 @@ declare class Key {
|
|
|
209
451
|
*
|
|
210
452
|
* @param degree 0-based scale degree of the chord root.
|
|
211
453
|
* @returns The triad, with this key attached.
|
|
454
|
+
* @throws If this key's scale is not heptatonic; stacking thirds needs seven
|
|
455
|
+
* degrees. Use {@link Key.chord} with an explicit quality instead.
|
|
212
456
|
*/
|
|
213
457
|
diatonicTriad(degree: number): Chord;
|
|
214
458
|
/**
|
|
@@ -216,6 +460,8 @@ declare class Key {
|
|
|
216
460
|
*
|
|
217
461
|
* @param degree 0-based scale degree of the chord root.
|
|
218
462
|
* @returns The seventh chord, with this key attached.
|
|
463
|
+
* @throws If this key's scale is not heptatonic; stacking thirds needs seven
|
|
464
|
+
* degrees. Use {@link Key.chord} with an explicit quality instead.
|
|
219
465
|
*/
|
|
220
466
|
diatonicSeventh(degree: number): Chord;
|
|
221
467
|
/**
|
|
@@ -248,6 +494,13 @@ declare class Key {
|
|
|
248
494
|
scale: KeyScale;
|
|
249
495
|
tonic: Note$1;
|
|
250
496
|
};
|
|
497
|
+
/**
|
|
498
|
+
* The key's tonic and mode, so a template literal or a log line reads as the
|
|
499
|
+
* key. Detected harmonic and melodic minor keys retain their scale form.
|
|
500
|
+
*
|
|
501
|
+
* @returns The name, e.g. `'C major'` or `'A minor'`.
|
|
502
|
+
*/
|
|
503
|
+
toString(): string;
|
|
251
504
|
}
|
|
252
505
|
|
|
253
506
|
/**
|
|
@@ -272,12 +525,69 @@ declare class Progression {
|
|
|
272
525
|
* @param key Optional key context for analysis methods.
|
|
273
526
|
*/
|
|
274
527
|
constructor(chords: readonly Chord[], key?: Key);
|
|
275
|
-
/**
|
|
528
|
+
/**
|
|
529
|
+
* Build a progression from the {@link ChordSpan} records the generators
|
|
530
|
+
* return, keeping their order.
|
|
531
|
+
*
|
|
532
|
+
* The spans' `startBeat`, `degree`, and `secondaryDominant` are analysis
|
|
533
|
+
* annotations that a chord sequence does not carry; only the harmony crosses
|
|
534
|
+
* over. Keep the spans themselves if the timing matters.
|
|
535
|
+
*
|
|
536
|
+
* @param spans The chord spans, in order.
|
|
537
|
+
* @param key Optional key context for the analysis methods.
|
|
538
|
+
* @returns The progression.
|
|
539
|
+
* @example
|
|
540
|
+
* ```ts
|
|
541
|
+
* import { generateProgression, Key, Progression } from '@libraz/libcantus';
|
|
542
|
+
* const key = Key.major('C');
|
|
543
|
+
* const spans = generateProgression({ key: key.scale, style: 'dance', bars: 4 });
|
|
544
|
+
* Progression.fromSpans(spans, key).roman();
|
|
545
|
+
* ```
|
|
546
|
+
*/
|
|
547
|
+
static fromSpans(spans: readonly ChordSpan[], key?: Key): Progression;
|
|
548
|
+
/**
|
|
549
|
+
* Rebuild a progression from its {@link Progression.toJSON} output.
|
|
550
|
+
*
|
|
551
|
+
* @param data The serialized chords and key.
|
|
552
|
+
* @returns The progression.
|
|
553
|
+
*/
|
|
554
|
+
static fromJSON(data: {
|
|
555
|
+
chords: Chord$1[];
|
|
556
|
+
key?: {
|
|
557
|
+
scale: KeyScale;
|
|
558
|
+
tonic: Note$1;
|
|
559
|
+
} | undefined;
|
|
560
|
+
}): Progression;
|
|
561
|
+
/**
|
|
562
|
+
* The chord sequence.
|
|
563
|
+
*
|
|
564
|
+
* The array is the progression's own and is frozen rather than copied, so
|
|
565
|
+
* reading it in a loop stays linear.
|
|
566
|
+
*/
|
|
276
567
|
get chords(): readonly Chord[];
|
|
277
568
|
/** The carried key context, if any. */
|
|
278
569
|
get key(): Key | undefined;
|
|
279
570
|
/** The number of chords. */
|
|
280
571
|
get length(): number;
|
|
572
|
+
/**
|
|
573
|
+
* The chord at an index.
|
|
574
|
+
*
|
|
575
|
+
* @param index 0-based position; a negative index counts from the end.
|
|
576
|
+
* @returns The chord, or undefined when the index is out of range.
|
|
577
|
+
*/
|
|
578
|
+
at(index: number): Chord | undefined;
|
|
579
|
+
/** Iterate the chords in order, so a progression works with `for...of`. */
|
|
580
|
+
[Symbol.iterator](): IterableIterator<Chord>;
|
|
581
|
+
/**
|
|
582
|
+
* Whether another progression holds the same chords in the same order.
|
|
583
|
+
*
|
|
584
|
+
* The key context is not compared: it is an analysis lens, not part of the
|
|
585
|
+
* harmony. Chord equality follows {@link Chord.equals}.
|
|
586
|
+
*
|
|
587
|
+
* @param other The progression to compare.
|
|
588
|
+
* @returns True when the chord sequences match.
|
|
589
|
+
*/
|
|
590
|
+
equals(other: Progression): boolean;
|
|
281
591
|
/**
|
|
282
592
|
* A copy of this progression with a chord appended.
|
|
283
593
|
*
|
|
@@ -304,10 +614,11 @@ declare class Progression {
|
|
|
304
614
|
* The Roman numeral of each chord in a key.
|
|
305
615
|
*
|
|
306
616
|
* @param key Key to analyze in; falls back to the carried context.
|
|
617
|
+
* @param opts Applied-numeral rendering options.
|
|
307
618
|
* @returns One numeral per chord.
|
|
308
619
|
* @throws If no key is given and none is carried.
|
|
309
620
|
*/
|
|
310
|
-
roman(key?: Key): string[];
|
|
621
|
+
roman(key?: Key, opts?: ChordToRomanOptions): string[];
|
|
311
622
|
/**
|
|
312
623
|
* The harmonic function of each chord in a key.
|
|
313
624
|
*
|
|
@@ -323,13 +634,20 @@ declare class Progression {
|
|
|
323
634
|
* progression has fewer than two chords.
|
|
324
635
|
*
|
|
325
636
|
* @param key Key to analyze in; falls back to the carried context.
|
|
637
|
+
* @param opts Applied-numeral rendering options.
|
|
326
638
|
* @returns Per-chord analyses and the closing cadence.
|
|
327
639
|
* @throws If no key is given and none is carried.
|
|
328
640
|
*/
|
|
329
|
-
analyze(key?: Key): {
|
|
641
|
+
analyze(key?: Key, opts?: ChordToRomanOptions): {
|
|
330
642
|
chords: ChordAnalysis[];
|
|
331
643
|
cadence: Cadence;
|
|
332
644
|
};
|
|
645
|
+
/**
|
|
646
|
+
* Choose one compatible scale for every chord, favoring smooth changes.
|
|
647
|
+
*
|
|
648
|
+
* @returns One scale choice per chord in this progression.
|
|
649
|
+
*/
|
|
650
|
+
scales(): ScaleChoice[];
|
|
333
651
|
/**
|
|
334
652
|
* The plain progression data, for JSON serialization.
|
|
335
653
|
*
|
|
@@ -339,6 +657,36 @@ declare class Progression {
|
|
|
339
657
|
*
|
|
340
658
|
* @returns The chord data sequence and the carried key, if any.
|
|
341
659
|
*/
|
|
660
|
+
/**
|
|
661
|
+
* Transpose every chord by a number of semitones.
|
|
662
|
+
*
|
|
663
|
+
* A carried key moves with the chords, so the progression keeps its degrees
|
|
664
|
+
* and functions in the new key.
|
|
665
|
+
*
|
|
666
|
+
* @param semitones The signed semitone offset.
|
|
667
|
+
* @returns The transposed progression.
|
|
668
|
+
* @example
|
|
669
|
+
* ```ts
|
|
670
|
+
* import { Chord, Progression } from '@libraz/libcantus';
|
|
671
|
+
* new Progression([Chord.parse('C'), Chord.parse('G')]).transpose(2).toString(); // 'D A'
|
|
672
|
+
* ```
|
|
673
|
+
*/
|
|
674
|
+
transpose(semitones: number): Progression;
|
|
675
|
+
/**
|
|
676
|
+
* The chord symbols separated by spaces, so a template literal or a log line
|
|
677
|
+
* reads as the progression.
|
|
678
|
+
*
|
|
679
|
+
* @returns The symbols in order, e.g. `'C Am F G'`.
|
|
680
|
+
*/
|
|
681
|
+
toString(): string;
|
|
682
|
+
/**
|
|
683
|
+
* The plain progression data, for JSON serialization.
|
|
684
|
+
*
|
|
685
|
+
* Private class fields do not serialize, so this preserves both the chord
|
|
686
|
+
* data and any carried key in `JSON.stringify(progression)`.
|
|
687
|
+
*
|
|
688
|
+
* @returns The chord data sequence and the carried key, if any.
|
|
689
|
+
*/
|
|
342
690
|
toJSON(): {
|
|
343
691
|
chords: Chord$1[];
|
|
344
692
|
key: {
|
|
@@ -375,10 +723,11 @@ declare class Chord {
|
|
|
375
723
|
*
|
|
376
724
|
* @param root Root as a note name (e.g. `'Eb'`) or a pitch class.
|
|
377
725
|
* @param quality The chord quality.
|
|
378
|
-
* @param bass Optional slash-chord bass
|
|
726
|
+
* @param bass Optional slash-chord bass, as a note name (e.g. `'Bb'`) or a
|
|
727
|
+
* pitch class. A named bass keeps its own spelling.
|
|
379
728
|
* @returns The chord (without key context).
|
|
380
729
|
*/
|
|
381
|
-
static of(root: string | number, quality: ChordQuality, bass?: number): Chord;
|
|
730
|
+
static of(root: string | number, quality: ChordQuality, bass?: string | number): Chord;
|
|
382
731
|
/**
|
|
383
732
|
* Wrap an existing plain chord object.
|
|
384
733
|
*
|
|
@@ -386,6 +735,24 @@ declare class Chord {
|
|
|
386
735
|
* @returns The wrapped chord (without key context).
|
|
387
736
|
*/
|
|
388
737
|
static from(data: Chord$1): Chord;
|
|
738
|
+
/**
|
|
739
|
+
* Alias of {@link Chord.from}, matching the `fromData` factory on the other
|
|
740
|
+
* classes.
|
|
741
|
+
*
|
|
742
|
+
* @param data The plain chord.
|
|
743
|
+
* @returns The wrapped chord (without key context).
|
|
744
|
+
*/
|
|
745
|
+
static fromData(data: Chord$1): Chord;
|
|
746
|
+
/**
|
|
747
|
+
* Rebuild a chord from its {@link Chord.toJSON} output.
|
|
748
|
+
*
|
|
749
|
+
* The key context is not serialized, so the result carries none; re-attach
|
|
750
|
+
* one with {@link Chord.withKey}.
|
|
751
|
+
*
|
|
752
|
+
* @param data The serialized chord.
|
|
753
|
+
* @returns The wrapped chord.
|
|
754
|
+
*/
|
|
755
|
+
static fromJSON(data: Chord$1): Chord;
|
|
389
756
|
/**
|
|
390
757
|
* Parse a lead-sheet chord symbol (e.g. `'Cmaj7'`, `'F#m7b5'`, `'C/G'`).
|
|
391
758
|
*
|
|
@@ -398,16 +765,40 @@ declare class Chord {
|
|
|
398
765
|
* Identify the chords matching a set of pitches, best interpretation first.
|
|
399
766
|
*
|
|
400
767
|
* @param pitches MIDI pitches or bare pitch classes.
|
|
768
|
+
* @param opts How to interpret the input; see {@link DetectChordOptions}.
|
|
401
769
|
* @returns Ranked chord interpretations (may be empty).
|
|
402
770
|
*/
|
|
403
|
-
static detect(pitches: number[], opts?: DetectChordOptions): Chord[];
|
|
771
|
+
static detect(pitches: readonly number[], opts?: DetectChordOptions): Chord[];
|
|
772
|
+
/**
|
|
773
|
+
* Identify the chords matching a set of pitches, keeping each match's
|
|
774
|
+
* recognition metadata beside the chord.
|
|
775
|
+
*
|
|
776
|
+
* {@link Chord.detect} discards the confidence signals a recognition UI needs
|
|
777
|
+
* — whether the set matched exactly, which chord tones were missing, which
|
|
778
|
+
* input notes were foreign, and which inversion the bass implies.
|
|
779
|
+
*
|
|
780
|
+
* @param pitches MIDI pitches or bare pitch classes.
|
|
781
|
+
* @param opts How to interpret the input; see {@link DetectChordOptions}.
|
|
782
|
+
* @returns Ranked interpretations, each with its chord and its match record.
|
|
783
|
+
* @example
|
|
784
|
+
* ```ts
|
|
785
|
+
* import { Chord } from '@libraz/libcantus';
|
|
786
|
+
* const [best] = Chord.detectMatches([60, 64, 67]);
|
|
787
|
+
* best?.match.exact; // true
|
|
788
|
+
* ```
|
|
789
|
+
*/
|
|
790
|
+
static detectMatches(pitches: readonly number[], opts?: DetectChordOptions): {
|
|
791
|
+
chord: Chord;
|
|
792
|
+
match: ChordMatch;
|
|
793
|
+
}[];
|
|
404
794
|
/**
|
|
405
795
|
* The single best chord interpretation of a pitch set.
|
|
406
796
|
*
|
|
407
797
|
* @param pitches MIDI pitches or bare pitch classes.
|
|
798
|
+
* @param opts How to interpret the input; see {@link DetectChordOptions}.
|
|
408
799
|
* @returns The top-ranked chord, or null when nothing matches.
|
|
409
800
|
*/
|
|
410
|
-
static detectBest(pitches: number[], opts?: DetectChordOptions): Chord | null;
|
|
801
|
+
static detectBest(pitches: readonly number[], opts?: DetectChordOptions): Chord | null;
|
|
411
802
|
/** The root pitch class (0..11). */
|
|
412
803
|
get rootPc(): number;
|
|
413
804
|
/** The chord quality. */
|
|
@@ -416,13 +807,22 @@ declare class Chord {
|
|
|
416
807
|
get intervals(): number[];
|
|
417
808
|
/** The slash-chord bass pitch class, or undefined in root position. */
|
|
418
809
|
get bassPc(): number | undefined;
|
|
419
|
-
/**
|
|
810
|
+
/**
|
|
811
|
+
* A copy of the underlying plain chord object, including the spellings
|
|
812
|
+
* derived from any attached key.
|
|
813
|
+
*/
|
|
420
814
|
get data(): Chord$1;
|
|
421
815
|
/** The carried key context, if any. */
|
|
422
816
|
get key(): Key | undefined;
|
|
423
817
|
/**
|
|
424
818
|
* A copy of this chord carrying the given key context.
|
|
425
819
|
*
|
|
820
|
+
* Only a spelling the caller supplied (via `Chord.parse`, `Chord.of` with a
|
|
821
|
+
* named root, or plain data carrying a hint) survives; a spelling that came
|
|
822
|
+
* from a previously attached key is re-derived, so re-keying a progression
|
|
823
|
+
* during a modulation does not keep the old key's letters and the order of
|
|
824
|
+
* `withKey` calls does not affect the result.
|
|
825
|
+
*
|
|
426
826
|
* @param key The key context to attach.
|
|
427
827
|
* @returns The new chord.
|
|
428
828
|
*/
|
|
@@ -437,10 +837,11 @@ declare class Chord {
|
|
|
437
837
|
* The chord's Roman numeral in a key.
|
|
438
838
|
*
|
|
439
839
|
* @param key Key to analyze in; falls back to the carried context.
|
|
840
|
+
* @param opts Applied-numeral rendering options.
|
|
440
841
|
* @returns The Roman numeral string.
|
|
441
842
|
* @throws If no key is given and none is carried.
|
|
442
843
|
*/
|
|
443
|
-
roman(key?: Key): string;
|
|
844
|
+
roman(key?: Key, opts?: ChordToRomanOptions): string;
|
|
444
845
|
/**
|
|
445
846
|
* The chord's harmonic function (tonic / subdominant / dominant) in a key.
|
|
446
847
|
*
|
|
@@ -453,10 +854,11 @@ declare class Chord {
|
|
|
453
854
|
* Full functional analysis: function, borrowing, and Roman numeral.
|
|
454
855
|
*
|
|
455
856
|
* @param key Key to analyze in; falls back to the carried context.
|
|
857
|
+
* @param opts Applied-numeral rendering options.
|
|
456
858
|
* @returns The chord analysis.
|
|
457
859
|
* @throws If no key is given and none is carried.
|
|
458
860
|
*/
|
|
459
|
-
analyze(key?: Key): ChordAnalysis;
|
|
861
|
+
analyze(key?: Key, opts?: ChordToRomanOptions): ChordAnalysis;
|
|
460
862
|
/**
|
|
461
863
|
* Whether the chord is borrowed from the parallel mode (modal interchange).
|
|
462
864
|
*
|
|
@@ -485,6 +887,9 @@ declare class Chord {
|
|
|
485
887
|
/**
|
|
486
888
|
* Realize the chord as one MIDI pitch per voice, ascending.
|
|
487
889
|
*
|
|
890
|
+
* A chord that carries a key passes it to the voicer, so the leading tone is
|
|
891
|
+
* not doubled; an explicit `opts.key` overrides it.
|
|
892
|
+
*
|
|
488
893
|
* @param opts Voicing options; defaults to four SATB voices.
|
|
489
894
|
* @returns MIDI pitches, ascending, one per voice.
|
|
490
895
|
* @throws If no voicing fits the given ranges.
|
|
@@ -521,6 +926,23 @@ declare class Chord {
|
|
|
521
926
|
* @throws If the chord has no intervals.
|
|
522
927
|
*/
|
|
523
928
|
invert(n: number): Chord;
|
|
929
|
+
/**
|
|
930
|
+
* Transpose the chord by a number of semitones.
|
|
931
|
+
*
|
|
932
|
+
* The quality and interval template are carried over, so a chord that a
|
|
933
|
+
* symbol round-trip could not express — a custom interval set, an inversion —
|
|
934
|
+
* survives. A carried key moves with the chord, so the transposed chord keeps
|
|
935
|
+
* the same degree and function inside the transposed key.
|
|
936
|
+
*
|
|
937
|
+
* @param semitones The signed semitone offset.
|
|
938
|
+
* @returns The transposed chord, in the transposed key when one is carried.
|
|
939
|
+
* @example
|
|
940
|
+
* ```ts
|
|
941
|
+
* import { Chord } from '@libraz/libcantus';
|
|
942
|
+
* Chord.parse('C/G').transpose(2).symbol(); // 'D/A'
|
|
943
|
+
* ```
|
|
944
|
+
*/
|
|
945
|
+
transpose(semitones: number): Chord;
|
|
524
946
|
/**
|
|
525
947
|
* The named scales that fit over this chord, best fit first, rooted on the
|
|
526
948
|
* chord root.
|
|
@@ -534,23 +956,36 @@ declare class Chord {
|
|
|
534
956
|
*
|
|
535
957
|
* @param scaleName A named scale, rooted on the chord root.
|
|
536
958
|
* @returns Tension pitch classes, ascending in [0, 11].
|
|
959
|
+
* @throws If `scaleName` is not a built-in scale.
|
|
537
960
|
*/
|
|
538
|
-
tensions(scaleName:
|
|
961
|
+
tensions(scaleName: ScaleNameInput): number[];
|
|
539
962
|
/**
|
|
540
963
|
* The avoid notes (scale tones a semitone above a chord tone) of a scale
|
|
541
964
|
* over this chord.
|
|
542
965
|
*
|
|
543
966
|
* @param scaleName A named scale, rooted on the chord root.
|
|
544
967
|
* @returns Avoid-note pitch classes, ascending in [0, 11].
|
|
968
|
+
* @throws If `scaleName` is not a built-in scale.
|
|
545
969
|
*/
|
|
546
|
-
avoidNotes(scaleName:
|
|
970
|
+
avoidNotes(scaleName: ScaleNameInput): number[];
|
|
547
971
|
/**
|
|
548
972
|
* Spell the chord tones with letter names, root first, in the key's spelling.
|
|
549
973
|
*
|
|
974
|
+
* A chord that already knows how its root is spelled — one from
|
|
975
|
+
* `Chord.parse`, or `Chord.of` with a named root — can spell itself with no
|
|
976
|
+
* key at all; a key is only needed to choose a spelling for a bare pitch
|
|
977
|
+
* class.
|
|
978
|
+
*
|
|
979
|
+
* A slash bass outside the chord tones is appended, so the spelled notes
|
|
980
|
+
* are the notes the chord sounds — the same set {@link Chord.pitchClasses}
|
|
981
|
+
* reports.
|
|
982
|
+
*
|
|
550
983
|
* @param key Key providing the spelled tonic; falls back to the carried
|
|
551
|
-
* context.
|
|
552
|
-
* @returns Spelled octave-less notes in the chord's own (tertian) order
|
|
553
|
-
*
|
|
984
|
+
* context, then to the chord's own root spelling.
|
|
985
|
+
* @returns Spelled octave-less notes in the chord's own (tertian) order,
|
|
986
|
+
* with any foreign slash bass last.
|
|
987
|
+
* @throws If no key is given, none is carried, and the chord has no root
|
|
988
|
+
* spelling of its own.
|
|
554
989
|
*/
|
|
555
990
|
spell(key?: Key): Note[];
|
|
556
991
|
/**
|
|
@@ -575,57 +1010,12 @@ declare class Chord {
|
|
|
575
1010
|
* @returns A copy of the underlying plain chord object.
|
|
576
1011
|
*/
|
|
577
1012
|
toJSON(): Chord$1;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
/**
|
|
581
|
-
* An immutable spelled interval value: a diatonic number, a quality label, and
|
|
582
|
-
* a signed semitone span. A thin convenience wrapper over the pitch module's
|
|
583
|
-
* plain interval result.
|
|
584
|
-
*
|
|
585
|
-
* @category Class API
|
|
586
|
-
* @example
|
|
587
|
-
* ```ts
|
|
588
|
-
* import { Interval, Note } from '@libraz/libcantus';
|
|
589
|
-
* Interval.between(Note.of('C4'), Note.of('G4')).name; // 'P5'
|
|
590
|
-
* ```
|
|
591
|
-
*/
|
|
592
|
-
declare class Interval {
|
|
593
|
-
#private;
|
|
594
|
-
private constructor();
|
|
595
1013
|
/**
|
|
596
|
-
* The
|
|
597
|
-
*
|
|
598
|
-
* @param a The first note.
|
|
599
|
-
* @param b The second note.
|
|
600
|
-
* @returns The interval from `a` to `b`.
|
|
601
|
-
*/
|
|
602
|
-
static between(a: Note, b: Note): Interval;
|
|
603
|
-
/**
|
|
604
|
-
* Build an interval from explicit components.
|
|
605
|
-
*
|
|
606
|
-
* @param numberValue Diatonic size: 1 = unison, 2 = second, ... 8 = octave.
|
|
607
|
-
* @param quality Quality label: `'P'`, `'M'`, `'m'`, or repeated `'A'`/`'d'`.
|
|
608
|
-
* @param semitones Signed semitone span.
|
|
609
|
-
* @returns The interval.
|
|
610
|
-
*/
|
|
611
|
-
static of(numberValue: number, quality: string, semitones: number): Interval;
|
|
612
|
-
/** Diatonic size: 1 = unison, 2 = second, ... 8 = octave, and beyond. */
|
|
613
|
-
get number(): number;
|
|
614
|
-
/** Quality label: `'P'`, `'M'`, `'m'`, or repeated `'A'`/`'d'`. */
|
|
615
|
-
get quality(): string;
|
|
616
|
-
/** Signed semitone span. */
|
|
617
|
-
get semitones(): number;
|
|
618
|
-
/** A readable label composed of quality and number, e.g. `'P5'` or `'M3'`. */
|
|
619
|
-
get name(): string;
|
|
620
|
-
/**
|
|
621
|
-
* The plain interval data, for JSON serialization.
|
|
1014
|
+
* The chord symbol, so a template literal or a log line reads as the chord.
|
|
622
1015
|
*
|
|
623
|
-
*
|
|
624
|
-
* `JSON.stringify(interval)` from collapsing to `{}`.
|
|
625
|
-
*
|
|
626
|
-
* @returns The diatonic number, quality, and semitone span.
|
|
1016
|
+
* @returns The symbol, e.g. `'Cmaj7'`.
|
|
627
1017
|
*/
|
|
628
|
-
|
|
1018
|
+
toString(): string;
|
|
629
1019
|
}
|
|
630
1020
|
|
|
631
|
-
export { Chord, Interval, Key, Note, Progression };
|
|
1021
|
+
export { BorrowedSource, Cadence, Chord, ChordAnalysis, Chord$1 as ChordData, ChordMatch, ChordQuality, ChordScaleMatch, ChordSpan, ChordToRomanOptions, DetectChordOptions, DetectKeyOptions, type DetectedKeyMatch, HarmonicFunction, Interval, IntervalQualityLabel, Key, KeyMatch, KeyScale, KeyVariant, Note, Note$1 as NoteData, Progression, ScaleChoice, ScaleNameInput, SpelledInterval, StyledVoicingOptions, VoicingOptions };
|