Jump to content
  • Advertisement
Sign in to follow this  
tuphdc

Scaling Engine Sounds

This topic is 4032 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a simple 2D car racing game. How can I add engine sounds to my game so that the engine sounds will scale with the speed of the cars?? This is really confusing me, I can't seem to figure out how it is done. I would suspect its done with some tricky audio looping techniques, but I'm not sure. Any help is appreciated.

Share this post


Link to post
Share on other sites
Advertisement
First, pick a sound library that allows you to change the interpreted sample rate of a sample on the fly. DirectSound and FMOD are capable of this, and I'm sure the list doesn't stop there. From here, you can make it as complicated as you like. The simplest solution, while still very convincing, is to play a looping 'idling' sample with the sample rate linked proportional to the rev count of the engine. Something like this:

CurrentSampleFrequency = OriginalSampleFrequency * (1 + Range * CurrentSpeed / MaxSpeed)

Where 'Range' is an engine-specific constant, somewhere around 10, if my dashboard is anything to go by. Here, I've made the somewhat iffy assumption that the car has only one gear and that clutch is fully engaged at all times with some magical force keeping the engine from stalling when stationary. If you have a working transmission system with a well-modelled, damped rev-counter then a far more accurate formula would be:

CurrentSampleFrequency = OriginalSampleFrequency * (1 + Range * (CurrentRPM - MinRPM) / (MaxRPM - MinRPM))

Admiral

Share this post


Link to post
Share on other sites
Thanks for the info.

It looks like I was sort of on the right track to begin with regarding the looping technique.

I'll see what I can do from here....

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!