Re: [pygame] Python3 version packaged?

2014-03-21 Thread Christopher Arndt
On 21.03.2014 02:06, Jason Marshall wrote:
 PS. I think the most recent version of pyportmidi, 0.0.7, is here:

That's exactly the problem. It's not clear, what the most recent version
or even the definite distribution of pyportmidi is.

There are, to my knowledge at least three versions, maybe more (but I
forget where) all different.

- The version in PyGame
- The version you mentioned
- The version in the portmidi repository

It's alspo not clear, if R. Dannenberg is really maintaining portmidi
anymore. Commits within th elast years have been very few (to say the
least) and the last change to pyportmidi is from late 2010. The repo on
bitbucket by aalex is even older.


Chris



Re: [pygame] Python3 version packaged?

2014-03-21 Thread Jake b
I tried to find what version SDL2 uses, but I didn't see any mention off
portmidi.


Re: [pygame] Python3 version packaged?

2014-03-21 Thread Christopher Arndt

Am 21.03.2014 12:45, schrieb Jake b:

I tried to find what version SDL2 uses, but I didn't see any mention off
portmidi.


SDL has, to my knowledge, never included any MIDI interfacing. MIDI 
support was a PyGame addition.


PyGame should, IMHO, ditch the included pyportmidi module altogether and 
instead rely on a third-party package to provide MIDI support.


Pyportmidi is, as I mentioned, poorly maintained, portmidi itself is 
very limited in some aspects (e.g. no MIDI input callback-API) and 
library packages on major Linux distros have been poorly maintained as 
well. Including its own binding for an external library but then having 
to rely on the presence of said shared library on the system has no 
advantage over depending on a third-party Python package anyway, from a 
distribution viewpoint.


One could easily write a module for providing a pygame.midi 
backwards-compatible API to a third-party MIDI module. In fact, I'm 
doing that for my python-rtmidi [1] module right now.



Chris

[1] http://python.org/pypi/python-rtmidi


[pygame] Error compiling Pygame Mercurial ISO C90 forbids mixed declarations and code

2014-03-21 Thread Fabio Venturi
Hello,
I'm trying to compile pygame from hg repository
with python3.4 (also this recompiled on  Centos 6.5)

and I got the error:
ISO C90 forbids mixed declarations and code

following the environment and the steps i followed:

[fabio@linbox ~]$ gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)

[fabio@linbox ~]$ /usr/local/bin/virtualenv --version
1.11.4

[fabio@linbox ~]$ which python3
/usr/local/bin/python3

[fabio@linbox ~]$ python3 -V
Python 3.4.0


[fabio@linbox ~]$ virtualenv -p /usr/local/bin/python3.4  testenv
Already using interpreter /usr/local/bin/python3.4
Using base prefix '/usr/local'
New python executable in testenv/bin/python3.4
Also creating executable in testenv/bin/python
Installing setuptools, pip...done.

[fabio@linbox ~]$ . testenv/bin/activate
(testenv)[fabio@linbox ~]$

(testenv)[fabio@linbox testenv]$ which pip3
~/testenv/bin/pip3


(testenv)[fabio@linbox testenv]$ pip3 install
hg+https://bitbucket.org/pygame/pygame
Downloading/unpacking hg+https://bitbucket.org/pygame/pygame
  Cloning hg https://bitbucket.org/pygame/pygame to /tmp/pip-opihfjlz-build
WARNING, No Setup File Exists, Running config.py
Using UNIX configuration...


Hunting dependencies...
SDL : found 1.2.14
FONT: found
IMAGE   : found
MIXER   : found
SMPEG   : found 0.4.5
PNG : found
JPEG: found
SCRAP   : found
PORTMIDI: found
PORTTIME: found
AVFORMAT: found
SWSCALE : found
FREETYPE: found 2.3.11

[...]
building 'pygame.scrap' extension

gcc -pthread -Werror=declaration-after-statement -DNDEBUG -g -fwrapv
-O3 -Wall -Wstrict-prototypes -fPIC -D_REENTRANT -DENABLE_NEWBUF=1
-I/usr/X11R6/include -I/usr/include/SDL
-I/usr/local/include/python3.4m -c src/scrap.c -o
build/temp.linux-x86_64-3.4/src/scrap.o

