win32midi for Python 2.5

54 views
Skip to first unread message

admin

unread,
Oct 15, 2006, 1:01:03 PM10/15/06
to Python for MIDI on Windows
I have updated the win32midi module and the player module for Python
2.5. Please find more information at my blog at
http://wahloft.qoolife.com/blog/2006/10/midi-module-for-python.html

notejam

unread,
Oct 30, 2006, 7:44:09 PM10/30/06
to Python for MIDI on Windows
Hi,
I am interested in this midi module. On your blog you just mention it,
but there is no link to obtain it or learn more. Is this still
available?
I have Python 2.5

admin

unread,
Oct 30, 2006, 8:17:47 PM10/30/06
to Python for MIDI on Windows
Hi,
Thanks for your interest in the midi module. The link is there,
embedded under the word 'here'. Anyway, the full URL is
http://wahloft.qoolife.com/software/win32midi-0.1.5-py25.zip
Hope you like it.

notejam

unread,
Oct 31, 2006, 9:12:36 PM10/31/06
to Python for MIDI on Windows
Do you have any docs for it? I looked in the file, and there are 4
possible modules, and then some midi files, and a patch file, but
nothing to tell how to use it.

admin

unread,
Nov 1, 2006, 2:46:50 AM11/1/06
to Python for MIDI on Windows
As mentioned on my blog, information can be found at
http://wahloft.qoolife.com/oldsite/Software/win32midi.html

notejam

unread,
Nov 1, 2006, 11:36:09 PM11/1/06
to Python for MIDI on Windows
Thanks for the links.
Regarding your blog, It is only displaying the first lil part of a
blog, here is a text capture of the blog below.

Think your blog does not work with IE yahoo version? Or maybe even most
versions of browsers?
Also links are difficult to locate, all text is grey even links, and
they only get underlined when mouse over them.

Your blog below:

wahloft
This is the blog of wahloft and contains information about software
that I develop, my interests in financial investments, digital
photography, music and other things.
Sunday, October 15, 2006
MIDI module for Python
I have written a win32mdi module for Python quite some time back. Since
then, there had been a lack of activity in continuing the development.
Since Python has already gone to version 2.5, I think it is time to
provide some upgrade. Hence, here is the zip file that contains those
things that you need to play music via the MIDI synthesizer on your
computer. For information on how to use this module, please refer to
the old information located here, until I can find time to update
anything that is missing.

If you like the package, please comment on this post. Thanks.
posted by WAHLOFT at 9:26 AM

0 Comments:
Post a Comment

<< Home
About Me
Name:WAHLOFT
View my complete profile

Previous Posts
testing


--------------------------------------------------------------------------------

notejam

unread,
Nov 1, 2006, 11:41:10 PM11/1/06
to Python for MIDI on Windows
Your blog does not seem to work as it does not show what you say other
than the here link.
Here is all text appearing on your blog below. Here link only shows up
on mouse over then it underlines, but who mouseovers each and every
word in a text? So maybe you can post things here where we can all
read it? Or someway get that blog to work for us?

Here is all text visable on your blog below:

notejam

unread,
Nov 2, 2006, 1:47:49 AM11/2/06
to Python for MIDI on Windows
I got it to work ok with python 2.5, the version with idle.
Nice. program, thanks for making it.

Now what this module zip file needs is a text file that tells what the
difference is between win32mid.pyc and win32mid2.pyc
And some example programs to show how to use either of these modules.
I am most interested right now in the midi command midioutshortmessage
so I can play the sounds through my sampler rather than the not so good
sounding sounds this music is playing.

Could you post some python code on how to send note on message on
channel 1 note number =60 A c note and play it two or three times.

What I need to start writting my own midi program is how to send the
note on message with one of these modules, and then how to do the time
delay while the note plays, and then turn off the note.

I think I could get everything I need from just looking at a demo like
I describe since I have done this before with other languages writting
midi programs, but just do not know how to make use of win32mid or
win32mid2 and pretty new at programming python code.

admin

unread,
Nov 2, 2006, 9:48:10 AM11/2/06
to Python for MIDI on Windows
Actually I have such a file in the zip file that is built for Python
2.4.
As not all the command in that file works with the current version, I
did not include it in this zip file. The following is extracted from
that file:
------X8----cut here----------------------
from win32midi2 import *
import time
print 'Num of Input/Output
Devices',midiInGetNumDevs(),'/',midiOutGetNumDevs()
r,h=midiOutOpen(0,0,0,0)
midiOutReset(h)
print 'Output Volume', hex(midiOutGetVolume(h)[1])
midiOutSetVolume(h,0xffffffffL)
print 'Output Volume', hex(midiOutGetVolume(h)[1])
midiOutShortMsg(h,0x90|(60<<8)|120<<16)
midiOutShortMsg(h,0x90|(61<<8)|120<<16)
time.sleep(1)
midiOutSetVolume(h,0x77007700L)
print 'Output Volume', hex(midiOutGetVolume(h)[1])
midiOutShortMsg(h,0x90|(62<<8)|120<<16)
midiOutShortMsg(h,0x90|(63<<8)|120<<16)
time.sleep(2)
cap = MIDIOUTCAPSA()
midiOutGetDevCapsA(0,cap)

print 'Output Device capabilities'
print cap.wMid, cap.wPid, cap.vDriverVersion, cap.szPname
print cap.wTechnology, cap.wVoices, cap.wNotes, cap.wChannelMask,

cap.dwSupport

print 'Input Device capabilities'
icap = MIDIINCAPSA()
midiInGetDevCapsA(0,icap)
print icap.wMid, icap.wPid, icap.vDriverVersion, icap.szPname,

icap.dwSupport
hdr = MIDIHDR()
b = chr(0x90)+chr(0x3C)+chr(0x40)
hdr.lpData = b
hdr.dwBufferLength = 3
hdr.dwRecordedLength = 0
hdr.dwFlags = 0
midiOutPrepareHeader(h,hdr)
print 'Sending long message'
midiOutLongMsg(h,hdr)
midiOutUnprepareHeader(h,hdr)
time.sleep(2)
print midiOutClose(h),'Closed'
#for i in range(10):
# print midiOutGetErrorTextA(i), midiInGetErrorTextA(i)
stout = midiStreamOpen(0,0,0)
print midiOutGetErrorTextA(stout[0])

------X8----cut here----------------------

win32midi2 is created for Python 2.5 using the built-in ctypes.
win32midi was
built using swig, for 2.4 and older version.
I'll take your advice to modify my blog to make it easier to nagivate
when I can
spare some time.

notejam

unread,
Nov 3, 2006, 1:02:01 PM11/3/06
to Python for MIDI on Windows
That code starts off with an import time module, which is not present.
So do I need to get a time module? Or do I just delete that line, and
have it import win32.pyc instead?.

admin

unread,
Nov 4, 2006, 9:59:37 AM11/4/06
to Python for MIDI on Windows
The time module is a standard library in Python distribution. Hence you
should have no
problem importing it. It is used in the script to provide the sleep
function for introducing
delay. However, similar to the sleep in Unix/Linux, the accuracy of the
time is quite bad.
It may not be the ideal function for timing MIDI events.
Reply all
Reply to author
Forward
0 new messages