Search code examples
pythonmidi

How to generate MIDI file with single track using MIDIUtil


I am trying to generate MIDI files that are type 0 single track with all messages saved in one track. The Python package I used is MIDIUtil.

Here is the post I was following the post How can I write a MIDI file with Python?.

However, based on the document of MIDIUtil. It supports "format 1 (the default) and format 2 files", but not type 0?

Here is the link the the file format documentation, http://midiutil.readthedocs.io/en/latest/creating.html# file-format.


Solution

  • According to its documentation, that library indeed does not support format 0 files.

    However, it never checks the file_format parameter, so you can simply use file_format = 0, and ensure that all events (including timing events) are put into a single track.
    (If this works, file a bug to update the documentation.)