I thought an E major triad is always E G# B
That is correct. The notes comprising an E Major Triad are always
E-G#-B - irrespective of key. However, the notes comprising a diatonic triad whose root is E do vary depending on the key. The cited illustrations are not only of E major triads, but several different types of triads with E as their
root. (The root is the base note of the chord - the first note in the series when describing a triad in its 'default' configuration - iterating through its parent scale in order. This configuration is known as the
Your question arises because you are unclear about how intervals are defined and named, and how the resulting different sorts of triads are built from these intervals. This subject is a source of much confusion among many new to music theory.
There are several good answers on the site explaining the basics of interval definition. I wrote about it here: Are intervals like major 3rd, minor 3rd, and major 2nd all based on the scales, or are they based on how many semitones they have? - so I remember this answer, but there are others as well, as good or better than mine.
Cutting to the chase for the purpose of answering this question, here are the rules you need to know:
- Every triad is built from two 3rds. Root->3rd is the first 3rd; 3rd->5th is the second 3rd.
- 3rds in this case are comprised of the Major 3rd - 4 half steps: for example,
C-E, or Minor 3rd - 3 half steps, for example
C-Eb (minor means small or
less, as in 3 is smaller than 4).
Those two types of 3rds can be combined in 4 different ways to build triads, giving us four different types of triads (there is no such thing as an 'absolute' or 'normal' triad'), based on the types of 3rds being used to build the triad, in the order they appear :
- Major 3rd/Minor 3rd: This gives us a
Major Triad - (
- Minor 3rd/Major 3rd: This gives us a
Minor Triad -
- Major 3rd/Major 3rd: This gives us an
Augmented Triad. (Not included
in the examples cited)
- Minor 3rd/Minor 3rd: This gives us a
Diminished Triad -
Now for your specific examples:
chords.triad(E,C) does not mean a major triad. It means the diatonic triad in the key of C Major (second argument in the function) with a root of E (first argument in the function). Same with all of those function calls.
Diatonic in this sense means that we use only the notes of the key in question to build the triad. That is the meaning of the text you posted:
Natural Diatonic Triads.
chords.triad(E,C) == E,G,B - a triad comprised only of notes of from the key of C major. However, this is an E Minor Triad, because E->G is a minor 3rd and G->B is a Major 3rd - as per the second item in our list of triads.
chords.triad(E,E) == E,G#,B - a triad comprised only of notes from the key of E Major. In that case this is an E Major Triad, because the first 3rd is major: E->G# is a major 3rd and the second 3rd G#->B is minor- as per the second item in our list of triads.
chords.triad(E,F) == E,G,Bb - a triad comprised only of notes from the key of F Major. In that case this is an E Diminished Triad, - as per the fourth item in our list of triads - because E->G is a minor 3rd, and from G-Bb is also a minor 3rd. Bb here is called a diminished 5th - meaning it is one half step lower than the perfect or 'normal' 5th - it is a 5th that is reduced-diminished in size and
diminished gives this triad its name, to distinguish from the minor triad.