Re: [pygame] Mixer Quit / Restart

2008-07-04 Thread Wyatt Olson

Cool!  I'll await the fix whenever SDL and then Pygame release the change.

Cheers

Lenard Lindstrom wrote:

This bug was already known and was fixed in the SDL SVN.

Lenard


Lenard Lindstrom wrote:


The problem is with Mix_SetPanning in SDL_mixer. The function is 
called by Pygame.mixer.Channel.set_volume.


Lenard



Wyatt Olson wrote:
Oh well, that's fine.  I will just inform potential users that they 
must convert all samples to a specific format first, and then not 
restart the mixer when loading new sounds.


Given that this software is to be used in a (relatively complex) 
open source DIY electronic drum brain, I would imagine that 
converting audio samples is probably the easiest of all the other 
required steps (soldering ICs, programming microcontrollers, etc).  ;-)


Cheers

FT wrote:
 
Hi!
 
It never worked, it is just that it never worked.
 
Wyatt Olson 

*To:* pygame-users@seul.org 

This appears to get the total number of channels, not the number of 
active channels.  However, I tried using get_busy(), but it still 
does not seem to work.


See the following modifications to my original code:

import pygame, time

for x in range(10):
print("Starting iteration " + str(x))
print("Initializing mixer")
pygame.mixer.init()

print("Loading sound")
sound = pygame.mixer.Sound("foo.wav")
print("Finding free channel")
channel = pygame.mixer.find_channel()
   print("Channel object: " + str(channel))
   print("Setting volume")
channel.set_volume(0.7)
   print("Playing sound")
channel.play(sound)
   print("Sleeping until sound is finished playing...")
while pygame.mixer.get_busy():
time.sleep(1)

print("Quitting mixer\n\n")
pygame.mixer.quit()



This displays the same behaviour.

In response to a previous comment about using channel.stop() before 
quitting the mixer: this does not work either, as can be seen by 
adding channel.stop() after the get_busy loop above.



Has anyone tried running this code themselves?  I am wondering if I 
am experiencing some obscure bug, possibly platform specific.  I am 
running on OS X, but don't have access to other systems for 
troubleshooting.  If someone else has access to a Windows or Linux 
box, and is able to prove if this fails on those systems as well, 
that may be useful.


Cheers

Ian Mallett wrote:
On 7/2/08, *Wyatt Olson* <[EMAIL PROTECTED] 
> wrote:


Is there anything which can return a list of all currently active
channels?

pygame.mixer.get_num_channels()
This returns 0 if none are playing and > 0 if there are.











signature.asc
Description: OpenPGP digital signature


Re: [pygame] Mixer Quit / Restart

2008-07-04 Thread Lenard Lindstrom

This bug was already known and was fixed in the SDL SVN.

Lenard


Lenard Lindstrom wrote:


The problem is with Mix_SetPanning in SDL_mixer. The function is 
called by Pygame.mixer.Channel.set_volume.


Lenard



Wyatt Olson wrote:
Oh well, that's fine.  I will just inform potential users that they 
must convert all samples to a specific format first, and then not 
restart the mixer when loading new sounds.


Given that this software is to be used in a (relatively complex) open 
source DIY electronic drum brain, I would imagine that converting 
audio samples is probably the easiest of all the other required steps 
(soldering ICs, programming microcontrollers, etc).  ;-)


Cheers

FT wrote:
 
Hi!
 
It never worked, it is just that it never worked.
 
Wyatt Olson 

*To:* pygame-users@seul.org 

This appears to get the total number of channels, not the number of 
active channels.  However, I tried using get_busy(), but it still 
does not seem to work.


See the following modifications to my original code:

import pygame, time

for x in range(10):
print("Starting iteration " + str(x))
print("Initializing mixer")
pygame.mixer.init()

print("Loading sound")
sound = pygame.mixer.Sound("foo.wav")
print("Finding free channel")
channel = pygame.mixer.find_channel()
   print("Channel object: " + str(channel))
   print("Setting volume")
channel.set_volume(0.7)
   print("Playing sound")
channel.play(sound)
   print("Sleeping until sound is finished playing...")
while pygame.mixer.get_busy():
time.sleep(1)

print("Quitting mixer\n\n")
pygame.mixer.quit()



