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 most specific (largest) chord. An exact match (no extras,
no missing) is flagged and ranked first.
Parameters
pitches: number[]
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 most specific (largest) chord. An exact match (no extras, no missing) is flagged and ranked first.