This is the reverse of Music: what's in this chord?, which is to print the notes in a given chord. This time the input is a list of notes in a chord, and your task is to output which chord it is.
Your program should support the following triadic chords. Examples are given with root C. Chords with other roots are the same chords with all notes rotated so C will become that root note, e.g. Dmaj consists of D, F# and A.
C C#D D#E F F#G G#A A#B Db Eb Gb Ab Bb Cmaj C E G Cm C D# G Caug C E G# Cdim C D# F# Csus4 C F G Csus2 C D G
Note that Caug is the same as Eaug and G#aug, and Csus4 is the same as Fsus2. You can output either one but there is a bonus if you output them all.
And the seventh chords for the bonus are listed in the follow table:
C C#D D#E F F#G G#A A#B Db Eb Gb Ab Bb C7 C E G A# Cm7 C D# G A# Cmmaj7 C D# G B Cmaj7 C E G B Caug7 C E G# A# Cdim7 C D# F# A
- You can write either a complete program or a function.
- The input is a list of notes, separated by a space or another convenient character. It can also be an array of strings (if it take input from function argument) or the string representation of such array.
- Input doesn't have to be in specific order.
- There may be duplicated notes in the input. They must be treated the same way as there is only one of them.
- The output is the name of the chord. In case it will output multiple names, the same rule for input applies.
- If the input isn't a supported chord, you should print the notes as-is. Your program can also support other chords not listed in the tables above (which is valid but has no bonus).
- You can use other notations listed in the Wikipedia article. But if you choose
Cfor C major, you should add a human readable prefix in either case to distinguish a chord with a single note.
- You cannot use built-in functions for this task (if there is any).
- This is code-golf. Shortest code in bytes wins.
C D# GOutput:
C Eb GOutput:
C Eb F#Output:
F A C#Output:
Faug Aaug C#aug,
Faug Aaug Dbaugin any order.
F D F F F F A A FOutput:
- -30 if it prints them all if there are more than one interpretations (for aug, sus4/sus2 and dim7).
- -70 if it also supports seventh chords.
- -200 if it accepts MIDI input and prints each chord it have received. Note that the notes doesn't have to begin or end at the same time. You decide what happens in the intermediate states (as long as it doesn't crash or stop working). You may assume there are no notes in percussion channels (or there is only one channel if that's convenient). It is recommended to also provide a text (or array) version for testing, especially if it is platform-dependent.
Cb, etc. \$\endgroup\$
Csus4 is the same as Gsus2. I think you mean
Csus2 is the same as Gsus4don't you? \$\endgroup\$