@libraz/libcantus 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/analyze/index.cjs +315 -42
- package/dist/analyze/index.cjs.map +1 -1
- package/dist/analyze/index.d.cts +11 -99
- package/dist/analyze/index.d.ts +11 -99
- package/dist/analyze/index.js +6 -6
- package/dist/chunk-2ZWMSJH6.js +30 -0
- package/dist/chunk-2ZWMSJH6.js.map +1 -0
- package/dist/{chunk-R3S2LUBH.js → chunk-4MHA432G.js} +316 -184
- package/dist/chunk-4MHA432G.js.map +1 -0
- package/dist/chunk-62QZKCJQ.js +49 -0
- package/dist/chunk-62QZKCJQ.js.map +1 -0
- package/dist/chunk-AKLYPWIN.js +83 -0
- package/dist/chunk-AKLYPWIN.js.map +1 -0
- package/dist/{chunk-XTC3X6MS.js → chunk-C5XYKUVG.js} +100 -12
- package/dist/chunk-C5XYKUVG.js.map +1 -0
- package/dist/{chunk-LN7ZZMD2.js → chunk-CHMXELDS.js} +33 -14
- package/dist/chunk-CHMXELDS.js.map +1 -0
- package/dist/{chunk-A4532ZFR.js → chunk-EH6EM37U.js} +60 -4
- package/dist/chunk-EH6EM37U.js.map +1 -0
- package/dist/chunk-FBQK3ZQN.js +131 -0
- package/dist/chunk-FBQK3ZQN.js.map +1 -0
- package/dist/{chunk-5HTNMQW4.js → chunk-GOAW4VYL.js} +87 -21
- package/dist/chunk-GOAW4VYL.js.map +1 -0
- package/dist/{chunk-MSWFZF7J.js → chunk-I5R7ZBJS.js} +90 -6
- package/dist/chunk-I5R7ZBJS.js.map +1 -0
- package/dist/{chunk-GQKN5KDT.js → chunk-IT2O4XFE.js} +4 -9
- package/dist/chunk-IT2O4XFE.js.map +1 -0
- package/dist/{chunk-7Y7WF64D.js → chunk-MIWO425M.js} +6 -4
- package/dist/chunk-MIWO425M.js.map +1 -0
- package/dist/chunk-N6IHQUOX.js +1 -0
- package/dist/chunk-N6IHQUOX.js.map +1 -0
- package/dist/{chunk-COKTX2G5.js → chunk-SGU7SPLK.js} +29 -12
- package/dist/chunk-SGU7SPLK.js.map +1 -0
- package/dist/core/index.cjs +230 -14
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +56 -4
- package/dist/core/index.d.ts +56 -4
- package/dist/core/index.js +24 -4
- package/dist/{function-2bJW1Zp_.d.ts → function-DVH4Eusr.d.ts} +1 -1
- package/dist/{function-r2sh-jOO.d.cts → function-DYt4iKsn.d.cts} +1 -1
- package/dist/generate/index.cjs +830 -494
- package/dist/generate/index.cjs.map +1 -1
- package/dist/generate/index.d.cts +11 -5
- package/dist/generate/index.d.ts +11 -5
- package/dist/generate/index.js +9 -9
- package/dist/{index-BOBXBNwP.d.cts → index-BNlGP86A.d.cts} +1 -1
- package/dist/{index-CP3wAfEH.d.ts → index-Bg5dYMmZ.d.ts} +1 -1
- package/dist/{index-CM5W4rcm.d.ts → index-Bt4tOUD9.d.ts} +1 -1
- package/dist/index-CnZCo29u.d.cts +108 -0
- package/dist/{index-D_ZTUNKp.d.cts → index-CpOsP1y9.d.cts} +2 -2
- package/dist/{index-DZ1M21do.d.cts → index-CxqBQtH1.d.cts} +2 -1
- package/dist/{index-BdeQ1r_p.d.cts → index-Dikst44v.d.cts} +1 -1
- package/dist/{index-BMPxwjwV.d.ts → index-DxvARIP2.d.ts} +2 -2
- package/dist/{index-BreoJRw0.d.ts → index-Jc0Ryi79.d.ts} +2 -1
- package/dist/index-JnF4v9bx.d.ts +108 -0
- package/dist/index.cjs +818 -283
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +34 -13
- package/dist/model/index.cjs +170 -31
- package/dist/model/index.cjs.map +1 -1
- package/dist/model/index.d.cts +6 -5
- package/dist/model/index.d.ts +6 -5
- package/dist/model/index.js +6 -6
- package/dist/{styled-D7BAx3S3.d.ts → styled-DZ7GjShb.d.ts} +1 -1
- package/dist/{styled-BjXtOFNk.d.cts → styled-ZTbdaVFM.d.cts} +1 -1
- package/dist/theory/index.cjs +180 -34
- package/dist/theory/index.cjs.map +1 -1
- package/dist/theory/index.d.cts +6 -6
- package/dist/theory/index.d.ts +6 -6
- package/dist/theory/index.js +6 -5
- package/package.json +50 -19
- package/src/analyze/arrange/internal.ts +3 -1
- package/src/analyze/arrange/tension.ts +15 -3
- package/src/analyze/arrange/tracks.ts +36 -3
- package/src/analyze/detect/index.ts +46 -9
- package/src/analyze/functional/roman.ts +14 -5
- package/src/analyze/index.ts +1 -1
- package/src/analyze/timeline/index.ts +43 -7
- package/src/analyze/voice/index.ts +11 -2
- package/src/core/event-index/index.ts +104 -0
- package/src/core/index.ts +14 -0
- package/src/core/meter/index.ts +24 -4
- package/src/core/random/index.ts +26 -3
- package/src/core/tuning/index.ts +36 -6
- package/src/core/validation/index.ts +119 -0
- package/src/generate/bass/index.ts +23 -0
- package/src/generate/countermelody/index.ts +167 -76
- package/src/generate/drums/euclid.ts +10 -3
- package/src/generate/drums/index.ts +56 -24
- package/src/generate/drums/percussion.ts +1 -1
- package/src/generate/groove/index.ts +25 -0
- package/src/generate/harmonize/index.ts +55 -44
- package/src/generate/index.ts +0 -1
- package/src/generate/motif/index.ts +45 -21
- package/src/generate/progression/index.ts +8 -16
- package/src/generate/reharmony/index.ts +1 -8
- package/src/generate/rhythm/index.ts +11 -1
- package/src/index.ts +13 -247
- package/src/model/chord.ts +29 -10
- package/src/theory/chord/index.ts +4 -2
- package/src/theory/harmony/index.ts +6 -21
- package/src/theory/index.ts +6 -1
- package/src/theory/safety/index.ts +71 -2
- package/src/theory/spelling/index.ts +70 -3
- package/src/theory/voicing/satb.ts +25 -4
- package/src/theory/voicing/styled.ts +26 -3
- package/dist/chunk-5HTNMQW4.js.map +0 -1
- package/dist/chunk-7Y7WF64D.js.map +0 -1
- package/dist/chunk-A4532ZFR.js.map +0 -1
- package/dist/chunk-BHUT2S5G.js +0 -22
- package/dist/chunk-BHUT2S5G.js.map +0 -1
- package/dist/chunk-CCBLVAPK.js +0 -42
- package/dist/chunk-CCBLVAPK.js.map +0 -1
- package/dist/chunk-COKTX2G5.js.map +0 -1
- package/dist/chunk-GQKN5KDT.js.map +0 -1
- package/dist/chunk-LN7ZZMD2.js.map +0 -1
- package/dist/chunk-MSWFZF7J.js.map +0 -1
- package/dist/chunk-R3S2LUBH.js.map +0 -1
- package/dist/chunk-SDM3VJJ5.js +0 -41
- package/dist/chunk-SDM3VJJ5.js.map +0 -1
- package/dist/chunk-XTC3X6MS.js.map +0 -1
- package/dist/chunk-ZXW5YIWK.js +0 -55
- package/dist/chunk-ZXW5YIWK.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { T as TimeSignature } from '../index-Cl7mhOFM.cjs';
|
|
2
2
|
import { K as KeyScale, N as NoteEvent } from '../types-MGP29r3t.cjs';
|
|
3
|
-
import { C as Chord, a as ChordQuality, b as ChordSpan } from '../index-
|
|
4
|
-
import { H as HarmonyRole } from '../index-
|
|
5
|
-
import { b as ChordTimeline } from '../index-
|
|
6
|
-
import { B as BorrowedSource, H as HarmonicFunction } from '../function-
|
|
3
|
+
import { C as Chord, a as ChordQuality, b as ChordSpan } from '../index-BNlGP86A.cjs';
|
|
4
|
+
import { H as HarmonyRole } from '../index-Dikst44v.cjs';
|
|
5
|
+
import { b as ChordTimeline } from '../index-CpOsP1y9.cjs';
|
|
6
|
+
import { B as BorrowedSource, H as HarmonicFunction } from '../function-DYt4iKsn.cjs';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Deterministic bass-line generation over a chord placement.
|
|
@@ -105,6 +105,12 @@ type CounterMelodyOptions = {
|
|
|
105
105
|
melody: NoteEvent[];
|
|
106
106
|
/** Chord sounding at an absolute beat position, or null when none applies. */
|
|
107
107
|
chordAt: (beat: number) => Chord | null;
|
|
108
|
+
/**
|
|
109
|
+
* Exact chord-change beats exposed by the caller's timeline. The generator
|
|
110
|
+
* also probes its half-beat grid, but callback discontinuities between grid
|
|
111
|
+
* points are not introspectable and should be listed here.
|
|
112
|
+
*/
|
|
113
|
+
chordChangeBeats?: number[];
|
|
108
114
|
/** Key/scale context for scale-tone decisions. */
|
|
109
115
|
key: KeyScale;
|
|
110
116
|
/**
|
|
@@ -977,4 +983,4 @@ declare function generateRhythm(ts: TimeSignature, opts?: RhythmOptions): Rhythm
|
|
|
977
983
|
*/
|
|
978
984
|
declare function rhythmDensity(events: RhythmEvent[], ts: TimeSignature): number;
|
|
979
985
|
|
|
980
|
-
export { type BassLineOptions, type BassSegment, type BassStyle, type BorrowedChord,
|
|
986
|
+
export { type BassLineOptions, type BassSegment, type BassStyle, type BorrowedChord, type CounterMelodyOptions, type DrumHit, type DrumRole, type DrumsOptions, type EuclideanKick, type GrooveFeel, type GrooveSlot, type GrooveStyle, type GrooveTemplate, type HarmonizeOptions, type HarmonizeResult, type HumanizeOptions, type MelodyNote, type MotifCell, type MotifContour, type MotifNote, type MotifOptions, type MotifTransform, type ProgFunction, type ProgStyle, type ProgressionOptions, type ProgressionPreset, type RhythmEvent, type RhythmOptions, type Section, type SubstituteOptions, type Substitution, type SubstitutionType, applyGrooveTemplate, developMotif, extractGrooveTemplate, generateBassLine, generateCounterMelody, generateDrums, generateMotif, generateProgression, generateRhythm, harmonizeMelody, humanize, modalInterchangePalette, negativeHarmonyMirror, onsetWeightCurve, progressions, progressionsByStyle, rhythmDensity, substituteChord, transformMotif };
|
package/dist/generate/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { T as TimeSignature } from '../index-Cl7mhOFM.js';
|
|
2
2
|
import { K as KeyScale, N as NoteEvent } from '../types-MGP29r3t.js';
|
|
3
|
-
import { C as Chord, a as ChordQuality, b as ChordSpan } from '../index-
|
|
4
|
-
import { H as HarmonyRole } from '../index-
|
|
5
|
-
import { b as ChordTimeline } from '../index-
|
|
6
|
-
import { B as BorrowedSource, H as HarmonicFunction } from '../function-
|
|
3
|
+
import { C as Chord, a as ChordQuality, b as ChordSpan } from '../index-Bt4tOUD9.js';
|
|
4
|
+
import { H as HarmonyRole } from '../index-Bg5dYMmZ.js';
|
|
5
|
+
import { b as ChordTimeline } from '../index-DxvARIP2.js';
|
|
6
|
+
import { B as BorrowedSource, H as HarmonicFunction } from '../function-DVH4Eusr.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Deterministic bass-line generation over a chord placement.
|
|
@@ -105,6 +105,12 @@ type CounterMelodyOptions = {
|
|
|
105
105
|
melody: NoteEvent[];
|
|
106
106
|
/** Chord sounding at an absolute beat position, or null when none applies. */
|
|
107
107
|
chordAt: (beat: number) => Chord | null;
|
|
108
|
+
/**
|
|
109
|
+
* Exact chord-change beats exposed by the caller's timeline. The generator
|
|
110
|
+
* also probes its half-beat grid, but callback discontinuities between grid
|
|
111
|
+
* points are not introspectable and should be listed here.
|
|
112
|
+
*/
|
|
113
|
+
chordChangeBeats?: number[];
|
|
108
114
|
/** Key/scale context for scale-tone decisions. */
|
|
109
115
|
key: KeyScale;
|
|
110
116
|
/**
|
|
@@ -977,4 +983,4 @@ declare function generateRhythm(ts: TimeSignature, opts?: RhythmOptions): Rhythm
|
|
|
977
983
|
*/
|
|
978
984
|
declare function rhythmDensity(events: RhythmEvent[], ts: TimeSignature): number;
|
|
979
985
|
|
|
980
|
-
export { type BassLineOptions, type BassSegment, type BassStyle, type BorrowedChord,
|
|
986
|
+
export { type BassLineOptions, type BassSegment, type BassStyle, type BorrowedChord, type CounterMelodyOptions, type DrumHit, type DrumRole, type DrumsOptions, type EuclideanKick, type GrooveFeel, type GrooveSlot, type GrooveStyle, type GrooveTemplate, type HarmonizeOptions, type HarmonizeResult, type HumanizeOptions, type MelodyNote, type MotifCell, type MotifContour, type MotifNote, type MotifOptions, type MotifTransform, type ProgFunction, type ProgStyle, type ProgressionOptions, type ProgressionPreset, type RhythmEvent, type RhythmOptions, type Section, type SubstituteOptions, type Substitution, type SubstitutionType, applyGrooveTemplate, developMotif, extractGrooveTemplate, generateBassLine, generateCounterMelody, generateDrums, generateMotif, generateProgression, generateRhythm, harmonizeMelody, humanize, modalInterchangePalette, negativeHarmonyMirror, onsetWeightCurve, progressions, progressionsByStyle, rhythmDensity, substituteChord, transformMotif };
|
package/dist/generate/index.js
CHANGED
|
@@ -15,19 +15,19 @@ import {
|
|
|
15
15
|
progressionsByStyle,
|
|
16
16
|
rhythmDensity,
|
|
17
17
|
transformMotif
|
|
18
|
-
} from "../chunk-
|
|
19
|
-
import "../chunk-
|
|
20
|
-
import "../chunk-
|
|
18
|
+
} from "../chunk-4MHA432G.js";
|
|
19
|
+
import "../chunk-62QZKCJQ.js";
|
|
20
|
+
import "../chunk-I5R7ZBJS.js";
|
|
21
21
|
import {
|
|
22
22
|
modalInterchangePalette,
|
|
23
23
|
negativeHarmonyMirror,
|
|
24
24
|
substituteChord
|
|
25
|
-
} from "../chunk-
|
|
26
|
-
import "../chunk-
|
|
27
|
-
import "../chunk-
|
|
28
|
-
import "../chunk-
|
|
29
|
-
import "../chunk-
|
|
30
|
-
import "../chunk-
|
|
25
|
+
} from "../chunk-IT2O4XFE.js";
|
|
26
|
+
import "../chunk-CHMXELDS.js";
|
|
27
|
+
import "../chunk-2ZWMSJH6.js";
|
|
28
|
+
import "../chunk-EH6EM37U.js";
|
|
29
|
+
import "../chunk-MIWO425M.js";
|
|
30
|
+
import "../chunk-FBQK3ZQN.js";
|
|
31
31
|
export {
|
|
32
32
|
applyGrooveTemplate,
|
|
33
33
|
developMotif,
|
|
@@ -154,4 +154,4 @@ declare function diatonicTriad(degree: number, key: KeyScale): Chord;
|
|
|
154
154
|
*/
|
|
155
155
|
declare function diatonicSeventh(degree: number, key: KeyScale): Chord;
|
|
156
156
|
|
|
157
|
-
export { type Chord as C, type ChordQuality as a, type ChordSpan as b, chordFromDegree as c, chordPitchClasses as d, chordQualities as e, chordToneRole as f, diatonicSeventh as g, diatonicTriad as h, makeChord as m };
|
|
157
|
+
export { type Chord as C, type PitchSpelling as P, type ChordQuality as a, type ChordSpan as b, chordFromDegree as c, chordPitchClasses as d, chordQualities as e, chordToneRole as f, diatonicSeventh as g, diatonicTriad as h, makeChord as m };
|
|
@@ -154,4 +154,4 @@ declare function diatonicTriad(degree: number, key: KeyScale): Chord;
|
|
|
154
154
|
*/
|
|
155
155
|
declare function diatonicSeventh(degree: number, key: KeyScale): Chord;
|
|
156
156
|
|
|
157
|
-
export { type Chord as C, type ChordQuality as a, type ChordSpan as b, chordFromDegree as c, chordPitchClasses as d, chordQualities as e, chordToneRole as f, diatonicSeventh as g, diatonicTriad as h, makeChord as m };
|
|
157
|
+
export { type Chord as C, type PitchSpelling as P, type ChordQuality as a, type ChordSpan as b, chordFromDegree as c, chordPitchClasses as d, chordQualities as e, chordToneRole as f, diatonicSeventh as g, diatonicTriad as h, makeChord as m };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { K as KeyScale } from './types-MGP29r3t.cjs';
|
|
2
|
+
import { a as ChordQuality, C as Chord } from './index-BNlGP86A.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Recognition: infer a chord name from a set of pitches, or a key from a set of
|
|
6
|
+
* pitch classes. This is the inverse direction of the chord/scale builders,
|
|
7
|
+
* which only go name -> notes.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A candidate chord interpretation of a pitch set.
|
|
12
|
+
*
|
|
13
|
+
* @category Recognition
|
|
14
|
+
*/
|
|
15
|
+
type ChordMatch = {
|
|
16
|
+
rootPc: number;
|
|
17
|
+
quality: ChordQuality;
|
|
18
|
+
/** Chord tones absent from the input (an incomplete voicing). */
|
|
19
|
+
missingPcs: number[];
|
|
20
|
+
/** Input pitch classes not belonging to the chord. */
|
|
21
|
+
extraPcs: number[];
|
|
22
|
+
/** True when the input pitch-class set equals the chord exactly. */
|
|
23
|
+
exact: boolean;
|
|
24
|
+
/** Inversion implied by a known bass, or null for an unordered pitch-class set. */
|
|
25
|
+
inversion: number | null;
|
|
26
|
+
/** Bass pitch class when inverted (the lowest note is not the root). */
|
|
27
|
+
bassPc?: number;
|
|
28
|
+
};
|
|
29
|
+
/** Input interpretation for {@link detectChord} and {@link detectChordBest}. */
|
|
30
|
+
type DetectChordOptions = {
|
|
31
|
+
/**
|
|
32
|
+
* `midi` uses the numerically lowest pitch as bass; `pitchClass` treats the
|
|
33
|
+
* input as unordered. `auto` (default) selects pitch-class mode only when all
|
|
34
|
+
* values lie in 0..11.
|
|
35
|
+
*/
|
|
36
|
+
input?: 'auto' | 'midi' | 'pitchClass';
|
|
37
|
+
/** Explicit bass pitch class, including for an unordered pitch-class set. */
|
|
38
|
+
bassPc?: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* A candidate key interpretation of a pitch-class set.
|
|
42
|
+
*
|
|
43
|
+
* @category Recognition
|
|
44
|
+
*/
|
|
45
|
+
type KeyMatch = {
|
|
46
|
+
key: KeyScale;
|
|
47
|
+
mode: 'major' | 'minor';
|
|
48
|
+
/** Fraction of input pitch classes that are in the scale, in [0, 1]. */
|
|
49
|
+
fit: number;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Identify chords matching a set of pitches.
|
|
53
|
+
*
|
|
54
|
+
* Every input pitch class is tried as a root against every known chord quality.
|
|
55
|
+
* A match is reported when all of the chord's tones are present in the input, or
|
|
56
|
+
* when the only absent tone is the perfect fifth (a common omission in shell
|
|
57
|
+
* voicings); matches are ranked best-first by fewest extra notes, then fewest
|
|
58
|
+
* missing notes, then most specific (largest) chord. An exact match (no extras,
|
|
59
|
+
* no missing) is flagged and ranked first.
|
|
60
|
+
*
|
|
61
|
+
* @param pitches MIDI pitches or bare pitch classes (octave-agnostic).
|
|
62
|
+
* @returns Ranked chord interpretations (may be empty).
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* import { detectChord } from '@libraz/libcantus';
|
|
66
|
+
* const matches = detectChord([60, 64, 67]); // C E G
|
|
67
|
+
* matches[0]; // { rootPc: 0, quality: 'maj', exact: true, ... }
|
|
68
|
+
* ```
|
|
69
|
+
* @category Recognition
|
|
70
|
+
*/
|
|
71
|
+
declare function detectChord(pitches: number[], opts?: DetectChordOptions): ChordMatch[];
|
|
72
|
+
/**
|
|
73
|
+
* The single best chord interpretation of a pitch set, or null if none.
|
|
74
|
+
*
|
|
75
|
+
* @param pitches MIDI pitches or bare pitch classes.
|
|
76
|
+
* @returns The top-ranked chord, or null when nothing matches.
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* import { detectChordBest } from '@libraz/libcantus';
|
|
80
|
+
* detectChordBest([60, 64, 67]); // C major triad: { rootPc: 0, quality: 'maj', ... }
|
|
81
|
+
* ```
|
|
82
|
+
* @category Recognition
|
|
83
|
+
*/
|
|
84
|
+
declare function detectChordBest(pitches: number[], opts?: DetectChordOptions): Chord | null;
|
|
85
|
+
/**
|
|
86
|
+
* Rank major and minor keys by how well they contain a set of pitch classes.
|
|
87
|
+
*
|
|
88
|
+
* The tonic is weighted so that, among equally-fitting keys, the one whose root
|
|
89
|
+
* appears in the input is preferred. Minor candidates are scored against the
|
|
90
|
+
* natural, harmonic, and melodic minor variants and keep the best of the three,
|
|
91
|
+
* so a minor cadence containing the leading tone still resolves to its own
|
|
92
|
+
* tonic; the returned key is always the natural-minor scale. Returns all 24
|
|
93
|
+
* keys ranked best-first, or an empty array for an empty input (mirroring
|
|
94
|
+
* {@link detectChord}).
|
|
95
|
+
*
|
|
96
|
+
* @param pitches MIDI pitches or bare pitch classes.
|
|
97
|
+
* @returns Ranked key interpretations (empty for an empty input).
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* import { detectKey } from '@libraz/libcantus';
|
|
101
|
+
* const keys = detectKey([60, 62, 64, 65, 67, 69, 71]); // C major scale
|
|
102
|
+
* keys[0].mode; // 'major', with keys[0].key.rootPc === 0
|
|
103
|
+
* ```
|
|
104
|
+
* @category Recognition
|
|
105
|
+
*/
|
|
106
|
+
declare function detectKey(pitches: number[]): KeyMatch[];
|
|
107
|
+
|
|
108
|
+
export { type ChordMatch as C, type DetectChordOptions as D, type KeyMatch as K, detectChordBest as a, detectKey as b, detectChord as d };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { T as TimeSignature } from './index-Cl7mhOFM.cjs';
|
|
2
2
|
import { K as KeyScale, N as NoteEvent } from './types-MGP29r3t.cjs';
|
|
3
|
-
import { C as Chord, b as ChordSpan } from './index-
|
|
4
|
-
import { C as Cadence } from './function-
|
|
3
|
+
import { C as Chord, b as ChordSpan } from './index-BNlGP86A.cjs';
|
|
4
|
+
import { C as Cadence } from './function-DYt4iKsn.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* A chord occupying a half-open beat span.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { K as KeyScale } from './types-MGP29r3t.cjs';
|
|
2
|
-
import { C as Chord } from './index-
|
|
2
|
+
import { C as Chord } from './index-BNlGP86A.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Severity policy: `strict` counterpoint vs. lenient `pop` voice-leading.
|
|
@@ -110,6 +110,7 @@ declare function evaluateSafety(q: SafetyQuery): SafetyResult;
|
|
|
110
110
|
* @param pitchLow Lowest MIDI pitch to consider (inclusive).
|
|
111
111
|
* @param pitchHigh Highest MIDI pitch to consider (inclusive).
|
|
112
112
|
* @returns Placeable pitches (non-dissonant), chord tones before others, each group descending.
|
|
113
|
+
* @throws If either bound is non-finite/non-integral, reversed, or exceeds the generation budget.
|
|
113
114
|
* @example
|
|
114
115
|
* ```ts
|
|
115
116
|
* import { enumerateSafePitches, makeChord, majorKey } from '@libraz/libcantus';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { T as TimeSignature } from './index-Cl7mhOFM.js';
|
|
2
2
|
import { K as KeyScale, N as NoteEvent } from './types-MGP29r3t.js';
|
|
3
|
-
import { C as Chord, b as ChordSpan } from './index-
|
|
4
|
-
import { C as Cadence } from './function-
|
|
3
|
+
import { C as Chord, b as ChordSpan } from './index-Bt4tOUD9.js';
|
|
4
|
+
import { C as Cadence } from './function-DVH4Eusr.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* A chord occupying a half-open beat span.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { K as KeyScale } from './types-MGP29r3t.js';
|
|
2
|
-
import { C as Chord } from './index-
|
|
2
|
+
import { C as Chord } from './index-Bt4tOUD9.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Severity policy: `strict` counterpoint vs. lenient `pop` voice-leading.
|
|
@@ -110,6 +110,7 @@ declare function evaluateSafety(q: SafetyQuery): SafetyResult;
|
|
|
110
110
|
* @param pitchLow Lowest MIDI pitch to consider (inclusive).
|
|
111
111
|
* @param pitchHigh Highest MIDI pitch to consider (inclusive).
|
|
112
112
|
* @returns Placeable pitches (non-dissonant), chord tones before others, each group descending.
|
|
113
|
+
* @throws If either bound is non-finite/non-integral, reversed, or exceeds the generation budget.
|
|
113
114
|
* @example
|
|
114
115
|
* ```ts
|
|
115
116
|
* import { enumerateSafePitches, makeChord, majorKey } from '@libraz/libcantus';
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { K as KeyScale } from './types-MGP29r3t.js';
|
|
2
|
+
import { a as ChordQuality, C as Chord } from './index-Bt4tOUD9.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Recognition: infer a chord name from a set of pitches, or a key from a set of
|
|
6
|
+
* pitch classes. This is the inverse direction of the chord/scale builders,
|
|
7
|
+
* which only go name -> notes.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A candidate chord interpretation of a pitch set.
|
|
12
|
+
*
|
|
13
|
+
* @category Recognition
|
|
14
|
+
*/
|
|
15
|
+
type ChordMatch = {
|
|
16
|
+
rootPc: number;
|
|
17
|
+
quality: ChordQuality;
|
|
18
|
+
/** Chord tones absent from the input (an incomplete voicing). */
|
|
19
|
+
missingPcs: number[];
|
|
20
|
+
/** Input pitch classes not belonging to the chord. */
|
|
21
|
+
extraPcs: number[];
|
|
22
|
+
/** True when the input pitch-class set equals the chord exactly. */
|
|
23
|
+
exact: boolean;
|
|
24
|
+
/** Inversion implied by a known bass, or null for an unordered pitch-class set. */
|
|
25
|
+
inversion: number | null;
|
|
26
|
+
/** Bass pitch class when inverted (the lowest note is not the root). */
|
|
27
|
+
bassPc?: number;
|
|
28
|
+
};
|
|
29
|
+
/** Input interpretation for {@link detectChord} and {@link detectChordBest}. */
|
|
30
|
+
type DetectChordOptions = {
|
|
31
|
+
/**
|
|
32
|
+
* `midi` uses the numerically lowest pitch as bass; `pitchClass` treats the
|
|
33
|
+
* input as unordered. `auto` (default) selects pitch-class mode only when all
|
|
34
|
+
* values lie in 0..11.
|
|
35
|
+
*/
|
|
36
|
+
input?: 'auto' | 'midi' | 'pitchClass';
|
|
37
|
+
/** Explicit bass pitch class, including for an unordered pitch-class set. */
|
|
38
|
+
bassPc?: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* A candidate key interpretation of a pitch-class set.
|
|
42
|
+
*
|
|
43
|
+
* @category Recognition
|
|
44
|
+
*/
|
|
45
|
+
type KeyMatch = {
|
|
46
|
+
key: KeyScale;
|
|
47
|
+
mode: 'major' | 'minor';
|
|
48
|
+
/** Fraction of input pitch classes that are in the scale, in [0, 1]. */
|
|
49
|
+
fit: number;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Identify chords matching a set of pitches.
|
|
53
|
+
*
|
|
54
|
+
* Every input pitch class is tried as a root against every known chord quality.
|
|
55
|
+
* A match is reported when all of the chord's tones are present in the input, or
|
|
56
|
+
* when the only absent tone is the perfect fifth (a common omission in shell
|
|
57
|
+
* voicings); matches are ranked best-first by fewest extra notes, then fewest
|
|
58
|
+
* missing notes, then most specific (largest) chord. An exact match (no extras,
|
|
59
|
+
* no missing) is flagged and ranked first.
|
|
60
|
+
*
|
|
61
|
+
* @param pitches MIDI pitches or bare pitch classes (octave-agnostic).
|
|
62
|
+
* @returns Ranked chord interpretations (may be empty).
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* import { detectChord } from '@libraz/libcantus';
|
|
66
|
+
* const matches = detectChord([60, 64, 67]); // C E G
|
|
67
|
+
* matches[0]; // { rootPc: 0, quality: 'maj', exact: true, ... }
|
|
68
|
+
* ```
|
|
69
|
+
* @category Recognition
|
|
70
|
+
*/
|
|
71
|
+
declare function detectChord(pitches: number[], opts?: DetectChordOptions): ChordMatch[];
|
|
72
|
+
/**
|
|
73
|
+
* The single best chord interpretation of a pitch set, or null if none.
|
|
74
|
+
*
|
|
75
|
+
* @param pitches MIDI pitches or bare pitch classes.
|
|
76
|
+
* @returns The top-ranked chord, or null when nothing matches.
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* import { detectChordBest } from '@libraz/libcantus';
|
|
80
|
+
* detectChordBest([60, 64, 67]); // C major triad: { rootPc: 0, quality: 'maj', ... }
|
|
81
|
+
* ```
|
|
82
|
+
* @category Recognition
|
|
83
|
+
*/
|
|
84
|
+
declare function detectChordBest(pitches: number[], opts?: DetectChordOptions): Chord | null;
|
|
85
|
+
/**
|
|
86
|
+
* Rank major and minor keys by how well they contain a set of pitch classes.
|
|
87
|
+
*
|
|
88
|
+
* The tonic is weighted so that, among equally-fitting keys, the one whose root
|
|
89
|
+
* appears in the input is preferred. Minor candidates are scored against the
|
|
90
|
+
* natural, harmonic, and melodic minor variants and keep the best of the three,
|
|
91
|
+
* so a minor cadence containing the leading tone still resolves to its own
|
|
92
|
+
* tonic; the returned key is always the natural-minor scale. Returns all 24
|
|
93
|
+
* keys ranked best-first, or an empty array for an empty input (mirroring
|
|
94
|
+
* {@link detectChord}).
|
|
95
|
+
*
|
|
96
|
+
* @param pitches MIDI pitches or bare pitch classes.
|
|
97
|
+
* @returns Ranked key interpretations (empty for an empty input).
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* import { detectKey } from '@libraz/libcantus';
|
|
101
|
+
* const keys = detectKey([60, 62, 64, 65, 67, 69, 71]); // C major scale
|
|
102
|
+
* keys[0].mode; // 'major', with keys[0].key.rootPc === 0
|
|
103
|
+
* ```
|
|
104
|
+
* @category Recognition
|
|
105
|
+
*/
|
|
106
|
+
declare function detectKey(pitches: number[]): KeyMatch[];
|
|
107
|
+
|
|
108
|
+
export { type ChordMatch as C, type DetectChordOptions as D, type KeyMatch as K, detectChordBest as a, detectKey as b, detectChord as d };
|