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

Re: [pygame] Better Python music playback?



Yeah, the synchronization problem is annoying.  That's the main
motivation why I wrote swmixer.  Take a look at the documentation
page, under the section EXPLICIT TICK INTERFACE.
http://code.google.com/p/pygalaxy/wiki/SWMixer

That section shows how you can calculate chunks of sound and
synchronize exactly with the game video framerate.  That method works
much better for rhythm games where loss of synchronization screws up
the whole game.  If you try out swmixer and have problems, let me
know.

-- Nathan

On Sun, May 24, 2009 at 10:42 PM, Zack Schilling
<zack.schilling@xxxxxxxxx> wrote:
> I suppose you're both right. Using just the mixer, I only lose two
> abilities: Starting the music from specific points and precise timing
> information.
>
> I can emulate the timing feedback using pygame.time.get_ticks and an offset
> when the song starts, but I'll need to work around not being able to start
> playing the song at an arbitrary number of milliseconds. I'm making a
> rhythm/combat/platformer, so the music and gameplay are closely tied. The
> biggest problem with losing the ability to start the music any place is that
> there is going to be desynchronization if the player happens to repeatedly
> pause the game.
>
> Each time the player pauses, a few milliseconds will slip by between
> pausing/resuming the music and recalculating the tick offset, regardless of
> what order I perform the two in. Eventually the music will desynchronize
> from the game. Can anyone think of a way to keep the music in sync through
> multiple pauses without either: 1.) allowing the music to play while paused
> or 2.) restarting the music on unpause. The music has to stop and resume
> exactly where it left off or else just the act of pausing affects gameplay.
> If the number of milliseconds that I think the song has been playing don't
> match the actual number, then the gameplay falls apart.
>
> Thanks,
>
> -Zack