Re: [pygame] hoe to create the RoundRect ?

2008-05-09 Thread Ian Mallett
...and I have.  This release of PAdLib implements this.
Ian


[pygame] GSoC: Vision Processing and Webcam Support in Pygame

2008-05-09 Thread Nirav Patel
Hello all,
I'm participating in Google Summer of Code with One Laptop Per Child,
and my project is to write a computer vision library that works on the
OLPC XO.  I plan on doing this by incorporating webcam support and
some vision functions into Pygame.

In the next few days, I will start writing a v4l2 interface that
initializes a v4l2 camera and loads a frame of video as a surfarray.
This will basically be a python wrapper around something like
http://www.linuxtv.org/downloads/video4linux/API/V4L2_API/spec/capture-example.html

The next step will be writing vision functions.  At minimum, I would
like to do thresholding, colorspace conversion, histograms,
convolution, and centroids of connected components.  Basically, things
that would be useful for gaming purposes.  It would also be useful to
have some kind of motion detection using multiple surfarrays and an
algorithm like the Lucas-Kanade method.  Most things past that, like
Haar feature detection for face detection, may be getting too heavy
for inclusion in Pygame.

Any suggestions, questions, or comments would be greatly appreciated.

Thanks,
Nirav Patel


Re: [pygame] starting sound playback at offset

2008-05-09 Thread Nathan Whitehead
On Thu, May 8, 2008 at 11:54 PM, Patrick Mullen <[EMAIL PROTECTED]> wrote:
> ... A more high tech
> solution may be to use a sndarray, but I am completely unfamiliar with how
> these array objects can be used exactly.  but it may be that you can make an
> array, and then slive it from where you want to start, and it will modify
> the sound such as to start from where you want. ...
> If you do figure out how to "seek" using a sndarray let me know, I'd be
> interested in such a thing as well.

Thanks for the suggestion to use sndarray, works great.  Here's my function:

def play_offset(snd, offset):
"""play a sound starting at a sample offset

returns channel new offset sound is playing on
"""
samps = pygame.sndarray.samples(snd)[offset:]
newsnd = pygame.sndarray.make_sound(samps)
return newsnd.play()

Also, the offset is measured in samples after resampling.  If the
mixer frequency is 44100, then 44100 samples is one second offset.
--
Nathan Whitehead


Re: [pygame] starting sound playback at offset

2008-05-09 Thread René Dudfield
Ah, we could probably have a better way of sharing data.  Maybe
something like a sub surface would be best.

But for now, you can copy the sound data and chop it up yourself.

cheers,


On Fri, May 9, 2008 at 5:28 PM, Brian Fisher <[EMAIL PROTECTED]> wrote:
> although it's probably not a huge thing, the sound constructor doc claims it
> won't share the buffer:
> "Note: The buffer will be copied internally, no data will be shared between
> it and the Sound object."
> if that's correct it means that approach would make copies of the music
>
> But more importantly, how would you get a buffer that points to an offset
> within another buffer?
>
> On Fri, May 9, 2008 at 12:24 AM, René Dudfield <[EMAIL PROTECTED]> wrote:
>>
>> You can get a buffer from Sound objects now.
>> http://pygame.org/docs/ref/mixer.html#Sound.get_buffer
>>
>> Then combined with the constructor... pygame.mixer.Sound(buffer)
>> should do the trick.
>> http://pygame.org/docs/ref/mixer.html#pygame.mixer.Sound
>>
>> cheers,
>>
>> On Fri, May 9, 2008 at 5:20 PM, Brian Fisher <[EMAIL PROTECTED]>
>> wrote:
>> > I didn't mean copying the sound - I meant with SDL could you make a
>> > mixer
>> > chunk that pointed to a portion of some other chunk.
>> >
>> > or are you saying it's easy in pygame to make a sound that points to a
>> > subset of the content of another sound? (like a subsurface...) If so,
>> > how
>> > would you do that?
>> >
>> > On Fri, May 9, 2008 at 12:17 AM, René Dudfield <[EMAIL PROTECTED]> wrote:
>> >>
>> >> yeah, pretty much.
>> >>
>> >> Doing that from python is just as easy though.
>> >>
>> >>
>> >> On Fri, May 9, 2008 at 5:16 PM, Brian Fisher
>> >> <[EMAIL PROTECTED]>
>> >> wrote:
>> >> > From looking at SDL_mixer it's hard to tell if it would even support
>> >> > playing
>> >> > from an offset... Would adding support for playing from an offset in
>> >> > pygame
>> >> > just be a matter of manually making a new chunk object that would
>> >> > point
>> >> > to a
>> >> > place within the original chunk for the sample?
>> >> >
>> >> >
>> >> > On Fri, May 9, 2008 at 12:09 AM, René Dudfield <[EMAIL PROTECTED]>
>> >> > wrote:
>> >> >>
>> >> >> yeah, you'll have to chop up the Sound samples yourself for that...
>> >> >> which shouldn't be too hard.
>> >> >>
>> >> >> cheers,
>> >> >
>> >> >
>> >
>> >
>
>


