I know that one scale consists of 12 half-tones. But my question is still: Why? Why not 13 or 11?
This requires an excursion into musical history.
Originally, instruments were made to simply play notes that sounded "right" together. Why some notes sounded right and others wrong wasn't of great concern for most of humanity's history, until Pythagoras, (yes, the guy with the theorem) noticed that it had to do with intervals, and made a music theory based on perfect fifths. This theory had its problems, however, and was improved upon by later people, eventually ending up on what is called a "just intonation"
Basically, notes sound harmonious if the frequency of the notes is close to a simple interval, like 3/2 or 5/4. These theories were important because it meant it was possible for different instrument makers to make instruments that could play scales together, thereby making orchestras.
But just tuning has a problem: you can basically only play the scale that the instrument is built for, because the intervals between the notes are different. If you play a tune on the wrong scale, it will sounds out of tune. This means that if you want to sing along with the instrument, you have to find a singer whose range fits the song in the scale the instrument is built for. You can't transpose the song to fit the singer. Also, musicians were exploring the limits of what you could do with just intoned instruments.
So out of this came then the equal temperament. It splits the scale into equal intervals, meaning you can transpose a tune into other keys, and also means you can do dramatic chord changes and other interesting things. You can indeed split the octave into 11 or 13 notes if you should wish to do so, but to most people it will sound out of tune. But when you split it into 12 notes, you get close enough to the seven notes of just intonation for it to be bearable, except to some unlucky few supposedly burdened with overactive perfect pitch. The five tones that are in between the basic seven are, as expected, called "half-tones".
There are equal temperaments other than the 12 tones per octave that will sound fine, but they don't generally have a integer number of notes per octave. Wendy Carlos experimented a lot with this, and made such scales as the Gamma scale with a slightly mind-boggling 34.29 notes per octave.
This question on math.se is quite similar to what you're asking and the answers give a lot of detail:
What's going on here is a massively convenient mathematical coincidence: several of the powers of 2^(1/12) happen to be good approximations to ratios of small integers, and there are enough of these to play Western music.
Two points that may have not been completely answered.
Why is C major the reference scale for natural tones ?
The anglo-saxon notation obscures the history a little. Tradition from church music led in Italy (then shortly after France and Spain) to naming notes of the reference major scale by conventional syllables: Ut Re Mi Fa Sol La Si (this corresponds to C D E F G A B) coming from the latin lyrics of a very well known piece of that time. The latter single-letter notation takes another starting point, but the reference character of the C major scale has persisted across Occidental countries even if you can find evidence of notations and keyboards using other notes as reference. One of the main influences has been the construction of keyboard instruments (notably the church organ). The current keyboard layout is a compromise between the typical width of the hands, playing the Ut (now mostly called Do or C) major scale easily and having access to all semitones and a few other things. Other designs have not been as successful.
You also have to know that the theorization and standardization of music at least up to the 19th century was made under the patronage of the churches (orthodox, catholic, reformed, ...) pushing for uniformity. The nineteenth century has seen an even larger standardization and internationalization of tuning, music teaching and piano domination as reference and composition instrument. The last three centuries have progressively suppressed or put into oblivion most of the divergent traditions (as to scales, modes, tuning) in Europe. Nowadays, people learning about music are taught as an evidence the C major scale as a foundation of music theory and the minor scale and his variants is not always treated fairly.
Why is there a semitone between E & F and B & C and not elsewhere ?
There are several scales/modes outside of the major scale, with a varying number of notes, where the semitones are not placed between the 3rd and 4th note and between the 7th and 8th. The three minor scales (harmonic, ascending, descending) for instance, but also dorian, phrygian, you can read an encyclopedia article about them.
It has to do with harmony. Notes clash the least when their frequencies match up. For example, a note and its octave match up every two cycles, or a 2/1 ratio. Other ratios that sound good are 3/2, 4/3, 5/3, 5/4, 6/5, and 8/5; these are called the basic consonant intervals. Intervals that clash are the dissonant intervals.
So why twelve notes?
The twelve-tone equal-tempered scale is the smallest equal-tempered scale that contains all seven of the basic consonant intervals to a good approximation — within one percent — and contains more consonant intervals than dissonant intervals.
This page (from which I quoted) provides greater detail: http://thinkzone.wlonk.com/Music/12Tone.htm
A fifth is the smallest non-octave consonant interval, with a frequency ratio of 3:2. If you start stacking pure fifths, the first result reasonably close to stacked octaves (2:1) is 12 fifths, which turns out to be 531441:4096 as opposed to 128:1 for 7 octaves. That's as close as you can get for a reasonable number of notes per octave. So if you are looking for a tonality built from stacked octaves and almost perfect fifths, a twelve-tone division will be pretty much what you'll arrive at.
This also happens to serve a few other intervals (major and minor thirds, for example), but worse so than fifths. "mean tone temperament" tries getting a number of major thirds pure at the cost of making several other intervals as well as some thirds sound worse, and "well-tempered tuning" gets several pure fifths and some nice thirds in exchange for some more distasteful fifths.
So over the millennia, tuning has changed its focus from pure thirds to pure fifths and finally settled on making only the octaves pure and building the rest of the scale around an equally-tempered fifth, resulting in 12 equal-tempered semitones.
When two notes are played together, they sound pleasing only if their wave curves come together every few cycles. We call them harmonic sounding.
If the wave curves never come together, or don't do so within a few cycles, they sound discordant.
Wave curves will only come together if the two frequencies are multiples of each other. For example, if one frequency is 200 cycles per second and the other is 600 cycles per second, their sound curves will coincide exactly 3 times every second, and they will sound harmonic.
By dividing each octave into 12 intervals, you maximize the number of pleasingly sounding pairs of notes. That is because the number 12 is divisible by more small numbers than any other number less than 60. It is divisible by 1,2,3,4,and 6. The number 60 would allow more pleasing combinations (1,2,3,4,and 5), but it would be ridiculous to divide an octave into 60 intervals.
So in modern western music they use 12 intervals. That provides the maximum number of pleasingly sounding combinations to create harmony.
The reason is THE BRAIN. THe brain likes frequencies that are simple proportions. It thinks they go together. You should really ask, first, why are there octaves?
Well the octave represents a doubling / halving of hertz (cycles per second).
So, midi middle C is 256 hz, and if you know your computer numbers, you'll realise that the next octave C's are at 512, 1024, 2048, etc and the lower octaves are at 128, 64, and (pimp your ride) 32.
Earthquakes, by the way, show up at around 11 hertz.
Every society starts with the octave. 'Cos 1/2. Got it?
(I propose that the 2nd Viennese school abandon the octave by the way, and also tuning the instruments. Niether make any sense for them. The current state of things with octaves and tuning and suchlike is pure hypocrisy. Let it go, boys! Also scores. And playing in public. Nobody comes anyway.)
How to divide the octave?
If we start it on C and divide it into 3 (which is a nice brain-friendly proportion) we will get a lovely 3 note scale:
C, E, G#, C
How about dividing it in to four:
C, Eb, F#, A, C
"THat's nice", says the brain, "but it's too SYMMETRICAL. Both of these scales just seem to go on forever and ever, I can't tell what's what. I know! Why don't you mix and match the proportions so they are slightly more uneven? Then I can figure out the bass note.".
And thus was born the "Proto Major Thingy":
C, E, G, C
and the "Proto Minor Thingy":
C, Eb, G, C
"Hang on a bit", says the brain, "you missed a note, didn't you?".
"Between G and C, I'm pretty sure you had something between G and C".
C, E, G, A, C ?
"Thas NICE! Rock and Rollish. Go on then, what about the other one?"
C, Eb, G, Bb, C ?
"Hey, what's with the Bb? We never heard that before. What kind of proportion is that?"
"You mean 5/6ths. Alright. Play it again".
C, Eb, G, Bb, C
"Kay, that's bluesy. All right! But its 70,000 years ago and there's loads of poor bastards buggerin' round the the scenery getting crunched and munched by sabre tooth tigers and suchlike. Lotta funerals. Mucho sadness. Like Trump nowadays, you should know! Need variety. "
C, D, E, G, A, C
C, D, E, G, Bb, C
C, Eb, F, G, Bb, C
C, Eb, F, G, A, C
"Whats the F proportion?"
"Great! I like it. 5 notes. Let's give it fancy Greek name. Tart it up a bit. Penta...?"
"I was kidding. You know, too literal..."
"Nevermind. It's awesome. we'll go with Pentatonic. More! We NEED MORE! Now there's chieftains, mud huts, jewelry"
"I need some rules".
"kay. Er.. keep the Minor third or the Major third and the Fifth where it is, and just move the others about... I know, like this: move the seventh up, the sixth down, the fourth up, and the second down!"
C, D, E, G, A, C
C, D, E, G, Ab, C
C, D, E, G, Bb, C
C, D, E, G, B, C
C, Eb, F, G, Bb, C
C, Eb, F#, G, Bb, C
C, Eb, F, G, A, C
C, Eb, F#, G, A, C
C, Db, E, G, A, C
C, Db, E, G, Ab, C
C, Db, E, G, Bb, C
C, Db, E, G, B, C
"Hey, then if we superimpose them all we''ll get 12 subdivisions of the octave! Brilliant!"
C, Db, D, Eb, E, F, F#, G, Ab, A, Bb, B, C
"That's why I'm called the BRAIN, son. Oh, and you're welcome."
For western music the greeks were the first to figure out the math that occurs naturally in the harmonics overtones generated by horns and other wind instruments. The Greeks applied the same mathematical ratios (golden ratio) to strings. Pythagoras invented the pythagorean tuning of (3:2) perfect fifths and Octaves (2:1) to match naturally occurring harmonic overtones. Later the greeks invented 7 modal scales based on pythagorean tuning. Seven Modes with eight notes in a scale. These scales were Ionian, Dorian, Phrygian, Lydian, Mixolydian, Aeolian and Locrian. We still use Ionian (Major) and Aeolian(Minor). The flaw with natural harmonics is that the octaves between each mode were slightly off from each other. Aristoxenus in the 4th century BC invented the 12 tones between octaves in an attempt to use the same ratio between each note. Later Keys were invented to use these 12 tones as a home base for each scale. The problem was that by nature these keys are slightly off from each other. To solve this J.S. Bach in the early 1700's promoted the use of the Tempered Scale. He equalized the natural occurring gap between each of the twelve semitones. Brass instruments in the baroque period had a bag of different sized crooks to adjust for each key that they performed in. String instruments also had to retune for each key change. By using the tempered scale a performer could switch between all of the different keys without re-tuning.
A simple picture is sometimes better than a huge explanation, so i'd also encourage to check the graphs in this link, you can mouseover the 10edo to the 19edo for example to see the differences between various divisions: http://www.tonalsoft.com/enc/e/edo-11-odd-limit-error.aspx ( just look at strongest consonances : 3 - 1/3** , 5 - 1/5 and 3/5 - 5/3 , the rest of the graph is really not important in comparison.)
Basically what it clearly shows, is that the 12-notes division is the only one to make the ratios 3/2 and 4/3 (the most importants*** after the octave) almost pure. And the thirds/sixths (ratios with the number "5", the next most importants***), are not so bad neither. No other division by a fair number of notes, 10 to 19, can even slightly approach this. This is mathematically remarquable and the reason why we use 12 notes and not 13, 11, or etc.
** ("1/3" just mean a 4/3 ratio with 2 octaves shifts, it's just the way they originally present the numbers.)
*** (What i mean is that if your brain wants to easily recognise and remember music, you rather need a big bunch of fifths, fourth and thirds to be more or less in tune, in your musical architecture, even melodic, otherwise it's mostly dissonant sounds, leading to noise, and hard to remember for your brain...)
Great answer by @john Baldwin above. Jut wanted to add that these minimum divisions are also the most practical to use. Taking the case of singing for instance between one note say C and its higher Octave C, 7 intervals produce the most distinct sound, plus 5 sharps and flats = 12.
And then if we start dividing it further it slowly starts getting very fine sub harmonies for the human hearing to discern. And these 12 divisions then also repeat in the higher and lower octaves and so on.
The easiest to identify is 4 divisions which is a divisor of 12, which makes up a pentatonic scale with the higher note, and is why is easily enjoyable.
Based on your wording of the question I would say that it is by design. It is not a coincidence that 12 half steps fit into an octave rather than 11 or 13. Though the details may change if one assumed just tuning I will explain assuming equal tempered tuning. First you should know that there is a continuum of frequencies and therefore pitches between any two notes. We have converged on a particular choice of pitch combinations for the western diatonic scale through centuries of experimentation. The notes in a scale reflect what is pleasing to the ear(s) for a particular culture. Over time Westerners standardized the half step by splitting the octave into 12 steps using the relation
f_octave = 2*f_tonic
they imposed the constraint that the ratio of two consecutive half steps be the same no matter where you start,
f_1/2 = r*f_tonic (this would be a minor second)
since we are forcing the number of 1/2 steps from tonic to octave to be 12 we get the relationship
r^12 = 2 or r = 2^(1/12)
IMO a few posts here are putting the cart before the horse. You cannot demonstrate that the octave has only 12 semitones using the above definition of a semitone. Rather you ask what does the ratio have to be in order to ensure there are 12 in an octave.
To that end there are all sorts of alternate chromaticisms that attempt to place N equal steps in an octave. These result in the tuning equation,
r = 2^(1/N)
There is a 24 TET containing 24 equal quarter steps in an octave. And you absolutely could build a scale with
r = 2^(1/13)
or some other root of 2. Of course these would NOT be 1/2 steps in the traditional sense of the term. Now the issue of how we got there is a longer story. Before 12TET tuning the Just major scale with 8 notes (including octave) have more than 5 accidentals. You can google this and find Wiki articles on the topic but there were, I believe, just scales with as many as 17 independent notes in the octave. Though all consecutive notes are probably slightly different ratio. Hence not really a 1/2 step. What you call a 1/2 step depends on how you learned the term.