Experimenting with Lilypond and MIDI

One amazing package that came with Cygwin is Lilypond. It converts simple text descriptions of songs into gorgeously artistic sheetmusic and standard MIDI files. I'm planning on creating a number of these files of popular songs for karaoke use and posting them here. I'm just worried about the copyright issues.

To help me enter the music, I hacked together this little python script which lets me try out different notes with the computer keyboard; if you play one note long enough, its Lilypond representation will stay in the textarea. When you're done you can cut and paste the output into a Lilypond source file. The script is really bad and probably has a memory leak, but you can use it if you feel courageous. It's GPL-licensed, and you're welcome to use and modify it however you wish. It requires the pymidi DLL or beep.py.

On a related note (pun intended), I'm also hacking a sound editing program using Tkinter. "How many projects can you work on at the same time?" you might ask. I haven't yet determined the upper limit...

And now (January 2004) I'm playing with MIDI seriously again, something I hadn't done since 1987-88 when my work made it as the cover story of Portable 100 magazine. See ../src/midi/ for midi.py, and the pymidi subdirectory for the DLL code. This is cygwin-specific, although you could probably port it to Windows with little difficulty. You can thank Jeff Glatt, as I do, for sharing his wealth of knowledge of Windows Multimedia, without which this project would not be progressing nearly as fast. As you may have noticed above, I've updated pyano.py to work with the new DLL.

I'll probably be hacking a lot more on those tools, but as I'm fast running out of money, what I want to do with these is to perform some songs and make a few bucks. So now that midi.py's 'midiplay' routine can transpose a song and drop the melody track, I wrote these two bash scripts, perform and practice, the latter (actually a symlink to the same script) which leaves the melody track (actually channel) in, and the former which removes it. To get this working on your XP/cygwin system, make a text database of song pathnames relative to "My Documents/My Music", followed by the transpose number (-8 to +8 half-steps), followed by the channel to drop. Leave off the ".mid" extension. For example, a file named songs.db:

shout 3 3
everybody_wants_to_rule_the_world 3 3
Then, assuming you have in your path the files 'practice', 'perform', 'pymidi.dll', and 'midiplay' (a symlink to midi.py), you should be able to:
perform songs.db
And it will play the songs one after the other, correctly transposed for your voice and with the melody tracks removed. If you want to find a lot of MIDI sequences to use, try googling '"index of" midi'. If you have the same filename ending in '.html' it will display the lyrics too.

If you aren't able to get this to work, let me know and I'll correct the instructions.

It may be more than obvious, but I'm very proud of these scripts. They allow me to do a lot of MIDI manipulation that would be prohibitively tedious using Windows tools, even Jeff Glatt's very friendly and lightweight programs. I hope you get some good use out of them, too.

November 2006: I finally can scratch this off my to-do list; I've made lilypond representations of a song my Dad wrote for my sister Ellen (PDF) (MIDI) and sang to both of us when we were babies, and another song my Dad used to sing (PDF) (MIDI), which, as I remember, he said one of his war buddies wrote while in Italy or France during WWII. This latter song, it turns out, was written by a James Cavenaugh, with quite different words, and was recorded in 1940, long before the U.S. got involved in the war! So much for my memory, or for my Dad's accuracy, or both!