So this year I threw away my code and started again. I believe that the two fundamentals of music are note and interval and that all else (scale, chord, etc) is build from them. Rhythm (i.e. time) is an orthogonal dimension and I’ll save that for much later. This post I’ll talk about my Note class.

So, last post I showed a diagram of how I’d modelled a circle of notes. You can see the circle and peanut shapes in that diagram: the peanuts are there to show notes with enharmonic names. I think I’d failed to separate out the ideas of tone, note, solfeggio, and scale in my original classes. A static class diagram of just a few of them looks like:

Furthermore, I’d written a ChromaticScale and a MajorScale class built from ScaleToneNames. The MajorScale doubled as a representation of the natural note names (i.e. the white piano-keys). I then used CodeDom together with a set of IntervalCycle instances with hardcoded intervals to generate classes for another ten scales including the modes and the minor scales.

My interval class left a lot to be desired and had few operators; the logic for generating a scale of ScaleToneNames from intervals was tortuous; the code which allowed Notes and Intervals to interact was not general; and the project was bloated with too many classes and too much code. I needed a re-think.

So, what’s the definition of a note? What comes to mind? A physical division on an instrument (piano-key, fretted guitar-string)? Or is a piano-key only a note when it’s played? Maybe you feel a note is something theoretical so that the same piano-key is sometimes the note C# and sometimes Db whether it’s sounded or not? Is a note something you can point at, press, and finger; or something you hear; or something you distinguish by its name and notate on paper? All these ideas are important but I think it’s necessary to give them unique names for the sake of clarity.

In 12-TET (twelve-tone equal temperament), the octave class is divided up into twelve pitch classes. Just like in the abbreviation TET, you’ll almost always hear these pitch classes referred to as tones so I’ll do the same to distinguish them from the idea of note.

Since an octave rolls around into its neighbours, it’s useful to consider only the octave class and to present it visually with its twelve tones arranged like the hour positions of a clock-face.

I’ve called this arrangement, and its corresponding C# class the TwelveToneClock. It’s composed of twelve Tones. As you can see, some tones have names and some don’t. So, derived from Tone are NamedTone (with a Name property) and UnnamedTone. Although the unnamed tones can be named in relation to the named ones (any of them in fact, but typically a neighbour), it’s also important to the theory of tonal harmony that a natural name can be overridden. For example, the tone at the twelve o’clock position is typically used as the note C natural, but a good musical model should allow for it to theoretically become the note B# or even Dbb. It’s in this (en)harmonic sense that I’ll define the Note class.

A Note, then, is defined as a reference to a NamedTone along with scalar properties representing the note’s octave number (approximately 1-8 on the piano, but capable of being much wider) and how many semitones that NamedNote has been sharpened or flattened (therefore a signed integer, typically in the range -1 to 1) known as its alteration. And here’s the relevant portion of the new static class diagram: