Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
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.Also,
midiutil
is 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__)[0],os.path.expanduser('~/Documents/site-packages-3/midiutil'))
-
The
midiutil
module 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
site-packages
midiutil
folder there is aMidiFile3.py
that 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.
Any suggestion? -
The current midiutil supports both Python 2 and Python 3.
-
@ccc Good to know, thanks!
-
OK mido helps.