Input
The symbol of any triadic chord (see http://en.wikipedia.org/wiki/Chord_(music)#Triads).
Output
The notes constituting the given chord.
Examples
Input: AM
Output: A C# E
Input: C#m
Output: C# E G#
Input: Db+
Output: C# F A
Input: C0
Output: C D# F#
Bonuses
-50 if you can also deal with seventh chords
-150 for actually playing the sound of the chord
-150 for using printable characters to show how to play the chord on a piano; example for AM
:
┌─┬─┬┬─┬─┬─┬─┬┬─┲┱─┬─┬─┲━┱┬─┲━┱─┬─┬┬─┬┬─┬─┐
│ │ ││ │ │ │ ││ ┃┃ │ │ ┃ ┃│ ┃ ┃ │ ││ ││ │ │
│ │ ││ │ │ │ ││ ┃┃ │ │ ┃ ┃│ ┃ ┃ │ ││ ││ │ │
│ │ ││ │ │ │ ││ ┃┃ │ │ ┃ ┃│ ┃ ┃ │ ││ ││ │ │
│ └┬┘└┬┘ │ └┬┘└┲┛┗┱┘ │ ┗┯┛└┲┛ ┃ └┬┘└┬┘└┬┘ │
│ │ │ │ │ ┃ ┃ │ │ ┃ ┃ │ │ │ │
└──┴──┴──┴──┴──┺━━┹──┴──┴──┺━━┹──┴──┴──┴──┘
-100 for using printable characters to show how to play the chord on a guitar; example for AM
:
x o o o o o
┌───┬───┬───┬───┬───┐
│ │ │ │ │ │
├───┼───┼───┼───┼───┤
│ │ │ │ │ │
├───┼───┼───┼───┼───┤
│ │ █ █ █ │
├───┼───┼───┼───┼───┤
│ │ │ │ │ │
(see https://en.wikipedia.org/wiki/Box-drawing_character)
Rules
The result must be a command-line program or script.
The input and output can be in any form, as long as it follows a music notation standard.
A guitar or piano representation is considered valid if and only if it contains the three (triadic) or four (seventh) required notes and nothing else. The same note can be present several times in the chord.
External libraries are not allowed, except for sound generation (in which case the
#include
,import
... directives are not added to the character count).This is code golf, the shortest code wins!
A little bit of music theory...
In modern Western tonal music, every octave is made of twelve successive notes, often noted:
A
A#
B
C
C#
D
D#
E
F
F#
G
G#
Or:
La
La#
Si
Do
Do#
Re
Re#
Mi
Fa
Fa#
Sol
Sol#
In this system, we consider that two successive notes (e.g. A
and A#
, or E
and F
) are separated by one semitone. Also, the notes are kind of "looping": what immediately follows G#
is A
.
A chord is constituted by a few (2, 3, 4, sometimes more) notes that "sound good together". For instance, triadic chords contain three different notes, and seventh chords contain four different notes.
Let's define the four triadic chords as:
Major triad: contains the root of the chord (in this question, the note given as input), the major third for the root (4 semitones higher than the root), and the perfect fifth for the root (7 semitones higher than the root); this can be symbolized 0-4-7
Minor triad, symbolized 0-3-7
Augmented triad, symbolized 0-4-8
Diminished triad, symbolized 0-3-6
So for example, if you want to make a C major triad, noted C
, CM
, Cmaj
, you will need three noted:
- 0: the root, in this case a
C
- 4: the minor third, 4 semitones higher than the root; that's an
E
- 7: the perfect fifth, 7 semitones higher than the root: a
G
This is what the 0-4-7
, 0-3-7
, 0-4-8
and 0-3-6
notations used above mean! For the seventh chords, use the following pattern:
That's it for today! Now, amaze me with amazing code... If you have any question, add some comments below.
Db+
isDb F A
there's no D# or G in there. That's perhaps a little more theory than necessary, the formulas were the important part. If you really want to include all eight of the seventh chords listed in wikipedia you should specify the input. I assume the ascii-art output of piano and guitar is flexible. \$\endgroup\$