MIDI in Python 3.
Hallo, is there any posibily to reand and write MIDI files in Pythonista 3.
In Pythonista 2 there was the midiutil.MIDIFILE to crate MIDI Files. In 3 is no midiutil module.
class sound.MIDIPlayer(file_path[, sound_bank_path])
A MIDIPlayer provides simple playback functions for MIDI (.mid) files, using either the built-in “Merlin Silver” sound bank or one that you provide. If you provide a custom sound bank, it must be in sf2 format.
midiutilis included with the python 2 interpreter in Pythonista3. I am guessing @omz either forgot to include it in the 3 site packages, or else it is not py3 compatible.
You could either use #!python2, or try copying the file from the python2 pylib site-packages to your own site-packages, and see if it works in py3.
#!python2 import os, midiutil,shutil shutil.copytree(os.path.split(midiutil.__file__),os.path.expanduser('~/Documents/site-packages-3/midiutil'))
midiutilmodule isn't compatible with Python 3, but as @JonB pointed out, you can still use Python 2 in Pythonista 3 (which is what the included "Random MIDI Melody" example does).
@omz Are you sure about that? In the Python 2
midiutilfolder there is a
MidiFile3.pythat looks like it's meant to be compatible with Python 3...
Many thanks for the answers. I would need a module to Read and Write/ Manipulate. Midiutil is only for writing/creating MIDI files.
https://github.com/vishnubob/python-midi/ has the necessary functionality but it has a hardware binding and I'm not so deep in Python to easily port it to Pythonista.
The current midiutil supports both Python 2 and Python 3.
@ccc Good to know, thanks!
OK mido helps.