In file included from src/scrap.c:60:

src/scrap_x11.c: In function '_clipboard_filter':

src/scrap_x11.c:164: error: ISO C90 forbids mixed declarations and code

src/scrap_x11.c: In function '_get_data_as':

src/scrap_x11.c:429: error: ISO C90 forbids mixed declarations and code

src/scrap_x11.c: In function 'pygame_scrap_get_types':

src/scrap_x11.c:842: warning: passing argument 2 of 'PyDict_Next' from
incompatible pointer type

/usr/local/include/python3.4m/dictobject.h:63: note: expected
'Py_ssize_t *' but argument is of type 'int *'

error: command 'gcc' failed with exit status 1


So I modified scrap_x11.c and other files till i got pygame compiled
and working,
I'm posting the diff between pygame-fab (modified) and pygame-hg (original):

(testenv)[fabio@linbox testenv]$ diff -r pygame-fab pygame-hg
Binary files pygame-fab/.hg/dirstate and pygame-hg/.hg/dirstate differ
Only in pygame-fab/lib: version.py
Only in pygame-fab: __pycache__
Only in pygame-fab: Setup
Only in pygame-fab: Setup.bak
diff -r pygame-fab/src/scale_mmx64.c pygame-hg/src/scale_mmx64.c
205,206d204
 long long srcdiff64 = srcdiff;
 long long dstdiff64 = dstdiff;
211a210,211
 long long srcdiff64 = srcdiff;
 long long dstdiff64 = dstdiff;
312,313d311
 long long srcdiff64 = srcdiff;
 long long dstdiff64 = dstdiff;
318a317,318
 long long srcdiff64 = srcdiff;
 long long dstdiff64 = dstdiff;
diff -r pygame-fab/src/scrap_x11.c pygame-hg/src/scrap_x11.c
159d158
 XEvent xevent = event-syswm.msg-event.xevent;
164a164
 XEvent xevent = event-syswm.msg-event.xevent;
427a428
 *length = 0;
434d434
 *length = 0;


