midi with ctypes
dan
danbmil99 at yahoo.com
Thu Aug 7 21:32:40 EDT 2003
Interesting idea, but frankly it seems like alot of extra overhead.
Now that midipy is compiling, I'm more inclined to add features in C
than using ctypes.
What advantages can we expect from doing it this way?
anton at vredegoor.doge.nl (Anton Vredegoor) wrote in message news:<bgu4k1$2ke$1 at news.hccnet.nl>...
> Recently there has been a lot of progress concerning the integration
> of midi into python. A midipy.cpp for Python20 is found and various
> compiling efforts having been undertaken to compile it for Python23.
> See the other threads about midipy.cpp for more info.
>
> However, seeing that the resulting midipy.pyd is only 48 kilobyte long
> and seeing that midipy.cpp exports only 14 functions, most of which
> are inside winmm.dll (for W98 and W2000 at least) I decided to start
> another effort, which I'm presenting below and for which I hope kind
> people will add some functions since I doesn't seem to be too hard.
>
> first create a winmm.def like this:
>
> pexports winmm.dll > winmm.def
>
> Now open winmm.def and find the relevant functions, compare them with
> what's inside midipy.cpp and try to reproduce them using ctypes. The
> file "mmedia.hlp" from Borland C++ Builder for example, contains
> detailed info about midi functions, most of which seem to be direct
> wrappers around the functions inside winmm.dll .
>
> Now to get started try this:
>
> #ctypesmidipy.py
>
> from ctypes import *
>
> def getNumMidiInDevices():
> return windll.winmm.midiInGetNumDevs()
>
> def getNumMidiOutDevices():
> return windll.winmm.midiOutGetNumDevs()
>
> def test():
> print getNumMidiInDevices()
> print getNumMidiOutDevices()
>
> if __name__=='__main__':
> test()
>
> Please note that after importing this file every function should work
> the same as if midipy.pyd had been imported. Not being very familiar
> with midi programming I succeeded only to get 2 of the 14 functions
> working. Getting more functions to work should be harder, but not very
> hard. Please, anybody reading this, add a function if there's a sudden
> insight into how it should be done. By and by ctypesmidipy.py will be
> put together like a little pypy-alike project replacing midipy.cpp :-)
> Any feasibility studies and remarks about possible legal objections to
> this are very welcome too.
>
> Anton
More information about the Python-list
mailing list