This displays the same behaviour.

In response to a previous comment about using channel.stop() before 
quitting the mixer: this does not work either, as can be seen by 
adding channel.stop() after the get_busy loop above.



Has anyone tried running this code themselves?  I am wondering if I 
am experiencing some obscure bug, possibly platform specific.  I am 
running on OS X, but don't have access to other systems for 
troubleshooting.  If someone else has access to a Windows or Linux 
box, and is able to prove if this fails on those systems as well, 
that may be useful.


Cheers

Ian Mallett wrote:
On 7/2/08, *Wyatt Olson* <[EMAIL PROTECTED] 
> wrote:


Is there anything which can return a list of all currently active
channels?

pygame.mixer.get_num_channels()
This returns 0 if none are playing and > 0 if there are.









Re: [pygame] Mixer Quit / Restart

2008-07-03 Thread Lenard Lindstrom
The problem is with Mix_SetPanning in SDL_mixer. The function is called 
by Pygame.mixer.Channel.set_volume.


Lenard



Wyatt Olson wrote:
Oh well, that's fine.  I will just inform potential users that they 
must convert all samples to a specific format first, and then not 
restart the mixer when loading new sounds.


Given that this software is to be used in a (relatively complex) open 
source DIY electronic drum brain, I would imagine that converting 
audio samples is probably the easiest of all the other required steps 
(soldering ICs, programming microcontrollers, etc).  ;-)


Cheers

FT wrote:
 
Hi!
 
It never worked, it is just that it never worked.
 
Wyatt Olson 

*To:* pygame-users@seul.org 

This appears to get the total number of channels, not the number of 
active channels.  However, I tried using get_busy(), but it still 
does not seem to work.


See the following modifications to my original code:

import pygame, time

for x in range(10):
print("Starting iteration " + str(x))
print("Initializing mixer")
pygame.mixer.init()

print("Loading sound")
sound = pygame.mixer.Sound("foo.wav")
print("Finding free channel")
channel = pygame.mixer.find_channel()
   print("Channel object: " + str(channel))
   print("Setting volume")
channel.set_volume(0.7)
   print("Playing sound")
channel.play(sound)
   print("Sleeping until sound is finished playing...")
while pygame.mixer.get_busy():
time.sleep(1)

print("Quitting mixer\n\n")
pygame.mixer.quit()



This displays the same behaviour.

In response to a previous comment about using channel.stop() before 
quitting the mixer: this does not work either, as can be seen by 
adding channel.stop() after the get_busy loop above.



Has anyone tried running this code themselves?  I am wondering if I 
am experiencing some obscure bug, possibly platform specific.  I am 
running on OS X, but don't have access to other systems for 
troubleshooting.  If someone else has access to a Windows or Linux 
box, and is able to prove if this fails on those systems as well, 
that may be useful.


Cheers

Ian Mallett wrote:
On 7/2/08, *Wyatt Olson* <[EMAIL PROTECTED] 
> wrote:


Is there anything which can return a list of all currently active
channels?

pygame.mixer.get_num_channels()
This returns 0 if none are playing and > 0 if there are.







Re: [pygame] Mixer Quit / Restart

2008-07-03 Thread Wyatt Olson
Oh well, that's fine.  I will just inform potential users that they must 
convert all samples to a specific format first, and then not restart the 
mixer when loading new sounds.


Given that this software is to be used in a (relatively complex) open 
source DIY electronic drum brain, I would imagine that converting audio 
samples is probably the easiest of all the other required steps 
(soldering ICs, programming microcontrollers, etc).  ;-)


Cheers

FT wrote:
 
Hi!
 
It never worked, it is just that it never worked.
 
Wyatt Olson 

*To:* pygame-users@seul.org 

This appears to get the total number of channels, not the number of 
active channels.  However, I tried using get_busy(), but it still does 
not seem to work.


See the following modifications to my original code:

import pygame, time

for x in range(10):
print("Starting iteration " + str(x))
print("Initializing mixer")
pygame.mixer.init()

print("Loading sound")
sound = pygame.mixer.Sound("foo.wav")
print("Finding free channel")
channel = pygame.mixer.find_channel()
   
print("Channel object: " + str(channel))
   
