Saturday, May 2, 2020

Signs and Magic

[If you don't feel like reading a lot, there's a fun new game about 2/3 of the way down. I LOVE burying the lede.]

There's a throwaway line in the article I wrote for the Boston Musical Intelligencer last week which I've found myself thinking about ever since. After boasting that my "blog combines various levels of expertise in writing, rhyming, piano playing, composing, arranging, animating, music engraving, video and graphic design, audio editing, and programming," I felt compelled to add the following parenthetical (bold added for emphasis here):
(I’m a novice programmer but intrigued by the ways in which programming and composition both magically transform bland symbols into entire worlds.)
I didn't want anyone to think I was claiming anything like real expertise as a programmer, which is why I added the first four parenthetical words. The other words just sort of magically followed - which is sort of like how this post has been magically generated by these previous bits of word-generated magic. Sort of.

The two contrasting points I'd want to make about my experiences as a programmer are:
  1. I really am mostly a self-taught novice, with perhaps a creative flair for getting things done, but with all sorts of faults I can't really even articulate - because my faultiness recursively includes not understanding fully what I don't understand - but having to do with writing inefficiently and struggling with more abstract principles of recursion and multi-dimensional thinking. 
  2. I LOVE programming. Maybe in part because I often don't quite know what I'm doing and am not working from familiar internal scripts, it's just always amazing to me when things work. Partly, the speed with which modern processors work and the remarkably flexible, powerful languages available mean that a lot can be accomplished with seemingly little. Paradoxically, there are many things that seems like they should be simple (because our own brains have so many sub-conscious algorithms) which can be a tricky to "explain" to a processor. And confronting that reality, while frustrating, is also fascinating.
The main reason I'm writing about this now is that I've been hard at work on a couple of code-oriented projects the last 2-3 days. One of them is still in process, but it's a music engraving challenge using Lilypond which has required a few deeper-than-normal dives into the program's text-based commands - commands that somehow produce really beautiful-looking music notes.

Unlike a more typical program such as Finale or Sibelius, you generally don't see results in real time in Lilypond. You type out commands and then update the output as needed. Finale and Sibelius will certainly take time to re-format a major layout change, but in Lilypond (using the Frescobaldi environment), even adding an articulation or accidental won't show up immediately in the notation. Although this might sound odd, my favorite part of this process is when I try out some solution, hit the "engrave" button and wait to see what happens. This can take 2-10 seconds depending on the complexity. A lot of times, it's back to the drawing board, but that makes the moments when things work that much more satisfying. 

My other recent project has to do with my day job, which I haven't written about much here. I have mentioned before that this blog got its start when I first started teaching a big arts lecture class to non-music majors. Grappling with "outsiders" who didn't necessarily think like musicians was a big disruption to my own way of thinking, and that's basically why I started blogging. I now teach at a boys prep school, work which includes general music classes for middle schoolers. This has pushed me yet further outside my comfort zone as the need to see things from a different perspective has shifted again. 

Currently, my 7th graders are learning about Beethoven's 5th - a handy topic in this Beethoven year - and I'm always searching for multimodal ways to get the boys into Beethoven's world. (We've done some simple composing using the primary motif, and one mad scientist student put this together in just fifteen minutes of class time after being provided only with the drums and once instance of the motif.) We've conducted the Exposition section of the first movement many times; conducting together is one thing that actually kind of works in this brave new Zoom world. Conducting has the advantage of being physical, without being as intimidating as dance, and it invites a range of ways to feel the music in the body and to pay attention to moments where the pulse is paused and where the character changes. It's also a fun excuse to show videos like this.

Earlier this week, I had each student submit a video of himself conducting the Exposition, and I was impressed by how well they were anticipating what was coming and responding to various style changes. (Was also fun to see the wide variety of conducting styles, from Bernstein-esque melodrama - one even donned a Beethovenesque wig -  to the most serious, sober-minded, technical focus.) So I thought it would be fun to put together a little puzzle game which would require re-assembling musical segments that are out of order. I'm sure that to some degree, something like this Google Doodle from Beethoven's 245th was in the back of my mind, though I wasn't thinking consciously about it.

Anyway, I dove into Scratch, MIT's amazing programming environment for "children" (which I've written about many times before) and after a few hours, I'd roughed out a little game. After a trial version with one class, I put some hours into refining it and adding fun graphics, and here you go:

I think it's pretty cool. It was a challenge for many students, though I had one solve it in less than three minutes. However, after their first attempt, for which they had no previous information about how the music was divided, we talked about what to listen for in each segment - not only what to recognize, but how to think about where it fits into the 8-part structure. (We had already spent a good bit of time learning to identify various themes, using my Beethoven listening map.) I think it was a very successful exercise.

If you don't feel like playing right now, you can watch this demo of the game in action.

Returning now to my parenthetical comment with which I began:
I’m a novice programmer but intrigued by the ways in which programming and composition both magically transform bland symbols into entire worlds.
I'm not saying that musical composition and programming are the same thing, although it is well-known now that computers can compose. My point is that the satisfactions both offer me feel similar. Of course, the situation is muddied by the fact that I do most of my composing and arranging on a computer, and most of my programming involves producing or manipulating music. (Here's a rare game I created which has nothing to do with music.)

But both do feel like a kind of magic. I'm proud to say I built my little Beethoven game in Scratch from scratch - meaning it's not based on another Scratch project. (One of the cool teaching features of Scratch is that anyone can look inside any other published project and copy the code to build something new. Programmers beware - the "code" inside my projects is typically sloppy, uncommented, and certainly inefficient). But even though I basically understand the logic of what's going on, it's still a little miracle when things work.

Here's a little summary of what it's like to do something like this: I conceived the basics of what I wanted the game to do, then put together a series of commands to get it to do what I wanted. This included such basic tasks as creating a function that puts 8 numbers in order by comparing them a pair a time. (A more advanced programming language would have this sort functionality built in, but part of the point of Scratch is to learn this kind of process.) There were multiple ways in which I could've written the instructions, but what matters most is the output. Also, as I worked and confronted challenges and successes, I added many elements to my original concept.

All of the above is pretty similar to what one does when composing, with music notation instead of code. (Yes, it is possible to compose without using notation.) It's also similar in some ways to writing (which also uses "codes") and other creative pursuits, but composition and programming feel a bit more closely connected to me. I find for example that when composing/arranging or programming, once my mind is switched into that mode, it's very difficult to come down from it. (I told my wife that, like drinking coffee, I should really try to stop programming by 6pm or I'll find it impossible to go to sleep.)

As I admitted parenthetically above, my code can be overlong and inefficient, and this is also true of my writing, so in final summary: GO PLAY.

No comments: