[python-win32] Re: Accessing Midi Devices from Win 2000

Thomas Heller theller at python.net
Wed Sep 8 20:58:26 CEST 2004


Tim Golden <tim.golden at viacom-outdoor.co.uk> writes:

> [Ian Dickinson]
>
>> I am interested in communicating with a midi 
>> device using python and Windows 2000
> [... snip ...]
>> I have done a bit of investigation and was wondering if I could access 
>> the windows API mciSendString from python.
>
> OK. I know nothing about how to access Midi from Windows, so
> hopefully someone else will be able to help there. But to
> answer your most immediate question: yes, you can, if you
> use ctypes (http://starship.python.net/crew/theller/ctypes/)
> But it'll be a messy business trying to define all the
> data structures etc., and I bet someone's already done
> the hard work somewhere.

There is hope for a ctypes solution for this problem.  I'm playing with
gccxml, which can parse windows header files and output them as XML.
Then, it's easy (although quite some work) to parse the xml, and
generate ctypes compatible Python code.

For example, parsing <windows.h> with -D _WIN32_WINNT=0x500 creates
1056(!)  public structure and union definitions.  The more than 10000
constants defined in #define and enum {} statements must be added - so
there is still some work to be done to avoid multi-megabyte Python
modules to store these.

But hopefully one day we will be able to write 'import winapi' and be
able to access all of them in the same namespace.

Thomas



More information about the Python-win32 mailing list