Archive for February, 2010

My music file plays slow in PyWright! Is it just me?

Thursday, February 25th, 2010

Ping’ informed me that there are songs that appear to play slower in PyWright than they should. Here is the reason:

In a typical music player, it is always only playing one music/sound at a time. Because of this, it can shape the music player to fit the rate of whatever is loaded. Music can have different sample rates, which is similar to a framerate. It says how many samples per second are stored in the file. When your music player loads a file, it adjust it’s playing rate based on what rate the file says.

Now, with a game engine, it’s not so simple. You have many sound effects and different music playing at different times. Because of the way the hardware works, you can only run things at one speed at a time. If you try to play music stored at one rate, and a sound effect stored at another rate, you either have to stop the music to change the settings and play the sound; or resample each file to the settings of the hardware. Resampling means analyzing the sound file and either cutting out frames to make it a slower rate, or adding frames to make it a higher rate.

Some kinds of resampling are very easy. To double the rate, you just have to read two frames at a time; while to half the rate, you can skip a frame. If you are not doubling or halving the frame rate of the sound though, you have to do deeper analysis of the frames.

The libraries PyWright depends on, namely SDL_Mixer, can do the cheap resampling for free. It doesn’t know anything about more advanced resampling however.

(more…)

Version number shuffle: 0.95 to be streaming down your tubes this February!

Friday, February 19th, 2010

I’ve been spending some serious time on the next release of PyWright, and been having a blast. It kind of started when Ptapcc from court-records.net started asking me if PyWright could handle certain features he was interested in. When looking closely at what he wanted, most of the things were either doable right now, or would be doable with just a few modifications to the PyWright core.

One of the features had to do with zooming, which had already been implemented but not hooked up to wrightscript; and the other had to do with being able to do collision detection with wrightscript alone.

Now I am not trying to compete with pwlib, I don’t intend to fully replicate the edgeworth walkabout code. But I was interested in whether implementing that was possible without too many changes to the engine.

After implementing a few things, each change led to another, and beta 10.95 is turning out to be one of the biggest updates PyWright has ever had. Most of the updates are small, but quite a few of them are meaningful enough to really have an effect. Being able to add graphics to buttons, rock-solid saving capabilities, and more control over where code jumps (label none is being deprecated) can make workarounds the exception rather than the norm.

It’s such a big set of fixes in fact, that I am starting to think that the “beta 10.95″ moniker isn’t really fitting. PyWright for the most part has been pretty stable. Each release brings issues along with it that can break games, but the amount of changes needed to update games to be compatible has been low. I would have liked to break old games less than I have, but it was beta right? Well now it’s not. I’m not going to hide behind the beta name any longer. The internet has enough betas on it’s hand.

Henceforth, the next version of PyWright is going to be named version 0.95, and it is the series of releases that will eventually (and soon) be 1.0. I will still keep tweaking things as I always do, I’m sure 0.95 will break something, but I am aiming for more stability from this series. Changing the name is part of that. 0.95 will be out this February for sure. It will require new binaries for those of you using the binary releases.

Currently I am methodically testing the save feature in every possible situation I can come up with to ensure that it is crash-free.

Oh, and the mythical beta 11? Besides being somewhat on hold, it’s new name is going to be version 2.0.