Every input pitch class is tried as a root against every known chord quality.
A match is reported when all of the chord's tones are present in the input, or
when the only absent tone is the perfect fifth (a common omission in shell
voicings); matches are ranked best-first by fewest extra notes, then fewest
missing notes, then root position over an inversion, then most specific
(largest) chord. An exact match (no extras, no missing) is flagged and ranked
first.
The root-position step decides between readings of the same pitches that are
otherwise equally good: [55, 59, 62, 64] is read as G6 rather than Em7,
because G is in the bass.
Parameters
pitches: readonlynumber[]
MIDI pitches or bare pitch classes (octave-agnostic).
Identify chords matching a set of pitches.
Every input pitch class is tried as a root against every known chord quality. A match is reported when all of the chord's tones are present in the input, or when the only absent tone is the perfect fifth (a common omission in shell voicings); matches are ranked best-first by fewest extra notes, then fewest missing notes, then root position over an inversion, then most specific (largest) chord. An exact match (no extras, no missing) is flagged and ranked first.
The root-position step decides between readings of the same pitches that are otherwise equally good:
[55, 59, 62, 64]is read as G6 rather than Em7, because G is in the bass.