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

    Type Alias KeyRegion

    A span of the piece over which one key is in force.

    type KeyRegion = {
        startBeat: number;
        endBeat: number;
        key: ResolvedKey;
        confidence: number;
        modulation?: KeyRelation;
        pivot?: PivotChord;
    }
    Index
    startBeat: number

    First beat of the region.

    endBeat: number

    End of the region, exclusive.

    The key in force across the region, owned by it: every entry point hands back a key of the region's own, so writing to one changes neither the other regions of the same run nor what a later call reports.

    Whole, whichever way the region was built. A caller who named the key hands its spelling and scale form down, and a key the analysis found is spelled and formed the way resolveKey reads a bare scale — the reading every other layer would have made of it. There is no third state to guess at: a key/scale alone says nothing about how it is written, so a region carrying one would report whichever spelling those pitch classes read best from, and an Ab minor handed in would come back out a G# minor.

    confidence: number

    How well the region's music fits the key, in [0, 1]: the correlation between the span's pitch-class distribution and the key's profile, with negative correlations reported as 0.

    One statistic whichever entry point built the region, so a threshold or a comparison means the same thing across them. Where the region came from chords rather than notes, the distribution is each chord's tones weighted by how long the chord holds.

    modulation?: KeyRelation

    How this key relates to the previous region's — 'dominant' for a move to the dominant, 'relative' for a move to the relative minor, and so on. Absent on the first region, and absent when the two keys stand in none of the named relations.

    Never 'same': a region is the maximal span of one key, so consecutive regions never share one and a region carrying this field is a place the piece moved.

    pivot?: PivotChord

    The chord the modulation turned on, when one was identified. Only the chord-aware entry points fill this in: a pivot is a chord that reads in both keys, so it cannot be named without knowing which chord sounded.