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.