As you can see i just moved variables definition before functions calls,
and now pygame compile and (for the things i've tried) works:

(testenv)[fabio@linbox testenv]$ python3 -c 'import pygame;
print(pygame.version.ver)'
1.9.2a0

I  thought this could help someone else,
my kindest regards,

 - Fabio


Re: [pygame] Python3 version packaged?

2014-03-21 Thread diliup gabadamudalige
10 days ago i wrote to John Harrision the author of pyportMIDI and he said
that he has discontinued the development and to use the MIDI in pygame.
below is his relevant text
I haven't worked on pyPortMidi in years, unfortunately, so I've lost track
of it. I think the developers of pyGame forked it and ran with it. I'd look
for their version.


On Fri, Mar 21, 2014 at 5:48 PM, Christopher Arndt ch...@chrisarndt.dewrote:

 Am 21.03.2014 12:45, schrieb Jake b:

  I tried to find what version SDL2 uses, but I didn't see any mention off
 portmidi.


 SDL has, to my knowledge, never included any MIDI interfacing. MIDI
 support was a PyGame addition.

 PyGame should, IMHO, ditch the included pyportmidi module altogether and
 instead rely on a third-party package to provide MIDI support.

 Pyportmidi is, as I mentioned, poorly maintained, portmidi itself is very
 limited in some aspects (e.g. no MIDI input callback-API) and library
 packages on major Linux distros have been poorly maintained as well.
 Including its own binding for an external library but then having to rely
 on the presence of said shared library on the system has no advantage over
 depending on a third-party Python package anyway, from a distribution
 viewpoint.

 One could easily write a module for providing a pygame.midi
 backwards-compatible API to a third-party MIDI module. In fact, I'm doing
 that for my python-rtmidi [1] module right now.


 Chris

 [1] http://python.org/pypi/python-rtmidi




-- 
Diliup Gabadamudalige


http://www.diliupg.com
http://soft.diliupg.com/

**
This e-mail is confidential. It may also be legally privileged. If you are
not the intended recipient or have received it in error, please delete it
and all copies from your system and notify the sender immediately by return
e-mail. Any unauthorized reading, reproducing, printing or further
dissemination of this e-mail or its contents is strictly prohibited and may
be unlawful. Internet communications cannot be guaranteed to be timely,
secure, error or virus-free. The sender does not accept liability for any
errors or omissions.
**


Re: [pygame] Python3 version packaged?

2014-03-21 Thread Christopher Arndt

Am 21.03.2014 14:32, schrieb diliup gabadamudalige:

10 days ago i wrote to John Harrision the author of pyportMIDI and he
said that he has discontinued the development and to use the MIDI in pygame.
below is his relevant text
I haven't worked on pyPortMidi in years, unfortunately, so I've lost
track of it. I think the developers of pyGame forked it and ran with it.
I'd look for their version.


Thanks for this information. It confirms what I already suspected: 
pyportmidi is an aboonded, unmaintained project.


I was the one that last worked on the pyportmidi version in PyGame 
(pypm.pyx), but I have since written my own Python MIDI module, the 
RtMidi binding I mentioned in my last post, so I'm not planning on 
maintaining the pypm module in PyGame either, because I think it is 
fundamentally flawed.


Chris



Re: [pygame] Python3 version packaged?

2014-03-21 Thread Michiel Overtoom

On Mar 21, 2014, at 13:18, Christopher Arndt wrote:

 One could easily write a module for providing a pygame.midi 
 backwards-compatible API to a third-party MIDI module. In fact, I'm doing 
 that for my python-rtmidi [1] module right now.

Thanks for the tip. I was looking around for a cross-platform python midi 
module which can do output and timestamped input. RtMidi and its python binding 
looks promising. I'm creating a FretsOnFire/BandHero-like training program, for 
drums only.

Greetings,


-- 
Veel spullen zijn tegenwoordig waardeloos, maar toch hecht men er veel waarde 
aan. Mensen hebben vaak teveel spullen. Hoe komt dat en wat doe je ertegen? - 
een essay van Paul Graham, op 
http://www.michielovertoom.com/articles/paul-graham-spullen

Een prima telefoon met draaischijf weggooien? Die zou ik nog wel eens nodig 
kunnen hebben!




Re: [pygame] Python3 version packaged?

2014-03-21 Thread Christopher Arndt
On 21.03.2014 16:58, Michiel Overtoom wrote:
 Thanks for the tip. I was looking around for a cross-platform python midi 
 module which can do output and timestamped input. RtMidi and its python 
 binding looks promising. I'm creating a FretsOnFire/BandHero-like training 
 program, for drums only.

If you try out python-rtmidi, let me know how it goes and whether you
encountered any problems. It is still marked as beta because I haven't
got much feedback from others using it yet, but the API should be
stable, I'm only adding extra functionality in extra Python modules.

There is one oddity about RtMidi and timestamps: incoming events come
with a delta time relative to the time the first event was received
after you opened the input port (the first event has a delta time of
zero). If you use the polling API (MidiIn.get_message()) there's no way
to tell exactly when that first event occured, because it could have
been at any time between when the port was opened and get_message() was
called for the first time. So these delta times are only relative and
you can't really reference them to anything except the other events.

The solution is to use the callback API, because then you'll get the
first event as soon as it appears and you can save this point in time as
a reference.


Chris


Re: [pygame] Python3 version packaged?

2014-03-21 Thread diliup gabadamudalige
Can any of you gentlemen help me out on a small query?
I am writing a music software and I need to calculate MIDI note on and note
off from key press duration either from the computer keyboard or a MIDI
input? Can I use the pygame.midi.time() counter to do that? (difference
between key on and key off time).
or should I simply use another module? What is your recommendation?

Thank You in advance


On Fri, Mar 21, 2014 at 9:28 PM, Michiel Overtoom mot...@xs4all.nl wrote:


 On Mar 21, 2014, at 13:18, Christopher Arndt wrote:

  One could easily write a module for providing a pygame.midi
 backwards-compatible API to a third-party MIDI module. In fact, I'm doing
 that for my python-rtmidi [1] module right now.

 Thanks for the tip. I was looking around for a cross-platform python midi
 module which can do output and timestamped input. RtMidi and its python
 binding looks promising. I'm creating a FretsOnFire/BandHero-like training
 program, for drums only.

 Greetings,


 --
 Veel spullen zijn tegenwoordig waardeloos, maar toch hecht men er veel
 waarde aan. Mensen hebben vaak teveel spullen. Hoe komt dat en wat doe je
 ertegen? - een essay van Paul Graham, op
 http://www.michielovertoom.com/articles/paul-graham-spullen

 Een prima telefoon met draaischijf weggooien? Die zou ik nog wel eens
 nodig kunnen hebben!





-- 
Diliup Gabadamudalige


http://www.diliupg.com
http://soft.diliupg.com/

**
This e-mail is confidential. It may also be legally privileged. If you are
not the intended recipient or have received it in error, please delete it
and all copies from your system and notify the sender immediately by return
e-mail. Any unauthorized reading, reproducing, printing or further
dissemination of this e-mail or its contents is strictly prohibited and may
be unlawful. Internet communications cannot be guaranteed to be timely,
secure, error or virus-free. The sender does not accept liability for any
errors or omissions.
**


pygame.MIDI input (Was: [pygame] Python3 version packaged?)

2014-03-21 Thread Christopher Arndt
On 21.03.2014 17:44, diliup gabadamudalige wrote:
 I am writing a music software and I need to calculate MIDI note on and
 note off from [...] MIDI input? Can I use the pygame.midi.time() counter to 
 do that?

You could, but I would just use the pygame.event queue to handle all
events in the same fashion. Just make sure you poll MIDI input often
enough (by calling poll/read on your MIDI Input instance) and pass the
received MIDI events to the pygame.event queue via
pygame.midi.midis2events and pygame.event.post.

Of course, MIDI input handling is much easier with a callback API,
because you don't need to poll regularly. Here's a short example of
handling MIDI input with python-rtmidi's callback mechanism:

http://trac.chrisarndt.de/code/browser/projects/python-rtmidi/trunk/tests/test_midiin_callback.py

 (difference between key on and key off time).

This has nothing to do with MIDI. Just use the pygame.event mechanism to
record the key events and when they occur (use time.time() or
pygame.time.get_ticks()) and then calculate the difference.


Chris


Re: pygame.MIDI input (Was: [pygame] Python3 version packaged?)

2014-03-21 Thread diliup gabadamudalige
Thank You very much!
Much appreciated.
May you be well.


On Fri, Mar 21, 2014 at 10:38 PM, Christopher Arndt ch...@chrisarndt.dewrote:

 On 21.03.2014 17:44, diliup gabadamudalige wrote:
  I am writing a music software and I need to calculate MIDI note on and
  note off from [...] MIDI input? Can I use the pygame.midi.time() counter
 to do that?

 You could, but I would just use the pygame.event queue to handle all
 events in the same fashion. Just make sure you poll MIDI input often
 enough (by calling poll/read on your MIDI Input instance) and pass the
 received MIDI events to the pygame.event queue via
 pygame.midi.midis2events and pygame.event.post.

 Of course, MIDI input handling is much easier with a callback API,
 because you don't need to poll regularly. Here's a short example of
 handling MIDI input with python-rtmidi's callback mechanism:


 http://trac.chrisarndt.de/code/browser/projects/python-rtmidi/trunk/tests/test_midiin_callback.py

  (difference between key on and key off time).

 This has nothing to do with MIDI. Just use the pygame.event mechanism to
 record the key events and when they occur (use time.time() or
 pygame.time.get_ticks()) and then calculate the difference.


 Chris




-- 
Diliup Gabadamudalige


http://www.diliupg.com
http://soft.diliupg.com/

**
This e-mail is confidential. It may also be legally privileged. If you are
not the intended recipient or have received it in error, please delete it
and all copies from your system and notify the sender immediately by return
e-mail. Any unauthorized reading, reproducing, printing or further
dissemination of this e-mail or its contents is strictly prohibited and may
be unlawful. Internet communications cannot be guaranteed to be timely,
secure, error or virus-free. The sender does not accept liability for any
errors or omissions.
**


Re: [pygame] Python3 version packaged?

2014-03-21 Thread Christopher Arndt

Am 21.03.2014 13:18, schrieb Christopher Arndt:

One could easily write a module for providing a pygame.midi
backwards-compatible API to a third-party MIDI module. In fact, I'm
doing that for my python-rtmidi [1] module right now.


There you go: 
https://bitbucket.org/pygame/pygame/pull-request/28/replace-internals-of-pygamemidi-with/diff



Chris