olemb / rawmidifile

Read and write MIDI files and get at the raw and get the raw MIDI bytes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rawmidifile

rawmdifile allows you to read and write MIDI files and get at the raw MIDI bytes.

Note: The API is experimental and may change.

>>> import pprint
>>> from rawmidifile import read_rawmidifile
>>> pprint.pprint(read_rawmidifile('example.mid'))
{'format': 1,
 'resolution': 480,
 'tracks': [[(0, b'\xff\x03Melody'),
             (0, b'\xc0\x0c'),
             (16, b'\x90@d'),
             (16, b'\x80@d'),
             (16, b'\x90Gd'),
             (16, b'\x80Gd'),
             (16, b'\x90@d'),
             (16, b'\x80@d'),
             (16, b'\x90@d'),
             (16, b'\x80@d'),
             (0, b'\xff/')]]}
  • read_rawmidifile() takes a filename or a file object and returns a dictionary with format (1 or 2), resolution (ticks per beat) and tracks (a list of tracks where each track is a list of (delta, msg) tuples.)
  • write_rawmidifile() takes a filename or file object and optional format, resolution and tracks.
  • is_meta() checks if a messages is a meta message. (The first byte is 0xff and there is more than one byte.)

Included example:

Acknowledgements

The code is based on the MIDI file module in Mido.

Author

Ole Martin Bjørndalen

About

Read and write MIDI files and get at the raw and get the raw MIDI bytes

License:MIT License


Languages

Language:Python 100.0%