Re: [pygame] starting sound playback at offset

2008-05-09 Thread Brian Fisher
although it's probably not a huge thing, the sound constructor doc claims it
won't share the buffer:
"Note: The buffer will be copied internally, no data will be shared between
it and the Sound object."
if that's correct it means that approach would make copies of the music

But more importantly, how would you get a buffer that points to an offset
within another buffer?

On Fri, May 9, 2008 at 12:24 AM, René Dudfield <[EMAIL PROTECTED]> wrote:

> You can get a buffer from Sound objects now.
> http://pygame.org/docs/ref/mixer.html#Sound.get_buffer
>
> Then combined with the constructor... pygame.mixer.Sound(buffer)
> should do the trick.
> http://pygame.org/docs/ref/mixer.html#pygame.mixer.Sound
>
> cheers,
>
> On Fri, May 9, 2008 at 5:20 PM, Brian Fisher <[EMAIL PROTECTED]>
> wrote:
> > I didn't mean copying the sound - I meant with SDL could you make a mixer
> > chunk that pointed to a portion of some other chunk.
> >
> > or are you saying it's easy in pygame to make a sound that points to a
> > subset of the content of another sound? (like a subsurface...) If so, how
> > would you do that?
> >
> > On Fri, May 9, 2008 at 12:17 AM, René Dudfield <[EMAIL PROTECTED]> wrote:
> >>
> >> yeah, pretty much.
> >>
> >> Doing that from python is just as easy though.
> >>
> >>
> >> On Fri, May 9, 2008 at 5:16 PM, Brian Fisher <[EMAIL PROTECTED]
> >
> >> wrote:
> >> > From looking at SDL_mixer it's hard to tell if it would even support
> >> > playing
> >> > from an offset... Would adding support for playing from an offset in
> >> > pygame
> >> > just be a matter of manually making a new chunk object that would
> point
> >> > to a
> >> > place within the original chunk for the sample?
> >> >
> >> >
> >> > On Fri, May 9, 2008 at 12:09 AM, René Dudfield <[EMAIL PROTECTED]>
> wrote:
> >> >>
> >> >> yeah, you'll have to chop up the Sound samples yourself for that...
> >> >> which shouldn't be too hard.
> >> >>
> >> >> cheers,
> >> >
> >> >
> >
> >
>


Re: [pygame] starting sound playback at offset

2008-05-09 Thread René Dudfield
You can get a buffer from Sound objects now.
http://pygame.org/docs/ref/mixer.html#Sound.get_buffer

Then combined with the constructor... pygame.mixer.Sound(buffer)
should do the trick.
http://pygame.org/docs/ref/mixer.html#pygame.mixer.Sound

cheers,

