Thursday, July 26, 2007

More formal midsummer overview

(Current code. Requires the puri and cxml packages in addition to Gsharp's other dependencies.)

As it is the midpoint of the summer, it seems an appropriate time to take a step back and examine my progress so far. Besides basic sequences of notes, the following features are now fully supported in both import and export, except where noted:

  • Accidentals
  • Key signatures
  • Chords/clusters
  • Multiple staves
  • Measures (export only)

The last feature tackled prior to this report was support for multiple staves. Several more basic features demand attention: clefs, and perhaps most prominently notes that vary by duration are good examples (right now my work assumes that everything is a whole note). But a certain group of features are more "basic" in a completely different way: they are at the root of the structure of the musical data as represented in Gsharp and MusicXML. These are best implemented sooner than later because doing so touches a great deal of other code already written; this is partly because in order to do anything, including the simple "hello world" example with which this project began, code had to be written to supply constant versions of these structures. Early versions of the code always created one staff in one layer with one measure. Working on these features has also uncovered weaknesses in my Lisp programming technique and overall design; I discovered, for example, that I was overzealous in my use of generic functions and this was hindering my progress.

I have had my previous programming experience hinder me here and there as well. For example, I recently had an occasion where I was passing a variable down as a function parameter through several layers of functions, refusing to make it a global variable simply because it had been drilled into my head that such behavior was acceptable only on very specific occasions, and this was clearly not one of them. Christophe kindly reminded me that I could use real honest-to-goodness dynamic scoping and that my choices weren't limited to 2 kinds of ugliness. Overall however, I am not under the impression that my previous experience has been too much of a burden.

My biggest obstacle continues to be a problem I have, over the years, realized occurs in all kinds of engineering projects (for me anyhow). I simply try to implement five things at once instead of focusing my attention at one specific task at a time. This happened right at the beginning of the project, when implementing the initial, "hello world" parser. Only after a few days did I realize that i was trying to parse multiple staves, multiple voices and multiple measures. I think this might present more of a problem in this context because being fairly new to Lisp means I am less able to picture the general structure of the program in my head before I write it.

The following features remain to be implemented:

  • Clefs (export completed as of this writing)
  • Notes of varying durations
  • Multiple voices/MusicXML motion declarations
  • Rests
  • Ties
  • Lyrics
  • Menu entries for export and import

"Notes of varying durations" will also entail beams/flags and dots. "MusicXML motion declarations" refers to the "forward" and "backup" elements, which are used in MusicXML "to coordinate multiple voices in one part" -- the current implementation for more than one stave does not correctly deal with concurrent clusters on those staves. This feature is dependent on notes of varying durations. Given my current rate of progress, I see no reason why these features should not be completed by the end of the summer.

Monday, July 9, 2007

an overdue update

when we last left our intrepid programmer, he had produced basic code that exported from Gsharp to MusicXML in record time, leaving him with a program that could convert but a single note from Gsharp to MusicXML and back. Since then, he has added support for a number of additional musical features:

  • More than one note
  • Measures
  • Accidentals
  • Key signatures
  • Chords

All of these things can be both imported and exported. We rejoin our hero as he is working on adding support for multiple staffs (staves? i like staffs myself). There are a number of more basic things which need to be added (say, notes of varying duration) but that fiendish villain Multiple Staffs is threatening to disturb a lot of code in his quest to control all of the innocent notes and rests that populate the fair city of Gsharp, so Brian has elected to vanquish him now, though perhaps not once and for all. Waiting around that next dark corner are more complicated features, like Multiple Voices and Ties, and our programmer is only beginning to suspect to what level they are in cahoots with Staffs in some kind of unholy criminal alliance.

As for the state of my lispiness, despite the considerate speed discussed in my last post, my progress seemed to slow down immensely immediately thereafter. However, I think my fluency continues to improve at a steady pace. Christophe (my mentor on this project) says that he thinks it takes 10 years to become truly fluent, so I'm feeling pretty good.