Key-Signature placement: A system without logic.
The traditional placing of a key signature, the general accidentals that indicate which scale you use, seems to be not a logical system.
The meaning is always clear, it does not matter where you place the accidentals on the lines, it is only a matter of layout, it has to look good. So what are the guidelines to place one accidental-sign on the lines? First let's have a look how the traditional placement looks like (image source: http://music.thefxcode.com/):

Initially I thought the algorhythm to find the correct placement for any accidental (for example the sign for F-Sharp) is:
"Go down in octave steps from the highest usable octave-variant of that pitch (derived from the human hearing range and therefore the design of instruments and music) until you get a note which, in combination with the current Clef, has no ledger line".
So let's have a look how that looks with just two clefs, Treble and Bass. The notes represent possible accidental positions. G-Major, F-Major and something with G-Sharp, probably A-Major:
We can see that the "First non-ledger-line position from top to bottom" works pretty well. The F-sharp marker would be on the first line (from the top) in treble clef or on the second line in bass clef. Same for measure two treble clef and measure three bass clef.
But wait…
Measure three treble and measure two bass need the same line/positions. The position mean different things, but remember this is all about layout. When we look up on the "traditional" chart we see that A Major still follows my pattern. g'' (Lilypond syntax) is outside of the five-line-system but has no ledger lines. Prediction -> Experiment -> Confirmed.
Again: This has nothing to do with pitches or music, so for the Bass clef the analog layout shoudld be true. F-Major needs an B-flat which can be found above the first line. Same situation: No ledger line, first case where this is true top-down direction.
Now look at the char above, second row first measure. Bang, contradiction! I can't see the reason.
On top of that the traditional approach does not even follow a pattern. Because of the nature of accidentals and their origin in the pillar of fifths you often can see a fourth and fifth up/down pattern. But this is obviously only a result of anoter pattern I can't see or, as I suspect, no pattern at all! The flat key signatures seem to follow a 4th up/5th down pattern. But with a different clef you exceed the Fife-Line Range again. What happens then can be seen when you use the treble clef. The pattern breaks and you have to use another position.
So we have a situation where we have two patterns/algorhythms. The one I desribed (top-down, first non-ledger line) and the mirror pattern: bottom-up which can be seen on the bass clef system. Additionaly there is a minor tendence to begin with a 4th interval and alternate with a 5th, which results in the up/down mirror situation with flats and sharps (because they go in different directions in the pillar of fifths).
For a conclusion I still have to check the other clefs: All C-Clefs and shifting the G and F clef to "french clef", "sub bass" and others. Even if there is a single rule/pattern which always results in the traditional layout I am disappointed how complex it must be and then still produces ugly output like B-Major with the treble clef. Maybe I can find another explanation. Do you know any? Please comment!
Nils Gey is the author of 