Thursday, May 15, 2008

Converting choral music scores to MP3s

I sing in a choir. Apparently music and programming are closely related (can't find link) and nearly everywhere I've worked it didn't take long till I found other programmers who sang or played or wrote or painted or whatever. For many (like me) it's an absorbing hobby. For others programming has been the day job and their "real" life was the music etc.

I've come to classical choral music very late in life. I grew up with the popular music of the time, got into blues and jazz via guitar playing in my 20s and slowly my musical interests have expanded. But when I turned 50 I decided I wanted to learn to sing properly (tired of the sore throats) and my singing teacher suggested I join a choir to give me some focus. I'm kicking myself now for not having learned to sight read music and not persisting with my occasional attempts to learn keyboard. I insisted my children learned to read music as part of their readin', writin' and 'rithmetic but didn't apply the same logic to myself. D'oh!

So how do I learn to sing my part (tenor) in the choral pieces we perform? Software of course! I reasoned that there must by now be reasonable music OCRing software, Googled a bit and found only two products that continue to be supported. The various other attempts over the years seem to have died. Choral music tends to be "dead white man's music" and thankfully most of it is out of copyright. There is the wonderful Choral Public Domain Library which can often supply an electronic version of a work, often in MIDI format (my preference), sometimes in Sibelius or Finale format (which is useful with Finale's free player), but often only a PDF version is available.

Of course CPDL is only the tip of a vast repository of choral music sequestered in various libraries and archives around the world, probably never to be unearthed and performed. One of our choir members visited the Vatican and was allowed to hand transcribe a simple choral work he found in an archive there. Our choir was the first to perform the work outside of the Vatican. Another piece we perform annually was written 900 years ago. This is simply "mind-blowing baby" as Austin would say.

Back to music OCRing. The two products that seemed worth a look are PhotoScore and SharpEye. PhotoScore is the more heavily promoted and costs more but a Lite version is bundled with Sibelius so the cost is often hidden. The only problem is that when I tried PhotoScore a couple of years ago it was awful. I spent hours having to manually correct all the bits it failed to comprehend. In desperation I went looking again and found the wonderful SharpEye. It simply works. It's accurate and complete and quite inexpensive.

The main problem for me was that I am a Mac zealot and SharpEye only runs on Windoze. Initially I had to run it on Virtual PC and it was painfully slow but then Parallels was released and I ordered a MacBook the next day. SharpEye under Parallels is easy to use. So the procedure is to either download a PDF of the score or scan it in. Then I let SharpEye OCR the score. Usually there are some minor note value errors. (But it has even read hand-written scores and was reasonably accurate.) Compared to PhotoScore, this was heaven.

The final irony was to read a recent press release announcing that PhotoScore now uses the SharpEye engine. But the demo version I tried didn't seem any better than the older versions.

SharpEye exports in MusicXML format and both Finale and Sibelius can import MusicXML. MusicXML is actually the only 'full-content' format I can use to transfer files from SharpEye to Sibelius. The other common format, MIDI, doesn't handle lyrics.

So I import the MusicXML file into Sibelius and clean up the score a bit more. I simply play it and usually I can hear the errors (sharp/flats missing, sometimes (rarely) a note at the wrong pitch, more often timing errors (crotchets/quarter notes for minims/half notes or vice-versa). I switch from Sibelius' default instruments for voices (very soppy oohs and aah) to a nice piano and use a macro to set all the dynamics marks (mf, p, pp etc.) to 'f'. I want to hear the notes and ppp is usually too soft.

Then I export the file as a MIDI and import the MIDI into GarageBand. Now there ought to be scripts that would create four MP3 files for me, each one with a different part being played loudly and the other three parts being played quietly in the background. I tried a couple of Automator scripts but they hung. I tried manually creating an Automator script myself but it also hung at a crucial point so it makes me think the interface to GB might be faulty. Finally I FTP the MP3s to the website ready for choir members to listen and learn.

Now this whole tedious, time-consuming process ought to be largely automated. Obviously manual correction needs to be done as some point but I keep wondering what a more automated process would look like. I wonder if such a Score-to-MP3 system exists (more Googling required I think). Maybe I if learn a bit more about MusicXML I could use a Perl script to extract the four parts and push them through some sort of MP3 creator. It's a thought.

No comments: