@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.
Files changed (126) hide show
  1. package/README.md +4 -3
  2. package/dist/analyze/index.cjs +315 -42
  3. package/dist/analyze/index.cjs.map +1 -1
  4. package/dist/analyze/index.d.cts +11 -99
  5. package/dist/analyze/index.d.ts +11 -99
  6. package/dist/analyze/index.js +6 -6
  7. package/dist/chunk-2ZWMSJH6.js +30 -0
  8. package/dist/chunk-2ZWMSJH6.js.map +1 -0
  9. package/dist/{chunk-R3S2LUBH.js → chunk-4MHA432G.js} +316 -184
  10. package/dist/chunk-4MHA432G.js.map +1 -0
  11. package/dist/chunk-62QZKCJQ.js +49 -0
  12. package/dist/chunk-62QZKCJQ.js.map +1 -0
  13. package/dist/chunk-AKLYPWIN.js +83 -0
  14. package/dist/chunk-AKLYPWIN.js.map +1 -0
  15. package/dist/{chunk-XTC3X6MS.js → chunk-C5XYKUVG.js} +100 -12
  16. package/dist/chunk-C5XYKUVG.js.map +1 -0
  17. package/dist/{chunk-LN7ZZMD2.js → chunk-CHMXELDS.js} +33 -14
  18. package/dist/chunk-CHMXELDS.js.map +1 -0
  19. package/dist/{chunk-A4532ZFR.js → chunk-EH6EM37U.js} +60 -4
  20. package/dist/chunk-EH6EM37U.js.map +1 -0
  21. package/dist/chunk-FBQK3ZQN.js +131 -0
  22. package/dist/chunk-FBQK3ZQN.js.map +1 -0
  23. package/dist/{chunk-5HTNMQW4.js → chunk-GOAW4VYL.js} +87 -21
  24. package/dist/chunk-GOAW4VYL.js.map +1 -0
  25. package/dist/{chunk-MSWFZF7J.js → chunk-I5R7ZBJS.js} +90 -6
  26. package/dist/chunk-I5R7ZBJS.js.map +1 -0
  27. package/dist/{chunk-GQKN5KDT.js → chunk-IT2O4XFE.js} +4 -9
  28. package/dist/chunk-IT2O4XFE.js.map +1 -0
  29. package/dist/{chunk-7Y7WF64D.js → chunk-MIWO425M.js} +6 -4
  30. package/dist/chunk-MIWO425M.js.map +1 -0
  31. package/dist/chunk-N6IHQUOX.js +1 -0
  32. package/dist/chunk-N6IHQUOX.js.map +1 -0
  33. package/dist/{chunk-COKTX2G5.js → chunk-SGU7SPLK.js} +29 -12
  34. package/dist/chunk-SGU7SPLK.js.map +1 -0
  35. package/dist/core/index.cjs +230 -14
  36. package/dist/core/index.cjs.map +1 -1
  37. package/dist/core/index.d.cts +56 -4
  38. package/dist/core/index.d.ts +56 -4
  39. package/dist/core/index.js +24 -4
  40. package/dist/{function-2bJW1Zp_.d.ts → function-DVH4Eusr.d.ts} +1 -1
  41. package/dist/{function-r2sh-jOO.d.cts → function-DYt4iKsn.d.cts} +1 -1
  42. package/dist/generate/index.cjs +830 -494
  43. package/dist/generate/index.cjs.map +1 -1
  44. package/dist/generate/index.d.cts +11 -5
  45. package/dist/generate/index.d.ts +11 -5
  46. package/dist/generate/index.js +9 -9
  47. package/dist/{index-BOBXBNwP.d.cts → index-BNlGP86A.d.cts} +1 -1
  48. package/dist/{index-CP3wAfEH.d.ts → index-Bg5dYMmZ.d.ts} +1 -1
  49. package/dist/{index-CM5W4rcm.d.ts → index-Bt4tOUD9.d.ts} +1 -1
  50. package/dist/index-CnZCo29u.d.cts +108 -0
  51. package/dist/{index-D_ZTUNKp.d.cts → index-CpOsP1y9.d.cts} +2 -2
  52. package/dist/{index-DZ1M21do.d.cts → index-CxqBQtH1.d.cts} +2 -1
  53. package/dist/{index-BdeQ1r_p.d.cts → index-Dikst44v.d.cts} +1 -1
  54. package/dist/{index-BMPxwjwV.d.ts → index-DxvARIP2.d.ts} +2 -2
  55. package/dist/{index-BreoJRw0.d.ts → index-Jc0Ryi79.d.ts} +2 -1
  56. package/dist/index-JnF4v9bx.d.ts +108 -0
  57. package/dist/index.cjs +818 -283
  58. package/dist/index.cjs.map +1 -1
  59. package/dist/index.d.cts +9 -8
  60. package/dist/index.d.ts +9 -8
  61. package/dist/index.js +34 -13
  62. package/dist/model/index.cjs +170 -31
  63. package/dist/model/index.cjs.map +1 -1
  64. package/dist/model/index.d.cts +6 -5
  65. package/dist/model/index.d.ts +6 -5
  66. package/dist/model/index.js +6 -6
  67. package/dist/{styled-D7BAx3S3.d.ts → styled-DZ7GjShb.d.ts} +1 -1
  68. package/dist/{styled-BjXtOFNk.d.cts → styled-ZTbdaVFM.d.cts} +1 -1
  69. package/dist/theory/index.cjs +180 -34
  70. package/dist/theory/index.cjs.map +1 -1
  71. package/dist/theory/index.d.cts +6 -6
  72. package/dist/theory/index.d.ts +6 -6
  73. package/dist/theory/index.js +6 -5
  74. package/package.json +50 -19
  75. package/src/analyze/arrange/internal.ts +3 -1
  76. package/src/analyze/arrange/tension.ts +15 -3
  77. package/src/analyze/arrange/tracks.ts +36 -3
  78. package/src/analyze/detect/index.ts +46 -9
  79. package/src/analyze/functional/roman.ts +14 -5
  80. package/src/analyze/index.ts +1 -1
  81. package/src/analyze/timeline/index.ts +43 -7
  82. package/src/analyze/voice/index.ts +11 -2
  83. package/src/core/event-index/index.ts +104 -0
  84. package/src/core/index.ts +14 -0
  85. package/src/core/meter/index.ts +24 -4
  86. package/src/core/random/index.ts +26 -3
  87. package/src/core/tuning/index.ts +36 -6
  88. package/src/core/validation/index.ts +119 -0
  89. package/src/generate/bass/index.ts +23 -0
  90. package/src/generate/countermelody/index.ts +167 -76
  91. package/src/generate/drums/euclid.ts +10 -3
  92. package/src/generate/drums/index.ts +56 -24
  93. package/src/generate/drums/percussion.ts +1 -1
  94. package/src/generate/groove/index.ts +25 -0
  95. package/src/generate/harmonize/index.ts +55 -44
  96. package/src/generate/index.ts +0 -1
  97. package/src/generate/motif/index.ts +45 -21
  98. package/src/generate/progression/index.ts +8 -16
  99. package/src/generate/reharmony/index.ts +1 -8
  100. package/src/generate/rhythm/index.ts +11 -1
  101. package/src/index.ts +13 -247
  102. package/src/model/chord.ts +29 -10
  103. package/src/theory/chord/index.ts +4 -2
  104. package/src/theory/harmony/index.ts +6 -21
  105. package/src/theory/index.ts +6 -1
  106. package/src/theory/safety/index.ts +71 -2
  107. package/src/theory/spelling/index.ts +70 -3
  108. package/src/theory/voicing/satb.ts +25 -4
  109. package/src/theory/voicing/styled.ts +26 -3
  110. package/dist/chunk-5HTNMQW4.js.map +0 -1
  111. package/dist/chunk-7Y7WF64D.js.map +0 -1
  112. package/dist/chunk-A4532ZFR.js.map +0 -1
  113. package/dist/chunk-BHUT2S5G.js +0 -22
  114. package/dist/chunk-BHUT2S5G.js.map +0 -1
  115. package/dist/chunk-CCBLVAPK.js +0 -42
  116. package/dist/chunk-CCBLVAPK.js.map +0 -1
  117. package/dist/chunk-COKTX2G5.js.map +0 -1
  118. package/dist/chunk-GQKN5KDT.js.map +0 -1
  119. package/dist/chunk-LN7ZZMD2.js.map +0 -1
  120. package/dist/chunk-MSWFZF7J.js.map +0 -1
  121. package/dist/chunk-R3S2LUBH.js.map +0 -1
  122. package/dist/chunk-SDM3VJJ5.js +0 -41
  123. package/dist/chunk-SDM3VJJ5.js.map +0 -1
  124. package/dist/chunk-XTC3X6MS.js.map +0 -1
  125. package/dist/chunk-ZXW5YIWK.js +0 -55
  126. 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-BOBXBNwP.cjs';
