Sharpen this
(doesn't quite work)
Flatten this
(doesn't quite work)

Current key

Reset to C Major
Toggle Linear/Circle view

This is an experiment in CSS and jQuery, and an experiment in musicology: The page represents the default key of C Major, using a clock-like representation of the notes of the scale. C - the root, or I degree of the scale - is represented at "noon", and each note follows 1 or 2 "hours" later depending on the number of semi-tones separating the notes.

Associated with the IV and vii degrees (Fa and Ti) are functions to change key: In any key, sharpening IV/Fa moves the key forward by a fifth, e.g., from C Major to G Major. Likewise, flattening vii/Ti moves the key backward by a fifth, e.g., from C Major to F Major. (Minor keys are always the vi degree of the major scale, i.e., the La note, e.g., A minor in the case of C Major... ...and that's all we need to know about minor keys for now.)

The idea of the circle is to represent visually what happens in any key: The major chords are always in the 12 o'clock, 5 o'clock, and 7 o'clock positions, the minors in 2, 4, and 9, and the diminished in 11. Always. That's kind of cool.

The idea of the clock comes from the fact that we use a 12 hour clock and there are 12 semi-tones in the Western scale. Isn't that conveeeenient!

The CSS part of the experiment is using CSS3 to draw the circle and position the notes. That part works fine. But the associated flatten/sharpen functions aren't getting placed properly, and even when they are, they don't work as expected: Clicking the underlined word is supposed to move the key forward or backward.

For some reason, this only works in the Linear version - below the circle is an underlined function to switch from a circular view to a linear view and everything works fine in the linear view: One can switch to linear, change the key, then switch back to circular to see where the notes now live. Fixing this is problem #1.

The Javascript/jQuery experiment is doing all the heavy lifting (changing keys, sharpening/flattening notes, etc.) from within Javascript, mostly using jQuery(). This includes switching from Linear to Circular view, which is done by toggling the CSS file in use, and storing the current CSS type - line or circle - in the class of the div that is used to toggle the CSS. That's kind of cool.

There are a lot of inefficiencies in the Javascript. For example, there is a lot of DOM access and many DOM updates, and each update will cause a page reflow. This isn't a big problem for such a small page, nor is it a problem on a powerful device, but on a larger, more complex page or on a mobile device this might be unacceptable.

Another problem is that there may or may not be a memory leak in the use of the temporary newKey object in some of the Javascript. Again, not a huge concern in a small page that is likely shortlived, but in a long-lived app on a mobile device, this might be problematic. If this problem exists, it is because of my still having a "C like" concept of scope - lexical scope - and not having adjusted to how scoping is different in languages like perl and Javascript, which use dynamic scope. So I may be creating stack objects and leaving them orphaned.

One note about the use of objects Vs arrays: I'm using objects instead of arrays because it was simply easier to declare and define them, e.g., the natural notes in C Major object, but this does lead to some awkwardisms:

What's next? Well....

Give credit where credit is due. I was inspired to do this after seeing the CSS3 clock created by Keran McKenzie, so props to him. Thanks!

The jQuery() team deserve massive praise for their work (and not just praise). The following pages were helpful in figuring out how to do specific bits: