[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Mixer Quit / Restart



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 <Bob@xxxxxxxxxxxxxxxxxxx> 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