| MIDIUtil |
|
IntroductionMIDIUtil is a pure Python library that allows one to write muti-track Musical Instrument Digital Interface (MIDI) files from within Python programs. It is object-oriented and allows one to create and write these files with a minimum of fuss. [Note to Python 3 users: An initial port to Python 3 had been made and committed to the development branch of the code (which is available via svn). The source file is called MidiFile3.py. To use it, change your import statement to read: from midiutil.MidiFile3 import MIDIFile
InstallationTo use the library one can either install it on one's system or copy the midiutil directory of the source distribution to your project's directory (or to any directory pointed to by the PYTHONPATH environment variable). For the Windows platforms an executable installer is provided. Alternately the source distribution can be downloaded, un-zipped (or un-tarred), and installed in the standard way: python setup.py install
Quick StartUsing the software is easy:
Detailed documentation is provided; what follows is a simple example to get you going quickly. In this example we'll create a one track MIDI File, assign a name and tempo to the track, add a one beat middle-C to the track, and write it to disk. #Import the library from midiutil.MidiFile import MIDIFile
# Create the MIDIFile Object with 1 track MyMIDI = MIDIFile(1)
# Tracks are numbered from zero. Times are measured in beats. track = 0 time = 0
# Add track name and tempo. MyMIDI.addTrackName(track,time,"Sample Track") MyMIDI.addTempo(track,time,120)
# Add a note. addNote expects the following information: track = 0 channel = 0 pitch = 60 time = 0 duration = 1 volume = 100
# Now add the note. MyMIDI.addNote(track,channel,pitch,time,duration,volume)
# And write it to disk. binfile = open("output.mid", 'wb')
MyMIDI.writeFile(binfile) binfile.close()
There are several additional event types that can be added and there are various options available for creating the MIDIFile object, but the above is sufficient to begin using the library and creating note sequences. DocumentationDownload
svn checkout http://midiutil.googlecode.com/svn/trunk/ midiutil-read-only Unless there is a feature in the development branch that you need, you are encouraged to use the most recent released version. While every effort is made to make sure the development branch is working and stable, errors can be introduced in development that could adversely affect the quality and stability of the code. Also note that unless I receive requests for extensions and features, the library is probably more or less "done" (insofar as software can ever be complete), so there will be little work done in the development branch. |
MIDIUtil


