@libraz/libcantus-wasm 0.0.0-stage → 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.
@@ -0,0 +1,1508 @@
1
+ /// <reference lib="esnext.disposable" />
2
+ import { e as KeyScale, h as NoteEvent, i as NoteLike, g as Note } from './index-C9MYbuKS.js';
3
+ import { d as ChordQuality, k as KeyVariant, b as Chord, r as SpelledKeyLike, c as ChordLike, K as KeyLike, n as ResolvedKey, N as NoteSafety, o as SafetyProfile } from './coerce-CUhHc3Tu.js';
4
+ import { r as ScaleName } from './masks-tycmkrgs.js';
5
+ import { p as KeyProfileName, q as KeyProfilePair, a6 as RejectedCandidate, r as KeyRegion, h as ChordTimeline, c as CadenceHit, a as AnalyzedNote, ab as TheoryLabel, K as KeyContext, d as CadenceResult, a5 as ReferenceProfile } from './types-7mGFwvMm.js';
6
+ import { b as MeterLike } from './index-Bf0Sv8a9.js';
7
+
8
+ /**
9
+ * Church-mode candidates for {@link detectKey}.
10
+ *
11
+ * A mode is not a key with a different scale bolted on: it is the same tonal
12
+ * hierarchy — tonic strongest, dominant next, the remaining diatonic degrees
13
+ * behind them — heard over a scale in which one degree has been replaced. Its
14
+ * profile is therefore derived from the profile of the major or minor key it
15
+ * sits closest to, rather than being a table of its own.
16
+ */
17
+
18
+ /**
19
+ * A church mode {@link detectKey} can rank alongside the major and minor keys.
20
+ *
21
+ * Ionian and Aeolian are absent because they are the major and the natural minor
22
+ * scale: a piece in either is already reported by the plain major or minor
23
+ * candidate, and adding a second candidate over the same pitch classes and the
24
+ * same profile would only produce a tie with itself.
25
+ *
26
+ * @category Recognition
27
+ */
28
+ type ModalScaleName = 'dorian' | 'phrygian' | 'lydian' | 'mixolydian' | 'locrian';
29
+ /**
30
+ * How a modal candidate is built out of its parallel major or minor key.
31
+ *
32
+ * @category Recognition
33
+ */
34
+ type ModalCandidate = {
35
+ /** The name reported as {@link KeyMatch.scaleName} when this candidate wins. */
36
+ scaleName: ModalScaleName;
37
+ /** The major or minor key this mode is closest to, reported as `mode`. */
38
+ mode: 'major' | 'minor';
39
+ /** The 12-bit scale mask of the mode. */
40
+ mask: number;
41
+ /**
42
+ * Degree pairs the mode substitutes, as `[replaced, replacing]` semitone
43
+ * offsets above the tonic. Applying them to the parallel scale yields `mask`,
44
+ * and applying them to the parallel profile yields this candidate's profile.
45
+ */
46
+ substitutions: readonly (readonly [number, number])[];
47
+ };
48
+ /**
49
+ * Every mode {@link DetectKeyOptions.modes} accepts, in candidate order.
50
+ *
51
+ * @category Recognition
52
+ */
53
+ declare const MODAL_SCALE_NAMES: readonly ModalScaleName[];
54
+
55
+ /**
56
+ * Recognition: infer a chord name from a set of pitches, or a key from a set of
57
+ * pitch classes. This is the inverse direction of the chord/scale builders,
58
+ * which only go name -> notes.
59
+ */
60
+
61
+ /**
62
+ * A candidate chord interpretation of a pitch set.
63
+ *
64
+ * @category Recognition
65
+ */
66
+ type ChordMatch = {
67
+ rootPc: number;
68
+ quality: ChordQuality;
69
+ /** Chord tones absent from the input (an incomplete voicing). */
70
+ missingPcs: number[];
71
+ /** Input pitch classes not belonging to the chord. */
72
+ extraPcs: number[];
73
+ /** True when the input pitch-class set equals the chord exactly. */
74
+ exact: boolean;
75
+ /**
76
+ * Inversion implied by a known bass: 0 for root position, 1..n for an
77
+ * inversion. Null when no inversion can be named — either the input is an
78
+ * unordered pitch-class set with no bass, or the bass is not a chord tone (a
79
+ * pedal or passing bass), in which case `bassPc` still reports it.
80
+ */
81
+ inversion: number | null;
82
+ /** Bass pitch class when the lowest note is not the root. */
83
+ bassPc?: number;
84
+ };
85
+ /**
86
+ * Input interpretation for {@link detectChord} and {@link detectChordBest}.
87
+ *
88
+ * @category Recognition
89
+ */
90
+ type DetectChordOptions = {
91
+ /**
92
+ * `midi` uses the numerically lowest pitch as bass; `pitchClass` treats the
93
+ * input as unordered. `auto` (default) selects pitch-class mode only when all
94
+ * values lie in 0..11.
95
+ */
96
+ input?: 'auto' | 'midi' | 'pitchClass';
97
+ /** Explicit bass pitch class, including for an unordered pitch-class set. */
98
+ bassPc?: number;
99
+ };
100
+ /**
101
+ * A candidate key interpretation of a pitch-class set.
102
+ *
103
+ * @category Recognition
104
+ */
105
+ type KeyMatch = {
106
+ /** The scale that scored best for this tonic and mode, `variant` included. */
107
+ key: KeyScale;
108
+ /**
109
+ * The major or minor key this match is closest to. A modal match reports the
110
+ * mode it leans on — dorian, phrygian and locrian are minor, lydian and
111
+ * mixolydian major — so a caller that reads nothing but `mode` still gets a
112
+ * musically sane answer; `scaleName` is where the mode itself is named.
113
+ */
114
+ mode: 'major' | 'minor';
115
+ /**
116
+ * Which scale form `key` uses. Minor keys report whichever of the natural,
117
+ * harmonic and melodic masks covers the most input weight; the variant does
118
+ * not take part in ranking. A church mode reports `'modal'`, since its scale
119
+ * is neither of the major nor one of the three minor forms.
120
+ */
121
+ variant: KeyVariant;
122
+ /**
123
+ * The entry of `NAMED_SCALES` whose mask is `key.modeMask12`, naming the scale
124
+ * exactly where `mode` and `variant` only place it: `'major'`,
125
+ * `'naturalMinor'`, `'harmonicMinor'`, `'melodicMinor'`, or one of the church
126
+ * modes when {@link DetectKeyOptions.modes} put them in the running. Ionian
127
+ * and Aeolian are reported as `'major'` and `'naturalMinor'`, the names of the
128
+ * candidates they are the same scale as.
129
+ */
130
+ scaleName: ScaleName;
131
+ /**
132
+ * Fraction of the distinct input pitch classes that belong to `key`, in
133
+ * [0, 1]. Measured against the returned scale, so it always agrees with
134
+ * `isScaleTone(pc, match.key)`. This is a coverage figure, not the ranking:
135
+ * see `score`.
136
+ */
137
+ fit: number;
138
+ /**
139
+ * The value the results are ranked by, in [-1, 1]: the Pearson correlation
140
+ * between the weighted pitch-class distribution of the input and this
141
+ * candidate's key profile rotated onto its tonic. 1 is a distribution shaped
142
+ * exactly like the profile, 0 no relationship, negative an anti-correlation.
143
+ * Unlike `fit` it is a distribution measure, not a membership count, so where
144
+ * the weight falls among the scale degrees is what separates a key from its
145
+ * relative. Always a finite number; see {@link DetectKeyOptions.profile} for
146
+ * the degenerate case.
147
+ */
148
+ score: number;
149
+ /**
150
+ * Why this candidate scored what it did, in the phrasing
151
+ * {@link analyzeVoice} uses for a note.
152
+ *
153
+ * Present only when {@link DetectKeyOptions.explain} asked for it: a ranking
154
+ * is 24 candidates before the modes are counted, and most callers read the
155
+ * first one or two.
156
+ */
157
+ rationale?: string;
158
+ /**
159
+ * The candidates that were considered and rejected, and why each ranked
160
+ * below this one.
161
+ *
162
+ * Carried by the top-ranked match alone — the rivals of a runner-up are the
163
+ * rest of the list, which the caller already holds — and only when
164
+ * {@link DetectKeyOptions.explain} asked for it.
165
+ */
166
+ alternatives?: RejectedCandidate[];
167
+ };
168
+
169
+ /**
170
+ * Input weighting for {@link detectKey}.
171
+ *
172
+ * @category Recognition
173
+ */
174
+ type DetectKeyOptions = {
175
+ /**
176
+ * How much each pitch counts toward the histogram, one entry per pitch.
177
+ * Defaults to one per pitch, which weighs a thirty-second-note ornament as
178
+ * heavily as the whole note under it. {@link detectKeyFromNotes} supplies
179
+ * duration times velocity, matching how chord inference weighs its own
180
+ * histogram.
181
+ */
182
+ weights?: readonly number[];
183
+ /**
184
+ * Which key profile ranks the candidates: the 12 degree weights a key is
185
+ * expected to distribute its music over, correlated against the distribution
186
+ * actually observed.
187
+ *
188
+ * `'krumhansl'` (the default) uses the Krumhansl–Kessler probe-tone ratings,
189
+ * `'temperley'` the Kostka–Payne corpus proportions, and `'flat'` a flat
190
+ * profile over the scale, which reduces the ranking to plain scale membership
191
+ * — the behaviour this detector had before profile correlation, kept as a way
192
+ * back for a caller that depends on it. A custom pair supplies two 12-entry
193
+ * vectors indexed from the tonic (index 0 = tonic, 1 = flat second, and so on
194
+ * to 11 = major seventh).
195
+ *
196
+ * When either the distribution or the rotated profile has zero variance the
197
+ * correlation is undefined; such a candidate is scored by the normalized dot
198
+ * product (cosine similarity) of the same two vectors instead, so a result
199
+ * never carries NaN.
200
+ *
201
+ * @defaultValue `'krumhansl'`
202
+ */
203
+ profile?: KeyProfileName | KeyProfilePair;
204
+ /**
205
+ * Whether the church modes join the 24 major and minor keys as candidates.
206
+ *
207
+ * Off by default, because a modal candidate can only change a ranking by
208
+ * outranking something: a caller working in common-practice repertoire, where
209
+ * a raised sixth over a minor tonic is a melodic-minor inflection rather than
210
+ * a dorian tonality, should keep reading the answer it reads today. Turn it on
211
+ * (`true` for all five, or a list to name the modes a repertoire actually
212
+ * uses) and each enabled mode adds one candidate per tonic, ranked on a
213
+ * profile derived from its parallel major or minor key.
214
+ *
215
+ * Ionian and Aeolian are not on the list: they are the major and natural minor
216
+ * candidates, which already carry `scaleName` `'major'` and `'naturalMinor'`.
217
+ *
218
+ * @defaultValue `false`
219
+ */
220
+ modes?: boolean | readonly ModalScaleName[];
221
+ /**
222
+ * Attach a {@link KeyMatch.rationale} to every candidate, and
223
+ * {@link KeyMatch.alternatives} to the top-ranked one.
224
+ *
225
+ * Off by default, and the one explanation in the library that is: the other
226
+ * entry points explain a single reading, while a ranking explains 24 of them
227
+ * (36 or more with the modes on), each needing a phrase built for a candidate
228
+ * nobody asked about. That cost outweighs the detection itself, so it is paid
229
+ * only on request.
230
+ *
231
+ * @defaultValue false
232
+ */
233
+ explain?: boolean;
234
+ /**
235
+ * Upper bound on the input pitches processed by this detection call.
236
+ *
237
+ * @defaultValue {@link DEFAULT_GENERATION_BUDGET}
238
+ */
239
+ budget?: number;
240
+ };
241
+ /**
242
+ * Identify chords matching a set of pitches.
243
+ *
244
+ * Every input pitch class is tried as a root against every known chord quality.
245
+ * A match is reported when all of the chord's tones are present in the input, or
246
+ * when the only absent tone is the perfect fifth (a common omission in shell
247
+ * voicings) and at least two of the chord's tones still sound, so a single
248
+ * pitch class matches no chord; matches are ranked best-first by fewest extra notes, then fewest
249
+ * missing notes, then root position over an inversion, then most specific
250
+ * (largest) chord. An exact match (no extras, no missing) is flagged and ranked
251
+ * first.
252
+ *
253
+ * The root-position step decides between readings of the same pitches that are
254
+ * otherwise equally good: `[55, 59, 62, 64]` is read as G6 rather than Em7,
255
+ * because G is in the bass.
256
+ *
257
+ * @param pitches MIDI pitches or bare pitch classes (octave-agnostic).
258
+ * @returns Ranked chord interpretations (may be empty).
259
+ * @example
260
+ * ```ts
261
+ * import { detectChord } from '@libraz/libcantus';
262
+ * const matches = detectChord([60, 64, 67]); // C E G
263
+ * matches[0]; // { rootPc: 0, quality: 'maj', exact: true, ... }
264
+ * ```
265
+ * @category Recognition
266
+ */
267
+ declare function detectChord(pitches: readonly number[], opts?: DetectChordOptions): ChordMatch[];
268
+ /**
269
+ * The single best chord interpretation of a pitch set, or null if none.
270
+ *
271
+ * @param pitches MIDI pitches or bare pitch classes.
272
+ * @returns The top-ranked chord, or null when nothing matches.
273
+ * @example
274
+ * ```ts
275
+ * import { detectChordBest } from '@libraz/libcantus';
276
+ * detectChordBest([60, 64, 67]); // C major triad: { rootPc: 0, quality: 'maj', ... }
277
+ * ```
278
+ * @category Recognition
279
+ */
280
+ declare function detectChordBest(pitches: readonly number[], opts?: DetectChordOptions): Chord | null;
281
+ /**
282
+ * Rank major and minor keys by how well a set of pitch classes is distributed
283
+ * like each key.
284
+ *
285
+ * The input becomes a weighted pitch-class distribution, and every one of the
286
+ * 24 candidates is scored by the Pearson correlation between that distribution
287
+ * and its key profile rotated onto the candidate tonic (see
288
+ * {@link DetectKeyOptions.profile}). Correlating against a profile rather than
289
+ * counting scale members is what tells a key apart from its relative: C major
290
+ * and A minor contain the same seven pitch classes, so a membership count can
291
+ * only separate them by a tie-break, while their profiles expect the weight on
292
+ * different degrees.
293
+ *
294
+ * Choosing the minor variant is deliberately not part of the ranking. A minor
295
+ * candidate is ranked once, on the minor profile, which already expects some
296
+ * weight on the raised seventh and treats the raised sixth as chromatic; only
297
+ * then does it report whichever of the natural, harmonic and melodic masks
298
+ * covers the most input weight, and `fit` is measured against that mask. That
299
+ * split is why a harmonic-minor cadence ranks its own tonic first without the
300
+ * harmonic variant having to win a scoring contest against the natural one.
301
+ *
302
+ * {@link DetectKeyOptions.modes} adds the church modes to the same contest, one
303
+ * candidate per mode per tonic, each ranked on a profile derived from its
304
+ * parallel major or minor key. A modal winner reports the mode in `scaleName`
305
+ * and still reports the key it leans on in `mode`. The option is off by default,
306
+ * so a caller that does not ask for modes gets the ranking of the 24 keys it has
307
+ * always got.
308
+ *
309
+ * Ties are broken by `fit` descending, then tonic pitch class ascending, then by
310
+ * scale — major, the minor forms, then the modes — so the order is fully
311
+ * determined by the input rather than by the order candidates happen to be built
312
+ * in. Returns all 24 keys ranked best-first, plus 12 more per enabled mode, or
313
+ * an empty array for an empty input (mirroring {@link detectChord}).
314
+ *
315
+ * {@link DetectKeyOptions.explain} adds a `rationale` to every candidate and,
316
+ * to the winner, the runners-up it beat with the link of that tie-break chain
317
+ * that separated each. It is off by default; see the option for why.
318
+ *
319
+ * @param pitches MIDI pitches or bare pitch classes.
320
+ * @param opts How to weigh the input, which profile to rank with, and whether
321
+ * the modes take part; see {@link DetectKeyOptions}.
322
+ * @returns Ranked key interpretations (empty for an empty input), each carrying
323
+ * a finite `score` in [-1, 1].
324
+ * @throws {InvalidInputError} When `weights` does not have one entry per pitch,
325
+ * `profile` is not a known name or a valid pair of 12-entry vectors, or
326
+ * `modes` names something that is not a church mode.
327
+ * @throws {RangeError} When a pitch is outside the MIDI domain or the input
328
+ * exceeds the budget.
329
+ * @example
330
+ * ```ts
331
+ * import { detectKey } from '@libraz/libcantus';
332
+ * const keys = detectKey([60, 62, 64, 65, 67, 69, 71]); // C major scale
333
+ * keys[0].mode; // 'major', with keys[0].key.rootPc === 0
334
+ * keys[1].mode; // 'minor' — on 9: A minor, the relative, ranked just below
335
+ * const riff = detectKey([62, 62, 65, 69, 71, 69, 65, 62], { modes: true });
336
+ * riff[0].scaleName; // 'dorian', on rootPc 2, still reported as mode 'minor'
337
+ * ```
338
+ * @category Recognition
339
+ */
340
+ declare function detectKey(pitches: readonly number[], opts?: DetectKeyOptions): KeyMatch[];
341
+ /**
342
+ * Rank keys by how well they contain a set of note events, weighting each note
343
+ * by how much of the music it actually occupies.
344
+ *
345
+ * {@link detectKey} counts every pitch once, which lets a run of fast ornamental
346
+ * notes outvote the sustained harmony that establishes the key. This weighs
347
+ * each note by the same measure chord inference weighs its own histogram by, so
348
+ * the two agree on what the music emphasises: duration times
349
+ * velocity, with a note that carries no velocity counted at full weight rather
350
+ * than at an assumed one. Notes that never sound (zero or negative duration)
351
+ * are ignored. The weighted distribution is then ranked exactly as
352
+ * {@link detectKey} ranks it, by correlation against a key profile, so `score`
353
+ * is a finite correlation in [-1, 1].
354
+ *
355
+ * The one term of that measure this cannot share is the metric accent, which
356
+ * chord inference adds to an onset by the beat it falls on: the notes arrive
357
+ * here without the meter they are counted in, and reading them against an
358
+ * assumed one would rank the same notes differently under a signature the
359
+ * caller never named. Ranking a whole piece is the coarser question, and the
360
+ * accents are what separate one window from the next rather than one key from
361
+ * another.
362
+ *
363
+ * @param notes The note events to weigh.
364
+ * @param opts Which profile to rank with, whether the modes take part, and the
365
+ * budget for processing imported note events; the weights are derived from the
366
+ * notes themselves.
367
+ * @returns Ranked key interpretations (empty when nothing sounds).
368
+ * @throws {InvalidInputError} When `profile` is not a known name or a valid
369
+ * pair of 12-entry vectors, or `modes` names something that is not a church
370
+ * mode.
371
+ * @throws {RangeError} When a note event is malformed or the input exceeds the
372
+ * budget.
373
+ * @example
374
+ * ```ts
375
+ * import { detectKeyFromNotes } from '@libraz/libcantus';
376
+ * detectKeyFromNotes([{ pitch: 60, startBeat: 0, durationBeat: 4 }])[0]?.key.rootPc; // 0
377
+ * ```
378
+ * @category Recognition
379
+ */
380
+ declare function detectKeyFromNotes(notes: readonly NoteEvent[], opts?: Omit<DetectKeyOptions, 'weights'>): KeyMatch[];
381
+ /**
382
+ * The single best key interpretation of a pitch set.
383
+ *
384
+ * The counterpart of {@link detectChordBest}: the ranked list is the general
385
+ * answer, but a caller that just wants "what key is this" should not have to
386
+ * index into it and assert the result is there. The winner is the candidate
387
+ * whose key profile correlates best with the input distribution, with the same
388
+ * deterministic tie-break {@link detectKey} applies, so its `score` is a finite
389
+ * correlation in [-1, 1] rather than a membership share.
390
+ *
391
+ * This is where {@link DetectKeyOptions.explain} earns its keep: the winner is
392
+ * the only match a caller of this function sees, and with `explain` it carries
393
+ * both its own rationale and the candidates it beat.
394
+ *
395
+ * @param pitches MIDI pitches or bare pitch classes.
396
+ * @param opts How to weigh the input, which profile to rank with, and whether
397
+ * the modes take part; see {@link DetectKeyOptions}.
398
+ * @returns The top-ranked key, or null when nothing sounds.
399
+ * @throws {InvalidInputError} When `weights` does not have one entry per pitch,
400
+ * `profile` is not a known name or a valid pair of 12-entry vectors, or
401
+ * `modes` names something that is not a church mode.
402
+ * @throws {RangeError} When a pitch is outside the MIDI domain or the input
403
+ * exceeds the budget.
404
+ * @example
405
+ * ```ts
406
+ * import { detectKeyBest } from '@libraz/libcantus';
407
+ * detectKeyBest([0, 2, 4, 5, 7, 9, 11])?.mode; // 'major'
408
+ * ```
409
+ * @category Recognition
410
+ */
411
+ declare function detectKeyBest(pitches: readonly number[], opts?: DetectKeyOptions): KeyMatch | null;
412
+
413
+ /**
414
+ * Augmented-sixth chords: the Italian, French, and German sixths.
415
+ *
416
+ * All three stand on the lowered submediant (b6) in the bass and carry an
417
+ * augmented sixth above it, and all three are predominants whose two outer
418
+ * voices resolve outward onto the dominant. The family is defined by that bass
419
+ * and that interval rather than by a stack of thirds, so a chord is recognized
420
+ * here from the tones sounding over that bass rather than through the
421
+ * Roman-numeral degree tables.
422
+ *
423
+ * The interval is spelled, so recognition reads letters and not only pitch
424
+ * classes: over an Ab bass the augmented sixth is F# and the minor seventh of
425
+ * the bVI7 it otherwise sounds exactly like is Gb. A caller holding pitch
426
+ * classes alone — an analysis of a MIDI track, which names no accidentals —
427
+ * makes that reading with {@link augmentedSixthFromPitchClasses}, and the chord
428
+ * it hands back carries the spelling that decided it.
429
+ */
430
+
431
+ /**
432
+ * The three augmented-sixth chords, under the nationalities convention gives
433
+ * them.
434
+ *
435
+ * Over an Ab bass in C: the Italian sixth is Ab C F#, the French sixth adds the
436
+ * supertonic (Ab C D F#), and the German sixth adds the lowered mediant
437
+ * (Ab C Eb F#).
438
+ *
439
+ * @category Functional Harmony
440
+ */
441
+ type AugmentedSixthKind = 'italian' | 'french' | 'german';
442
+ /**
443
+ * Build an augmented-sixth chord in a key.
444
+ *
445
+ * The chord always carries an explicit `bassPc` on the lowered submediant,
446
+ * which is what makes it an augmented sixth rather than the dominant seventh or
447
+ * the altered supertonic seventh it shares pitch classes with, and an explicit
448
+ * interval template naming exactly the tones that sound.
449
+ *
450
+ * It also carries its spelling: the tones as `toneSpellings`, and the root and
451
+ * bass as the usual hints. Those are what let the ordinary chord speller and
452
+ * the symbol formatter name the chord — `Ab C Eb F#` and `Ab7` for the German
453
+ * sixth of C major — since a stack of thirds over that root would put a Gb
454
+ * where the augmented sixth belongs. The spelling is the one the key is written
455
+ * on, so a flat-side key takes the double flats it genuinely needs.
456
+ *
457
+ * The lowered submediant is taken as eight semitones above the tonic in every
458
+ * mode, since the chord is a chromatic alteration rather than a degree of the
459
+ * prevailing scale.
460
+ *
461
+ * @param kind Which of the three augmented sixths to build.
462
+ * @param key The prevailing key, as a key name, a key/scale, or a `Key`.
463
+ * @returns The chord, with its bass on the lowered submediant.
464
+ * @throws If `kind` is not one of the three, or the key's root is not finite.
465
+ * @see {@link spellAugmentedSixth} to spell the family from a tonic without
466
+ * building a chord at all.
467
+ * @example
468
+ * ```ts
469
+ * import { augmentedSixthChord, majorKey } from '@libraz/libcantus';
470
+ * augmentedSixthChord('german', majorKey(0));
471
+ * // Ab C Eb F# in C: { rootPc: 8, quality: 'dom7', intervals: [0, 4, 7, 10], bassPc: 8, ... }
472
+ * ```
473
+ * @category Functional Harmony
474
+ */
475
+ declare function augmentedSixthChord(kind: AugmentedSixthKind, key: SpelledKeyLike): Chord;
476
+ /**
477
+ * Identify a chord as one of the augmented sixths, or null when it is none.
478
+ *
479
+ * A chord qualifies when it sounds the lowered submediant of `key` in the bass,
480
+ * its pitch classes are exactly one of the three sets built over that bass, and
481
+ * its own letters spell the augmented sixth above it. All three are needed: the
482
+ * same pitch classes over the same bass are an ordinary bVI7 when the tone ten
483
+ * semitones above the bass is written as a minor seventh, and the letters are
484
+ * the only place that distinction lives.
485
+ *
486
+ * A chord naming no `bassPc` sounds its root lowest, which is how the two
487
+ * conventions for that field — the sounding bass always, or only a bass that
488
+ * differs from the root — are read alike here.
489
+ *
490
+ * The root the chord is measured from is not consulted, so a chord voiced or
491
+ * rebuilt around any of its own tones still identifies as long as it keeps its
492
+ * spelling.
493
+ *
494
+ * @param chord The chord to test, as a chord symbol, chord data, or a `Chord`.
495
+ * @param key The prevailing key, as a key name, a key/scale, or a `Key`.
496
+ * @returns The kind of augmented sixth, or null.
497
+ * @see {@link augmentedSixthFromPitchClasses} to make the reading from pitch
498
+ * classes that carry no spelling at all.
499
+ * @example
500
+ * ```ts
501
+ * import { augmentedSixthKind, majorKey, romanToChord } from '@libraz/libcantus';
502
+ * augmentedSixthKind(romanToChord('Fr6', majorKey(0)), majorKey(0)); // 'french'
503
+ * ```
504
+ * @category Functional Harmony
505
+ */
506
+ declare function augmentedSixthKind(chord: ChordLike, key: KeyLike): AugmentedSixthKind | null;
507
+ /**
508
+ * Read a set of sounding pitch classes over a sounding bass as an augmented
509
+ * sixth, or null when they are none.
510
+ *
511
+ * The reading a caller holding no spelling has to make for itself: pitch
512
+ * classes name no accidentals, so nothing downstream can tell the German sixth
513
+ * from the bVI7 it sounds like once the letters are gone. The chord returned is
514
+ * the one {@link augmentedSixthChord} builds, spelling and all, so it keeps
515
+ * identifying as an augmented sixth everywhere it travels.
516
+ *
517
+ * Not every b6-1-b3-#4 over a b6 bass is an augmented sixth, and this cannot
518
+ * know which one is: it answers what the tones would spell, and the caller
519
+ * decides whether that reading is the one the music supports.
520
+ *
521
+ * @param pcs The sounding pitch classes; duplicates and unreduced values are
522
+ * fine.
523
+ * @param bassPc The pitch class sounding in the bass.
524
+ * @param key The prevailing key, as a key name, a key/scale, or a `Key`.
525
+ * @returns The augmented-sixth chord, or null.
526
+ * @see {@link augmentedSixthKind} to read a chord that already carries its
527
+ * spelling.
528
+ * @example
529
+ * ```ts
530
+ * import { augmentedSixthFromPitchClasses, majorKey } from '@libraz/libcantus';
531
+ * // Ab C Eb Gb sounding over Ab in C: the German sixth, spelled with its F#.
532
+ * augmentedSixthFromPitchClasses([8, 0, 3, 6], 8, majorKey(0))?.quality; // 'dom7'
533
+ * ```
534
+ * @category Functional Harmony
535
+ */
536
+ declare function augmentedSixthFromPitchClasses(pcs: readonly number[], bassPc: number, key: SpelledKeyLike): Chord | null;
537
+ /**
538
+ * Spell an augmented-sixth chord from a spelled tonic, lowest note first.
539
+ *
540
+ * This is the spelled counterpart of {@link augmentedSixthChord}, and the table
541
+ * the chord's own spelling is built from: every tone is placed by a named
542
+ * interval above the bass, so the outer interval is an augmented sixth in every
543
+ * key rather than the minor seventh its ten semitones would otherwise imply.
544
+ * Reach for it when a spelled tonic is all there is; spelling the chord itself
545
+ * with {@link spellChord} names the same notes, in the chord's own order.
546
+ *
547
+ * A tonic carrying an octave yields notes carrying octaves, ascending from the
548
+ * bass; an octave-less tonic yields octave-less notes.
549
+ *
550
+ * @param kind Which of the three augmented sixths to spell.
551
+ * @param tonic The spelled tonic of the key, as a note name, a MIDI number,
552
+ * note data, or a `Note`.
553
+ * @returns The spelled tones, bass first and ascending.
554
+ * @throws If `kind` is not one of the three, or `tonic` is not a note.
555
+ * @example
556
+ * ```ts
557
+ * import { noteNames, parseNote, spellAugmentedSixth } from '@libraz/libcantus';
558
+ * noteNames(spellAugmentedSixth('german', parseNote('C'))); // ['Ab', 'C', 'Eb', 'F#']
559
+ * noteNames(spellAugmentedSixth('italian', 'E')); // ['C', 'E', 'A#']
560
+ * ```
561
+ * @category Functional Harmony
562
+ */
563
+ declare function spellAugmentedSixth(kind: AugmentedSixthKind, tonic: NoteLike): Note[];
564
+
565
+ /**
566
+ * Arrangement track-role analysis: a single harmony is inferred from every
567
+ * track's notes pooled together, each track is then analysed against that shared
568
+ * harmony, and notes that clash with the sounding chord are collected as
569
+ * conflicts.
570
+ */
571
+
572
+ /**
573
+ * The musical role a track plays in the arrangement.
574
+ *
575
+ * Only `drums` changes the analysis: its pitches select instruments rather than
576
+ * naming harmony, so such a track is excluded from chord and key inference and
577
+ * from every voice-leading comparison, and is reported back with no
578
+ * annotations. `harmony` is meaningful through
579
+ * {@link ArrangementOptions.harmonyTracks}, which names the tracks the chords
580
+ * are inferred from. The rest are labels carried through to
581
+ * {@link TrackAnalysis.role} for the caller's own use; nothing is inferred, so
582
+ * a track left unlabelled reports `'other'` rather than a guess.
583
+ *
584
+ * @category Arrangement & Analysis
585
+ */
586
+ type TrackRole = 'melody' | 'harmony' | 'bass' | 'drums' | 'other';
587
+ /**
588
+ * One input track: its notes plus optional name and role.
589
+ *
590
+ * @category Arrangement & Analysis
591
+ */
592
+ type ArrangementTrack = {
593
+ name?: string;
594
+ role?: TrackRole;
595
+ notes: readonly NoteEvent[];
596
+ };
597
+ /**
598
+ * A track after analysis: its resolved name, role, and per-note annotations.
599
+ *
600
+ * @category Arrangement & Analysis
601
+ */
602
+ type TrackAnalysis = {
603
+ name: string;
604
+ role: TrackRole;
605
+ /** One {@link AnalyzedNote} per note, labelled against the inferred chords. */
606
+ notes: AnalyzedNote[];
607
+ };
608
+ /**
609
+ * A note sounding with a {@link Conflict} that raises a pairwise flag against it.
610
+ *
611
+ * @category Arrangement & Analysis
612
+ */
613
+ type ConflictPartner = {
614
+ /** The partner's track index in the caller's input array. */
615
+ trackIndex: number;
616
+ /** The partner note's index in that track's own note array. */
617
+ originalIndex?: number;
618
+ /** The id the partner note carries in {@link TrackAnalysis.notes}. */
619
+ noteId: number;
620
+ /** The pairwise flags this note raises, as {@link SafetyPartner.reasons}. */
621
+ reasons: number;
622
+ };
623
+ /**
624
+ * A note that clashes with the harmony sounding beneath it.
625
+ *
626
+ * @category Arrangement & Analysis
627
+ */
628
+ type Conflict = {
629
+ beat: number;
630
+ trackName: string;
631
+ /** The clashing track's index in the caller's input array. */
632
+ trackIndex: number;
633
+ /** The note's index in that track's own note array. */
634
+ originalIndex?: number;
635
+ /** The id the note carries in {@link TrackAnalysis.notes}. */
636
+ noteId: number;
637
+ pitch: number;
638
+ /**
639
+ * The note's theory labels at its onset, so a caller can tell a genuine clash
640
+ * from a passing tone, a neighbour, or a prepared suspension — all of which
641
+ * are ordinary non-chord tones that still evaluate as unsafe.
642
+ */
643
+ labels: TheoryLabel[];
644
+ /** The clash severity: {@link NoteSafety.Warning} or {@link NoteSafety.Dissonant}. */
645
+ safety: NoteSafety;
646
+ /** {@link SafetyResult.reasons} bitmask. */
647
+ reasons: number;
648
+ /** Preferred stepwise resolution, when the safety evaluator provides one. */
649
+ resolveTo?: number;
650
+ /** Nearby fully safe replacement pitches, nearest first. */
651
+ suggestions?: number[];
652
+ /**
653
+ * The notes behind the pairwise flags in `reasons` — a parallel fifth, a
654
+ * crossing, a vertical clash — when any are set.
655
+ */
656
+ partners?: ConflictPartner[];
657
+ rationale?: string;
658
+ };
659
+ /**
660
+ * The full result of {@link analyzeArrangement}.
661
+ *
662
+ * @category Arrangement & Analysis
663
+ */
664
+ type ArrangementAnalysis = {
665
+ /**
666
+ * The key regions the analysis ran against, in time order. Roman numerals,
667
+ * harmonic function and note safety are all judged against the region
668
+ * covering the beat, so a piece that modulates is not read against the key it
669
+ * started in for every bar after it leaves.
670
+ */
671
+ keys: KeyRegion[];
672
+ /**
673
+ * The key held longest across {@link ArrangementAnalysis.keys}, whole: the
674
+ * pitch classes with the spelling and the scale form the regions carry.
675
+ */
676
+ prevailingKey: ResolvedKey;
677
+ timeline: ChordTimeline;
678
+ segmentConfidence: number[];
679
+ cadences: CadenceHit[];
680
+ tracks: TrackAnalysis[];
681
+ /** Notes clashing with the sounding harmony, worst severity first. */
682
+ conflicts: Conflict[];
683
+ };
684
+ /**
685
+ * Options controlling {@link analyzeArrangement} and {@link tensionCurve}.
686
+ *
687
+ * @category Arrangement & Analysis
688
+ */
689
+ type ArrangementOptions = {
690
+ /**
691
+ * A single key held across the whole arrangement. Omit it, and `keys` with
692
+ * it, to have the key searched for over time so a modulating piece is read
693
+ * against the key actually in force.
694
+ *
695
+ * Taken in whatever form the caller holds a key, and kept whole: the region
696
+ * built from it carries the spelling and the scale form it was named with.
697
+ */
698
+ key?: KeyLike;
699
+ /**
700
+ * Key regions to judge against, when a previous pass already worked them out.
701
+ * Takes precedence over `key`; supplying both is answering the same question
702
+ * twice, and the more specific answer wins.
703
+ */
704
+ keys?: KeyRegion[];
705
+ /**
706
+ * A chord timeline to analyse against, instead of inferring one from the
707
+ * notes. Supply it to analyse a hand-written progression, or to reuse the
708
+ * timeline of an earlier call rather than re-running chord inference.
709
+ */
710
+ timeline?: ChordTimeline;
711
+ /**
712
+ * Indices of the tracks the harmony is inferred from. Defaults to every
713
+ * pitched track. Percussion tracks are excluded either way. An index naming
714
+ * no track is an input error rather than one that matches nothing.
715
+ */
716
+ harmonyTracks?: number[];
717
+ /**
718
+ * Lowest severity reported in `conflicts`.
719
+ *
720
+ * @defaultValue {@link NoteSafety.Warning}
721
+ */
722
+ minSeverity?: NoteSafety;
723
+ /**
724
+ * A single time signature held across the whole arrangement, as sugar for a
725
+ * one-element `meters`; defaults to 4/4. Giving both is an input error.
726
+ *
727
+ * @defaultValue `4/4`
728
+ */
729
+ ts?: MeterLike;
730
+ /**
731
+ * The meter as it changes over the arrangement. Bar lines, downbeats and
732
+ * metric weight all follow the signature in force at the beat in question.
733
+ *
734
+ * @defaultValue 4/4 throughout
735
+ */
736
+ meters?: MeterLike;
737
+ /**
738
+ * Length of the pickup in beats, when the piece starts with one.
739
+ *
740
+ * The first downbeat is beat 0, so an upbeat is written at negative beats.
741
+ * Declaring its length rejects a note that starts before the pickup does;
742
+ * leave it unset to accept any onset within ±`Number.MAX_SAFE_INTEGER`
743
+ * (2^53 - 1).
744
+ *
745
+ * @defaultValue no declared pickup
746
+ */
747
+ pickupBeats?: number;
748
+ /**
749
+ * Expected chord length in beats; defaults to the length of the opening bar.
750
+ *
751
+ * A prior rather than a grid: the arrangement analysis infers its harmony
752
+ * with dynamic segmentation, where the longer a chord is expected to last the
753
+ * more evidence a change needs before the search will place one. A chord may
754
+ * still begin at any position the notes argue for. Supply `timeline` to
755
+ * analyse against boundaries you have fixed yourself.
756
+ *
757
+ * @defaultValue the length of the opening bar
758
+ */
759
+ harmonicRhythm?: number;
760
+ /**
761
+ * Safety profile used for conflict detection; defaults to `pop`.
762
+ *
763
+ * @defaultValue `'pop'`
764
+ */
765
+ profile?: SafetyProfile;
766
+ /**
767
+ * Upper bound on the work this call may do — note counts, windows, and
768
+ * candidate counts are each checked against it before anything is allocated.
769
+ *
770
+ * Raise it to analyse a piece larger than the default allows; the default is
771
+ * {@link DEFAULT_GENERATION_BUDGET}, chosen so a runaway input fails fast
772
+ * rather than blocking the thread.
773
+ *
774
+ * @defaultValue {@link DEFAULT_GENERATION_BUDGET}
775
+ */
776
+ budget?: number;
777
+ };
778
+ /**
779
+ * Label every note of one polyphonic passage against the harmony under it and
780
+ * the voices around it.
781
+ *
782
+ * {@link analyzeVoice} reads a single line: it takes the note before and the note
783
+ * after each note as that note's melodic neighbours, and it is given no other
784
+ * voices, so over a flat array of everything that sounds it invents figures
785
+ * across parts — the alto between two soprano notes becomes a passing tone —
786
+ * and can never find a suspension, which is by definition a dissonance against
787
+ * something else sounding. So the passage is partitioned into monophonic
788
+ * sub-voices first and each is read with the others handed to it, which is what
789
+ * {@link analyzeArrangement} does with the tracks it is given.
790
+ *
791
+ * @param notes The passage, in any order; the ids are indices into this array.
792
+ * @param chordAtBeat Chord sounding at a given beat, or null.
793
+ * @param key The key, or the key in force at a given beat.
794
+ * @returns One annotation per note, in the order the notes were given, each
795
+ * carrying its position in that array as its id.
796
+ */
797
+ declare function analyzePolyphony(notes: readonly NoteEvent[], chordAtBeat: (beat: number) => Chord | null, key: KeyContext): AnalyzedNote[];
798
+ /**
799
+ * Analyse a whole arrangement against the harmony inferred from it.
800
+ *
801
+ * The chord timeline and the key regions it is read against are inferred from
802
+ * the pooled notes of every pitched track (see
803
+ * {@link chordTimelineFromNotes}); pooling all voices is
804
+ * robust even when roles are absent or a track doubles the harmony, so it is
805
+ * preferred over deriving the harmony from a subset. A track marked
806
+ * `role: 'drums'` is excluded — its pitches name instruments, not harmony, and
807
+ * pooling them would corrupt the key, the timeline and every reading built on
808
+ * them. Pass `harmonyTracks` to restrict inference further, or `timeline` to
809
+ * analyse against a progression you already have. Zero- and negative-length
810
+ * notes never sound, so they are dropped at ingest and appear in neither the
811
+ * annotations nor the conflicts.
812
+ *
813
+ * Voice analysis assumes one monophonic voice at a time, so each track is
814
+ * first partitioned into monophonic sub-voices (a polyphonic block-chord track
815
+ * fans out into one sub-voice per simultaneous note; a monophonic track is
816
+ * unaffected). Each sub-voice is labelled note-by-note against the harmony
817
+ * with {@link analyzeVoice}, seeing every other sub-voice — including siblings
818
+ * within the same track — as its accompaniment. Every note is then re-checked
819
+ * with {@link evaluateSafety} at its onset and again at each chord change it
820
+ * sustains across, so a held note that clashes with a later chord is caught:
821
+ * evaluations that are not {@link NoteSafety.Safe} become conflicts, one per
822
+ * clashing beat, sorted worst severity first and then by beat.
823
+ *
824
+ * Every ordinary non-chord tone — a passing note, a neighbour, a prepared
825
+ * suspension — is by definition unsafe against the chord under it, so the
826
+ * conflict list is a report, not a fault list. Each conflict carries the note's
827
+ * `labels` and its `trackIndex`/`originalIndex`, so a caller can tell those
828
+ * apart and map a conflict back to the note it passed in; `minSeverity` narrows
829
+ * the list to outright dissonance.
830
+ *
831
+ * @param tracks The tracks to analyse.
832
+ * @param opts Analysis options; see {@link ArrangementOptions}.
833
+ * @returns The inferred harmony, per-track annotations, cadences, and conflicts.
834
+ * @example
835
+ * ```ts
836
+ * import { analyzeArrangement } from '@libraz/libcantus';
837
+ * const melody = [
838
+ * { pitch: 60, startBeat: 0, durationBeat: 2 },
839
+ * { pitch: 67, startBeat: 2, durationBeat: 2 },
840
+ * ];
841
+ * const { prevailingKey, conflicts } = analyzeArrangement([{ role: 'melody', notes: melody }]);
842
+ * prevailingKey.scale.rootPc; // the key held longest across the analysis
843
+ * conflicts; // notes clashing with the inferred harmony, worst severity first
844
+ * ```
845
+ * @category Arrangement & Analysis
846
+ */
847
+ declare function analyzeArrangement(tracks: ArrangementTrack[], opts?: ArrangementOptions): ArrangementAnalysis;
848
+
849
+ /**
850
+ * Incremental arrangement analysis: an analysis held open across edits, so a
851
+ * host that re-analyses on every keystroke pays for the beats that changed
852
+ * rather than for the whole piece.
853
+ */
854
+
855
+ /**
856
+ * One track's notes as they stand after an edit.
857
+ *
858
+ * The whole note array is given rather than a description of what moved: a host
859
+ * always has the track's current contents, and working out what actually
860
+ * changed is this module's job, not the caller's.
861
+ *
862
+ * @category Arrangement & Analysis
863
+ */
864
+ type TrackEdit = {
865
+ /** Index of the track in the session's track array. */
866
+ trackIndex: number;
867
+ /** The track's notes after the edit. */
868
+ notes: readonly NoteEvent[];
869
+ };
870
+ /**
871
+ * An arrangement analysis held open for editing.
872
+ *
873
+ * @category Arrangement & Analysis
874
+ */
875
+ type ArrangementSession = {
876
+ /** Release the handle now; later calls on it fail with `RELEASED_HANDLE`. */
877
+ [Symbol.dispose](): void;
878
+ /** The tracks the current analysis was made from. */
879
+ readonly tracks: readonly ArrangementTrack[];
880
+ /** The analysis of those tracks. */
881
+ readonly analysis: ArrangementAnalysis;
882
+ /**
883
+ * Re-analyse after replacing the notes of one or more tracks, reusing
884
+ * everything the edit provably cannot reach.
885
+ *
886
+ * The result equals {@link analyzeArrangement} over the edited tracks — the
887
+ * same segments, confidences, key regions, cadences, annotations and
888
+ * conflicts — so a host may hold a session for as long as it likes without
889
+ * the analysis drifting from what a fresh pass would say.
890
+ */
891
+ update: (edits: readonly TrackEdit[]) => ArrangementSession;
892
+ };
893
+ /**
894
+ * Open an arrangement analysis that can be updated a few beats at a time.
895
+ *
896
+ * The first pass is an ordinary {@link analyzeArrangement}; what the session
897
+ * adds is the slot-level evidence behind it, so a later {@link
898
+ * ArrangementSession.update} can work out which beats an edit could possibly
899
+ * have changed and leave the rest of the harmony alone. An update returns a new
900
+ * session, so the analysis before an edit stays valid and a host can keep it
901
+ * for undo.
902
+ *
903
+ * What an update recomputes is derived rather than guessed at:
904
+ *
905
+ * - The edited beats are the beats covered by the notes the old and new track
906
+ * arrays disagree on, which is narrower than the track and usually far
907
+ * narrower than the piece.
908
+ * - A slot's evidence sees exactly the notes overlapping it, so the slots to
909
+ * re-derive are the slots overlapping those beats — plus one either side, so
910
+ * that an onset sitting a floating-point hair off a slot boundary cannot
911
+ * leave a stale slot behind.
912
+ * - The boundary search itself has no such margin. It is a shortest-path search
913
+ * over a whole run of slots, so a changed slot can move a boundary anywhere in
914
+ * the run, and its change cost is calibrated on the mean weight of every
915
+ * sounding slot in the piece, which couples the runs to one another. The
916
+ * search is therefore re-run over the whole piece — arithmetic over the
917
+ * carried-over evidence, with nothing allocated per slot — rather than being
918
+ * spliced at a margin that does not exist.
919
+ * - Each settled segment's chord is carried over when its bounds, its key and
920
+ * its slots are all unchanged, since those are the only things chord
921
+ * inference reads.
922
+ *
923
+ * Key regions and the per-note annotations are recomputed in full. Both are
924
+ * whole-piece passes — the key search is a shortest-path search with no reset
925
+ * points, sub-voice lane assignment is greedy from the first note, and every
926
+ * note is judged against the other voices sounding beneath it — so neither has
927
+ * a sound local answer, and reporting one would mean an update that quietly
928
+ * disagreed with a fresh analysis.
929
+ *
930
+ * An update falls back to a full analysis whenever the edit moves the ground the
931
+ * evidence stands on: a changed piece length, a changed first onset (both of
932
+ * which move the slot grid), or an edit to a session whose harmony was supplied
933
+ * through {@link ArrangementOptions.timeline}. The answer is the same either
934
+ * way; only the work differs.
935
+ *
936
+ * @param tracks The tracks to analyse.
937
+ * @param opts Analysis options; see {@link ArrangementOptions}.
938
+ * @returns A session holding the analysis and the evidence behind it.
939
+ * @example
940
+ * ```ts
941
+ * import { createArrangementSession } from '@libraz/libcantus';
942
+ * const melody = [{ pitch: 60, startBeat: 0, durationBeat: 4 }];
943
+ * const session = createArrangementSession([{ role: 'melody', notes: melody }]);
944
+ * const moved = [{ pitch: 62, startBeat: 0, durationBeat: 4 }];
945
+ * const next = session.update([{ trackIndex: 0, notes: moved }]);
946
+ * next.analysis.timeline.segments; // as if analyzed from scratch
947
+ * ```
948
+ * @category Arrangement & Analysis
949
+ */
950
+ declare function createArrangementSession(tracks: ArrangementTrack[], opts?: ArrangementOptions): ArrangementSession;
951
+
952
+ /**
953
+ * Arrangement tension analysis: a coarse harmonic-tension curve sampled at
954
+ * regular beats across a whole multi-track piece, combining the sounding
955
+ * chord's harmonic function, the dissonance of the sounding notes, and their
956
+ * registral span into a single normalized reading.
957
+ */
958
+
959
+ /**
960
+ * A tension reading sampled at a beat.
961
+ *
962
+ * @category Arrangement & Analysis
963
+ */
964
+ type TensionPoint = {
965
+ beat: number;
966
+ /** Combined tension in [0, 1]. */
967
+ tension: number;
968
+ };
969
+ /**
970
+ * Sample the harmonic tension of an arrangement at regular beats.
971
+ *
972
+ * At each sample beat the tension combines three normalized terms:
973
+ * - the sounding chord's harmonic function (dominant `1`, subdominant `0.5`,
974
+ * tonic or no chord `0`), weighted `FUNCTION_WEIGHT`;
975
+ * - the dissonance of the sounding notes — the larger of the share of sounding
976
+ * pitches that are not chord tones and the share that {@link evaluateSafety}
977
+ * rates {@link NoteSafety.Dissonant} — weighted `DISSONANCE_WEIGHT`;
978
+ * - the registral span of the sounding notes, saturating at
979
+ * `SPAN_SATURATION` semitones, weighted `SPAN_WEIGHT`.
980
+ *
981
+ * The weighted sum is clamped to [0, 1]. The harmony is inferred from all tracks
982
+ * pooled together, so the result is deterministic and self-contained.
983
+ *
984
+ * @param tracks The tracks to sample.
985
+ * @param opts Analysis options plus an optional `step` (default one beat).
986
+ * @returns One {@link TensionPoint} per sampled beat, in beat order.
987
+ * @throws If `step` is not positive.
988
+ * @example
989
+ * ```ts
990
+ * import { tensionCurve } from '@libraz/libcantus';
991
+ * const notes = [{ pitch: 60, startBeat: 0, durationBeat: 4 }];
992
+ * const curve = tensionCurve([{ notes }], { step: 1 });
993
+ * curve; // one { beat, tension } sample per beat, in beat order
994
+ * ```
995
+ * @category Arrangement & Analysis
996
+ */
997
+ declare function tensionCurve(tracks: ArrangementTrack[], opts?: ArrangementOptions & {
998
+ step?: number;
999
+ }): TensionPoint[];
1000
+ /**
1001
+ * Sample the tension of an arrangement already analysed by
1002
+ * {@link analyzeArrangement}, reusing its harmony instead of inferring it again.
1003
+ *
1004
+ * `analyzeArrangement` followed by `tensionCurve` runs chord and key inference
1005
+ * twice over the same notes. This takes the analysis it already produced, so
1006
+ * the curve and the annotations describe the same harmony by construction.
1007
+ *
1008
+ * The analysis is the harmony to fall back on rather than one laid over the
1009
+ * caller: `key`, `keys` and `harmonyTracks` each name a harmony the analysis
1010
+ * does not hold, so naming one is asking for a different reading, and the curve
1011
+ * is taken under it. Nothing else about the analysis is re-derived.
1012
+ *
1013
+ * @param tracks The same tracks that were analysed.
1014
+ * @param analysis The result of {@link analyzeArrangement} for those tracks.
1015
+ * @param opts Analysis options plus an optional `step` (default one beat).
1016
+ * @returns One {@link TensionPoint} per sampled beat, in beat order.
1017
+ * @example
1018
+ * ```ts
1019
+ * import { analyzeArrangement, tensionCurveFrom } from '@libraz/libcantus';
1020
+ * const tracks = [{ notes: [{ pitch: 60, startBeat: 0, durationBeat: 4 }] }];
1021
+ * const analysis = analyzeArrangement(tracks);
1022
+ * tensionCurveFrom(tracks, analysis, { step: 1 });
1023
+ * ```
1024
+ * @category Arrangement & Analysis
1025
+ */
1026
+ declare function tensionCurveFrom(tracks: ArrangementTrack[], analysis: ArrangementAnalysis, opts?: ArrangementOptions & {
1027
+ step?: number;
1028
+ }): TensionPoint[];
1029
+
1030
+ /**
1031
+ * Hypermeter: the grouping of bars into hyperbars.
1032
+ *
1033
+ * Bars are felt in groups the way beats are felt in bars — four bars at a time
1034
+ * in most tonal and popular music, but two, three, six or eight elsewhere. The
1035
+ * grouping is not written in the score, so it has to be inferred from where the
1036
+ * music actually restarts: harmony changes on a hypermetric downbeat, and
1037
+ * cadences arrive at the end of a hyperbar.
1038
+ */
1039
+
1040
+ /**
1041
+ * A bar grouping inferred from the music.
1042
+ *
1043
+ * @category Arrangement & Analysis
1044
+ */
1045
+ type Hypermeter = {
1046
+ /**
1047
+ * Bars per hyperbar. Falls back to the span's own bar count when the span is
1048
+ * too short to hold two of any candidate grouping.
1049
+ */
1050
+ groupBars: number;
1051
+ /**
1052
+ * Absolute beat of each hypermetric downbeat inside the analysed span, in
1053
+ * time order. A pickup bar is not a group head, so the first entry is the
1054
+ * first full bar that starts a group.
1055
+ */
1056
+ downbeats: number[];
1057
+ /**
1058
+ * How much the music supports the grouping, in [0, 1]: how strongly harmonic
1059
+ * change and cadences prefer these bars over the others, discounted when the
1060
+ * runner-up grouping explains the music nearly as well.
1061
+ */
1062
+ confidence: number;
1063
+ /** Why this grouping was chosen. */
1064
+ rationale: string;
1065
+ };
1066
+ /**
1067
+ * Options for {@link hypermeter}.
1068
+ *
1069
+ * @category Arrangement & Analysis
1070
+ */
1071
+ type HypermeterOptions = {
1072
+ /**
1073
+ * End of the analysed span in beats; defaults to the end of the last note.
1074
+ *
1075
+ * @defaultValue the end of the last note
1076
+ */
1077
+ totalBeats?: number;
1078
+ /**
1079
+ * Beats at which cadences arrive, as {@link CadenceHit.atBeat} reports them.
1080
+ *
1081
+ * A cadence is the clearest hypermetric evidence there is — it arrives at the
1082
+ * end of a hyperbar — but finding one needs a chord timeline and a key, which
1083
+ * this function is not given. Callers that already hold cadences should pass
1084
+ * them; {@link phrasesFromTimeline} does.
1085
+ *
1086
+ * @defaultValue none
1087
+ */
1088
+ cadenceBeats?: readonly number[];
1089
+ /**
1090
+ * Upper bound on the work this call may do.
1091
+ *
1092
+ * @defaultValue {@link DEFAULT_GENERATION_BUDGET}
1093
+ */
1094
+ budget?: number;
1095
+ };
1096
+ /**
1097
+ * Infer how a piece's bars group into hyperbars.
1098
+ *
1099
+ * Groupings of 2, 3, 4, 6, and 8 bars are tried at every phase, and each
1100
+ * reading is scored on two counts: how much more harmonic change lands on the
1101
+ * bars it calls group heads than on the bars between them, and how many of the
1102
+ * hyperbar ends it predicts are closed by one of the cadences it is given.
1103
+ * Where cadences are given they settle the phase, since a hyperbar is what a
1104
+ * cadence ends; the harmony then chooses among the phases they agree with. The
1105
+ * commonest groupings are believed a little more readily than the rare ones,
1106
+ * which settles ties without letting a prior overrule the music.
1107
+ *
1108
+ * The meter is read at the beat in question rather than at the start, so a
1109
+ * piece that changes metre keeps being cut at its own bar lines. Bar 0 is the
1110
+ * first full bar however much pickup precedes it, so an upbeat is bar -1 and is
1111
+ * never taken for a hypermetric downbeat. Whether there is an upbeat at all is
1112
+ * decided the way the rest of the analysis decides it: a note a millibeat early
1113
+ * is playing the downbeat, not anticipating it.
1114
+ *
1115
+ * @param notes The notes to read, in any order. Notes that never sound are
1116
+ * dropped.
1117
+ * @param meter A single time signature, or the piece's meter map; defaults to
1118
+ * 4/4 throughout.
1119
+ * @param opts Analysis options; see {@link HypermeterOptions}.
1120
+ * @returns The grouping, its downbeats, a confidence, and a rationale.
1121
+ * @example
1122
+ * ```ts
1123
+ * import { hypermeter } from '@libraz/libcantus';
1124
+ * const notes = [
1125
+ * { pitch: 60, startBeat: 0, durationBeat: 16 },
1126
+ * { pitch: 65, startBeat: 16, durationBeat: 16 },
1127
+ * ];
1128
+ * hypermeter(notes).groupBars; // 4
1129
+ * ```
1130
+ * @category Arrangement & Analysis
1131
+ */
1132
+ declare function hypermeter(notes: readonly NoteEvent[], meter?: MeterLike, opts?: HypermeterOptions): Hypermeter;
1133
+
1134
+ /**
1135
+ * Phrases: the unit of music one bar larger than the chord.
1136
+ *
1137
+ * Every other analysis in this library is local — a chord against the next
1138
+ * chord, a note against the chord under it — and that is the ceiling on what it
1139
+ * can say. A cadence is a cadence because it falls at the end of a phrase, so
1140
+ * two chords read in isolation cannot settle how much weight one carries. This
1141
+ * module draws the boundaries, then ranks the cadences that sit on them.
1142
+ *
1143
+ * No single signal draws a phrase boundary reliably, so three are combined: the
1144
+ * cadences the harmony forms, the rests and long notes the melody breathes at,
1145
+ * and the points where the music starts saying something it has said before. A
1146
+ * boundary is reported with the evidence behind it and a confidence, because a
1147
+ * phrase reading is an interpretation and pretending otherwise would be worse
1148
+ * than useless to a caller deciding whether to trust it.
1149
+ */
1150
+
1151
+ /**
1152
+ * A reason a phrase boundary was placed where it was.
1153
+ *
1154
+ * @category Arrangement & Analysis
1155
+ */
1156
+ type PhraseSignal =
1157
+ /** A cadence closed on the beat the boundary falls at. */
1158
+ 'cadence'
1159
+ /** The melody stopped sounding long enough to have taken a breath. */
1160
+ | 'rest'
1161
+ /** A note was held long enough to read as an arrival. */
1162
+ | 'longNote'
1163
+ /** The music began repeating material heard immediately before. */
1164
+ | 'repetition'
1165
+ /** The boundary falls on a hypermetric downbeat. */
1166
+ | 'hypermeter'
1167
+ /** The music ends here, which closes whatever phrase was open. */
1168
+ | 'pieceEnd';
1169
+ /**
1170
+ * One phrase: a span of music closed by a boundary, and the evidence for it.
1171
+ *
1172
+ * @category Arrangement & Analysis
1173
+ */
1174
+ type Phrase = {
1175
+ /** First beat of the phrase; negative when the phrase begins in a pickup. */
1176
+ startBeat: number;
1177
+ /** End of the phrase, exclusive. */
1178
+ endBeat: number;
1179
+ /**
1180
+ * The cadence closing the phrase, or null when the boundary rests on the
1181
+ * melody and the metre alone.
1182
+ */
1183
+ cadence: CadenceHit | null;
1184
+ /** Why the closing boundary was placed here, strongest evidence first. */
1185
+ signals: PhraseSignal[];
1186
+ /**
1187
+ * How well evidenced the phrase is, in [0, 1]: how strong its closing
1188
+ * boundary is, and how close its length is to the length expected of a
1189
+ * phrase in this piece.
1190
+ */
1191
+ confidence: number;
1192
+ /**
1193
+ * How much structural weight the closing cadence carries, in [0, 1]; 0 for a
1194
+ * phrase that no cadence closes.
1195
+ *
1196
+ * This is the number that answers "which cadence matters most": it grades the
1197
+ * cadence by how conclusive its type is, then by where the phrase it closes
1198
+ * sits — a cadence ending the piece or landing on a hypermetric boundary
1199
+ * closes more than one in the middle of a hyperbar.
1200
+ * {@link structuralCadences} ranks by it.
1201
+ */
1202
+ structuralWeight: number;
1203
+ /** A short reading of the phrase in words. */
1204
+ rationale: string;
1205
+ };
1206
+ /**
1207
+ * Options for {@link phrasesFromTimeline}.
1208
+ *
1209
+ * @category Arrangement & Analysis
1210
+ */
1211
+ type PhraseOptions = {
1212
+ /**
1213
+ * A single time signature held across the whole span, as sugar for a
1214
+ * one-element `meters`; defaults to 4/4. Giving both is an input error.
1215
+ *
1216
+ * @defaultValue `4/4`
1217
+ */
1218
+ ts?: MeterLike;
1219
+ /**
1220
+ * The meter as it changes over the span. Bar lines and hypermetric downbeats
1221
+ * follow the signature in force at the beat in question, so a piece that
1222
+ * changes metre is cut at its own bar lines; the length defaults below are
1223
+ * lengths rather than positions, and each is taken once from the meter the
1224
+ * span opens in.
1225
+ *
1226
+ * @defaultValue 4/4 throughout
1227
+ */
1228
+ meters?: MeterLike;
1229
+ /**
1230
+ * Key context for cadence detection: one key for the whole span, or the key
1231
+ * in force at a given beat. Omit it to have the key searched for over time,
1232
+ * so a piece that modulates has each cadence read in the key it arrives in.
1233
+ *
1234
+ * @defaultValue the key inferred from the notes over time
1235
+ */
1236
+ key?: KeyContext;
1237
+ /**
1238
+ * End of the analysed span in beats; defaults to the end of the last note or
1239
+ * timeline segment.
1240
+ *
1241
+ * @defaultValue the end of the input
1242
+ */
1243
+ totalBeats?: number;
1244
+ /**
1245
+ * Length a phrase is expected to run, in beats; defaults to one hyperbar.
1246
+ *
1247
+ * This is a prior, not a rule: a boundary is placed where the evidence puts
1248
+ * it, and this decides how much evidence an irregular length has to carry
1249
+ * before it is preferred to a regular one. Set it to two hyperbars for music
1250
+ * whose phrases are periods.
1251
+ *
1252
+ * @defaultValue one hyperbar of the opening meter
1253
+ */
1254
+ expectedPhraseBeats?: number;
1255
+ /**
1256
+ * Shortest phrase that may be reported, in beats; defaults to one bar of the
1257
+ * opening meter.
1258
+ *
1259
+ * @defaultValue one bar of the opening meter
1260
+ */
1261
+ minPhraseBeats?: number;
1262
+ /**
1263
+ * Silence at least this long divides phrases; defaults to half a bar of the
1264
+ * opening meter.
1265
+ *
1266
+ * @defaultValue half a bar of the opening meter
1267
+ */
1268
+ restBeats?: number;
1269
+ /**
1270
+ * A note held at least this long reads as an arrival and closes a phrase;
1271
+ * defaults to one bar of the opening meter.
1272
+ *
1273
+ * @defaultValue one bar of the opening meter
1274
+ */
1275
+ longNoteBeats?: number;
1276
+ /**
1277
+ * A hypermeter already computed for this piece, to be used instead of
1278
+ * inferring one. Pass it when the caller has already asked for the grouping,
1279
+ * or to impose a grouping the search would not have chosen.
1280
+ *
1281
+ * @defaultValue inferred from the notes and the cadences found
1282
+ */
1283
+ hypermeter?: Hypermeter;
1284
+ /**
1285
+ * Upper bound on the work this call may do.
1286
+ *
1287
+ * @defaultValue {@link DEFAULT_GENERATION_BUDGET}
1288
+ */
1289
+ budget?: number;
1290
+ };
1291
+ /**
1292
+ * A cadence ranked by how much of the structure it closes.
1293
+ *
1294
+ * @category Arrangement & Analysis
1295
+ */
1296
+ type StructuralCadence = {
1297
+ /** Index of the phrase this cadence closes, in the array it came from. */
1298
+ phraseIndex: number;
1299
+ /** The beat the cadence arrives on. */
1300
+ atBeat: number;
1301
+ /** The beat the phrase it closes ends at. */
1302
+ endBeat: number;
1303
+ /** The cadence itself. */
1304
+ cadence: CadenceResult;
1305
+ /** Structural weight in [0, 1]; {@link Phrase.structuralWeight}. */
1306
+ weight: number;
1307
+ /** Why it weighs what it does. */
1308
+ rationale: string;
1309
+ };
1310
+ /**
1311
+ * Split a piece into phrases.
1312
+ *
1313
+ * Three kinds of evidence are gathered independently and then reconciled. The
1314
+ * harmony contributes its cadences, each closing at the end of the chord it
1315
+ * arrives on, and at every bar line that chord is held across — a tonic still
1316
+ * sounding into the next phrase closed this one at the bar line. The
1317
+ * cadence reported for a phrase is always one that arrived inside it. The
1318
+ * melody contributes the rests it breathes at and the notes it
1319
+ * holds long enough to read as arrivals. Repetition contributes the beats where
1320
+ * the music restarts material it has just played. The metre contributes its
1321
+ * hypermetric downbeats, which confirm a boundary but never declare one on
1322
+ * their own.
1323
+ *
1324
+ * The boundaries are then chosen together rather than one at a time: the
1325
+ * reading that best trades each boundary's evidence against how regular the
1326
+ * phrase lengths come out is selected by dynamic programming, at a fixed cost
1327
+ * per cut. That is what stops a phrase being declared at every plausible beat,
1328
+ * and what lets a well-evidenced irregular phrase survive next to regular ones.
1329
+ *
1330
+ * The result is contiguous: phrases abut, and together they cover the span from
1331
+ * the first note to the end of the music. A cadence found in the middle of a
1332
+ * phrase is not lost — it is still reachable through {@link detectCadences} —
1333
+ * but only the cadences the reading puts at phrase ends are ranked by
1334
+ * {@link structuralCadences}.
1335
+ *
1336
+ * @param timeline The chord timeline the cadences are read from.
1337
+ * @param notes The melody, for its rests, held notes and repetitions. Notes
1338
+ * that never sound are dropped.
1339
+ * @param opts Analysis options; see {@link PhraseOptions}.
1340
+ * @returns The phrases, in time order; one phrase covering the whole span when
1341
+ * the span is too short to divide, and none at all when nothing sounds —
1342
+ * silence is no material to hear a phrase in.
1343
+ * @example
1344
+ * ```ts
1345
+ * import { chordTimelineFromNotes, phrasesFromTimeline } from '@libraz/libcantus';
1346
+ * // Four bars of C - F - G - C. Triads rather than single notes: one line at a
1347
+ * // time names no harmony, so nothing would cadence.
1348
+ * const triad = (pitches: number[], startBeat: number) =>
1349
+ * pitches.map((pitch) => ({ pitch, startBeat, durationBeat: 4 }));
1350
+ * const notes = [
1351
+ * ...triad([60, 64, 67], 0),
1352
+ * ...triad([65, 69, 72], 4),
1353
+ * ...triad([67, 71, 74], 8),
1354
+ * ...triad([60, 64, 67], 12),
1355
+ * ];
1356
+ * const { timeline } = chordTimelineFromNotes(notes);
1357
+ * const phrases = phrasesFromTimeline(timeline, notes);
1358
+ * phrases[phrases.length - 1]?.cadence?.cadence.type; // 'authentic'
1359
+ * phrases[phrases.length - 1]?.cadence?.atBeat; // 12, inside the phrase it closes
1360
+ * ```
1361
+ * @category Arrangement & Analysis
1362
+ */
1363
+ declare function phrasesFromTimeline(timeline: ChordTimeline, notes: readonly NoteEvent[], opts?: PhraseOptions): Phrase[];
1364
+ /**
1365
+ * Rank the cadences that close phrases by how much structure they close.
1366
+ *
1367
+ * This is the question the phrase layer exists to answer. Two chords alone
1368
+ * cannot say whether a V-to-I is the end of the piece or a passing confirmation
1369
+ * halfway through a hyperbar; a phrase reading can, because it knows what the
1370
+ * cadence closes and where that sits. Phrases no cadence closes are left out.
1371
+ *
1372
+ * @param phrases The phrases, as {@link phrasesFromTimeline} returns them.
1373
+ * @returns The cadences, heaviest first; ties keep the earlier one.
1374
+ * @example
1375
+ * ```ts
1376
+ * import { chordTimelineFromNotes, phrasesFromTimeline, structuralCadences } from '@libraz/libcantus';
1377
+ * const triad = (pitches: number[], startBeat: number) =>
1378
+ * pitches.map((pitch) => ({ pitch, startBeat, durationBeat: 4 }));
1379
+ * const notes = [
1380
+ * ...triad([60, 64, 67], 0),
1381
+ * ...triad([65, 69, 72], 4),
1382
+ * ...triad([67, 71, 74], 8),
1383
+ * ...triad([60, 64, 67], 12),
1384
+ * ];
1385
+ * const { timeline } = chordTimelineFromNotes(notes);
1386
+ * const ranked = structuralCadences(phrasesFromTimeline(timeline, notes));
1387
+ * ranked[0]?.cadence.type; // 'authentic' — the cadence carrying the most weight
1388
+ * ranked[0]?.atBeat; // 12
1389
+ * ```
1390
+ * @category Arrangement & Analysis
1391
+ */
1392
+ declare function structuralCadences(phrases: readonly Phrase[]): StructuralCadence[];
1393
+
1394
+ /**
1395
+ * Reading a piece into a {@link ReferenceProfile}.
1396
+ *
1397
+ * The profile is assembled from analyses the library already runs — chord and
1398
+ * key inference, hypermeter, phrases, sections, reduction, motifs and rhythm —
1399
+ * each run exactly once and all read against one span: every analysis is handed
1400
+ * the same `totalBeats`, so the phrases, sections and both rhythm readings
1401
+ * describe the same stretch of music. The harmonic reading enters as a bundle
1402
+ * of its own, so a caller already holding one (a score's kept chord analysis,
1403
+ * an arrangement's session) builds the profile from it without inferring the
1404
+ * harmony a second time.
1405
+ */
1406
+
1407
+ /**
1408
+ * Options for {@link analyzeReference}.
1409
+ *
1410
+ * @category Arrangement & Analysis
1411
+ */
1412
+ type ReferenceProfileOptions = {
1413
+ /**
1414
+ * A single time signature held across the whole span, as sugar for a
1415
+ * one-element `meters`; defaults to 4/4. Giving both is an input error.
1416
+ *
1417
+ * @defaultValue `4/4`
1418
+ */
1419
+ ts?: MeterLike;
1420
+ /**
1421
+ * The meter as it changes over the span.
1422
+ *
1423
+ * @defaultValue 4/4 throughout
1424
+ */
1425
+ meters?: MeterLike;
1426
+ /**
1427
+ * The key, when it is already known: read as one key across the whole span,
1428
+ * as {@link chordTimelineFromNotes} reads it. Omit it to have the keys
1429
+ * searched for over time.
1430
+ *
1431
+ * @defaultValue the keys inferred from the notes over time
1432
+ */
1433
+ key?: KeyLike;
1434
+ /**
1435
+ * The harmony, given rather than inferred — the shape an arrangement's
1436
+ * `timeline` option takes. The key regions are still read from `key` or,
1437
+ * without one, from the notes.
1438
+ *
1439
+ * @defaultValue inferred from the notes
1440
+ */
1441
+ timeline?: ChordTimeline;
1442
+ /**
1443
+ * The melodic line. Omit it to read the top line of `notes`, where notes
1444
+ * struck together are one event and the highest of them stands for it. Only
1445
+ * notes struck together are collapsed: a lower note struck while a higher
1446
+ * one still sounds — a broken-chord or Alberti accompaniment under a held
1447
+ * melody note — joins the line, so pass the melody of such a texture.
1448
+ *
1449
+ * @defaultValue the top line of the notes
1450
+ */
1451
+ melody?: readonly NoteEvent[];
1452
+ /**
1453
+ * End of the analysed span in beats.
1454
+ *
1455
+ * @defaultValue the end of the last note or chord segment
1456
+ */
1457
+ totalBeats?: number;
1458
+ /**
1459
+ * Upper bound on the work each analysis may do.
1460
+ *
1461
+ * @defaultValue {@link DEFAULT_GENERATION_BUDGET}
1462
+ */
1463
+ budget?: number;
1464
+ };
1465
+ /**
1466
+ * Read a piece's structure into a {@link ReferenceProfile}: its form, phrase
1467
+ * shapes, harmonic function and rhythm, motif derivations and melodic rhythm,
1468
+ * without the notes themselves.
1469
+ *
1470
+ * The melody is the `melody` option when given, and otherwise the top line of
1471
+ * the notes — notes struck together read as one event, the highest standing
1472
+ * for it. A lower note struck while a higher one still sounds stays in that
1473
+ * line, so a part whose accompaniment moves under a held melody note is read
1474
+ * as its melody only when the melody is passed. The harmony
1475
+ * is the `timeline` option when given, and otherwise inferred from all the
1476
+ * notes. The motif search expects quantized onsets.
1477
+ *
1478
+ * The sections are cut on the hyperbar grouping the phrase reading settles
1479
+ * on, which weighs where the harmony cadences; `sectionsFromNotes` alone
1480
+ * groups without the cadences, so the two can differ.
1481
+ *
1482
+ * @param notes The piece's notes, in any order. Notes that never sound are dropped.
1483
+ * @param opts The meter, key, harmony, melody, span end and budget; see
1484
+ * {@link ReferenceProfileOptions}.
1485
+ * @returns The profile.
1486
+ * @throws {InvalidInputError} If the notes or an option cannot be read.
1487
+ * @throws {BudgetExceededError} If an analysis would exceed the budget.
1488
+ * @example
1489
+ * ```ts
1490
+ * import { analyzeReference } from '@libraz/libcantus';
1491
+ * const triad = (pitches: number[], startBeat: number) =>
1492
+ * pitches.map((pitch) => ({ pitch, startBeat, durationBeat: 4 }));
1493
+ * const notes = [
1494
+ * ...triad([60, 64, 67], 0),
1495
+ * ...triad([65, 69, 72], 4),
1496
+ * ...triad([67, 71, 74], 8),
1497
+ * ...triad([60, 64, 67], 12),
1498
+ * ];
1499
+ * const profile = analyzeReference(notes, { key: 'C major' });
1500
+ * profile.harmony.chords.map((chord) => chord.roman); // ['I', 'IV', 'V', 'I']
1501
+ * profile.span.bars; // 4
1502
+ * ```
1503
+ * @category Arrangement & Analysis
1504
+ */
1505
+ declare function analyzeReference(notes: readonly NoteEvent[], opts?: ReferenceProfileOptions): ReferenceProfile;
1506
+
1507
+ export { detectKeyFromNotes as B, hypermeter as E, phrasesFromTimeline as F, spellAugmentedSixth as G, structuralCadences as I, tensionCurve as J, tensionCurveFrom as L, MODAL_SCALE_NAMES as M, analyzeArrangement as p, analyzePolyphony as q, analyzeReference as r, augmentedSixthChord as s, augmentedSixthFromPitchClasses as t, augmentedSixthKind as u, createArrangementSession as v, detectChord as w, detectChordBest as x, detectKey as y, detectKeyBest as z };
1508
+ export type { ArrangementAnalysis as A, ChordMatch as C, DetectChordOptions as D, Hypermeter as H, KeyMatch as K, Phrase as P, ReferenceProfileOptions as R, StructuralCadence as S, TensionPoint as T, ArrangementOptions as a, ArrangementSession as b, ArrangementTrack as c, AugmentedSixthKind as d, Conflict as e, ConflictPartner as f, DetectKeyOptions as g, HypermeterOptions as h, ModalCandidate as i, ModalScaleName as j, PhraseOptions as k, PhraseSignal as l, TrackAnalysis as m, TrackEdit as n, TrackRole as o };