@libraz/libcantus 1.2.0 → 1.4.0
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/NOTICE +63 -0
- package/README.md +7 -1
- package/README_ja.md +17 -11
- package/dist/analyze/index.cjs +31 -7
- package/dist/analyze/index.cjs.map +1 -1
- package/dist/analyze/index.d.cts +161 -13
- package/dist/analyze/index.d.ts +161 -13
- package/dist/analyze/index.js +37 -13
- package/dist/{chunk-NB25P3EH.js → chunk-2G5MCGYU.js} +33 -11
- package/dist/chunk-2G5MCGYU.js.map +1 -0
- package/dist/{chunk-NM7UAMC3.cjs → chunk-3FDBMIPR.cjs} +64 -64
- package/dist/chunk-3FDBMIPR.cjs.map +1 -0
- package/dist/{chunk-HPVSH7SF.cjs → chunk-3MDOEFIQ.cjs} +618 -954
- package/dist/chunk-3MDOEFIQ.cjs.map +1 -0
- package/dist/{chunk-FBH75DAY.js → chunk-5MWRBYAT.js} +560 -159
- package/dist/chunk-5MWRBYAT.js.map +1 -0
- package/dist/{chunk-J7FHVZII.cjs → chunk-6TTBEON3.cjs} +3074 -740
- package/dist/chunk-6TTBEON3.cjs.map +1 -0
- package/dist/{chunk-UMWZ4ZET.js → chunk-7NQ6AL3H.js} +4 -4
- package/dist/chunk-7NQ6AL3H.js.map +1 -0
- package/dist/{chunk-HWHGOVO6.cjs → chunk-E3QO3UET.cjs} +31 -23
- package/dist/chunk-E3QO3UET.cjs.map +1 -0
- package/dist/{chunk-H2KJHBW4.js → chunk-FJFULJZE.js} +2375 -191
- package/dist/chunk-FJFULJZE.js.map +1 -0
- package/dist/{chunk-Q6LFSAKV.js → chunk-FK3DGAIZ.js} +2657 -323
- package/dist/chunk-FK3DGAIZ.js.map +1 -0
- package/dist/chunk-GEDTJHAC.cjs.map +1 -1
- package/dist/{chunk-RFIBF2RR.js → chunk-H7FVMBUC.js} +138 -65
- package/dist/chunk-H7FVMBUC.js.map +1 -0
- package/dist/{chunk-DSMJRXCZ.cjs → chunk-HYSVSFNI.cjs} +931 -530
- package/dist/chunk-HYSVSFNI.cjs.map +1 -0
- package/dist/{chunk-35NBV2FT.cjs → chunk-KMYGRFZ6.cjs} +47 -24
- package/dist/chunk-KMYGRFZ6.cjs.map +1 -0
- package/dist/chunk-LQZQDBCD.cjs +5513 -0
- package/dist/chunk-LQZQDBCD.cjs.map +1 -0
- package/dist/{chunk-PM4XJE2Y.cjs → chunk-P3CPXAJ5.cjs} +76 -54
- package/dist/chunk-P3CPXAJ5.cjs.map +1 -0
- package/dist/{chunk-S5BKZZGM.cjs → chunk-S3QELJUE.cjs} +72 -56
- package/dist/chunk-S3QELJUE.cjs.map +1 -0
- package/dist/{chunk-PUKJP2Z5.js → chunk-TXFWSU5D.js} +31 -8
- package/dist/chunk-TXFWSU5D.js.map +1 -0
- package/dist/{chunk-76ZBTRG2.cjs → chunk-U4EQTDGN.cjs} +258 -218
- package/dist/chunk-U4EQTDGN.cjs.map +1 -0
- package/dist/chunk-UGLFDG7L.cjs.map +1 -1
- package/dist/{chunk-HYJJ2V2I.js → chunk-UTE5A36R.js} +483 -819
- package/dist/chunk-UTE5A36R.js.map +1 -0
- package/dist/{chunk-NFJ4P6ZZ.js → chunk-UZKQISRF.js} +17 -9
- package/dist/chunk-UZKQISRF.js.map +1 -0
- package/dist/{chunk-7KG3RTYS.js → chunk-VL5NXVCN.js} +281 -155
- package/dist/chunk-VL5NXVCN.js.map +1 -0
- package/dist/{chunk-CGBADIO5.cjs → chunk-WOMCXN2W.cjs} +328 -202
- package/dist/chunk-WOMCXN2W.cjs.map +1 -0
- package/dist/{chunk-3R3QVKY5.cjs → chunk-YDGMWH43.cjs} +397 -324
- package/dist/chunk-YDGMWH43.cjs.map +1 -0
- package/dist/{chunk-AGOVW7U6.js → chunk-YYVXRV3V.js} +72 -56
- package/dist/chunk-YYVXRV3V.js.map +1 -0
- package/dist/{chunk-M5RYMAFI.js → chunk-ZLNSH4UL.js} +71 -31
- package/dist/chunk-ZLNSH4UL.js.map +1 -0
- package/dist/{coerce-DRERzdve.d.cts → coerce-CUhHc3Tu.d.ts} +16 -8
- package/dist/{coerce-DP0vYu-x.d.ts → coerce-Ytt2Eiq9.d.cts} +16 -8
- package/dist/core/index.cjs +5 -5
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +9 -8
- package/dist/core/index.d.ts +9 -8
- package/dist/core/index.js +4 -4
- package/dist/generate/index.cjs +20 -8
- package/dist/generate/index.cjs.map +1 -1
- package/dist/generate/index.d.cts +105 -17
- package/dist/generate/index.d.ts +105 -17
- package/dist/generate/index.js +19 -7
- package/dist/{index-CL4b4gUQ.d.ts → index-5VJgKz_Q.d.cts} +6 -2
- package/dist/{index-B9QLziDe.d.cts → index-BLuDesVG.d.ts} +20 -13
- package/dist/{index-BHIUyjhZ.d.ts → index-BV6APVa6.d.cts} +20 -13
- package/dist/{index-BMweUlm5.d.cts → index-Bf0Sv8a9.d.ts} +6 -2
- package/dist/{index-Dw2DP7vm.d.ts → index-BkT21EMv.d.cts} +3 -2
- package/dist/{index-BL5N2Oyz.d.cts → index-C7KCaTRz.d.ts} +3 -2
- package/dist/{index-Cy15oTvh.d.ts → index-C9MYbuKS.d.cts} +7 -3
- package/dist/{index-Cy15oTvh.d.cts → index-C9MYbuKS.d.ts} +7 -3
- package/dist/{index-BNSM-DSk.d.cts → index-DVInzCDS.d.cts} +533 -28
- package/dist/{index-9eoQs2C1.d.ts → index-Dg-SAfhz.d.ts} +6 -4
- package/dist/{index-BJgP97N1.d.ts → index-jgeug9EA.d.ts} +533 -28
- package/dist/{index-cHvbYgJI.d.cts → index-pQihL4z7.d.cts} +6 -4
- package/dist/index.cjs +49 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.js +55 -19
- package/dist/{masks-Cc7-MzzY.d.ts → masks-BnzXnBj0.d.cts} +3 -2
- package/dist/{masks-pADfTOiD.d.cts → masks-tycmkrgs.d.ts} +3 -2
- package/dist/model/index.cjs +12 -12
- package/dist/model/index.cjs.map +1 -1
- package/dist/model/index.d.cts +259 -48
- package/dist/model/index.d.ts +259 -48
- package/dist/model/index.js +11 -11
- package/dist/{positional-DJgs6ltD.d.ts → positional-CscpxtlE.d.cts} +3 -2
- package/dist/{positional-DMZer-FM.d.cts → positional-DLnfUgqG.d.ts} +3 -2
- package/dist/{index-BRMbPkHE.d.ts → profile-B4WqcM4H.d.ts} +85 -610
- package/dist/{index-DGCNKAUr.d.cts → profile-BJd1XkPB.d.cts} +85 -610
- package/dist/theory/index.cjs +5 -5
- package/dist/theory/index.cjs.map +1 -1
- package/dist/theory/index.d.cts +18 -14
- package/dist/theory/index.d.ts +18 -14
- package/dist/theory/index.js +4 -4
- package/dist/{index-CJBBiAmU.d.ts → types-7mGFwvMm.d.ts} +1210 -31
- package/dist/{index-BBWNZS0f.d.cts → types-_ofpb2be.d.cts} +1210 -31
- package/package.json +13 -13
- package/dist/chunk-35NBV2FT.cjs.map +0 -1
- package/dist/chunk-3R3QVKY5.cjs.map +0 -1
- package/dist/chunk-76ZBTRG2.cjs.map +0 -1
- package/dist/chunk-7KG3RTYS.js.map +0 -1
- package/dist/chunk-AGOVW7U6.js.map +0 -1
- package/dist/chunk-CGBADIO5.cjs.map +0 -1
- package/dist/chunk-DSMJRXCZ.cjs.map +0 -1
- package/dist/chunk-FBH75DAY.js.map +0 -1
- package/dist/chunk-H2KJHBW4.js.map +0 -1
- package/dist/chunk-HPVSH7SF.cjs.map +0 -1
- package/dist/chunk-HWHGOVO6.cjs.map +0 -1
- package/dist/chunk-HYJJ2V2I.js.map +0 -1
- package/dist/chunk-J7FHVZII.cjs.map +0 -1
- package/dist/chunk-M5RYMAFI.js.map +0 -1
- package/dist/chunk-NB25P3EH.js.map +0 -1
- package/dist/chunk-NFJ4P6ZZ.js.map +0 -1
- package/dist/chunk-NM7UAMC3.cjs.map +0 -1
- package/dist/chunk-PM4XJE2Y.cjs.map +0 -1
- package/dist/chunk-PUKJP2Z5.js.map +0 -1
- package/dist/chunk-Q6LFSAKV.js.map +0 -1
- package/dist/chunk-RFIBF2RR.js.map +0 -1
- package/dist/chunk-S5BKZZGM.cjs.map +0 -1
- package/dist/chunk-SGLEQVJH.cjs +0 -3329
- package/dist/chunk-SGLEQVJH.cjs.map +0 -1
- package/dist/chunk-UMWZ4ZET.js.map +0 -1
package/dist/analyze/index.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { i as NoteLike, h as NoteEvent, g as Note } from '../index-
|
|
2
|
-
export { a as Articulation, I as IntervalData, c as IntervalQualityLabel, e as KeyScale, S as SpelledInterval } from '../index-
|
|
3
|
-
export { M as MeterChange, b as MeterLike, c as MeterMap, T as TimeSignature } from '../index-
|
|
4
|
-
import { r as SpelledKeyLike } from '../coerce-
|
|
5
|
-
export { b as ChordData, c as ChordLike, d as ChordQuality, e as ChordSegment, g as ChordSpan, i as ChordToneRole, K as KeyLike, j as KeyRelation, k as KeyVariant, N as NoteSafety, l as PitchSpelling, n as ResolvedKey, o as SafetyProfile, s as SpelledKeyScale, V as VoiceSnapshot } from '../coerce-
|
|
6
|
-
export { r as ScaleName } from '../masks-
|
|
7
|
-
import {
|
|
8
|
-
export { A as AnalyzeChordOptions, a as AnalyzedNote, B as BorrowedSource, C as CadenceHit,
|
|
9
|
-
|
|
10
|
-
export { A as ArrangementAnalysis, a as ArrangementOptions, b as ArrangementSession, c as ArrangementTrack, d as AugmentedSixthKind, C as ChordMatch, e as Conflict, f as ConflictPartner, g as ContourDirection, D as DetectChordOptions, h as DetectKeyOptions, E as ExtractMotifsOptions, F as FormSection, i as FormSectionOptions, H as Hypermeter, j as HypermeterOptions, K as KeyMatch, M as MODAL_SCALE_NAMES, k as MelodicContour, l as MelodicContourShape, n as ModalCandidate, o as ModalScaleName, p as MotifData, q as MotifOccurrence, r as MotifRelation, s as MotifRelationKind, P as Phrase, t as PhraseOptions, u as PhraseSignal, R as ReduceProgressionOptions, v as ReducedChord, w as ReductionBasis, x as ReductionLevel, S as StructuralCadence, T as TensionPoint, y as TrackAnalysis, z as TrackEdit, B as TrackRole, G as analyzeArrangement, I as analyzePolyphony, J as augmentedSixthChord, L as augmentedSixthFromPitchClasses, N as augmentedSixthKind, O as createArrangementSession, Q as detectChord, U as detectChordBest, V as detectKey, W as detectKeyBest, X as detectKeyFromNotes, Y as extractMotifs, Z as hypermeter, _ as melodicContour, $ as motifFromNotes, a0 as phrasesFromTimeline, a1 as reduceProgression, a2 as relateMotifs, a3 as sectionsFromNotes, a4 as spellAugmentedSixth, a5 as structuralCadences, a6 as tensionCurve, a7 as tensionCurveFrom } from '../index-BRMbPkHE.js';
|
|
1
|
+
import { i as NoteLike, h as NoteEvent, g as Note } from '../index-C9MYbuKS.js';
|
|
2
|
+
export { a as Articulation, I as IntervalData, c as IntervalQualityLabel, e as KeyScale, S as SpelledInterval } from '../index-C9MYbuKS.js';
|
|
3
|
+
export { M as MeterChange, b as MeterLike, c as MeterMap, T as TimeSignature } from '../index-Bf0Sv8a9.js';
|
|
4
|
+
import { r as SpelledKeyLike } from '../coerce-CUhHc3Tu.js';
|
|
5
|
+
export { b as ChordData, c as ChordLike, d as ChordQuality, e as ChordSegment, g as ChordSpan, i as ChordToneRole, K as KeyLike, j as KeyRelation, k as KeyVariant, N as NoteSafety, l as PitchSpelling, n as ResolvedKey, o as SafetyProfile, s as SpelledKeyScale, V as VoiceSnapshot } from '../coerce-CUhHc3Tu.js';
|
|
6
|
+
export { r as ScaleName } from '../masks-tycmkrgs.js';
|
|
7
|
+
import { w as MelodicPhrase, a5 as ReferenceProfile, h as ChordTimeline } from '../types-7mGFwvMm.js';
|
|
8
|
+
export { A as AnalyzeChordOptions, a as AnalyzedNote, B as BarPositionProfile, b as BorrowedSource, C as CADENCE_TYPES, c as CadenceHit, d as CadenceResult, e as CadenceType, f as ChordAnalysis, g as ChordSegmentation, i as ChordTimelineOptions, j as ChordTimelineResult, k as ChordToRomanOptions, l as ContourDirection, D as DetectCadenceOptions, E as ExplainRomanOptions, m as ExtractMotifsOptions, F as FormSection, n as FormSectionOptions, H as HARMONIC_FUNCTIONS, o as HarmonicFunction, I as IdentifiedVoiceNote, K as KeyContext, p as KeyProfileName, q as KeyProfilePair, r as KeyRegion, s as KeyTimelineOptions, M as MELODIC_CONTOUR_SHAPES, t as MOTIF_RELATION_KINDS, u as MelodicContour, v as MelodicContourShape, x as MotifData, y as MotifGraph, z as MotifGraphEdge, G as MotifGraphNode, J as MotifGraphOptions, L as MotifOccurrence, N as MotifRelation, O as MotifRelationKind, P as MotifRelationSummary, Q as PivotChord, R as REDUCTION_LEVELS, S as REFERENCE_PROFILE_VERSION, T as RHYTHM_IOI_BINS, U as ReduceProgressionOptions, V as ReducedChord, W as ReductionBasis, X as ReductionLevel, Y as ReferenceCadence, Z as ReferenceChord, _ as ReferenceForm, $ as ReferenceHarmony, a0 as ReferenceKeyRegion, a1 as ReferenceMelody, a2 as ReferenceMotif, a3 as ReferencePhrase, a4 as ReferencePhraseMelody, a6 as RejectedCandidate, a7 as RhythmAnalysis, a8 as RhythmAnalysisOptions, a9 as RomanExplanation, aa as SuspensionFigure, ab as TheoryLabel, ac as VoiceNote, ad as analyzeChord, ae as analyzeRhythm, af as analyzeVoice, ag as assertChordTimeline, ah as borrowedSource, ai as chordTimelineFromChords, aj as chordTimelineFromNotes, ak as chordToRoman, al as detectCadence, am as detectCadences, an as detectModulations, ao as explainRoman, ap as extractMotifs, aq as functionOf, ar as isBorrowedChord, as as isDiatonic, at as isMinorKey, au as keyTimelineFromNotes, av as melodicContour, aw as motifFromNotes, ax as motifGraph, ay as pivotChords, az as prevailingKeyOf, aA as reduceProgression, aB as relateMotifs, aC as romanToChord, aD as secondaryDominant, aE as secondaryDominantOf, aF as sectionsFromNotes, aG as toVoiceNotes } from '../types-7mGFwvMm.js';
|
|
9
|
+
export { A as ArrangementAnalysis, a as ArrangementOptions, b as ArrangementSession, c as ArrangementTrack, d as AugmentedSixthKind, C as ChordMatch, e as Conflict, f as ConflictPartner, D as DetectChordOptions, g as DetectKeyOptions, H as Hypermeter, h as HypermeterOptions, K as KeyMatch, M as MODAL_SCALE_NAMES, i as ModalCandidate, j as ModalScaleName, P as Phrase, k as PhraseOptions, l as PhraseSignal, R as ReferenceProfileOptions, S as StructuralCadence, T as TensionPoint, m as TrackAnalysis, n as TrackEdit, o as TrackRole, p as analyzeArrangement, q as analyzePolyphony, r as analyzeReference, s as augmentedSixthChord, t as augmentedSixthFromPitchClasses, u as augmentedSixthKind, v as createArrangementSession, w as detectChord, x as detectChordBest, y as detectKey, z as detectKeyBest, B as detectKeyFromNotes, E as hypermeter, F as phrasesFromTimeline, G as spellAugmentedSixth, I as structuralCadences, J as tensionCurve, L as tensionCurveFrom } from '../profile-B4WqcM4H.js';
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* How alike two phrases are, when they stand in no named relation.
|
|
@@ -95,6 +94,153 @@ declare function compareMelodies(a: MelodicPhrase, b: MelodicPhrase): MelodicCom
|
|
|
95
94
|
*/
|
|
96
95
|
declare function melodicSimilarity(a: MelodicPhrase, b: MelodicPhrase): number;
|
|
97
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Comparing two {@link ReferenceProfile}s dimension by dimension.
|
|
99
|
+
*
|
|
100
|
+
* The answer is never folded into one number: each field names the aspect it
|
|
101
|
+
* measures, so "a different song built the same way" reads as high structural
|
|
102
|
+
* fields beside a low surface one. Only `melody.surfaceSimilarity` reads the
|
|
103
|
+
* motifs' intervals; every other field is invariant under transposition, tempo
|
|
104
|
+
* and a change of motif intervals.
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Options for {@link compareReferences}.
|
|
109
|
+
*
|
|
110
|
+
* @category Arrangement & Analysis
|
|
111
|
+
*/
|
|
112
|
+
type ReferenceComparisonOptions = {
|
|
113
|
+
/**
|
|
114
|
+
* Upper bound on the cells of the progression alignment.
|
|
115
|
+
*
|
|
116
|
+
* @defaultValue {@link DEFAULT_GENERATION_BUDGET}
|
|
117
|
+
*/
|
|
118
|
+
budget?: number;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* How alike two profiled pieces are, one field per aspect.
|
|
122
|
+
*
|
|
123
|
+
* Every value is in [0, 1] and symmetric in the two profiles. A value is
|
|
124
|
+
* `null` when neither profile has anything to measure it on, and 0 when only
|
|
125
|
+
* one does.
|
|
126
|
+
*
|
|
127
|
+
* @category Arrangement & Analysis
|
|
128
|
+
*/
|
|
129
|
+
type ReferenceComparison = {
|
|
130
|
+
/** Formal layout. */
|
|
131
|
+
form: {
|
|
132
|
+
/** Likeness of the section-label sequences. */
|
|
133
|
+
sectionSequenceSimilarity: number | null;
|
|
134
|
+
/** Likeness of the phrase-length sequences. */
|
|
135
|
+
phraseLengthSimilarity: number | null;
|
|
136
|
+
};
|
|
137
|
+
/** Harmony. */
|
|
138
|
+
harmony: {
|
|
139
|
+
/** Likeness of the structural Roman-numeral progressions. */
|
|
140
|
+
progressionSimilarity: number | null;
|
|
141
|
+
/** Likeness of how long each harmonic function is held. */
|
|
142
|
+
functionSimilarity: number | null;
|
|
143
|
+
/** Likeness of the phrase-by-phrase cadence sequences. */
|
|
144
|
+
cadenceSimilarity: number | null;
|
|
145
|
+
/** Likeness of the key plans, read relative to each piece's first key. */
|
|
146
|
+
keyPlanSimilarity: number | null;
|
|
147
|
+
/** Likeness of where in the bar the chords change. */
|
|
148
|
+
harmonicRhythmOnsetSimilarity: number | null;
|
|
149
|
+
/** Likeness of how often the chords change. */
|
|
150
|
+
harmonicRhythmDensitySimilarity: number | null;
|
|
151
|
+
};
|
|
152
|
+
/** Melody. */
|
|
153
|
+
melody: {
|
|
154
|
+
/** Likeness of the motifs' interval content: the one field that reads the surface. */
|
|
155
|
+
surfaceSimilarity: number | null;
|
|
156
|
+
/** Likeness of how the motifs derive from one another. */
|
|
157
|
+
motifStructureSimilarity: number | null;
|
|
158
|
+
/** Likeness of the phrases' melodic outlines, each scaled by its own range. */
|
|
159
|
+
contourSimilarity: number | null;
|
|
160
|
+
/** Likeness of the phrases' registers, each relative to its piece's melodic mean. */
|
|
161
|
+
registerSimilarity: number | null;
|
|
162
|
+
};
|
|
163
|
+
/** Melodic rhythm. */
|
|
164
|
+
rhythm: {
|
|
165
|
+
/** Likeness of where in the bar the melody's onsets fall. */
|
|
166
|
+
onsetSimilarity: number | null;
|
|
167
|
+
/** Likeness of the melodies' onsets per bar. */
|
|
168
|
+
densitySimilarity: number | null;
|
|
169
|
+
/** Likeness of the melodies' inter-onset-interval distributions. */
|
|
170
|
+
durationSimilarity: number | null;
|
|
171
|
+
/** Likeness of the melodies' syncopation. */
|
|
172
|
+
syncopationSimilarity: number | null;
|
|
173
|
+
};
|
|
174
|
+
/** The two most and the two least alike fields, by name. */
|
|
175
|
+
rationale: string;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Compare two profiled pieces aspect by aspect: form, harmony, melody and
|
|
179
|
+
* melodic rhythm.
|
|
180
|
+
*
|
|
181
|
+
* Sequences — sections, phrase lengths, cadences, key plans, structural
|
|
182
|
+
* chords, phrase contours and registers — are aligned by a graded edit
|
|
183
|
+
* distance; distributions — harmonic function, onset placement, inter-onset
|
|
184
|
+
* intervals, motif derivations — by histogram intersection. The surface field
|
|
185
|
+
* compares the motifs' interval cells, so a transposition of the same piece
|
|
186
|
+
* reads 1 on every field. No aggregate is returned: which aspects agree is the
|
|
187
|
+
* answer.
|
|
188
|
+
*
|
|
189
|
+
* @param a The first profile.
|
|
190
|
+
* @param b The second profile.
|
|
191
|
+
* @param opts The work budget.
|
|
192
|
+
* @returns One likeness per aspect, and a rationale naming the extremes.
|
|
193
|
+
* @throws {InvalidInputError} If either profile or the options cannot be read.
|
|
194
|
+
* @throws {BudgetExceededError} If the progression alignment would exceed the budget.
|
|
195
|
+
* @category Arrangement & Analysis
|
|
196
|
+
*/
|
|
197
|
+
declare function compareReferences(a: ReferenceProfile, b: ReferenceProfile, opts?: ReferenceComparisonOptions): ReferenceComparison;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Boundary validation for {@link ReferenceProfile}: a caller can hand this a
|
|
201
|
+
* value restored from JSON, a config file, or a plugin host, and every field
|
|
202
|
+
* is checked before anything downstream reads it. A violation names the path
|
|
203
|
+
* to the offending field, so a malformed document is diagnosed at the field
|
|
204
|
+
* that is wrong rather than wherever the first bad read happens to land.
|
|
205
|
+
*/
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Reject a value that is not a {@link ReferenceProfile}.
|
|
209
|
+
*
|
|
210
|
+
* A profile is the shape a caller's stored JSON, a config file, or a plugin
|
|
211
|
+
* host most plausibly hands back malformed: a missing field, a distribution
|
|
212
|
+
* that no longer sums to 1, an index a later edit left dangling, a numeral no
|
|
213
|
+
* reader can parse. Every field is checked before {@link compareReferences} or
|
|
214
|
+
* a caller's own code reads it, and a violation names the path to the field
|
|
215
|
+
* that is wrong.
|
|
216
|
+
*
|
|
217
|
+
* @param value The value to check.
|
|
218
|
+
* @param name What the value is, for the error message.
|
|
219
|
+
* @returns The same profile.
|
|
220
|
+
* @throws {InvalidInputError} If the value is not a valid reference profile.
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* import { assertReferenceProfile } from '@libraz/libcantus';
|
|
224
|
+
* const emptyRhythm = {
|
|
225
|
+
* startBeat: 0, endBeat: 0, bars: 0, onsets: 0, onsetDensity: 0,
|
|
226
|
+
* barOnsets: [], onsetLevels: [0, 0, 0, 0, 0, 0], barPositions: [],
|
|
227
|
+
* interOnsetShares: new Array(17).fill(0), restRatio: 0, syncopation: 0,
|
|
228
|
+
* offGridRatio: 0, rationale: 'nothing sounds',
|
|
229
|
+
* };
|
|
230
|
+
* const profile = {
|
|
231
|
+
* profileVersion: 1,
|
|
232
|
+
* span: { startBeat: 0, endBeat: 0, bars: 0 },
|
|
233
|
+
* meters: [{ startBeat: 0, ts: { numerator: 4, denominator: 4 } }],
|
|
234
|
+
* form: { hypermeter: { groupBars: 1, confidence: 0 }, sections: [], phrases: [] },
|
|
235
|
+
* harmony: { keys: [], chords: [], rhythm: emptyRhythm },
|
|
236
|
+
* melody: { register: null, shape: null, motifs: [], graph: { nodes: [], edges: [] }, rhythm: emptyRhythm },
|
|
237
|
+
* };
|
|
238
|
+
* assertReferenceProfile(profile); // the profile, unchanged
|
|
239
|
+
* ```
|
|
240
|
+
* @category Arrangement & Analysis
|
|
241
|
+
*/
|
|
242
|
+
declare function assertReferenceProfile(value: unknown, name?: string): ReferenceProfile;
|
|
243
|
+
|
|
98
244
|
/**
|
|
99
245
|
* Line spelling: name every note of a melodic line in one pass.
|
|
100
246
|
*
|
|
@@ -144,8 +290,9 @@ type SpellLineOptions = {
|
|
|
144
290
|
* 1. A note the sounding chord names takes that chord's spelling of it, even
|
|
145
291
|
* when the key spells the pitch otherwise — the seventh of a Db7 reads Cb in
|
|
146
292
|
* C major, not B.
|
|
147
|
-
* 2. Anything else the key
|
|
148
|
-
*
|
|
293
|
+
* 2. Anything else the key spells as its own — a scale tone, or the raised
|
|
294
|
+
* sixth and seventh of a minor key — keeps its key spelling, so the leading
|
|
295
|
+
* tone of A minor reads G# even where the line falls through it.
|
|
149
296
|
* 3. A chromatic note is spelled so the written intervals around it match the
|
|
150
297
|
* sounding ones, and then so a rising step carries a sharp and a falling
|
|
151
298
|
* step a flat.
|
|
@@ -190,4 +337,5 @@ type SpellLineOptions = {
|
|
|
190
337
|
*/
|
|
191
338
|
declare function spellLine(notes: readonly NoteEvent[], timeline: ChordTimeline | null, key: SpelledKeyLike, opts?: SpellLineOptions): Note[];
|
|
192
339
|
|
|
193
|
-
export { ChordTimeline,
|
|
340
|
+
export { ChordTimeline, MelodicPhrase, Note as NoteData, NoteEvent, NoteLike, ReferenceProfile, SpelledKeyLike, assertReferenceProfile, compareMelodies, compareReferences, melodicSimilarity, spellLine };
|
|
341
|
+
export type { MelodicComparison, ReferenceComparison, ReferenceComparisonOptions, SpellLineOptions };
|
package/dist/analyze/index.js
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
import {
|
|
2
2
|
spellLine
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-UZKQISRF.js";
|
|
4
4
|
import {
|
|
5
5
|
analyzeArrangement,
|
|
6
6
|
analyzePolyphony,
|
|
7
|
-
|
|
7
|
+
analyzeReference,
|
|
8
|
+
compareReferences,
|
|
8
9
|
createArrangementSession,
|
|
9
|
-
extractMotifs,
|
|
10
10
|
hypermeter,
|
|
11
|
-
melodicContour,
|
|
12
|
-
melodicSimilarity,
|
|
13
|
-
motifFromNotes,
|
|
14
11
|
phrasesFromTimeline,
|
|
15
|
-
reduceProgression,
|
|
16
|
-
relateMotifs,
|
|
17
12
|
sectionsFromNotes,
|
|
18
13
|
structuralCadences,
|
|
19
14
|
tensionCurve,
|
|
20
15
|
tensionCurveFrom
|
|
21
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-UTE5A36R.js";
|
|
22
17
|
import {
|
|
18
|
+
CADENCE_TYPES,
|
|
19
|
+
HARMONIC_FUNCTIONS,
|
|
20
|
+
MELODIC_CONTOUR_SHAPES,
|
|
23
21
|
MODAL_SCALE_NAMES,
|
|
22
|
+
MOTIF_RELATION_KINDS,
|
|
23
|
+
REDUCTION_LEVELS,
|
|
24
|
+
REFERENCE_PROFILE_VERSION,
|
|
25
|
+
RHYTHM_IOI_BINS,
|
|
24
26
|
analyzeChord,
|
|
27
|
+
analyzeRhythm,
|
|
25
28
|
analyzeVoice,
|
|
26
29
|
assertChordTimeline,
|
|
30
|
+
assertReferenceProfile,
|
|
27
31
|
augmentedSixthChord,
|
|
28
32
|
augmentedSixthFromPitchClasses,
|
|
29
33
|
augmentedSixthKind,
|
|
@@ -31,6 +35,7 @@ import {
|
|
|
31
35
|
chordTimelineFromChords,
|
|
32
36
|
chordTimelineFromNotes,
|
|
33
37
|
chordToRoman,
|
|
38
|
+
compareMelodies,
|
|
34
39
|
detectCadence,
|
|
35
40
|
detectCadences,
|
|
36
41
|
detectChord,
|
|
@@ -40,32 +45,49 @@ import {
|
|
|
40
45
|
detectKeyFromNotes,
|
|
41
46
|
detectModulations,
|
|
42
47
|
explainRoman,
|
|
48
|
+
extractMotifs,
|
|
43
49
|
functionOf,
|
|
44
50
|
isBorrowedChord,
|
|
45
51
|
isDiatonic,
|
|
46
52
|
isMinorKey,
|
|
47
53
|
keyTimelineFromNotes,
|
|
54
|
+
melodicContour,
|
|
55
|
+
melodicSimilarity,
|
|
56
|
+
motifFromNotes,
|
|
57
|
+
motifGraph,
|
|
48
58
|
pivotChords,
|
|
49
59
|
prevailingKeyOf,
|
|
60
|
+
reduceProgression,
|
|
61
|
+
relateMotifs,
|
|
50
62
|
romanToChord,
|
|
51
63
|
secondaryDominant,
|
|
52
64
|
secondaryDominantOf,
|
|
53
65
|
spellAugmentedSixth,
|
|
54
66
|
toVoiceNotes
|
|
55
|
-
} from "../chunk-
|
|
56
|
-
import "../chunk-
|
|
67
|
+
} from "../chunk-FJFULJZE.js";
|
|
68
|
+
import "../chunk-TXFWSU5D.js";
|
|
57
69
|
import {
|
|
58
70
|
NoteSafety
|
|
59
|
-
} from "../chunk-
|
|
60
|
-
import "../chunk-
|
|
71
|
+
} from "../chunk-H7FVMBUC.js";
|
|
72
|
+
import "../chunk-YYVXRV3V.js";
|
|
61
73
|
export {
|
|
74
|
+
CADENCE_TYPES,
|
|
75
|
+
HARMONIC_FUNCTIONS,
|
|
76
|
+
MELODIC_CONTOUR_SHAPES,
|
|
62
77
|
MODAL_SCALE_NAMES,
|
|
78
|
+
MOTIF_RELATION_KINDS,
|
|
63
79
|
NoteSafety,
|
|
80
|
+
REDUCTION_LEVELS,
|
|
81
|
+
REFERENCE_PROFILE_VERSION,
|
|
82
|
+
RHYTHM_IOI_BINS,
|
|
64
83
|
analyzeArrangement,
|
|
65
84
|
analyzeChord,
|
|
66
85
|
analyzePolyphony,
|
|
86
|
+
analyzeReference,
|
|
87
|
+
analyzeRhythm,
|
|
67
88
|
analyzeVoice,
|
|
68
89
|
assertChordTimeline,
|
|
90
|
+
assertReferenceProfile,
|
|
69
91
|
augmentedSixthChord,
|
|
70
92
|
augmentedSixthFromPitchClasses,
|
|
71
93
|
augmentedSixthKind,
|
|
@@ -74,6 +96,7 @@ export {
|
|
|
74
96
|
chordTimelineFromNotes,
|
|
75
97
|
chordToRoman,
|
|
76
98
|
compareMelodies,
|
|
99
|
+
compareReferences,
|
|
77
100
|
createArrangementSession,
|
|
78
101
|
detectCadence,
|
|
79
102
|
detectCadences,
|
|
@@ -94,6 +117,7 @@ export {
|
|
|
94
117
|
melodicContour,
|
|
95
118
|
melodicSimilarity,
|
|
96
119
|
motifFromNotes,
|
|
120
|
+
motifGraph,
|
|
97
121
|
phrasesFromTimeline,
|
|
98
122
|
pivotChords,
|
|
99
123
|
prevailingKeyOf,
|
|
@@ -7,19 +7,21 @@ import {
|
|
|
7
7
|
namedScaleMask,
|
|
8
8
|
requireScaleMask,
|
|
9
9
|
resolveScaleName,
|
|
10
|
+
soundsDominantSeventh,
|
|
10
11
|
thirdSlotOf,
|
|
11
12
|
toChordData
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-H7FVMBUC.js";
|
|
13
14
|
import {
|
|
14
15
|
InvalidInputError,
|
|
15
16
|
assertArray,
|
|
16
17
|
assertFiniteNumber,
|
|
17
18
|
assertGenerationBudget,
|
|
19
|
+
assertOneOf,
|
|
18
20
|
assertOptions,
|
|
19
21
|
assertPitchClass,
|
|
20
22
|
assertPositiveInt,
|
|
21
23
|
pitchClassOf
|
|
22
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-YYVXRV3V.js";
|
|
23
25
|
|
|
24
26
|
// src/theory/chordscale/index.ts
|
|
25
27
|
function requireChordScaleMask(name, label = "scale") {
|
|
@@ -54,7 +56,8 @@ function scaleMatchesChord(chordPcs, scaleMask, scaleRootPc) {
|
|
|
54
56
|
}
|
|
55
57
|
return true;
|
|
56
58
|
}
|
|
57
|
-
var
|
|
59
|
+
var ALIASED_SCALE_NAME_LIST = ["major", "naturalMinor"];
|
|
60
|
+
var ALIASED_SCALE_NAMES = new Set(ALIASED_SCALE_NAME_LIST);
|
|
58
61
|
var HEPTATONIC_SIZE = 7;
|
|
59
62
|
var SCALE_PREFERENCE = [
|
|
60
63
|
"ionian",
|
|
@@ -90,13 +93,20 @@ function idiomaticRank(chord, name) {
|
|
|
90
93
|
return index < 0 ? choices.length + 1 : index;
|
|
91
94
|
}
|
|
92
95
|
function isAlteredDominant(chord, scaleName) {
|
|
93
|
-
|
|
96
|
+
if (scaleName !== "altered" || !soundsDominantSeventh(chord)) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
const mask = namedScaleMask(scaleName);
|
|
100
|
+
const rootPc = pitchClassOf(chord.rootPc);
|
|
101
|
+
const fifthPc = pitchClassOf(rootPc + 7);
|
|
102
|
+
return mask !== void 0 && chordPitchClasses(chord).every((pc) => pc === fifthPc || maskHasPitchClass(mask, rootPc, pc));
|
|
94
103
|
}
|
|
95
104
|
function chordScales(chord) {
|
|
96
105
|
const data = toChordData(chord);
|
|
97
106
|
const chordPcs = chordPitchClasses(data);
|
|
98
107
|
const rootPc = pitchClassOf(data.rootPc);
|
|
99
108
|
const ranked = [];
|
|
109
|
+
const writesTension = chordPcs.some((pc) => ![0, 4, 7, 10].includes(pitchClassOf(pc - rootPc)));
|
|
100
110
|
const seenMasks = /* @__PURE__ */ new Set();
|
|
101
111
|
for (const name of Object.keys(NAMED_SCALES)) {
|
|
102
112
|
if (name === "chromatic" || ALIASED_SCALE_NAMES.has(name)) {
|
|
@@ -113,7 +123,10 @@ function chordScales(chord) {
|
|
|
113
123
|
name,
|
|
114
124
|
extra: size - chordPcs.length,
|
|
115
125
|
size,
|
|
116
|
-
avoid:
|
|
126
|
+
avoid: clashingNotes(data, mask, false).length,
|
|
127
|
+
// Eligible only through the fifth exemption: a scale that holds every
|
|
128
|
+
// written tone is the better answer for a chord that writes a tension.
|
|
129
|
+
borrowed: writesTension && !scaleMatchesChord(chordPcs, mask, rootPc)
|
|
117
130
|
});
|
|
118
131
|
}
|
|
119
132
|
}
|
|
@@ -133,6 +146,9 @@ function chordScales(chord) {
|
|
|
133
146
|
if (preferHeptatonic && a.size === HEPTATONIC_SIZE !== (b.size === HEPTATONIC_SIZE)) {
|
|
134
147
|
return a.size === HEPTATONIC_SIZE ? -1 : 1;
|
|
135
148
|
}
|
|
149
|
+
if (a.borrowed !== b.borrowed) {
|
|
150
|
+
return a.borrowed ? 1 : -1;
|
|
151
|
+
}
|
|
136
152
|
if (a.extra !== b.extra) {
|
|
137
153
|
return a.extra - b.extra;
|
|
138
154
|
}
|
|
@@ -152,25 +168,31 @@ function avoidNotes(chord, scaleName, opts = {}) {
|
|
|
152
168
|
const asked = assertOptions(opts, "opts");
|
|
153
169
|
const mask = requireChordScaleMask(scaleName);
|
|
154
170
|
const data = toChordData(chord);
|
|
171
|
+
const use = assertOneOf(asked.use ?? "harmonic", ["harmonic", "melodic"], "avoid-note use");
|
|
172
|
+
if (isAlteredDominant(data, scaleName)) {
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
return clashingNotes(data, mask, use === "melodic");
|
|
176
|
+
}
|
|
177
|
+
function clashingNotes(data, mask, melodic) {
|
|
155
178
|
const rootPc = pitchClassOf(data.rootPc);
|
|
156
179
|
const chordPcs = chordPitchClasses(data);
|
|
157
|
-
|
|
158
|
-
if (!scaleMatchesChord(chordPcs, mask, rootPc) && !alteredDominant) {
|
|
180
|
+
if (!scaleMatchesChord(chordPcs, mask, rootPc)) {
|
|
159
181
|
return [];
|
|
160
182
|
}
|
|
161
183
|
const chordSet = new Set(chordPcs);
|
|
162
184
|
const displaced = new Set(displacedThirds(data));
|
|
163
|
-
const melodic = asked.use === "melodic";
|
|
164
185
|
const semitoneAboveRoot = pitchClassOf(rootPc + 1);
|
|
186
|
+
const dominantNinth = soundsDominantSeventh(data) ? semitoneAboveRoot : void 0;
|
|
165
187
|
const avoid = [];
|
|
166
188
|
for (let pc = 0; pc < 12; pc += 1) {
|
|
167
|
-
if (!maskHasPitchClass(mask, rootPc, pc) || chordSet.has(pc)) {
|
|
189
|
+
if (!maskHasPitchClass(mask, rootPc, pc) || chordSet.has(pc) || pc === dominantNinth) {
|
|
168
190
|
continue;
|
|
169
191
|
}
|
|
170
192
|
if (melodic && pc !== semitoneAboveRoot) {
|
|
171
193
|
continue;
|
|
172
194
|
}
|
|
173
|
-
if (
|
|
195
|
+
if (chordSet.has(pitchClassOf(pc - 1)) || displaced.has(pc)) {
|
|
174
196
|
avoid.push(pc);
|
|
175
197
|
}
|
|
176
198
|
}
|
|
@@ -360,4 +382,4 @@ export {
|
|
|
360
382
|
scalesForChanges,
|
|
361
383
|
roleOf
|
|
362
384
|
};
|
|
363
|
-
//# sourceMappingURL=chunk-
|
|
385
|
+
//# sourceMappingURL=chunk-2G5MCGYU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/theory/chordscale/index.ts","../src/theory/harmony/index.ts"],"sourcesContent":["import { InvalidInputError } from '../../core/errors/index.js';\nimport { pitchClassOf as pitchClass } from '../../core/pitch/index.js';\nimport {\n assertArray,\n assertGenerationBudget,\n assertOneOf,\n assertOptions,\n assertPitchClass,\n assertPositiveInt,\n} from '../../core/validation/index.js';\nimport type { Chord } from '../chord/index.js';\nimport { chordPitchClasses, displacedThirds } from '../chord/index.js';\nimport type { ScaleNameInput } from '../scale/index.js';\nimport {\n assertModeMask,\n NAMED_SCALES,\n namedScaleMask,\n requireScaleMask,\n resolveScaleName,\n} from '../scale/index.js';\nimport { type ChordLike, toChordData } from '../symbol/index.js';\nimport { soundsDominantSeventh } from '../tendency/index.js';\n\n/**\n * The mask of a scale a chord-scale question may be asked about.\n *\n * Chord-scale theory is a Western practice, so the register of world scales is\n * not a vocabulary these functions answer from: a raga offered as the scale\n * over an altered dominant would read as an answer while being a category\n * error. {@link chordScales} proposes {@link NAMED_SCALES} and nothing else,\n * and the questions asked about one chosen scale accept exactly what it can\n * propose — an alias of a Western scale included, a world scale not.\n *\n * @param name The scale name or alias.\n * @param label What the name is, for the error message.\n * @returns The 12-bit mask.\n * @throws If the name is not a built-in scale, or names a world scale.\n */\nfunction requireChordScaleMask(name: ScaleNameInput, label = 'scale'): number {\n const canonical = resolveScaleName(name);\n if (canonical !== undefined && !Object.hasOwn(NAMED_SCALES, canonical)) {\n throw new InvalidInputError(\n `${label} must name a scale chord-scale theory ranks; ${String(name)} is a world scale`,\n );\n }\n return requireScaleMask(name, label);\n}\n\n/** Count the set bits (scale tones) in a 12-bit mode mask. */\nfunction popcount12(mask: number): number {\n let count = 0;\n for (let n = 0; n < 12; n += 1) {\n count += (mask >> n) & 1;\n }\n return count;\n}\n\n/** Test whether a pitch class belongs to a mode mask rooted on `scaleRootPc`. */\nfunction maskHasPitchClass(mask: number, scaleRootPc: number, pc: number): boolean {\n const offset = pitchClass(pc - scaleRootPc);\n return ((mask >> offset) & 1) === 1;\n}\n\n/**\n * Test whether every chord pitch class is contained in a scale.\n *\n * @param chordPcs The chord's pitch classes (0..11).\n * @param scaleMask The scale's 12-bit mode mask.\n * @param scaleRootPc The pitch class the mask is rooted on.\n * @returns True if the scale is a superset of the chord.\n *\n * @category Scales\n */\nexport function scaleMatchesChord(\n chordPcs: number[],\n scaleMask: number,\n scaleRootPc: number,\n): boolean {\n // The mask is read with bit operations and a pitch class shifts it, so both\n // coerce: an entry that is not a pitch class would silently be read as one.\n assertModeMask(scaleMask, 'scaleMask');\n assertPitchClass(scaleRootPc, 'scaleRootPc');\n const pcs = assertArray<number>(chordPcs, 'chord pitch classes');\n for (let index = 0; index < pcs.length; index += 1) {\n const pc = assertPitchClass(pcs[index] ?? Number.NaN, `chord pitch classes[${index}]`);\n if (!maskHasPitchClass(scaleMask, scaleRootPc, pc)) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * A named scale rooted on a pitch class that fits over a chord.\n *\n * @category Scales\n */\nexport type ChordScaleMatch = {\n name: string;\n rootPc: number;\n};\n\n/**\n * Scale names whose mask duplicates another {@link NAMED_SCALES} entry\n * (major/ionian, naturalMinor/aeolian). Chord-scale analysis conventionally\n * speaks in mode names, so these aliases are skipped and only the modal name\n * is reported.\n */\nexport const ALIASED_SCALE_NAME_LIST: readonly string[] = ['major', 'naturalMinor'];\n\nconst ALIASED_SCALE_NAMES = new Set(ALIASED_SCALE_NAME_LIST);\n\n/** Number of tones in a heptatonic (seven-note) scale. */\nexport const HEPTATONIC_SIZE = 7;\n\n/**\n * Conventional preference among equally-fitting scales, brightest first.\n *\n * Several modes fit a chord that states no third or sixth — a power chord, a\n * suspension — equally well. Alphabetical order made `aeolian` the answer for\n * those, naming a minor mode as the best fit for a mode-neutral chord.\n */\nexport const SCALE_PREFERENCE = [\n 'ionian',\n 'major',\n 'mixolydian',\n 'dorian',\n 'lydian',\n 'aeolian',\n 'naturalMinor',\n 'phrygian',\n 'locrian',\n] as const;\n\n/** Conventional first choices that pure set-fit ranking cannot express. */\nexport const IDIOMATIC_SCALES: Partial<Record<Chord['quality'], readonly string[]>> = {\n aug: ['wholeTone'],\n m7b5: ['locrian'],\n // The diminished scale played over a diminished seventh is the whole-half\n // octatonic. Its half-whole rotation belongs to the dominant it colours: over\n // a diminished seventh every one of its non-chord tones lands a semitone\n // above a chord tone, so it offers no tension at all.\n dim7: ['octatonicWholeHalf'],\n minMaj7: ['melodicMinor'],\n};\n\n/** Position of a scale in {@link SCALE_PREFERENCE}, or last when unlisted. */\nfunction conventionalRank(name: string): number {\n const index = (SCALE_PREFERENCE as readonly string[]).indexOf(name);\n return index < 0 ? SCALE_PREFERENCE.length : index;\n}\n\n/** Whether this scale is an idiomatic color choice for the chord quality. */\nfunction idiomaticRank(chord: Chord, name: string): number {\n const choices = IDIOMATIC_SCALES[chord.quality];\n if (choices === undefined) {\n return 0;\n }\n const index = choices.indexOf(name);\n return index < 0 ? choices.length + 1 : index;\n}\n\n/**\n * A dominant seventh may use altered colors while retaining its perfect fifth\n * in the voicing. It is read from the tones, as every dominant is: a major\n * third with a minor seventh whose only tones outside the altered scale are the\n * fifth, so `7`, `7alt`, `7b9`, `7#9` and `7b13` all take it while `9` and `13`\n * do not. Lead sheets commonly write the shorter `7` here.\n */\nfunction isAlteredDominant(chord: Chord, scaleName: string): boolean {\n if (scaleName !== 'altered' || !soundsDominantSeventh(chord)) {\n return false;\n }\n const mask = namedScaleMask(scaleName);\n const rootPc = pitchClass(chord.rootPc);\n const fifthPc = pitchClass(rootPc + 7);\n return (\n mask !== undefined &&\n chordPitchClasses(chord).every((pc) => pc === fifthPc || maskHasPitchClass(mask, rootPc, pc))\n );\n}\n\n/**\n * List the scales that fit over a chord, best fit first.\n *\n * Only the chord root is considered as the scale root, matching the\n * conventional chord-scale relationship. Every entry of {@link NAMED_SCALES}\n * whose pitch-class set is a superset of the chord's is returned once per\n * distinct pitch-class set (aliased masks such as major/ionian report only the\n * modal name). The chromatic scale is only returned as a fallback when no other\n * scale contains the chord.\n *\n * The ranking applies these keys in order:\n *\n * 1. The idiomatic scales for the chord quality, in the order they are named\n * there, ahead of every scale that is not one of them.\n * 2. For bare triads and smaller chords, heptatonic scales ahead of pentatonics\n * and other sizes: a pentatonic adds no modal color over a triad, so the\n * seven-note modes are the more useful answer.\n * 3. Fewest extra scale tones beyond the chord.\n * 4. Conventional modal preference.\n * 5. Fewest avoid notes, which separates the symmetric and melodic-minor\n * scales the modal preference does not name.\n * 6. Alphabetical order, so the list is stable.\n *\n * The idiomatic key comes first, so the head of the list is the scale a player\n * would name rather than the tightest fit: over `Cm7b5` the locrian mode leads\n * even though the blues scale adds fewer tones, because locrian is what a\n * half-diminished chord is read as. Read further down the list, or pick by name,\n * when the closest fit is what is wanted; {@link scalesForChanges} makes the\n * choice for a whole progression.\n *\n * @param chord The chord to fit scales over, as a chord symbol, chord data, or\n * a `Chord`.\n * @returns The matching scales rooted on the chord root, best fit first.\n *\n * @example\n * ```ts\n * import { makeChord, chordScales } from '@libraz/libcantus';\n * const scales = chordScales(makeChord(0, 'maj7'));\n * // scales for Cmaj7, best fit first; each is { name, rootPc: 0 }\n * ```\n *\n * @category Scales\n */\nexport function chordScales(chord: ChordLike): ChordScaleMatch[] {\n const data = toChordData(chord);\n const chordPcs = chordPitchClasses(data);\n const rootPc = pitchClass(data.rootPc);\n const ranked: {\n name: string;\n extra: number;\n size: number;\n avoid: number;\n borrowed: boolean;\n }[] = [];\n // A tone beyond the plain seventh chord is a written alteration or extension.\n const writesTension = chordPcs.some((pc) => ![0, 4, 7, 10].includes(pitchClass(pc - rootPc)));\n const seenMasks = new Set<number>();\n for (const name of Object.keys(NAMED_SCALES)) {\n if (name === 'chromatic' || ALIASED_SCALE_NAMES.has(name)) {\n continue;\n }\n const mask = namedScaleMask(name);\n if (mask === undefined || seenMasks.has(mask)) {\n continue;\n }\n seenMasks.add(mask);\n if (scaleMatchesChord(chordPcs, mask, rootPc) || isAlteredDominant(data, name)) {\n const size = popcount12(mask);\n ranked.push({\n name,\n extra: size - chordPcs.length,\n size,\n avoid: clashingNotes(data, mask, false).length,\n // Eligible only through the fifth exemption: a scale that holds every\n // written tone is the better answer for a chord that writes a tension.\n borrowed: writesTension && !scaleMatchesChord(chordPcs, mask, rootPc),\n });\n }\n }\n if (ranked.length === 0) {\n // No diatonic-style scale contains the chord; fall back to the chromatic\n // scale, which trivially contains every pitch class.\n if (NAMED_SCALES.chromatic !== undefined) {\n return [{ name: 'chromatic', rootPc }];\n }\n return [];\n }\n const preferHeptatonic = chordPcs.length <= 3;\n ranked.sort((a, b) => {\n const idiomaticA = idiomaticRank(data, a.name);\n const idiomaticB = idiomaticRank(data, b.name);\n if (idiomaticA !== idiomaticB) {\n return idiomaticA - idiomaticB;\n }\n if (preferHeptatonic && (a.size === HEPTATONIC_SIZE) !== (b.size === HEPTATONIC_SIZE)) {\n return a.size === HEPTATONIC_SIZE ? -1 : 1;\n }\n if (a.borrowed !== b.borrowed) {\n return a.borrowed ? 1 : -1;\n }\n if (a.extra !== b.extra) {\n return a.extra - b.extra;\n }\n const rankA = conventionalRank(a.name);\n const rankB = conventionalRank(b.name);\n if (rankA !== rankB) {\n return rankA - rankB;\n }\n // Among scales the modal preference does not name — the symmetric and\n // melodic-minor scales — the one that clashes with the chord least is the\n // one a player reaches for. Alphabetical order answered with the rotation\n // that leaves nothing playable.\n if (a.avoid !== b.avoid) {\n return a.avoid - b.avoid;\n }\n return a.name < b.name ? -1 : a.name > b.name ? 1 : 0;\n });\n return ranked.map((entry) => ({ name: entry.name, rootPc }));\n}\n\n/**\n * Which use an avoid note is judged for: sounding it, or passing through it.\n *\n * `'harmonic'` is the Berklee-style rule — a tone that must not be\n * sounded against the chord. `'melodic'` keeps only what a line cannot pass\n * through either, which is the semitone above the root; every other clash\n * resolves as the line moves on. Over a chord that sounds a dominant seventh\n * the semitone above the root is the flat ninth, a tension under either use\n * whichever scale supplies it; the flat thirteenth stays a harmonic avoid note.\n *\n * @category Scales\n */\nexport type AvoidNoteUse = 'harmonic' | 'melodic';\n\n/**\n * Options for {@link avoidNotes}.\n *\n * @category Scales\n */\nexport type AvoidNotesOptions = {\n use?: AvoidNoteUse;\n};\n\n/**\n * List a scale's avoid notes over a chord.\n *\n * An avoid note is a non-chord scale tone that lies a semitone directly above a\n * chord tone, or the third a suspension displaced; sounding it against the\n * chord clashes. The scale is rooted on the chord root. If the scale does not\n * contain the chord, no avoid notes exist.\n *\n * The rule states which tones must not be *sounded* against the chord, which is\n * not the same question as which tones a line may not touch. Pass\n * `{ use: 'melodic' }` for the melodic reading: only the semitone above the\n * root survives it, so the result is always a subset of the harmonic one.\n *\n * @param chord The chord providing the chord tones, as a chord symbol, chord\n * data, or a `Chord`.\n * @param scaleName A key of {@link NAMED_SCALES}, or an alias of one. A world\n * scale is not one: chord-scale theory is a Western practice, so a raga named\n * here is rejected rather than answered with a number.\n * @param opts Set `use: 'melodic'` to judge a line rather than a voicing.\n * @returns The avoid-note pitch classes, sorted ascending in [0, 11].\n * @throws If `scaleName` is not a built-in scale. An empty result already\n * means \"this scale has no avoid notes over this chord\"; answering a typo\n * the same way would make the two indistinguishable.\n *\n * @example\n * ```ts\n * import { makeChord, avoidNotes } from '@libraz/libcantus';\n * avoidNotes(makeChord(0, 'maj7'), 'ionian'); // [5] — F clashes with the third\n * avoidNotes(makeChord(0, 'maj7'), 'ionian', { use: 'melodic' }); // [] — a line may pass through it\n * ```\n *\n * @category Scales\n */\nexport function avoidNotes(\n chord: ChordLike,\n scaleName: ScaleNameInput,\n opts: AvoidNotesOptions = {},\n): number[] {\n const asked = assertOptions(opts, 'opts');\n const mask = requireChordScaleMask(scaleName);\n const data = toChordData(chord);\n const use = assertOneOf(asked.use ?? 'harmonic', ['harmonic', 'melodic'], 'avoid-note use');\n if (isAlteredDominant(data, scaleName)) {\n return [];\n }\n return clashingNotes(data, mask, use === 'melodic');\n}\n\n/**\n * The scale tones that clash with the chord by the avoid-note rule, whatever\n * function the chord serves: {@link avoidNotes} before the altered dominant's\n * exemption. Empty when the scale does not contain the chord.\n */\nfunction clashingNotes(data: Chord, mask: number, melodic: boolean): number[] {\n const rootPc = pitchClass(data.rootPc);\n const chordPcs = chordPitchClasses(data);\n if (!scaleMatchesChord(chordPcs, mask, rootPc)) {\n return [];\n }\n const chordSet = new Set(chordPcs);\n // Sounding the third a suspension stands in for is what undoes the\n // suspension, so it is an avoid note however consonant it is against the\n // scale. Both thirds are named: a suspension does not say which one it\n // displaced — that is what suspending is — so meeting either one ends it.\n const displaced = new Set(displacedThirds(data));\n const semitoneAboveRoot = pitchClass(rootPc + 1);\n // The flat ninth is a dominant's own tension, whichever scale supplies it.\n const dominantNinth = soundsDominantSeventh(data) ? semitoneAboveRoot : undefined;\n const avoid: number[] = [];\n for (let pc = 0; pc < 12; pc += 1) {\n if (!maskHasPitchClass(mask, rootPc, pc) || chordSet.has(pc) || pc === dominantNinth) {\n continue;\n }\n if (melodic && pc !== semitoneAboveRoot) {\n continue;\n }\n if (chordSet.has(pitchClass(pc - 1)) || displaced.has(pc)) {\n avoid.push(pc);\n }\n }\n return avoid.sort((a, b) => a - b);\n}\n\n/**\n * Semitones above the root of the colors a dominant takes when it resolves to a\n * minor tonic: the flat ninth, the sharp ninth, and the flat thirteenth.\n *\n * Over a dominant read on its own, the flat ninth is already a tension and the\n * others sit a semitone above a chord tone. Heard as the dominant of a minor key\n * they are the key's own tones, and standard practice, so the function the\n * chord serves is what decides.\n */\nexport const MINOR_RESOLUTION_TENSIONS = [1, 3, 8] as const;\n\n/** Whether this chord is a dominant seventh resolving down a fifth to minor. */\nfunction resolvesToMinorTonic(\n chord: Chord,\n chordPcs: number[],\n target: Chord | undefined,\n): boolean {\n if (target === undefined) {\n return false;\n }\n const rootPc = pitchClass(chord.rootPc);\n const sounds = (semitones: number): boolean => chordPcs.includes(pitchClass(rootPc + semitones));\n if (!sounds(4) || !sounds(10)) {\n return false;\n }\n const targetRootPc = pitchClass(target.rootPc);\n if (targetRootPc !== pitchClass(rootPc + 5)) {\n return false;\n }\n return chordPitchClasses(target).includes(pitchClass(targetRootPc + 3));\n}\n\n/**\n * Options for {@link availableTensions}.\n *\n * @category Scales\n */\nexport type AvailableTensionsOptions = {\n /**\n * The chord this one resolves to, as a chord symbol, chord data, or a\n * `Chord`.\n */\n resolvesTo?: ChordLike;\n};\n\n/**\n * List a scale's available tensions over a chord.\n *\n * Available tensions are scale tones that are neither chord tones nor avoid\n * notes, i.e. the usable color tones (typically the 9/11/13 region). The scale\n * is rooted on the chord root. If the scale does not contain the chord, there\n * are no available tensions.\n *\n * A tension's availability also depends on what the chord is doing. Pass\n * `resolvesTo` to say which chord this one resolves to: a dominant seventh\n * resolving down a fifth to a minor tonic takes its sharp ninth and flat\n * thirteenth as well as the flat ninth every dominant takes. Only\n * scale tones are ever added, so the result stays within the scale.\n *\n * @param chord The chord providing the chord tones, as a chord symbol, chord\n * data, or a `Chord`.\n * @param scaleName A key of {@link NAMED_SCALES}, or an alias of one; a world\n * scale is outside chord-scale theory, as in {@link avoidNotes}.\n * @param opts Set `resolvesTo` to the chord this one resolves to.\n * @returns The available-tension pitch classes, sorted ascending in [0, 11].\n * @throws If `scaleName` is not a built-in scale, as {@link avoidNotes} does.\n *\n * @example\n * ```ts\n * import { makeChord, availableTensions } from '@libraz/libcantus';\n * availableTensions(makeChord(0, 'maj7'), 'ionian'); // [2, 9] — color tones over Cmaj7\n * availableTensions(makeChord(7, 'dom7'), 'phrygianDominant', { resolvesTo: makeChord(0, 'min') });\n * // [3, 8] — the b9, and the b13 the resolution to C minor makes available\n * ```\n *\n * @category Scales\n */\nexport function availableTensions(\n chord: ChordLike,\n scaleName: ScaleNameInput,\n opts: AvailableTensionsOptions = {},\n): number[] {\n const asked = assertOptions(opts, 'opts');\n const mask = requireChordScaleMask(scaleName);\n const data = toChordData(chord);\n const rootPc = pitchClass(data.rootPc);\n const chordPcs = chordPitchClasses(data);\n const alteredDominant = isAlteredDominant(data, scaleName);\n if (!scaleMatchesChord(chordPcs, mask, rootPc) && !alteredDominant) {\n return [];\n }\n const chordSet = new Set(chordPcs);\n const avoidSet = alteredDominant ? new Set<number>() : new Set(avoidNotes(data, scaleName));\n const functional = resolvesToMinorTonic(\n data,\n chordPcs,\n asked.resolvesTo === undefined ? undefined : toChordData(asked.resolvesTo),\n )\n ? new Set(MINOR_RESOLUTION_TENSIONS.map((semitones) => pitchClass(rootPc + semitones)))\n : undefined;\n const tensions: number[] = [];\n for (let pc = 0; pc < 12; pc += 1) {\n if (!maskHasPitchClass(mask, rootPc, pc) || chordSet.has(pc)) {\n continue;\n }\n if (avoidSet.has(pc) && functional?.has(pc) !== true) {\n continue;\n }\n tensions.push(pc);\n }\n return tensions.sort((a, b) => a - b);\n}\n\n/**\n * A scale fit over a chord, with its non-chord tones sorted by what may be done\n * with them.\n *\n * `avoid`, `passing` and `tensions` partition the scale tones the chord does\n * not state: `avoid` may not be played at all, `passing` may be passed through\n * melodically but not sounded against the chord, and `tensions` may be added\n * freely as color. `avoid` is {@link avoidNotes} under `use: 'melodic'`, and\n * `avoid` together with `passing` is the harmonic reading.\n *\n * @category Scales\n */\nexport type ChordScaleReportEntry = {\n name: string;\n rootPc: number;\n avoid: number[];\n passing: number[];\n tensions: number[];\n};\n\n/**\n * Report the best-fitting scales for a chord with their avoid notes and tensions.\n *\n * Combines {@link chordScales}, {@link avoidNotes}, and {@link availableTensions}\n * into a single ergonomic result, ordered best fit first. The report is read as\n * playing advice, so the tones a line may pass through are reported apart from\n * the ones it may not touch; see {@link ChordScaleReportEntry}.\n *\n * @param chord The chord to analyze, as a chord symbol, chord data, or a\n * `Chord`.\n * @param limit Optional maximum number of scales to report; all by default.\n * @returns One entry per reported scale, best fit first.\n *\n * @category Scales\n */\nexport function chordScaleReport(chord: ChordLike, limit?: number): ChordScaleReportEntry[] {\n if (limit !== undefined) {\n assertPositiveInt(limit, 'chord-scale report limit');\n }\n const data = toChordData(chord);\n const matches = chordScales(data);\n const chosen = limit === undefined ? matches : matches.slice(0, limit);\n return chosen.map((match) => {\n const harmonic = avoidNotes(data, match.name);\n const melodic = new Set(avoidNotes(data, match.name, { use: 'melodic' }));\n return {\n name: match.name,\n rootPc: match.rootPc,\n avoid: harmonic.filter((pc) => melodic.has(pc)),\n passing: harmonic.filter((pc) => !melodic.has(pc)),\n tensions: availableTensions(data, match.name),\n };\n });\n}\n\n/**\n * A chord paired with the scale chosen for it by {@link scalesForChanges}.\n *\n * @category Scales\n */\nexport type ScaleChoice = {\n chord: Chord;\n scale: ChordScaleMatch;\n};\n\n/**\n * Small per-candidate penalty added in {@link scalesForChanges} so that, among\n * choices of otherwise-equal transition cost, the tighter best-fit scale wins.\n */\nexport const RANK_PENALTY = 0.01;\n\n/** Build the pitch-class set of a named scale rooted on `rootPc`. */\nfunction scalePitchClassSet(name: string, rootPc: number): Set<number> {\n const mask = namedScaleMask(name);\n const pcs = new Set<number>();\n if (mask === undefined) {\n return pcs;\n }\n for (let n = 0; n < 12; n += 1) {\n if (((mask >> n) & 1) === 1) {\n pcs.add(pitchClass(rootPc + n));\n }\n }\n return pcs;\n}\n\n/** Count pitch classes that belong to exactly one of two sets. */\nfunction symmetricDifferenceSize(a: Set<number>, b: Set<number>): number {\n let count = 0;\n for (const pc of a) {\n if (!b.has(pc)) {\n count += 1;\n }\n }\n for (const pc of b) {\n if (!a.has(pc)) {\n count += 1;\n }\n }\n return count;\n}\n\n/**\n * Choose one scale per chord across a progression, favoring continuity.\n *\n * Each chord's {@link chordScales} candidates form a stage in a Viterbi-style\n * dynamic program. The transition cost between adjacent choices is the number\n * of pitch classes that differ between their pitch-class sets (the symmetric\n * difference), plus a small penalty for straying from a chord's best-fit scale\n * so that ties break toward the tighter fit. The minimum-total-cost path is\n * returned, one {@link ScaleChoice} per input chord in the original order.\n *\n * Each choice pairs its scale with the chord exactly as it was handed in, so\n * this takes plain chord data rather than the wider forms the entry points\n * above accept.\n *\n * @param chords The chord sequence to choose scales for.\n * @returns One scale choice per chord, in input order.\n *\n * @category Scales\n */\nexport function scalesForChanges(chords: readonly Chord[]): ScaleChoice[] {\n assertArray(chords, 'chord-scale changes');\n assertGenerationBudget(chords.length, 'chord-scale changes');\n if (chords.length === 0) {\n return [];\n }\n const candidateLists = chords.map((chord) => chordScales(chord));\n const pcSets = candidateLists.map((candidates) =>\n candidates.map((match) => scalePitchClassSet(match.name, match.rootPc)),\n );\n\n const first = candidateLists[0] ?? [];\n const dp: number[][] = [first.map((_, j) => j * RANK_PENALTY)];\n const back: number[][] = [first.map(() => -1)];\n\n for (let i = 1; i < candidateLists.length; i += 1) {\n const candidates = candidateLists[i] ?? [];\n const prevCosts = dp[i - 1] ?? [];\n const prevSets = pcSets[i - 1] ?? [];\n const curSets = pcSets[i] ?? [];\n const stageCosts: number[] = [];\n const stageBack: number[] = [];\n for (let j = 0; j < candidates.length; j += 1) {\n let bestCost = Number.POSITIVE_INFINITY;\n let bestPrev = -1;\n for (let k = 0; k < prevCosts.length; k += 1) {\n const transition = symmetricDifferenceSize(\n prevSets[k] ?? new Set(),\n curSets[j] ?? new Set(),\n );\n const cost = (prevCosts[k] ?? 0) + transition;\n if (cost < bestCost) {\n bestCost = cost;\n bestPrev = k;\n }\n }\n stageCosts.push(bestCost + j * RANK_PENALTY);\n stageBack.push(bestPrev);\n }\n dp.push(stageCosts);\n back.push(stageBack);\n }\n\n const lastCosts = dp[dp.length - 1] ?? [];\n let bestFinal = 0;\n for (let j = 1; j < lastCosts.length; j += 1) {\n if ((lastCosts[j] ?? Number.POSITIVE_INFINITY) < (lastCosts[bestFinal] ?? 0)) {\n bestFinal = j;\n }\n }\n\n const chosenIndices: number[] = new Array(candidateLists.length);\n let current = bestFinal;\n for (let i = candidateLists.length - 1; i >= 0; i -= 1) {\n chosenIndices[i] = current;\n current = back[i]?.[current] ?? -1;\n }\n\n return chords.map((chord, i) => {\n const candidates = candidateLists[i] ?? [];\n const scale = candidates[chosenIndices[i] ?? 0] ?? { name: 'chromatic', rootPc: chord.rootPc };\n return { chord, scale };\n });\n}\n","import { pitchClassOf } from '../../core/pitch/index.js';\nimport { assertFiniteNumber } from '../../core/validation/index.js';\nimport { type ChordToneRole, chordToneRole, thirdSlotOf } from '../chord/index.js';\nimport { type ChordLike, toChordData } from '../symbol/index.js';\n\n/**\n * Harmonic role a pitch plays within a chord.\n *\n * @category Functional Harmony\n */\nexport type HarmonyRole = ChordToneRole | 'tension' | 'doubling';\n\n/**\n * How firmly a pitch is locked to the chord's identity.\n *\n * - `identity`: moving it produces a different chord (the root).\n * - `quality`: moving it flips the chord quality (the third).\n * - `voicing`: it can move freely without changing chord identity or quality.\n *\n * @category Functional Harmony\n */\nexport type LockLevel = 'identity' | 'quality' | 'voicing';\n\n/**\n * A pitch's role, lock level, and owning chord.\n *\n * @category Functional Harmony\n */\nexport type VoicedRole = {\n role: HarmonyRole;\n lock: LockLevel;\n belongsToChordId: number;\n};\n\n/**\n * Classify a pitch's harmonic role and lock level within a chord.\n *\n * The role comes from the pitch's interval class above the chord root, read\n * against the chord's own template: root (0), third (3/4), fifth (6/7/8),\n * sixth or seventh (9/10/11). Every pitch the template does not claim is\n * `'tension'` — including one that is simply foreign to the chord, which this\n * single-pitch query cannot tell from a colour tone. The root locks the chord\n * identity, the third locks its quality, and everything else is free voicing.\n * Where a chord has no third, the tone standing in its place — the fourth of a\n * `sus4`, the second of a `sus2`, the eleventh of an eleventh chord — takes the\n * third's slot and is locked to `quality`, since moving it changes the chord.\n * At most one interval class of a chord is ever reported as its third, so a\n * consumer reading `lock: 'quality'` as \"this tone identifies the chord\" gets\n * one answer rather than two. Detecting an octave doubling requires the\n * surrounding voicing, which this query does not carry, so `'doubling'` is part\n * of the type — the shared vocabulary of harmonic roles — but is never returned\n * here.\n *\n * @param pitch MIDI pitch or bare pitch class.\n * @param chord The chord providing the root reference, as a chord symbol, chord\n * data, or a `Chord`.\n * @param chordId Identifier stored on the result (defaults to 0).\n * @returns The pitch's role, lock level, and owning chord id.\n * @example\n * ```ts\n * import { roleOf, makeChord } from '@libraz/libcantus';\n * roleOf(64, makeChord(0, 'maj')); // E over C major\n * // { role: 'third', lock: 'quality', belongsToChordId: 0 }\n * ```\n * @category Functional Harmony\n */\nexport function roleOf(pitch: number, chord: ChordLike, chordId = 0): VoicedRole {\n // The id is carried into the result, so a value that is not one would be\n // reported back as the chord this role belongs to.\n assertFiniteNumber(chordId, 'chordId');\n const data = toChordData(chord);\n const interval = (pitchClassOf(pitch) - pitchClassOf(data.rootPc) + 12) % 12;\n // What stands in the third's slot is read where the chord is read, not here:\n // the tone that identifies a chord and the tone the avoid-note rule refuses\n // against it are two consequences of one fact about the chord.\n const slot = thirdSlotOf(data);\n const isSuspendedTone = slot.kind === 'suspension' && interval === slot.interval;\n const chordRole = chordToneRole(pitch, data);\n let role: HarmonyRole;\n let lock: LockLevel;\n if (isSuspendedTone) {\n role = 'third'; // suspended tone occupies the third's quality-defining slot\n lock = 'quality';\n } else if (chordRole !== null) {\n role = chordRole;\n lock = chordRole === 'root' ? 'identity' : chordRole === 'third' ? 'quality' : 'voicing';\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