Tuesday, March 31, 2009

Midi (part 4)

Today I released a new project, bmidi to wave.

It can be used to:

  • Turn midi files into great-sounding wav and mp3 files.
  • Play midi files, especially if you are unsatisfied with your current midi out quality.
  • Get information about SoundFont files and preview their voices.

You can find high quality SoundFonts online, and play each instrument in the midi with the SoundFont of your choice, resulting in the best possible sound. Use the mixer to fine-tune the volume and pan of each channel. Also, you can see a score view of notes in a particular track.

It is essentially a frontend for Timidity, the program that does the actual playback. Instead of having to edit the configuration files by hand, though, there is a gui.

This is a program I've been meaning to write for a long time. I first had the idea and initial designs in 2002, when midi files were more common. It didn't take very long to write.

Process management in Python is not too bad thanks to the subprocess module, which has a good interface. I also learned about Python threads through this project, primarily because one wants a responsive GUI while the song is playing and the time slider is moving.

Surprisingly, one of the more complicated parts of the program was allowing playback to start other places in the song. Timidity doesn't do this, and so I have to create a temporary truncated midi file for it to play. I would just chop off all events before a certain time, but because events like instrument change can occur at any time, all of the instruments would be wrong, let alone tempo and pitch bend. Tempo changes can occur at any time, and so it is not simple to correlate a midi tick with clock time.

Midi is a compact, but pretty well-designed format. Not many binary formats from 1982 are around today.

1 comment:

toorg said...

Thanks for that, Ben. A friend of mine was looking for exactly that!