print("Setting volume")

channel.set_volume(0.7)
   
print("Playing sound")

channel.play(sound)
   
print("Sleeping until sound is finished playing...")

while pygame.mixer.get_busy():
time.sleep(1)

print("Quitting mixer\n\n")
pygame.mixer.quit()



This displays the same behaviour.

In response to a previous comment about using channel.stop() before 
quitting the mixer: this does not work either, as can be seen by 
adding channel.stop() after the get_busy loop above.



Has anyone tried running this code themselves?  I am wondering if I am 
experiencing some obscure bug, possibly platform specific.  I am 
running on OS X, but don't have access to other systems for 
troubleshooting.  If someone else has access to a Windows or Linux 
box, and is able to prove if this fails on those systems as well, that 
may be useful.


Cheers

Ian Mallett wrote:
On 7/2/08, *Wyatt Olson* <[EMAIL PROTECTED] 
> wrote:


Is there anything which can return a list of all currently active
channels?

pygame.mixer.get_num_channels()
This returns 0 if none are playing and > 0 if there are.





Re: [pygame] Mixer Quit / Restart

2008-07-03 Thread FT

Hi!

It never worked, it is just that it never worked.

Wyatt Olson 
To: pygame-users@seul.org 


This appears to get the total number of channels, not the number of active 
channels.  However, I tried using get_busy(), but it still does not seem to 
work.

See the following modifications to my original code:

import pygame, time

for x in range(10):
print("Starting iteration " + str(x))
print("Initializing mixer")
pygame.mixer.init()

print("Loading sound")
sound = pygame.mixer.Sound("foo.wav")
print("Finding free channel")
channel = pygame.mixer.find_channel()

print("Channel object: " + str(channel))

print("Setting volume")
channel.set_volume(0.7)

print("Playing sound")
channel.play(sound)

print("Sleeping until sound is finished playing...")
while pygame.mixer.get_busy():
time.sleep(1)

print("Quitting mixer\n\n")
pygame.mixer.quit()



This displays the same behaviour.

In response to a previous comment about using channel.stop() before quitting 
the mixer: this does not work either, as can be seen by adding channel.stop() 
after the get_busy loop above.


Has anyone tried running this code themselves?  I am wondering if I am 
experiencing some obscure bug, possibly platform specific.  I am running on OS 
X, but don't have access to other systems for troubleshooting.  If someone else 
has access to a Windows or Linux box, and is able to prove if this fails on 
those systems as well, that may be useful.

Cheers

Ian Mallett wrote: 
  On 7/2/08, Wyatt Olson <[EMAIL PROTECTED]> wrote: 
Is there anything which can return a list of all currently active channels?
  pygame.mixer.get_num_channels()
  This returns 0 if none are playing and > 0 if there are.




Re: [pygame] Mixer Quit / Restart

2008-07-02 Thread Wyatt Olson
This appears to get the total number of channels, not the number of 
active channels.  However, I tried using get_busy(), but it still does 
not seem to work.


See the following modifications to my original code:

import pygame, time

for x in range(10):
   print("Starting iteration " + str(x))
   print("Initializing mixer")
   pygame.mixer.init()

   print("Loading sound")
   sound = pygame.mixer.Sound("foo.wav")
   print("Finding free channel")
   channel = pygame.mixer.find_channel()
  
   print("Channel object: " + str(channel))
  
   print("Setting volume")

   channel.set_volume(0.7)
  
   print("Playing sound")

   channel.play(sound)
  
   print("Sleeping until sound is finished playing...")

   while pygame.mixer.get_busy():
   time.sleep(1)

   print("Quitting mixer\n\n")
   pygame.mixer.quit()



This displays the same behaviour.

In response to a previous comment about using channel.stop() before 
quitting the mixer: this does not work either, as can be seen by adding 
channel.stop() after the get_busy loop above.



Has anyone tried running this code themselves?  I am wondering if I am 
experiencing some obscure bug, possibly platform specific.  I am running 
on OS X, but don't have access to other systems for troubleshooting.  If 
someone else has access to a Windows or Linux box, and is able to prove 
if this fails on those systems as well, that may be useful.


Cheers

Ian Mallett wrote:
On 7/2/08, *Wyatt Olson* <[EMAIL PROTECTED] 
> wrote:


