Mido is a library for working with MIDI messages and ports.
