17 December 2007

Getting Back Online with Music Theory

Well, this hellacious year is almost over. Most of my spare time has been spent on the archiving and family history project, which I'm documenting at The Marcella Armstrong Memorial Collection. That project is bearing fruit in that I have almost a thousand images scanned, and so I'll be giving some of the originals to family members. I've created some beautiful prints, as well, and over Christmas I'm hoping to share some of the images with family members in the form of slideshows.

Meanwhile, in the back of my mind I'm thinking about how to get back into Haskell programming. Music theory keeps coming to mind.

The problem with music theory is that it is really a collection of ad hoc convenient rules and relationships in the guise of a coherent theory. The various named entities have completely inconsistent nomenclatures. You kind of get used to this when you learn to play chords and transcribe songs, but it is easy to forget how inconsistent it is and thus confusing for students.

For example, intervals. A major second is an interval also known as a whole step. If you start on the root note of a scale, say, a C major scale, the C is known as the root or "first." If you add a major second to a first, you might imagine that you'd get to a third note of the scale. But, no, you have a second note.

Does that mean the steps in the scale are off by one in their naming (that is, the first is really the zeroth?) No, because if you add two major seconds to the root, you have a third, not a fourth. It is the naming of the intervals that are off.

So can you just start the intervals at zero instead of one? Well, kind of. A minor second is a half-step, or the difference between adjacent keys on a piano. Call that 0.5. A major second is then 1.0. But this still doesn't explain intervals, because a "fourth" is actually three whole steps and a half step. And if you add a third and a third, you don't have a sixth, you have a flat seventh!

So it keeps coming back to me that I should try to codify the rules of intervals and chords in some bits of Haskell code. It might even be of use to geeks trying to understand music theory.

Don't even get me started on time signatures or tuning!

Bill Mill said...

Andy said...

I've been thinking along the same lines myself, since I've learned Haskell and Csound, and have been learning music theory along the way. I'd like to be able to generate Csound scores using Haskell, taking into account concepts of keys, chords, major/minor scales, etc. There's a package called Haskore that seems almost but not quite what I'm aiming at. Haskore doesn't seem to have much of a concept of keys or chord layout (unless I'm missing something), and besides, I haven't been able to make it compile with the later versions of GHC. I started messing with some ideas for how to code scales and chords using simple lists of half-step counts, but I have nothing that is really usable yet, and since I recently trashed my BIOS I can't get back to it until I get that fixed. I'd be glad to send you the code I have so far when I can, in case you'd find that useful, but it may be a few weeks from now.

Paul R. Potts said...

James Tauber's work looks interesting, but I want to (at least initially) work through the problem myself as an exercise. Tauber's approach seems more complex than it needs to be, but I had not been thinking in terms of preserving the distinction between enharmonic equivalents. That is sometimes valuable for notational convenience but it is another illustration of how music theory is really a hack! Kind of a "syntactic sugar" for musicians!