Is there anything which can return a list of all currently active
channels?

pygame.mixer.get_num_channels()
This returns 0 if none are playing and > 0 if there are.



signature.asc
Description: OpenPGP digital signature


Re: [pygame] Mixer Quit / Restart

2008-07-02 Thread Ian Mallett
On 7/2/08, Wyatt Olson <[EMAIL PROTECTED]> wrote:
>
> Is there anything which can return a list of all currently active channels?

pygame.mixer.get_num_channels()
This returns 0 if none are playing and > 0 if there are.


Re: [pygame] Mixer Quit / Restart

2008-07-02 Thread Wyatt Olson
I have not done that, as I don't keep track of channels after they are 
obtained and started playing.  Is there anything which can return a list 
of all currently active channels?


Now that being said, in my real program, I am able to recreate the bug 
even when waiting for all currently playing sounds to stop, before 
selecting the new configuration.  Unless channel.stop() results in a 
different state from just leaving the channel to finish playing the 
sound by itself, I don't think that it should matter.


Cheers

Lenard Lindstrom wrote:

Did you try calling Channel.stop before calling quit?

Lenard


Wyatt Olson wrote:
This seems to work.  It would be nice to be able to re-init the 
mixer, in case there were different bitrates, but if that can't work, 
I can just specify that the samples must all be the same bitrate.


Thanks for the quick replies, all!

Cheers

On Tue, Jul 1, 2008 at 2:22 PM, Wyatt Olson <[EMAIL PROTECTED] 
> wrote:


Cool, I'll give that a shot, and let you know what happens.

Cheers


On Tue, Jul 1, 2008 at 2:20 PM, Ian Mallett <[EMAIL PROTECTED]
> wrote:

James, yes, I realized this was a test case, the questions
apply to that.  Thanks for clearing that up. :-)

Why reinit the mixer?  Are the sounds necessarily different
bitrates?
If you want to delete things, I believe you can use
del(pointer_to_sound) or something, which should not require a
mixer reinit.







Re: [pygame] Mixer Quit / Restart

2008-07-02 Thread Lenard Lindstrom

Did you try calling Channel.stop before calling quit?

Lenard


Wyatt Olson wrote:
This seems to work.  It would be nice to be able to re-init the mixer, 
in case there were different bitrates, but if that can't work, I can 
just specify that the samples must all be the same bitrate.


Thanks for the quick replies, all!

Cheers

On Tue, Jul 1, 2008 at 2:22 PM, Wyatt Olson <[EMAIL PROTECTED] 
> wrote:


Cool, I'll give that a shot, and let you know what happens.

Cheers


On Tue, Jul 1, 2008 at 2:20 PM, Ian Mallett <[EMAIL PROTECTED]
> wrote:

James, yes, I realized this was a test case, the questions
apply to that.  Thanks for clearing that up. :-)

Why reinit the mixer?  Are the sounds necessarily different
bitrates? 


If you want to delete things, I believe you can use
del(pointer_to_sound) or something, which should not require a
mixer reinit.





Re: [pygame] Mixer Quit / Restart

2008-07-01 Thread Wyatt Olson
This seems to work.  It would be nice to be able to re-init the mixer, in
case there were different bitrates, but if that can't work, I can just
specify that the samples must all be the same bitrate.

Thanks for the quick replies, all!

Cheers

On Tue, Jul 1, 2008 at 2:22 PM, Wyatt Olson <[EMAIL PROTECTED]> wrote:

> Cool, I'll give that a shot, and let you know what happens.
>
> Cheers
>
>
> On Tue, Jul 1, 2008 at 2:20 PM, Ian Mallett <[EMAIL PROTECTED]> wrote:
>
>> James, yes, I realized this was a test case, the questions apply to that.
>> Thanks for clearing that up. :-)
>>
>> Why reinit the mixer?  Are the sounds necessarily different bitrates?
>>
>> If you want to delete things, I believe you can use del(pointer_to_sound)
>> or something, which should not require a mixer reinit.
>>
>> Ian
>>
>
>
>
> --
> Wyatt Olson
> http://thecave.homeunix.org
>



-- 
Wyatt Olson
http://thecave.homeunix.org


