Why are there both sharps and flats?
Gee.. page full of very low quality&#x2F;BS answers there! Hadn&#x27;t seen Music StackExchange before.. super non-impressive. The 2 top-voted answers are absolute without-a-clue nonsense, people-who-don&#x27;t-know rambling aimlessly, not explaining anything.<p>I am also no music historian, don&#x27;t know all the history, but:<p>Not until the third-top-voted answer, the one beginning &quot;Historically, keyboards didn&#x27;t always work that way&quot; is it mentioned that..keyboards didn&#x27;t always work that way. But they go on &quot;Our musical notation is older than enharmonic equivalency that you get with &quot;well-tempered&quot; keyboards&quot; -  evidently confusing well temperament with equal temperament.<p>Which is understandable - it seems everyone&#x27;s &#x27;educated&#x27; with that misconception; I certainly was. (Classical then jazz pianist) Even in my 30s I remember reading a book from the 1880s talking in detail about the specific emotional qualities of the different keys, thinking they were just imagining things, deluded. Then I learnt that no, Bach&#x27;s &quot;well-tempered&quot; actually wasn&#x27;t our equal temperament, with each note 2^(1&#x2F;12) higher than the next.[0] Every key (C major, E minor etc) actually sounded different, the intervals were different etc. So that 1880s book wasn&#x27;t crazy at all. Apparently that&#x27;s about when equal temperament was brought in everywhere (mid to late 19th C), and the old &quot;different keys sound different&quot; was abolished.[1] Many composers complained about the loss of..key personality, didn&#x27;t want the new system. Now all the keys sounded exactly the same. (Well, not to me, I&#x27;ve got perfect pitch. But to most people they do now.) It seems a strangely huge cultural forgetting, that somehow I never heard about all that, during decades in various music worlds.<p>So before the equal temperament system of e.g. middle C is 3 semitones above A, so 220 x 2^(3&#x2F;12) Hz, many different systems of ratios were used to compute the note frequencies, producing lots of different tunings, &#x27;temperaments&#x27;.<p>The problem in all this is the Pythagorean comma, the gap resulting from the awkward fact that when trying to construct a scale from octaves (2x the frequency) and 5ths (3&#x2F;2x), 2^x=3^y has no positive integer solution. With continued fractions they worked out that 2^7~(3&#x2F;2)^12 (128~129.7463..) is a good approximation, which is, in short, why pianos have 12 notes per octave, and going up 12 5ths takes you up 7 octaves. With equal temperament, the gap is spread evenly among the notes, only now none of the intervals have simple ratios of frequencies like they did before (except the octave). There&#x27;s now nothing perfect about a &quot;perfect 4th&quot; or &quot;perfect 5th&quot;.<p>Anyway..going <i>up</i> in 5ths you get C,G,D,A,E,B,F#..<p>Going down you get C,F,Bb,Eb,Ab,Db,Gb..<p>Gb and F# on modern pianos are (just different names for) the same note, but in the pre-equal temperament days, <i>going up a 5th</i> wasnt just Freq x 2^(7&#x2F;12) but multiplication by some ratio, most simply 3&#x2F;2. And then the note you got going up (F#) was different to that you got going down (Gb). Some keyboards had black notes split in half, one playing the sharp, one the flat.<p>But I won&#x27;t go into more historical detail, because I don&#x27;t know it and I&#x27;m rambling aimlessly enough already. And you could fill a book with the answer to the Q.<p>[0] well, pedantic piano tuners won&#x27;t agree, but that&#x27;s the theory.<p>[1] Some instruments had been equal temperamentish for centuries, e.g. guitar I think, (it using the same frets for different keys) but others, like pianos, not until then.