The span is examined in minKeyBeats slots. Each slot's pitch-class
distribution is correlated against all 24 major and minor key profiles, and
the run of keys that best explains the piece is chosen, paying a cost per
modulation that rises with the distance travelled around the circle of
fifths and falls on strong beats. Adjacent slots agreeing on a key become one
region.
The metric accents that discount a modulation follow the signature in force
at the beat in question, so a piece that changes meter is read in the meter
it is actually in. The first downbeat is beat 0, so a pickup is written at
negative beats and its notes argue for the key like any others rather than
falling outside the span.
Pivot chords are not reported here: naming one requires knowing which chord
sounded at the boundary, which raw notes do not say. Use
detectModulations when a chord timeline is in hand.
Infer where the key changes from raw notes.
The span is examined in
minKeyBeatsslots. Each slot's pitch-class distribution is correlated against all 24 major and minor key profiles, and the run of keys that best explains the piece is chosen, paying a cost per modulation that rises with the distance travelled around the circle of fifths and falls on strong beats. Adjacent slots agreeing on a key become one region.The metric accents that discount a modulation follow the signature in force at the beat in question, so a piece that changes meter is read in the meter it is actually in. The first downbeat is beat 0, so a pickup is written at negative beats and its notes argue for the key like any others rather than falling outside the span.
Pivot chords are not reported here: naming one requires knowing which chord sounded at the boundary, which raw notes do not say. Use detectModulations when a chord timeline is in hand.