4
- import { H as HarmonyRole } from '../index-BdeQ1r_p.cjs';
5
- import { b as ChordTimeline } from '../index-D_ZTUNKp.cjs';
6
- import { B as BorrowedSource, H as HarmonicFunction } from '../function-r2sh-jOO.cjs';
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, ChordSpan, 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 };
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 };
@@ -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-CM5W4rcm.js';
4
- import { H as HarmonyRole } from '../index-CP3wAfEH.js';
5
- import { b as ChordTimeline } from '../index-BMPxwjwV.js';
6
- import { B as BorrowedSource, H as HarmonicFunction } from '../function-2bJW1Zp_.js';
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, ChordSpan, 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 };
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 };
@@ -15,19 +15,19 @@ import {
15
15
  progressionsByStyle,
16
16
  rhythmDensity,
17
17
  transformMotif
18
- } from "../chunk-R3S2LUBH.js";
19
- import "../chunk-BHUT2S5G.js";
20
- import "../chunk-MSWFZF7J.js";
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-GQKN5KDT.js";
26
- import "../chunk-LN7ZZMD2.js";
27
- import "../chunk-SDM3VJJ5.js";
28
- import "../chunk-A4532ZFR.js";
29
- import "../chunk-7Y7WF64D.js";
30
- import "../chunk-CCBLVAPK.js";
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 };
@@ -1,4 +1,4 @@
1
- import { C as Chord } from './index-CM5W4rcm.js';
1
+ import { C as Chord } from './index-Bt4tOUD9.js';
2
2
 
3
3
  /**
4
4
  * Harmonic role a pitch plays within a chord.
@@ -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-BOBXBNwP.cjs';
4
- import { C as Cadence } from './function-r2sh-jOO.cjs';
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-BOBXBNwP.cjs';
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,4 +1,4 @@
1
- import { C as Chord } from './index-BOBXBNwP.cjs';
1
+ import { C as Chord } from './index-BNlGP86A.cjs';
2
2
 
3
3
  /**
4
4
  * Harmonic role a pitch plays within a chord.
@@ -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-CM5W4rcm.js';
4
- import { C as Cadence } from './function-2bJW1Zp_.js';
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-CM5W4rcm.js';
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 };