Sign in to follow this  
Storyyeller

variable speed sound playback

Recommended Posts

I have making a 2d game in C++ with SDL ands SDL_Mixer for audio. It is completely deterministic, and designs to operate at a fixed framerate, but if the computer is lagging, then it obviously has to go into slow motion. The problem is that this causes the audio to get out of sync from everything else. The game is supposed to be able to run properly without knowing anything about its framerate, but that is obviously impossible with audio. What can I do? Do I need to custom mix together all of my music and sounds? Are there any libraries I can use for this?

Share this post


Link to post
Share on other sites
The problem does not lie in your audio implementation, it lies in your game.

You need to make it handle variable frame rates. You usually do this by passing a timestep into your update functions.

If you don't fix your game, then not only will the audio be out of sync, but your game will also play differently on different systems.

You *can* adapt your audio to fit by using time stretching techniques, but you will find that a LOT harder than fixing your game. Take a look (google) at FFTs (Fast Fourrier Transforms) to see what you would be up against.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this