Moved some functions in midifiles.py.