Re: [pygame] BUG: MIDI Input Close on macOS
Hi, In addition I tried to update to pygame 2.0.1 however it is the same. you'll find here after the complete outcome on the terminal: Python 3.8.2 (default, Nov 4 2020, 21:23:28) [Clang 12.0.0 (clang-1200.0.32.28)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import pygame.midi pygame 2.0.1 (SDL 2.0.14, Python 3.8.2) Hello from the pygame community. https://www.pygame.org/contribute.html >>> pygame.midi.init() >>> pygame.midi.get_count() 2 >>> pygame.midi.get_device_info(0) (b'CoreMIDI', b'P\x8eriph\x8erique MIDI USB', 1, 0, 0) >>> midiin1 = pygame.midi.Input(0) >>> pygame.midi.get_device_info(0) (b'CoreMIDI', b'P\x8eriph\x8erique MIDI USB', 1, 0, 1) >>> midiin1.close() >>> pygame.midi.get_device_info(0) (b'CoreMIDI', b'P\x8eriph\x8erique MIDI USB', 1, 0, 1) >>> midiin1 = pygame.midi.Input(0) Traceback (most recent call last): File "", line 1, in File "/Users/familleaupepin/Library/Python/3.8/lib/python/site-packages/pygame/midi.py", line 287, in __init__ self._input = _pypm.Input(device_id, buffer_size) File "src_c\cython\pygame\pypm.pyx", line 547, in pygame.pypm.Input.__init__ Exception: b"PortMidi: `Invalid device ID'" >>> Sincerely, Frédéric Le samedi 9 janvier 2021 à 19:23:16 UTC+1, Frédéric AUPÉPIN a écrit : > Hi, > > I’m a macOS user under Catalina (10.15.7) and I think there might be an > issue related to the closure of a MIDI Input. > I have currently Python 3.8.2 and Pygame 2.0.0 with SDL 2.0.12. > > The issue is following: if I close a MIDI input it is impossible to reopen > one afterwards unless I exit Python. > Here is what I did: > > import pygame.midi > pygame.midi.init() > pygame.midi.get_count() #to verify that there are MIDI devices > pygame.midi.get_device_info(0) # verify information of the input (at list > id 0 was my input) at verify that the input is available > midiin1 = pygame.midi.Input(0) # everything is fine and can read > midiin1.close() > pygame.midi.get_device_info(0) # then it is stated that the device is > still opened preventing to reopen an Input > midiin1 = pygame.midi.Input(0) # will return error > > > Sincerely, > > Frédéric > >
[pygame] Re: Pygame Read MIDI Input
Thanks a lot! To understand fully what is happening I will have to learn about pygame events. But I have the Midi data available now and can just use it for further processing. Again, thanks for the quick and to the point help. -- Sent from: http://pygame-users.25799.x6.nabble.com/
Re: [pygame] Re: Pygame Read MIDI Input
Good! import pygame.examples.midi print(pygame.examples.midi.__file__)
[pygame] Re: Pygame Read MIDI Input
Thanks for your quick answer! - OS: Windows 10 - 'python -m pygame.examples.midi --list' lists the following: 0: interface :b'MMSystem':, name :b'Microsoft MIDI Mapper':, opened :0: (output) 1: interface :b'MMSystem':, name :b'External':, opened :0: (input) 2: interface :b'MMSystem':, name :b'Eleven Rack':, opened :0: (input) 3: interface :b'MMSystem':, name :b'Maschine Mikro MK2 In':, opened :0: (input) 4: interface :b'MMSystem':, name :b'TASCAM US-122 MKII MIDI':, opened :0: (input) 5: interface :b'MMSystem':, name :b'Microsoft GS Wavetable Synth':, opened :0: (output) 6: interface :b'MMSystem':, name :b'External':, opened :0: (output) 7: interface :b'MMSystem':, name :b'Eleven Rack':, opened :0: (output) 8: interface :b'MMSystem':, name :b'Maschine Mikro MK2 Out':, opened :0: (output) 9: interface :b'MMSystem':, name :b'TASCAM US-122 MKII MIDI':, opened :0: (output) - 'python -m pygame.examples.midi --input 4' It actually works for both USB Midi interfaces now! Can you tell me where these example files are located so I can check what I did wrong? -- Sent from: http://pygame-users.25799.x6.nabble.com/
Re: [pygame] pygame midi module
Hi, thanks for the report. If you feel like it, please file an issue at https://bitbucket.org/pygame/pygame It's in python and cython, so maybe you can even fix this issue yourself :) A few people have used it for projects(including me), and it's based on PortMidi which has also been used by numerous projects. So if you avoid the rough corners it's sort of usable :) cheers, On Mon, Jul 22, 2013 at 8:39 PM, Silver rockac...@gmail.com wrote: I was trying out the pygame.midi module in the python interpreter. It seems nice although it is a WIP (?). Just thought I'd let you know trying to create multiple output objects for the same output can cause a segfault. Specifically, when you re-init the module (pygame.midi.quit(); pygame.midi.init()) it doesnt remember that the output is already occupied. Is there anywhere I should report this?
Re: [pygame] no midi
I think last I heard MIDI output was not working. It seems to not be included in the current build. Anthony On Wed, Jan 4, 2012 at 5:40 PM, John Jameson jwin...@gmail.com wrote: I have a new Macbook Pro running 10.6 Snow Leopard and when I do: import pygame pygame.init() print pygame.midi.get_count() it says: AttributeError: 'module' object has no attribute 'midi' I've tried it with Macports python 2.6 and 2.7 and darwin's native pythons 2.6 and 2.7. Anyone know what happened to the midi? thanks, john
Re: [pygame] detectng midi events in pygame?
Thanks for your reply Lenard, I looked at the examples and created this working program (see program below). When I close the program, this error message appears in the terminal: PortMidi call failed... PortMidi: `Bad pointer' type ENTER... What can I change in the program to avoid the PortMidi-call-failed-Bad-pointer error? Any code snippets, links to articles, or suggestions would be greatly appreciated. #--start miditest.py-- import pygame import pygame.midi from pygame.locals import * pygame.init() pygame.fastevent.init() event_get = pygame.fastevent.get event_post = pygame.fastevent.post pygame.midi.init() input_id = pygame.midi.get_default_input_id() i = pygame.midi.Input( input_id ) pygame.display.set_caption(midi test) screen = pygame.display.set_mode((400, 300), RESIZABLE, 32) print starting going = True while going: events = event_get() for e in events: if e.type in [QUIT]: going = False if e.type in [KEYDOWN]: going = False if i.poll(): midi_events = i.read(10) #print full midi_events + str(midi_events) print my midi note is + str(midi_events[0][0][1]) # convert them into pygame events. midi_evs = pygame.midi.midis2events(midi_events, i.device_id) for m_e in midi_evs: event_post( m_e ) print exit button clicked. i.close() pygame.midi.quit() pygame.quit() exit() #-- end miditest.py-- On Wed, Dec 15, 2010 at 7:13 PM, Lenard Lindstrom le...@telus.net wrote: Hi Brian, The pygame midi.py example has an input event display mode. python -m pygame.examples.midi -i It is in the examples subdirectory in the pygame package directory. Unfortunately, the PortMidi with pygame.midi wraps does not have a midi event callback option, so midi events must be polled. Lenard Lindstrom On 15/12/10 03:19 PM, Brian Gryder wrote: How can I detect midi events in pygame? I am able to detect the count of MIDI devices and input and output device names (see program below) I'd like to display the midi note names like C3 ON or D3 OFF. I am using the JACK Audio Connection Kit. Any code snippets, links to articles, or suggestions would be greatly appreciated. import pygame import pygame.midi from pygame.locals import * pygame.init() pygame.display.set_caption(midi test) screen = pygame.display.set_mode((400, 300), RESIZABLE, 32) pygame.midi.init() print There are + str(pygame.midi.get_count()) + MIDI devices print The default input device number is + str(pygame.midi.get_default_input_id()) print The default input device info is + str(pygame.midi.get_device_info(pygame.midi.get_default_input_id())) print The default output device info is + str(pygame.midi.get_device_info(pygame.midi.get_default_output_id())) print The current time on the PortMidi timer is + str(pygame.midi.time()) + ms event_text = [] while True: for event in pygame.event.get(): if event.type == QUIT: exit() event = pygame.event.wait() print str(event) output: u...@lappy:~/Documents$ python -u miditest.py There are 5 MIDI devices The default input device number is 1 The default input device info is ('ALSA', 'Midi Through Port-0', 1, 0, 0) The default output device info is ('ALSA', 'Midi Through Port-0', 0, 1, 0) The current time on the PortMidi timer is 1 ms
Re: [pygame] detectng midi events in pygame?
Hi, See below: On 17/12/10 05:13 PM, Brian Gryder wrote: #--start miditest.py-- import pygame import pygame.midi from pygame.locals import * [snip some code] print exit button clicked. i.close() Replace i.close() with del i pygame.midi.quit() pygame.quit() exit() #-- end miditest.py-- I don't know why i.close() fails? Lenard Lindstrom
Re: [pygame] detectng midi events in pygame?
Hi Brian, The pygame midi.py example has an input event display mode. python -m pygame.examples.midi -i It is in the examples subdirectory in the pygame package directory. Unfortunately, the PortMidi with pygame.midi wraps does not have a midi event callback option, so midi events must be polled. Lenard Lindstrom On 15/12/10 03:19 PM, Brian Gryder wrote: How can I detect midi events in pygame? I am able to detect the count of MIDI devices and input and output device names (see program below) I'd like to display the midi note names like C3 ON or D3 OFF. I am using the JACK Audio Connection Kit. Any code snippets, links to articles, or suggestions would be greatly appreciated. import pygame import pygame.midi from pygame.locals import * pygame.init() pygame.display.set_caption(midi test) screen = pygame.display.set_mode((400, 300), RESIZABLE, 32) pygame.midi.init() print There are + str(pygame.midi.get_count()) + MIDI devices print The default input device number is + str(pygame.midi.get_default_input_id()) print The default input device info is + str(pygame.midi.get_device_info(pygame.midi.get_default_input_id())) print The default output device info is + str(pygame.midi.get_device_info(pygame.midi.get_default_output_id())) print The current time on the PortMidi timer is + str(pygame.midi.time()) + ms event_text = [] while True: for event in pygame.event.get(): if event.type == QUIT: exit() event = pygame.event.wait() print str(event) output: u...@lappy:~/Documents$ python -u miditest.py There are 5 MIDI devices The default input device number is 1 The default input device info is ('ALSA', 'Midi Through Port-0', 1, 0, 0) The default output device info is ('ALSA', 'Midi Through Port-0', 0, 1, 0) The current time on the PortMidi timer is 1 ms
Re: [pygame] Getting midi events for midi files playing in pygame
Hi, you should be able to do it with pygame.midi with a fair bit of work. However pygame currently does not have any special midi timing code, so you'd have to write that yourself (or maybe someone else has written some). You'd also need to do the midi file parsing yourself. There's probably existing packages to do both though. There's the pygame.midi module, which can get input midi, and also output midi. There is also pygame.music.play which can play midi. On Wed, Oct 27, 2010 at 5:20 PM, Ivan DelSol sunspi...@gmail.com wrote: I'm writing a visualizer for midi in pygame. Currently, I play a midi file in one program and get midi events in pygame via a virtual patch cable. I'd much rather play the midi file in pygame and receive the events, so that the user doesn't have to run a virtual patch program at the same time. Is that possible?
Re: [pygame] [BUG] midi unit test for Pygame rev 2500, Python 2.6.2, Windows XP
The svn builds get what I think is the same error but only on python 2.4: http://thorbrian.com/pygame/builds.php Note they've had the bug for a long time - but the portmidi debug prints were a red herring that obscured it. On Thu, Jul 9, 2009 at 3:21 PM, Lenard Lindstrom le...@telus.net wrote: Hi, The Python 1.9.0 rc 3 unit tests fail with the following midi related bug: == ERROR: MidiTest.test_get_device_info -- Traceback (most recent call last): File C:\python26\lib\site-packages\pygame\tests\midi_test.py, line 400, in t est_get_device_info raise Exception(repr(r)) Exception: None -- Lenard
Re: [pygame] [BUG] midi unit test for Pygame rev 2500, Python 2.6.2, Windows XP
On Mon, Jul 13, 2009 at 1:27 PM, Brian Fisher br...@hamsterrepublic.comwrote: The svn builds get what I think is the same error but only on python 2.4: http://thorbrian.com/pygame/builds.php Note they've had the bug for a long time - but the portmidi debug prints were a red herring that obscured it. ah, cool. the test was buggy I think. It was checking against a previously declared variable. Committed revision 2503. cheers,
Re: [pygame] controlled midi playback
thanks, i will keep trying to compile it considering your tips but it would be nice if i could test your pypm.pyd in the meantime! On 1/2/08, Lenard Lindstrom [EMAIL PROTECTED] wrote: I guess it is getting late. LIBCMT.LIB is one version of the VC 6.0 C library, so apparently isn't present in VC 7.1. I expect uuid.lib is still be available. I am not so sure about OLDNAMES.LIB, but then you did not mention a LNK1104 for it so I assume it is also available. So try replacing line 34 in setup.py with the following two lines: libraries = [portmidi, winmm, porttime], extra_link_args = [NODEFAULTLIB:LIBCMT]) If it the linker complains about an invalid argument try adding a forward slash / before NODEFAULTLIB. Lenard Lenard Lindstrom wrote: Python 2.5 extensions are compiled on Windows with vctoolkit2003 by default. It is the same compiler used on Python 2.5. When I compile with MinGW I get these warnings: Warning: .drectve `-defaultlib:LIBCMT ' unrecognized Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized Warning: .drectve `-defaultlib:uuid.lib ' unrecognized Warning: .drectve `-defaultlib:uuid.lib ' unrecognized Warning: .drectve `-defaultlib:LIBCMT ' unrecognized Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized Warning: .drectve `-defaultlib:LIBCMT ' unrecognized Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized Warning: .drectve `-defaultlib:uuid.lib ' unrecognized Warning: .drectve `-defaultlib:uuid.lib ' unrecognized Warning: .drectve `-defaultlib:LIBCMT ' unrecognized Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized which appear to be related to the libraries portmidi.lib and porttime.lib. Maybe the VC linker can ignore -defaultlib directives in a library. I find there is a /NODEFAULTLIB:library linker option. Maybe add something like the following to setup.py after libraries = [] for win32: extra_link_args=[NODEFAULTLIB:LIBCMT, NODEFAULTLIB:OLDNAMES, NODEFAULTLIB:uuid.lib] Or try running vcvars32.bat (is there one for the 2003 toolkit) before executing setup.py. If you wish you may try the pypm.pyd I compiled MinGW. It links to msvcr71.dll, which is the big issue with Python 2.5, and works with my small test program. Lenard [EMAIL PROTECTED] wrote: that fixed the pyrex problem. i have the .c file now but there is another problem i ran into. i tried to use code::blocks and the vctoolkit2003 to compile the extension. i get this error message: fatal error LNK1104: cannot open file 'LIBCMTD.LIB' maybe you can give me another tip? what compiler did python 2.5 for windows get compiled with? i read somewhere that it can get messy if you don't use the same compiler for extensions.
Re: [pygame] controlled midi playback
thanks! it works great! :) the next step for my project is figuring out the best way to read midi files but this shouldn't be that hard... i found some specifications and example code already. On 1/2/08, Lenard Lindstrom [EMAIL PROTECTED] wrote: Here it is. Lenard [EMAIL PROTECTED] wrote: thanks, i will keep trying to compile it considering your tips but it would be nice if i could test your pypm.pyd in the meantime!
Re: [pygame] controlled midi playback
thanks! and does anyone know if there are examples somewhere? like a simple program which allows you to play a midi instrument (best using the integrated synthesizer on the sound card) with the computer keyboard? On 1/1/08, Lenard Lindstrom [EMAIL PROTECTED] wrote: Try http://alumni.media.mit.edu/~harrison/code.html Lenard [EMAIL PROTECTED] wrote: thanks! http://sound.media.mit.edu/~harrison/pyportmidi/ http://sound.media.mit.edu/%7Eharrison/pyportmidi/ it sounds like it is what i need but unfortunately it doesn't seem to be available anymore... On 1/1/08, *Lenard Lindstrom* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: hi, i have a midi song (not polyphonic) and want to play back one note after another triggered by key presses. what would be the best way to do this? i guess i can't directly do this with pygame but i need some midi library? does anyone know which one would be suited for that (ideally it should work in linux and windows)? has anyone tried to do something similar? Check out the Python music page: http://wiki.python.org/moin/PythonInMusic http://wiki.python.org/moin/PythonInMusic Of the various midi packages PyPortMidi is still available.
Re: [pygame] controlled midi playback
awesome! :) thanks a lot... now i only have to get pyportmidi compiled for python 2.5. i get this pyrex error: pypm.pyx:357:21: Type 'PmError' not acceptable as a boolean do you have an idea what causes this? On 1/1/08, Lenard Lindstrom [EMAIL PROTECTED] wrote: This was something I put together to see if pygame and PyPortMidi would get along. They do. It is very simple. You can use the keyboard or the mouse to play a four note pipe organ. Lenard [EMAIL PROTECTED] wrote: thanks! and does anyone know if there are examples somewhere? like a simple program which allows you to play a midi instrument (best using the integrated synthesizer on the sound card) with the computer keyboard? On 1/1/08, *Lenard Lindstrom* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Try http://alumni.media.mit.edu/~harrison/code.html http://alumni.media.mit.edu/%7Eharrison/code.html Lenard [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: thanks! http://sound.media.mit.edu/~harrison/pyportmidi/ http://sound.media.mit.edu/%7Eharrison/pyportmidi/ http://sound.media.mit.edu/%7Eharrison/pyportmidi/ it sounds like it is what i need but unfortunately it doesn't seem to be available anymore... On 1/1/08, *Lenard Lindstrom* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: hi, i have a midi song (not polyphonic) and want to play back one note after another triggered by key presses. what would be the best way to do this? i guess i can't directly do this with pygame but i need some midi library? does anyone know which one would be suited for that (ideally it should work in linux and windows)? has anyone tried to do something similar? Check out the Python music page: http://wiki.python.org/moin/PythonInMusic http://wiki.python.org/moin/PythonInMusic Of the various midi packages PyPortMidi is still available.
Re: [pygame] controlled midi playback
Yeah. To make Pyrex compatible with C++ enumerations are no longer treated as integers, though assignment of an enumeration to an integer is still allowd. Not accepting an enumeration as a boolean value may be a bug. I would have to check. But then again it makes some sense. Just edit line 357 to be: while(Pm_Poll(self.midi) != pmNoError): [EMAIL PROTECTED] wrote: awesome! :) thanks a lot... now i only have to get pyportmidi compiled for python 2.5. i get this pyrex error: pypm.pyx:357:21: Type 'PmError' not acceptable as a boolean do you have an idea what causes this? On 1/1/08, *Lenard Lindstrom* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: This was something I put together to see if pygame and PyPortMidi would get along. They do. It is very simple. You can use the keyboard or the mouse to play a four note pipe organ. Lenard [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: thanks! and does anyone know if there are examples somewhere? like a simple program which allows you to play a midi instrument (best using the integrated synthesizer on the sound card) with the computer keyboard? On 1/1/08, *Lenard Lindstrom* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Try http://alumni.media.mit.edu/~harrison/code.html http://alumni.media.mit.edu/%7Eharrison/code.html http://alumni.media.mit.edu/%7Eharrison/code.html Lenard [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: thanks! http://sound.media.mit.edu/~harrison/pyportmidi/ http://sound.media.mit.edu/%7Eharrison/pyportmidi/ http://sound.media.mit.edu/%7Eharrison/pyportmidi/ http://sound.media.mit.edu/%7Eharrison/pyportmidi/ it sounds like it is what i need but unfortunately it doesn't seem to be available anymore... On 1/1/08, *Lenard Lindstrom* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: hi, i have a midi song (not polyphonic) and want to play back one note after another triggered by key presses. what would be the best way to do this? i guess i can't directly do this with pygame but i need some midi library? does anyone know which one would be suited for that (ideally it should work in linux and windows)? has anyone tried to do something similar? Check out the Python music page: http://wiki.python.org/moin/PythonInMusic http://wiki.python.org/moin/PythonInMusic http://wiki.python.org/moin/PythonInMusic Of the various midi packages PyPortMidi is still available.
Re: [pygame] controlled midi playback
that fixed the pyrex problem. i have the .c file now but there is another problem i ran into. i tried to use code::blocks and the vctoolkit2003 to compile the extension. i get this error message: fatal error LNK1104: cannot open file 'LIBCMTD.LIB ' maybe you can give me another tip? what compiler did python 2.5 for windows get compiled with? i read somewhere that it can get messy if you don't use the same compiler for extensions. On 1/2/08, Lenard Lindstrom [EMAIL PROTECTED] wrote: Yeah. To make Pyrex compatible with C++ enumerations are no longer treated as integers, though assignment of an enumeration to an integer is still allowd. Not accepting an enumeration as a boolean value may be a bug. I would have to check. But then again it makes some sense. Just edit line 357 to be: while(Pm_Poll(self.midi) != pmNoError): [EMAIL PROTECTED] wrote: awesome! :) thanks a lot... now i only have to get pyportmidi compiled for python 2.5. i get this pyrex error: pypm.pyx:357:21: Type 'PmError' not acceptable as a boolean do you have an idea what causes this? On 1/1/08, *Lenard Lindstrom* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: This was something I put together to see if pygame and PyPortMidi would get along. They do. It is very simple. You can use the keyboard or the mouse to play a four note pipe organ. Lenard [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: thanks! and does anyone know if there are examples somewhere? like a simple program which allows you to play a midi instrument (best using the integrated synthesizer on the sound card) with the computer keyboard? On 1/1/08, *Lenard Lindstrom* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Try http://alumni.media.mit.edu/~harrison/code.html http://alumni.media.mit.edu/%7Eharrison/code.html http://alumni.media.mit.edu/%7Eharrison/code.html Lenard [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: thanks! http://sound.media.mit.edu/~harrison/pyportmidi/ http://sound.media.mit.edu/%7Eharrison/pyportmidi/ http://sound.media.mit.edu/%7Eharrison/pyportmidi/ http://sound.media.mit.edu/%7Eharrison/pyportmidi/ it sounds like it is what i need but unfortunately it doesn't seem to be available anymore... On 1/1/08, *Lenard Lindstrom* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: hi, i have a midi song (not polyphonic) and want to play back one note after another triggered by key presses. what would be the best way to do this? i guess i can't directly do this with pygame but i need some midi library? does anyone know which one would be suited for that (ideally it should work in linux and windows)? has anyone tried to do something similar? Check out the Python music page: http://wiki.python.org/moin/PythonInMusic http://wiki.python.org/moin/PythonInMusic http://wiki.python.org/moin/PythonInMusic Of the various midi packages PyPortMidi is still available.
Re: [pygame] controlled midi playback
Python 2.5 extensions are compiled on Windows with vctoolkit2003 by default. It is the same compiler used on Python 2.5. When I compile with MinGW I get these warnings: Warning: .drectve `-defaultlib:LIBCMT ' unrecognized Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized Warning: .drectve `-defaultlib:uuid.lib ' unrecognized Warning: .drectve `-defaultlib:uuid.lib ' unrecognized Warning: .drectve `-defaultlib:LIBCMT ' unrecognized Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized Warning: .drectve `-defaultlib:LIBCMT ' unrecognized Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized Warning: .drectve `-defaultlib:uuid.lib ' unrecognized Warning: .drectve `-defaultlib:uuid.lib ' unrecognized Warning: .drectve `-defaultlib:LIBCMT ' unrecognized Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized which appear to be related to the libraries portmidi.lib and porttime.lib. Maybe the VC linker can ignore -defaultlib directives in a library. I find there is a /NODEFAULTLIB:library linker option. Maybe add something like the following to setup.py after libraries = [] for win32: extra_link_args=[NODEFAULTLIB:LIBCMT, NODEFAULTLIB:OLDNAMES, NODEFAULTLIB:uuid.lib] Or try running vcvars32.bat (is there one for the 2003 toolkit) before executing setup.py. If you wish you may try the pypm.pyd I compiled MinGW. It links to msvcr71.dll, which is the big issue with Python 2.5, and works with my small test program. Lenard [EMAIL PROTECTED] wrote: that fixed the pyrex problem. i have the .c file now but there is another problem i ran into. i tried to use code::blocks and the vctoolkit2003 to compile the extension. i get this error message: fatal error LNK1104: cannot open file 'LIBCMTD.LIB' maybe you can give me another tip? what compiler did python 2.5 for windows get compiled with? i read somewhere that it can get messy if you don't use the same compiler for extensions. On 1/2/08, *Lenard Lindstrom* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Yeah. To make Pyrex compatible with C++ enumerations are no longer treated as integers, though assignment of an enumeration to an integer is still allowd. Not accepting an enumeration as a boolean value may be a bug. I would have to check. But then again it makes some sense. Just edit line 357 to be: while(Pm_Poll(self.midi) != pmNoError): [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: awesome! :) thanks a lot... now i only have to get pyportmidi compiled for python 2.5. i get this pyrex error: pypm.pyx:357:21: Type 'PmError' not acceptable as a boolean do you have an idea what causes this? On 1/1/08, *Lenard Lindstrom* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: This was something I put together to see if pygame and PyPortMidi would get along. They do. It is very simple. You can use the keyboard or the mouse to play a four note pipe organ. Lenard [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: thanks! and does anyone know if there are examples somewhere? like a simple program which allows you to play a midi instrument (best using the integrated synthesizer on the sound card) with the computer keyboard? On 1/1/08, *Lenard Lindstrom* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Try http://alumni.media.mit.edu/~harrison/code.html http://alumni.media.mit.edu/%7Eharrison/code.html http://alumni.media.mit.edu/%7Eharrison/code.html http://alumni.media.mit.edu/%7Eharrison/code.html Lenard [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: thanks! http://sound.media.mit.edu/~harrison/pyportmidi/ http://sound.media.mit.edu/%7Eharrison/pyportmidi/ http://sound.media.mit.edu/%7Eharrison/pyportmidi/ http://sound.media.mit.edu/%7Eharrison/pyportmidi/ http://sound.media.mit.edu/%7Eharrison/pyportmidi/ it sounds like it is what i need but unfortunately it doesn't seem to be available anymore... On 1/1/08, *Lenard Lindstrom* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL
Re: [pygame] controlled midi playback
I guess it is getting late. LIBCMT.LIB is one version of the VC 6.0 C library, so apparently isn't present in VC 7.1. I expect uuid.lib is still be available. I am not so sure about OLDNAMES.LIB, but then you did not mention a LNK1104 for it so I assume it is also available. So try replacing line 34 in setup.py with the following two lines: libraries = [portmidi, winmm, porttime], extra_link_args = [NODEFAULTLIB:LIBCMT]) If it the linker complains about an invalid argument try adding a forward slash / before NODEFAULTLIB. Lenard Lenard Lindstrom wrote: Python 2.5 extensions are compiled on Windows with vctoolkit2003 by default. It is the same compiler used on Python 2.5. When I compile with MinGW I get these warnings: Warning: .drectve `-defaultlib:LIBCMT ' unrecognized Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized Warning: .drectve `-defaultlib:uuid.lib ' unrecognized Warning: .drectve `-defaultlib:uuid.lib ' unrecognized Warning: .drectve `-defaultlib:LIBCMT ' unrecognized Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized Warning: .drectve `-defaultlib:LIBCMT ' unrecognized Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized Warning: .drectve `-defaultlib:uuid.lib ' unrecognized Warning: .drectve `-defaultlib:uuid.lib ' unrecognized Warning: .drectve `-defaultlib:LIBCMT ' unrecognized Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized which appear to be related to the libraries portmidi.lib and porttime.lib. Maybe the VC linker can ignore -defaultlib directives in a library. I find there is a /NODEFAULTLIB:library linker option. Maybe add something like the following to setup.py after libraries = [] for win32: extra_link_args=[NODEFAULTLIB:LIBCMT, NODEFAULTLIB:OLDNAMES, NODEFAULTLIB:uuid.lib] Or try running vcvars32.bat (is there one for the 2003 toolkit) before executing setup.py. If you wish you may try the pypm.pyd I compiled MinGW. It links to msvcr71.dll, which is the big issue with Python 2.5, and works with my small test program. Lenard [EMAIL PROTECTED] wrote: that fixed the pyrex problem. i have the .c file now but there is another problem i ran into. i tried to use code::blocks and the vctoolkit2003 to compile the extension. i get this error message: fatal error LNK1104: cannot open file 'LIBCMTD.LIB' maybe you can give me another tip? what compiler did python 2.5 for windows get compiled with? i read somewhere that it can get messy if you don't use the same compiler for extensions.
Re: [pygame] controlled midi playback
[EMAIL PROTECTED] wrote: hi, i have a midi song (not polyphonic) and want to play back one note after another triggered by key presses. what would be the best way to do this? i guess i can't directly do this with pygame but i need some midi library? does anyone know which one would be suited for that (ideally it should work in linux and windows)? has anyone tried to do something similar? Check out the Python music page: http://wiki.python.org/moin/PythonInMusic Of the various midi packages PyPortMidi is still available. -- Lenard Lindstrom [EMAIL PROTECTED]