I made a tcl package to read, write and edit MIDI files. I'm reworking this package. If you are interested, drop me a mail. Also try Muzic to make music with Tcl.
Needed to assist in local elections, I made this little script to allocate the seats according to the Imperiali method