Thanks. That helps somewhat, though it is still crazy complex. But, why is the major scale 2212221? Is there a 1212122 scale (end every other possible combination)?
> Is there a 1212122 scale (end every other possible combination)?
The steps have to add up to 12 to end up on the same octave. I'm not sure about every possible combination but there are other scales called "modes" which are rotations of that pattern (which can be derived from the white keys on the piano, just starting one of the 7 different notes; whether something is a 2 or a 1 depends on whether there is a black key between the white keys). The different scales derived from that are:
2 2 1 2 2 2 1
2 1 2 2 2 1 2
1 2 2 2 1 2 2
2 2 2 1 2 2 1
2 2 1 2 2 1 2
2 1 2 2 1 2 2
1 2 2 1 2 2 2
The first pattern is a typical Major (associated with happy songs) scale. The sixth one is a standard Minor scale (associated with less happy songs). The third one is called Phrygian and has a dark/exotic feel that works well in metal ( https://www.youtube.com/watch?v=-DzGlzdbkDI )
A 1212122 scale doesn't add to 12, and so would not work very well. When you play through a scale, low to high, you generally want to end up back where you started but up an octave.
The main other combinations you see are the same 2212221 pattern, but starting on a different note. For example, if you start on the sixth note, this permutes to 2122122 which we call the (natural) minor scale. We call each of these permutations a "mode".
Technically any sequence of notes within the octave is a scale, including the chromatic scale (111111111111). The French composer Olivier Messiaen did some investigation into how many scales can be built, I think the number is a bit over 800. Of course most scales sound weird to unaccostumed ears.
I'll try to explain why we choose those 7 notes out of 12. Note, that this is just my opinion and not a scientific and proven research.
According to observations by ancient Greeks, the sounds whose frequency have simple ratios of small natural numbers like 2/3 or 4/3 or 5/4 sound harmonically and pleasing together. Except for number 7 (I don't know why). So, if we take several such sounds we expect to get a nice sounding chord.
For example, in a C major chord (C + E + G) the frequencies ratio of E to C is 5/4, ratio of G to C is 3/2 and ratio of G to E is 6/5. So, if we denote frequency of C as 4f, then the frequencies of C, E, G are 4f, 5f and 6f. Those are indeed ratios of small numbers and notes in C major chord are considered in harmony with each other.
By the way, if we invert the chord as G, C, E we get ratios of 3f, 4f and 5f. These are the smallest numbers that we can use to build a 3-note chord. Does it mean that inverted C chord is the most perfect and sounds most harmonical? As a person without an ear for music I don't understand.
Because of this ancient people made scales that consisted of notes with good ratios. For example, if we take first 6 notes of a major scale (C, D, E, F, G, A), the frequencies would be f, 9/8f, 5/4f, 4/3f, 3/2f, 5/3f. Except for D, all of these are small numbers and if ancient Greeks were right, the song made from them should sound harmonical. D also has good ratios with some notes like G (D/G ratio is 3/4).
But this scale has a disadvantage, that one cannot easily raise or lower the pitch. Different people have different voice ranges, but if you have an instrument with these notes, you cannot change the key and transpose the melody. For example, if you had a sequence of C, D, F then you cannot pick higher or lower notes with same ratios.
That's why people invented an equally tempered scale. It turned out that if you divide an octave into 12 equally spaced notes, then 7 of them are pretty close to a traditional major scale. That's why it is 2212221 and not something else. With equally tempered scale one can transpose a song up or down easily, keeping the same ratios between notes.
By the way, note B seems to use different pitches in different scales. There is a space between frequencies of A and C, so there is a place for a note, but there is no simple ratio one could use for B and different scales used different pitches for the note.
You can read more about pitch ratios here [1].
While major chord sounds "most" harmonical, but there are only 3 major chords in a major scale, and the music tends to be boring if it uses only perfect ratios. I guess that's why musicians started to use more and more "imperfect" chords over time. For example, in a minor chord like A, C, E ratios are 10f:12f:15f. And indeed a minor chord sounds like a wrong version of a major chord. If we take a chord with 7th, the ratios get even worse, and some musicians use chords with notes that do not belong to a normal chord, or even do not belong to the key.
By the way, non-harmonical notes are ones that differ only by a half tone - for example, E and F (ratio is 16:15) or three tones (ratio is 36:25).