Tcl Powered Pictures of Real Tcl/Tk Applications

Lick Observatory

Santa Cruz, CA


The anchors will take you to PostScript versions (better resolution, and you can print them on nice printers).

Musicology with Tcl and Tk


The computer musicology world is dominated mainly by LISP, due to the nifty stuff written and used at Stanford (CM and related applications). I've played with CM some, but I'm not a LISP programmer. And CM doesn't have much in the way of graphics.

I have several interests in quantitative musicology: one is visualization of musical structure and style. Another is phrase and style analysis. The third is algorithmic composition -- I've played around with a robot compositor, but decided to learn some counterpoint theory before proceeding.

I used to use commercial Mac-based tools for MIDI composition and recording: Vision, Galaxy, Finale, etc. Of all the commercial ware, I think Band-in-a-Box, the notoriously nifty algo accompanist, is the only one I can't live without. All the rest of these expensive and slick packages ended up hampering and annoying me after a few years. I wanted to do aleatory and algorithmic things which my sequencer wouldn't permit. I wanted to analyze MIDI files (huh?) quantitatively. I wanted real databases, not some quasi-database-like facility for storing (e.g.) MIDI patches. Frustration. Decline of productivity.

After a long wait, a couple of years or more, I decided that Linux was ready to roll. I invested in a 133MHz Pentium and Red Hat Linux, with a MIDI bus card. After some newbie thrashing I managed to get the tclmidi extension working, and for a couple of months I was grabbing every MIDI utility off the Net and checking it out. I even put up Franz LISP and tried out CM. But this is what I finally settled on as 'the right' toolkit for the MIDI hacker under Linux (your mileage and opinions may vary, of course):

  1. Tcl, because it's the best scripting language on the planet.
  2. ABC as the archival notation, because it's ASCII, portable, and has good tools
  3. tkseq as the MIDI sequencer/tweaker package
  4. abc2midi for MIDI/ABC translation
  5. abc2ps for typesetting
  6. PostgreSQL for a database

I don't get much time to work on this stuff, but here are some snapshots of work in progress. I've written on tools that eat abc files, turning them into database records, then performing some preliminary numerical analysis on the stored records. A GUI tool called 'xplore' then manipulates the stored data:


xplore : A Musicological Toy

We'll point xplore at a simple piece of music, the famous duet from Act I of Les Pecheur de Perles by Bizet. Ignoring accompaniment, there are 3 voices: Tenor, Baritone, and a Flute counterpoint early in the piece.


xplore : Note Trace Plot

Here we see the Tenor and Bari voices (Voice 1 and Voice 2 in the database): notes are represented by horizontal lines of length proportional to the note length, with MIDI note numbers establishing the Y values. Where the notes are connected, there are no rests or breathing. Where they are discrete, there's a rest or opportunity to breathe.


xplore : Pitch Movement rather than Pitch

Here's a view that interests musicologists: For Voice 1, plot Pitch as Relative to the Preceding Note. In other words, show me the steps and leaps that Voice 1 is making, rather than the actual pitches.


xplore : Note Duration as Y

Here we'll move later in the piece, to Bar 16, and look at the Tenor voice in terms of Duration rather than Pitch. Y is now note duration. We can immediately see that the Tenor never gets anything longer than a half-note, and that there's the pattern we would expect (a series of shorter notes leading up to dramatic longer notes. Composers have 'signatures' of note length usage, just as they have harmonic and pitch cluster signatures. This tool lets us visualize these statistics quickly and easily.


xplore : Just Pitch, with Average

Here we've lost duration and are just looking at the two voices (during the later part of the piece, from Bar 16 on) in Pitch. But we're showing the Average Pitch for each voice (over the plotted bar range). As you would expect, the Baritone voice has a significantly lower average than the Tenor. That's a high tenor part, by the way! I can sing it, and I'm a contralto.


xplore : Note Trace Plot

Back to the Note Trace plot: here's the very beautiful main theme, with the tenor and bari working in counterpoint.


xplore : Degree From Fundamental

Here's another way of looking at pitch: the degree from the fundamental pitch (the 'key' of the piece). This piece is in Eb, so we can analyze all pitches in the tune as merely degrees (fourth, fifth, unison) from Eb. This gives us a visual reckoning of the degrees the composer is using across time.


xplore : Degree From Fundamental

Here we see the Degree plot for both voices. You can see a kind of movement between them, but it's not as clear as it might be. We really want a better way to visualize harmony. So...


xplore : Harmony Plot

Here we visualize harmony, fading the actual voices back to gray and highlighting the interval between them in colour. Not only do we show the absolute interval, we analyze it for type according to the classical counterpoint rules: perfect consonance, imperfect consonance, dissonance, and those pesky fourths. Surprise! you can see that Bizet is writing classical counterpoint, with nice resolutions to perfect intervals at the end of each section.


xplore : Note Name Distribution

Now we'll wander off into statistics again. This is an 'Incidence' or 'Distribution' plot showing the tone cluster in which Bizet is writing. We analyze the same set of bars, counting incidence of each scale degree (note name). The result shows the scale notes Bizet used the most in each voice. The Baritone voice line has less amplitude on the graph because the Bari part just has fewer notes all round (try being a bass singer sometimes, it gets worse).


xplore : Scale Degree Distribution

We could also look at this in terms of scale degrees. It should look rather similar, since scale degrees and note names are just two ways of expressing the same idea. Note the nonlinearity of the X axis: those mumble.5 numbers are just my crude way of expressing accidentals!


xplore : Duration Distribution

We could also look at the distribution of note lengths: that would tell us whether the feeling of the piece was leisurely or busy, and whether it was a tedious plainchant kind of piece where most of the notes are the same length, or a more interesting one with a wide variety of note lengths. We see that Bizet has a rather strong preference for quarter notes :-) and that the two voices, interestingly, have a markedly similar note distribution. If you listen to the piece you will see why.


xplore : Pitch Distribution

I'm not at all sure I believe this plot. It seems unlikely that the bari part would encompass a note higher than anything the tenor ever reaches. Looks like a software bug to me! But hey, this code is only a couple of days old.


xplore : Tenor and Flute (Bar 1)

I did say there was a flute in there somewhere. Here's the tenor and the flute.


xplore : All Together Now (Bar 1)

And here's everyone, all together. We're showing average pitch again, and you can see how neatly the voices cover an almost equally spaced set of three pitch ranges.


Here's the way I think of this piece (this is generated from the database in imitation of the worksheet I used when transcribing the piece): Music Ledger This will horrify all the musically-literate readers; but I'm only barely literate and this is just about as legible to me as traditional staff. It's also more compact :-). That's ABC notation, by the way.


Back to Photo Gallery.
Further Back to Lick Tcl homepage.
Way Back to my homepage.
Way Way Back to the UCO/Lick homepage.

de@ucolick.org
webmaster@ucolick.org
De Clarke
UCO/Lick Observatory
University of California
Santa Cruz, CA 95064
Tel: +1 408 459 2630
Fax: +1 408 454 9863