Re: [pygame] MIDI output on OS X???

2009-10-09 Thread Chris Phoenix
OK... with SimpleSynth running, I now get "in stat: : No such file or
directory" printed twice on the pygame.midi.init() call.

If I continue, pygame.midi.get_default_output_id() returns 0, and
pygame.midi.get_count() returns 1.

But then midiOut = pygame.midi.Output(0, latency = 1) gives me this:
PortMidi call failed...
  PortMidi: `Bad pointer'
type ENTER...

Meanwhile, I'm using pygame.mixer to play midi files that I create. I
find that it doesn't play the last note of the tracks, even when
Quicktime does. And neither one seems to pay attention to the Pitch
Bend Range controller message. Any insight into any of this?

Thanks,
Chris

On Fri, Oct 9, 2009 at 6:55 AM, René Dudfield  wrote:
> Hi,
>
> Roger from portmedia explains the situation here:
>
> http://lists.create.ucsb.edu/pipermail/media_api/2009-October/000751.html
>
> In short, OSX does not come with midi output on all machines by default.
> You need to install a software synth to use it with CoreMidi.  SDL_mixer
> must be using something else to play midi files.
>
> Fluidsynth, and simplesynth would be two free options for software synths on
> osx.
>
> cu,
>
>
> On Fri, Oct 9, 2009 at 1:07 PM, René Dudfield  wrote:
>>
>> Hi,
>>
>> it seems to be able to list output devices that are plugged in.  Like it
>> lists my midi keyboard when plugged in.
>>
>> However it does not seem to list the internal midi hardware on sound
>> cards.
>>
>> pygame.midi uses CoreMIDI through portaudio on OSX.  pygame.music.midi
>> uses a different older API.  So maybe that's the cause of the problems.
>>
>> Will need to look into it some more.  If you can, please ask on the
>> portmedia mailing list at:
>> http://lists.create.ucsb.edu/mailman/listinfo/media_api
>>
>> If you can't post, I'll follow up on it later there.
>>
>>
>> cheers,
>>
>>
>> On Thu, Oct 8, 2009 at 10:20 AM, Chris Phoenix  wrote:
>>>
>>> I'd like to make a MIDI sound from a Python program. PyGame's midi
>>> module was supposed to do it, but it doesn't seem to have a default
>>> midi output device - or any midi output device!
>>>
>>> pygame.midi.get_default_output_id() returns -1. Half an hour of
>>> googling didn't help. Looking at the unit tests didn't help (there's a
>>> bugfix aimed at this problem, but it seems to just bypass the test).
>>>
>>> The mixer module can indeed read a midi file and make a sound come out
>>> the speakers, but I'd rather drive the midi directly instead of
>>> writing mini-files and playing them...
>>>
>>> What should I pass in to pygame.midi.Output() on 10.5? Or what should
>>> I do to create the midi device so that
>>> pygame.midi.get_default_output_id() will tell me something other than
>>> -1?
>>>
>>> Thanks...
>>>
>>> Chris
>>>
>>> --
>>> Chris Phoenix
>>> cphoe...@gmail.com
>>> 650-776-5195
>>>
>>> Director of Research
>>> Center for Responsible Nanotechnology
>>> http://CRNano.org
>>
>
>



-- 
Chris Phoenix
cphoe...@gmail.com
650-776-5195

Director of Research
Center for Responsible Nanotechnology
http://CRNano.org


Re: [pygame] Keyboards, other questions

2009-10-09 Thread The Music Guy
On Fri, Oct 9, 2009 at 6:33 PM, pierrelafran...@sympatico.ca
 wrote:
> Hi
> If I have a Linux base application, with 2 USB keyboards connected to
> it, is it possible to know, when a key is press, from wich keyboard the
> command is from ?
>
> Thanks
>
> --
> Pierre
>

AFAIK, by default most Linux setups treat multiple keyboards as though
they were all the same device. This is true for tty's as well as X. I
believe this is handled by the kernel, but I could be wrong. Getting
multiple keyboards to work as separate devices would definitely
require some per-system configuration requiring root privileges, and
would not be easy to do from within a Python app, assuming it is even
possible.


[pygame] Keyboards, other questions

2009-10-09 Thread pierrelafran...@sympatico.ca
Hi
If I have a Linux base application, with 2 USB keyboards connected to
it, is it possible to know, when a key is press, from wich keyboard the
command is from ?

Thanks

-- 
Pierre


Re: [pygame] duplicate images

2009-10-09 Thread Patrick Mullen
You actually can still share the same image between sprites:

image = pygame.image.load("image.py")
s1 = Sprite()
s1.image = image
s2 = Sprite()
s2.image = image

They have the same image but can be placed in different groups, or put
at different places.

On Fri, Oct 9, 2009 at 9:02 AM, Thiago Petruccelli
 wrote:
> Thanks everybody! Problem solved.
>
> I couldn't just blit the same img in different objects because they're
> contained in sprite.Groups (OrderedUpdates). Every image in my game is in a
> class that extends Sprite. But the copy command of the image solved the
> problem.
>
> thanks everybody =)
> --
> Thiago Henrique Petruccelli
>
>
> On Fri, Oct 9, 2009 at 3:09 AM, Jake b  wrote:
>>
>> How are you handling the windows. ( Do you have a class that stores its
>> location? )
>> It sounds like what happens if two variables point to / and modify the
>> same object.
>> [ Whereas you want the same image, but different location ]
>>
>> You can create a new sprite object, for every unit. But you are able to
>> load it's image one time, shared among 100 (or more) units on screen.
>>
>> Or you can skip using SpriteGroup()'s entirely, by just blitting the
>> surface at a location. ( like RB[0] said ).
>>
>> Here are a couple tutorials that may interest you:
>>
>> pinman's sprite group tutorial:
>> http://www.sacredchao.net/~piman/writing/sprite-tutorial.shtml
>>
>> pygame.org's  sprite group tutorial:
>> http://www.pygame.org/docs/tut/SpriteIntro.html
>>
>> and pygame.org's Sprite documentation:
>> http://www.pygame.org/docs/ref/sprite.html
>>
>> example shows how you draw multiple sprites with one image.
>>
>> """Psuedo-code example 1"""
>> close_img = pygame.image.load("close.png")
>> windows = [ Window(), Window() ] # two windows, wiih defaults
>>
>> # for every window
>> for current in windows:
>>     x,y = current.location()
>>     screen.blit( close_img, (x,y) )
>>
>>
>> # ==
>>
>>
>> This second example is taken from piman's tutorial: If you want to load
>> the image the first time the class is instantiated, and every instance uses
>> the first image, you can do this.
>>
>> "real code: example 2"
>> class MySprite(pygame.sprite.Sprite):
>>     image = None
>>
>>     def __init__(self):
>>     pygame.sprite.Sprite.__init__(self)
>>
>>     if MySprite.image is None:
>>     # This is the first time this class has been instantiated.
>>     # So, load the image for this and all subsequence instances.
>>     MySprite.image = pygame.image.load("image.png")
>>
>>     self.image = MySprite.image
>>
>>
>> # ==
>>
>> # Then you could have code like this:
>>
>> # ==
>>
>> # load map
>> units = []
>> units.append( Wolf() )
>> units.append( Troll() )
>>
>> # draw
>> for unit in self.units:
>>     unit.move()
>>     unit.draw()
>>
>> # your loading and drawing code is now defined inside class Wolf() and
>> class Troll().
>> # You could even write a wrapper, so that you can do something like this:
>>
>> class Unit(pygame.sprite.Sprite)
>>     # base class.
>>     # ... like the above MySprite class, but adds a filename as argument.
>>     # also can handles locations, movement, and .draw() that all units
>> need
>>     def __init__(self, filename ):
>>     # ... code snipped, saves to variable class.
>>
>> # Wolf uses default blit, movement, attack, etc... functions
>> # only needs to define image.
>> class Wolf(Unit):
>>     def __init__(self):
>>     Unit.__init__(self, "wolf.png")
>>
>> # troll draws extra ontop of default
>> class Troll(Unit):
>>     def __init__(self):
>>     Unit.__init__(self, "troll.png")
>>     def draw(self):
>>     #overwrides default blit, here.
>>
>> see also: cookbook: sprite sheet.
>> http://www.pygame.org/wiki/Spritesheet?parent=CookBook
>>
>> hope that helps :P
>> --
>> Jake
>
>


Re: [pygame] duplicate images

2009-10-09 Thread Thiago Petruccelli
Thanks everybody! Problem solved.

I couldn't just blit the same img in different objects because they're
contained in sprite.Groups (OrderedUpdates). Every image in my game is in a
class that extends Sprite. But the copy command of the image solved the
problem.

thanks everybody =)
--
Thiago Henrique Petruccelli


On Fri, Oct 9, 2009 at 3:09 AM, Jake b  wrote:

> How are you handling the windows. ( Do you have a class that stores its
> location? )
> It sounds like what happens if two variables point to / and modify the same
> object.
> [ Whereas you want the same image, but different location ]
>
> You can create a new sprite object, for every unit. But you are able to
> load it's image one time, shared among 100 (or more) units on screen.
>
> Or you can skip using SpriteGroup()'s entirely, by just blitting the
> surface at a location. ( like RB[0] said ).
>
> Here are a couple tutorials that may interest you:
>
> pinman's sprite group tutorial:
> http://www.sacredchao.net/~piman/writing/sprite-tutorial.shtml
>
> pygame.org's  sprite group tutorial:
> http://www.pygame.org/docs/tut/SpriteIntro.html
>
> and pygame.org's Sprite documentation:
> http://www.pygame.org/docs/ref/sprite.html
>
> example shows how you draw multiple sprites with one image.
>
> """Psuedo-code example 1"""
> close_img = pygame.image.load("close.png")
> windows = [ Window(), Window() ] # two windows, wiih defaults
>
> # for every window
> for current in windows:
> x,y = current.location()
> screen.blit( close_img, (x,y) )
>
>
> # ==
>
>
> This second example is taken from piman's tutorial: If you want to load the
> image the first time the class is instantiated, and every instance uses the
> first image, you can do this.
>
> "real code: example 2"
> class MySprite(pygame.sprite.Sprite):
> image = None
>
> def __init__(self):
> pygame.sprite.Sprite.__init__(self)
>
> if MySprite.image is None:
> # This is the first time this class has been instantiated.
> # So, load the image for this and all subsequence instances.
> MySprite.image = pygame.image.load("image.png")
>
> self.image = MySprite.image
>
>
> # ==
>
> # Then you could have code like this:
>
> # ==
>
> # load map
> units = []
> units.append( Wolf() )
> units.append( Troll() )
>
> # draw
> for unit in self.units:
> unit.move()
> unit.draw()
>
> # your loading and drawing code is now defined inside class Wolf() and
> class Troll().
> # You could even write a wrapper, so that you can do something like this:
>
> class Unit(pygame.sprite.Sprite)
> # base class.
> # ... like the above MySprite class, but adds a filename as argument.
> # also can handles locations, movement, and .draw() that all units need
> def __init__(self, filename ):
> # ... code snipped, saves to variable class.
>
> # Wolf uses default blit, movement, attack, etc... functions
> # only needs to define image.
> class Wolf(Unit):
> def __init__(self):
> Unit.__init__(self, "wolf.png")
>
> # troll draws extra ontop of default
> class Troll(Unit):
> def __init__(self):
> Unit.__init__(self, "troll.png")
> def draw(self):
> #overwrides default blit, here.
>
> see also: cookbook: sprite sheet.
> http://www.pygame.org/wiki/Spritesheet?parent=CookBook
>
> hope that helps :P
> --
> Jake
>


Re: [pygame] MIDI output on OS X???

2009-10-09 Thread René Dudfield
Hi,

Roger from portmedia explains the situation here:

http://lists.create.ucsb.edu/pipermail/media_api/2009-October/000751.html

In short, OSX does not come with midi output on all machines by default.
You need to install a software synth to use it with CoreMidi.  SDL_mixer
must be using something else to play midi files.

Fluidsynth, and simplesynth would be two free options for software synths on
osx.

cu,


On Fri, Oct 9, 2009 at 1:07 PM, René Dudfield  wrote:

> Hi,
>
> it seems to be able to list output devices that are plugged in.  Like it
> lists my midi keyboard when plugged in.
>
> However it does not seem to list the internal midi hardware on sound cards.
>
> pygame.midi uses CoreMIDI through portaudio on OSX.  pygame.music.midi uses
> a different older API.  So maybe that's the cause of the problems.
>
> Will need to look into it some more.  If you can, please ask on the
> portmedia mailing list at:
> http://lists.create.ucsb.edu/mailman/listinfo/media_api
>
> If you can't post, I'll follow up on it later there.
>
>
> cheers,
>
>
>
> On Thu, Oct 8, 2009 at 10:20 AM, Chris Phoenix  wrote:
>
>> I'd like to make a MIDI sound from a Python program. PyGame's midi
>> module was supposed to do it, but it doesn't seem to have a default
>> midi output device - or any midi output device!
>>
>> pygame.midi.get_default_output_id() returns -1. Half an hour of
>> googling didn't help. Looking at the unit tests didn't help (there's a
>> bugfix aimed at this problem, but it seems to just bypass the test).
>>
>> The mixer module can indeed read a midi file and make a sound come out
>> the speakers, but I'd rather drive the midi directly instead of
>> writing mini-files and playing them...
>>
>> What should I pass in to pygame.midi.Output() on 10.5? Or what should
>> I do to create the midi device so that
>> pygame.midi.get_default_output_id() will tell me something other than
>> -1?
>>
>> Thanks...
>>
>> Chris
>>
>> --
>> Chris Phoenix
>> cphoe...@gmail.com
>> 650-776-5195
>>
>> Director of Research
>> Center for Responsible Nanotechnology
>> http://CRNano.org
>>
>
>


Re: [pygame] Movie Module Segfault

2009-10-09 Thread Tyler Laing
Theres another neat work around someone else found, which is to use the
pygstreamer wrapper. It apparently works fairly good.

-Tyler

On Fri, Oct 9, 2009 at 2:26 AM, René Dudfield  wrote:

> Hi,
>
> unfortunately the movie module is not very good :(
>
> This is one of the reasons why there is a new movie module in development.
> However, that won't be release until the next pygame version.
>
> A work around could be to put the movie into jpgs + ogg file.
>
>
> cu,
>
>
>
>
>
> On Fri, Oct 9, 2009 at 7:26 AM, Vitor Bosshard  wrote:
>
>> Hello,
>>
>>
>> I've been using the movie module in one of my projects, and I am
>> running into an intermittent crash:
>>
>>
>> XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server
>> ":0.0"
>>  after 16581 requests (16579 known processed) with 0 events remaining.
>> Fatal Python error: (pygame parachute) Segmentation Fault
>> Aborted
>>
>>
>> My app runs anywhere from a few seconds to 10 minutes, then crashes
>> with this kind of error. I'm running Ubuntu 9.04, Python 2.6.2, pygame
>> 1.8.1. I appreciate any help in figuring out what this is about.
>>
>>
>> Thanks,
>> Vitor
>>
>
>


-- 
Visit my blog at http://oddco.ca/zeroth/zblog


Re: [pygame] MIDI output on OS X???

2009-10-09 Thread René Dudfield
Hi,

it seems to be able to list output devices that are plugged in.  Like it
lists my midi keyboard when plugged in.

However it does not seem to list the internal midi hardware on sound cards.

pygame.midi uses CoreMIDI through portaudio on OSX.  pygame.music.midi uses
a different older API.  So maybe that's the cause of the problems.

Will need to look into it some more.  If you can, please ask on the
portmedia mailing list at:
http://lists.create.ucsb.edu/mailman/listinfo/media_api

If you can't post, I'll follow up on it later there.


cheers,


On Thu, Oct 8, 2009 at 10:20 AM, Chris Phoenix  wrote:

> I'd like to make a MIDI sound from a Python program. PyGame's midi
> module was supposed to do it, but it doesn't seem to have a default
> midi output device - or any midi output device!
>
> pygame.midi.get_default_output_id() returns -1. Half an hour of
> googling didn't help. Looking at the unit tests didn't help (there's a
> bugfix aimed at this problem, but it seems to just bypass the test).
>
> The mixer module can indeed read a midi file and make a sound come out
> the speakers, but I'd rather drive the midi directly instead of
> writing mini-files and playing them...
>
> What should I pass in to pygame.midi.Output() on 10.5? Or what should
> I do to create the midi device so that
> pygame.midi.get_default_output_id() will tell me something other than
> -1?
>
> Thanks...
>
> Chris
>
> --
> Chris Phoenix
> cphoe...@gmail.com
> 650-776-5195
>
> Director of Research
> Center for Responsible Nanotechnology
> http://CRNano.org
>


Re: [pygame] Movie Module Segfault

2009-10-09 Thread René Dudfield
Hi,

unfortunately the movie module is not very good :(

This is one of the reasons why there is a new movie module in development.
However, that won't be release until the next pygame version.

A work around could be to put the movie into jpgs + ogg file.


cu,




On Fri, Oct 9, 2009 at 7:26 AM, Vitor Bosshard  wrote:

> Hello,
>
>
> I've been using the movie module in one of my projects, and I am
> running into an intermittent crash:
>
>
> XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server
> ":0.0"
>  after 16581 requests (16579 known processed) with 0 events remaining.
> Fatal Python error: (pygame parachute) Segmentation Fault
> Aborted
>
>
> My app runs anywhere from a few seconds to 10 minutes, then crashes
> with this kind of error. I'm running Ubuntu 9.04, Python 2.6.2, pygame
> 1.8.1. I appreciate any help in figuring out what this is about.
>
>
> Thanks,
> Vitor
>