On Fri, May 9, 2008 at 5:20 PM, Brian Fisher <[EMAIL PROTECTED]> wrote:
> I didn't mean copying the sound - I meant with SDL could you make a mixer
> chunk that pointed to a portion of some other chunk.
>
> or are you saying it's easy in pygame to make a sound that points to a
> subset of the content of another sound? (like a subsurface...) If so, how
> would you do that?
>
> On Fri, May 9, 2008 at 12:17 AM, René Dudfield <[EMAIL PROTECTED]> wrote:
>>
>> yeah, pretty much.
>>
>> Doing that from python is just as easy though.
>>
>>
>> On Fri, May 9, 2008 at 5:16 PM, Brian Fisher <[EMAIL PROTECTED]>
>> wrote:
>> > From looking at SDL_mixer it's hard to tell if it would even support
>> > playing
>> > from an offset... Would adding support for playing from an offset in
>> > pygame
>> > just be a matter of manually making a new chunk object that would point
>> > to a
>> > place within the original chunk for the sample?
>> >
>> >
>> > On Fri, May 9, 2008 at 12:09 AM, René Dudfield <[EMAIL PROTECTED]> wrote:
>> >>
>> >> yeah, you'll have to chop up the Sound samples yourself for that...
>> >> which shouldn't be too hard.
>> >>
>> >> cheers,
>> >
>> >
>
>


Re: [pygame] starting sound playback at offset

2008-05-09 Thread Brian Fisher
I didn't mean copying the sound - I meant with SDL could you make a mixer
chunk that pointed to a portion of some other chunk.

or are you saying it's easy in pygame to make a sound that points to a
subset of the content of another sound? (like a subsurface...) If so, how
would you do that?

On Fri, May 9, 2008 at 12:17 AM, René Dudfield <[EMAIL PROTECTED]> wrote:

> yeah, pretty much.
>
> Doing that from python is just as easy though.
>
>
> On Fri, May 9, 2008 at 5:16 PM, Brian Fisher <[EMAIL PROTECTED]>
> wrote:
> > From looking at SDL_mixer it's hard to tell if it would even support
> playing
> > from an offset... Would adding support for playing from an offset in
> pygame
> > just be a matter of manually making a new chunk object that would point
> to a
> > place within the original chunk for the sample?
> >
> >
> > On Fri, May 9, 2008 at 12:09 AM, René Dudfield <[EMAIL PROTECTED]> wrote:
> >>
> >> yeah, you'll have to chop up the Sound samples yourself for that...
> >> which shouldn't be too hard.
> >>
> >> cheers,
> >
> >
>


Re: [pygame] starting sound playback at offset

2008-05-09 Thread René Dudfield
yeah, pretty much.

Doing that from python is just as easy though.


On Fri, May 9, 2008 at 5:16 PM, Brian Fisher <[EMAIL PROTECTED]> wrote:
> From looking at SDL_mixer it's hard to tell if it would even support playing
> from an offset... Would adding support for playing from an offset in pygame
> just be a matter of manually making a new chunk object that would point to a
> place within the original chunk for the sample?
>
>
> On Fri, May 9, 2008 at 12:09 AM, René Dudfield <[EMAIL PROTECTED]> wrote:
>>
>> yeah, you'll have to chop up the Sound samples yourself for that...
>> which shouldn't be too hard.
>>
>> cheers,
>
>


Re: [pygame] starting sound playback at offset

2008-05-09 Thread Brian Fisher
>From looking at SDL_mixer it's hard to tell if it would even support playing
from an offset... Would adding support for playing from an offset in pygame
just be a matter of manually making a new chunk object that would point to a
place within the original chunk for the sample?


On Fri, May 9, 2008 at 12:09 AM, René Dudfield <[EMAIL PROTECTED]> wrote:

> yeah, you'll have to chop up the Sound samples yourself for that...
> which shouldn't be too hard.
>
> cheers,
>


Re: [pygame] starting sound playback at offset

2008-05-09 Thread René Dudfield
yeah, you'll have to chop up the Sound samples yourself for that...
which shouldn't be too hard.

cheers,