@libraz/libcantus - v1.1.0
    Preparing search index...

    Type Alias DetectKeyOptions

    Input weighting for detectKey.

    type DetectKeyOptions = {
        weights?: readonly number[];
        profile?: KeyProfileName | KeyProfilePair;
        modes?: boolean | readonly ModalScaleName[];
        explain?: boolean;
        budget?: number;
    }
    Index
    weights?: readonly number[]

    How much each pitch counts toward the histogram, one entry per pitch. Defaults to one per pitch, which weighs a thirty-second-note ornament as heavily as the whole note under it. detectKeyFromNotes supplies duration times velocity, matching how chord inference weighs its own histogram.

    Which key profile ranks the candidates: the 12 degree weights a key is expected to distribute its music over, correlated against the distribution actually observed.

    'krumhansl' (the default) uses the Krumhansl–Kessler probe-tone ratings, 'temperley' the Kostka–Payne corpus proportions, and 'flat' a flat profile over the scale, which reduces the ranking to plain scale membership — the behaviour this detector had before profile correlation, kept as a way back for a caller that depends on it. A custom pair supplies two 12-entry vectors indexed from the tonic (index 0 = tonic, 1 = flat second, and so on to 11 = major seventh).

    When either the distribution or the rotated profile has zero variance the correlation is undefined; such a candidate is scored by the normalized dot product (cosine similarity) of the same two vectors instead, so a result never carries NaN.

    'krumhansl'

    modes?: boolean | readonly ModalScaleName[]

    Whether the church modes join the 24 major and minor keys as candidates.

    Off by default, because a modal candidate can only change a ranking by outranking something: a caller working in common-practice repertoire, where a raised sixth over a minor tonic is a melodic-minor inflection rather than a dorian tonality, should keep reading the answer it reads today. Turn it on (true for all five, or a list to name the modes a repertoire actually uses) and each enabled mode adds one candidate per tonic, ranked on a profile derived from its parallel major or minor key.

    Ionian and Aeolian are not on the list: they are the major and natural minor candidates, which already carry scaleName 'major' and 'naturalMinor'.

    false

    explain?: boolean

    Attach a KeyMatch.rationale to every candidate, and KeyMatch.alternatives to the top-ranked one.

    Off by default, and the one explanation in the library that is: the other entry points explain a single reading, while a ranking explains 24 of them (36 or more with the modes on), each needing a phrase built for a candidate nobody asked about. That cost outweighs the detection itself, so it is paid only on request.

    false
    
    budget?: number

    Upper bound on the input pitches processed by this detection call.