Contents
pyPortMidi
build on Linux
ubuntu
test on 64 bit ubuntu Gutsy (7.10 x64) machine. Probably also works on 32 bit and ubuntu/debian friends.
- go to the root directory of the pyPortMidi download
change line 357 of pypm.pyx to read:
while(Pm_Poll(self.midi) != pmNoError):
apt-get install python-pyrex python-dev libportmidi-dev timidity freepats libasound2-dev sudo python setup.py install
build on OS X
notes
- successful test on Leopard OSX 10.5 Jan 12, 2008
between unsuccessful builds of pyPortMidi, delete the build directory or the rebuild will not be complete
instructions
- download and build portmidi
test with virtual midi keyboard
- download Pyrex
for Pyrex 0.9.6.4 at least you need to edit Pyrex/Mac/DarwinSystem.py. Line 21 should read:
os.environ["MACOSX_DEPLOYMENT_TARGET"] = "10.5"
- build Pyrex
- download pyPortMidi 0.0.3
replace portmidi.h, porttime.h, and OSX/libportmidi.a with the same named files in the portmidi download/build
copy libporttime.a from the portmidi build into pyPortMidi's OSX directory
change line 357 of pypm.pyx to read:
while(Pm_Poll(self.midi) != pmNoError):
change line 52 of pyPortMidi's setup.py file to read:
libraries = ["portmidi", "porttime"],
build: sudo python setup.py install
test: python test.py
build on WinXP
notes
- There are 2 ways to go:
- build with MSVC - Microsoft's free tools. You need to use compiler v.7.1
- build with MinGW - GNU's open-source compiler which magically emulates msvc v7.1 at the right moments (no I don't get it). Apparently the optimizations aren't quite as good as with MSVC.
I did testing with midiyoke and virtual midi keyboard
instructions: PyPortMidi built using MinGW
- successful test on WinXP/Python 2.6
set up MinGW
- install MinGW. I used the automated installer and told it to install make and C++.
add \MinGW\bin to your path
build portmidi (MinGW)
download latest portmidi. I used release 200 dated 2010-01-11 from here
download this Makefile and put it in the main portmidi directory
edit the Makefile to add -DNEWBUFFER in line 5. Comment out line 23 so it now reads # pmdlllib = pm_win/libpmdll.a
from a terminal window, change to the main portmidi directory and build: mingw32-make
test: pm_test/test
build pyPortMidi (minGW)
- build Pyrex
download PyPortMidi 0.0.3
replace portmidi.h, porttime.h with the same named files in the portmidi download/build
delete everything in the win32 directory
copy the following files into the win32 directory: libpmdll.a, libportmidi.a, libporttime.a
change line 357 of pypm.pyx to read:
while(Pm_Poll(self.midi) != pmNoError):
change line 34 of pyPortMidi's setup.py file to read:
libraries = ["portmidi", "porttime", "pmdll", "winmm"])
build and install: python setup.py build -cmingw32 install --skip-build
test: python test.py
distribute binary: python setup.py build -cmingw32 bdist --skip-build --format=wininst
resulting files (MinGW)
self-installing executable: pyPortMidi 0.0.3a for Python 2.5.x/Win32
instructions: pyPortMidi built using MSVC
I couldn't get this to work. This is currently abandoned
build portmidi (MSVC)
successful
- download and install Visual C++ Express from Microsoft (free download. Takes up 1.1G of disk space).
download latest portmidi. I used svn from cygwin:
svn co https://portmedia.svn.sourceforge.net/svnroot/portmedia/portmidi/trunk portmidi
open portmidi.sln with Visual C++ Express. If Visual C++ Express wants to convert the files for the latest version, let it.
choose project -> pm_dll properties -> configuration manager and switch to the release version
choose build -> batch build and build all the portmidi files
find pm_dll.dll and copy it to c:\windows\system32
test using test.exe
build pyPortMidi (MSVC)
unsuccessful
- download and build Pyrex
- download pyPortMidi 0.0.3
replace portmidi.h, porttime.h, win32/portmidi.lib and win/porttime.lib with the same named files in the portmidi download/build
change line 357 of pypm.pyx to read:
while(Pm_Poll(self.midi) != pmNoError):
change line 52 of pyPortMidi's setup.py file to read:
libraries = ["portmidi", "porttime"],
build: sudo python setup.py install. Failing:
extensions must be built with a compiler than can generate compatible binaries. Visual Studio 2003 was not found on this system. If you have Cygwin installed, you can try compiling with MingW32, by passing "-c mingw32" to setup.py.
References
http://mail.python.org/pipermail/python-win32/2004-November/002586.html
http://mail.python.org/pipermail/python-list/2007-November/465958.html
Troubleshooting/Misc notes and stuff
pm_dll.dll: copy this to your \windows\system32 directory
midiBuffer.py: handles scheduling if you want to send midi events out of order