Re: [pygame] Mixer Quit / Restart

2008-07-01 Thread Wyatt Olson
Cool, I'll give that a shot, and let you know what happens.

Cheers

On Tue, Jul 1, 2008 at 2:20 PM, Ian Mallett <[EMAIL PROTECTED]> wrote:

> James, yes, I realized this was a test case, the questions apply to that.
> Thanks for clearing that up. :-)
>
> Why reinit the mixer?  Are the sounds necessarily different bitrates?
>
> If you want to delete things, I believe you can use del(pointer_to_sound)
> or something, which should not require a mixer reinit.
>
> Ian
>



-- 
Wyatt Olson
http://thecave.homeunix.org


Re: [pygame] Mixer Quit / Restart

2008-07-01 Thread Ian Mallett
James, yes, I realized this was a test case, the questions apply to that.
Thanks for clearing that up. :-)

Why reinit the mixer?  Are the sounds necessarily different bitrates?

If you want to delete things, I believe you can use del(pointer_to_sound) or
something, which should not require a mixer reinit.

Ian


Re: [pygame] Mixer Quit / Restart

2008-07-01 Thread Wyatt Olson
This is correct; this is just an example showing the problem.  In my real
program (a drum sequencer), I load a number of samples which correlate to
various elements in a drum set, then play a bunch of stuff.  At some point
in the future, the user can switch to a different set.  When they do this, I
unload all sound objects, unload the mixer, and reload everything.  I unload
the samples to save memory; there are potentially hundreds of MB of samples
for a single set, and I don't want to leak memory if the user repeatedly
switches back and forth.

As for setting the volume on the channel instead of the sound object, I need
to be able to play the same sample multiple times with different volumes.
For instance, think of playing a cymbal - if you hit the cymbal two times in
quick succession, the first at volume 1.0, the second at 0.5, you would want
to hear the samples playing at different volumes.  If you set the volume on
the sound object, when you play the second sample, the first sample's volume
is reduced as well.


Everything in my main program is working, but just the unloading / loading
code fails.

If you want to see a copy of the real program, let me know, but it is much
more complicated than this simple test case.  I just included the elements
here which demonstrate the problem.

Cheers


On Tue, Jul 1, 2008 at 1:37 PM, James Paige <[EMAIL PROTECTED]> wrote:

> On Tue, Jul 01, 2008 at 11:43:42AM -0700, Ian Mallett wrote:
> >Note that if this were to work (init/deinit aside), the sound would
> start
> >playing, then the mixer would be deinited immediately, so you would
> likely
> >hear nothing or at most ten little clicks.
> >
> >I'm curious about this problem--why deinitialize the mixer between
> >sounds?  Are they all different bitrates?  Why micromanage channels?
> >sound.play() should work equally well.
> >
> >Ian
>
> If I understood the original poster correctly, he was only presenting
> that code as a test case. I believe his real intention would be to
> re-init sound according to user-specified settings within an "Options"
> menu inside a game.
>
> ---
> James Paige
>



-- 
Wyatt Olson
http://thecave.homeunix.org


Re: [pygame] Mixer Quit / Restart

2008-07-01 Thread James Paige
On Tue, Jul 01, 2008 at 11:43:42AM -0700, Ian Mallett wrote:
>Note that if this were to work (init/deinit aside), the sound would start
>playing, then the mixer would be deinited immediately, so you would likely
>hear nothing or at most ten little clicks. 
> 
>I'm curious about this problem--why deinitialize the mixer between
>sounds?  Are they all different bitrates?  Why micromanage channels? 
>sound.play() should work equally well.
> 
>Ian

If I understood the original poster correctly, he was only presenting 
that code as a test case. I believe his real intention would be to 
re-init sound according to user-specified settings within an "Options" 
menu inside a game.

---
James Paige


Re: [pygame] Mixer Quit / Restart

2008-07-01 Thread Ian Mallett
Note that if this were to work (init/deinit aside), the sound would start
playing, then the mixer would be deinited immediately, so you would likely
hear nothing or at most ten little clicks.

I'm curious about this problem--why deinitialize the mixer between sounds?
Are they all different bitrates?  Why micromanage channels?  sound.play()
should work equally well.

Ian