Game Development Community

Code strategy for multiple engine sounds at diff RPMs

by Thomas \"Man of Ice\" Lund · in Torque Game Engine · 08/19/2006 (6:59 am) · 4 replies

For Air Ace we recently got sound files for the different airplane engines used (Merlin, Allison etc)

The delivery has several files of the engines running at different RPMs, and I an now unsure how to proceed implementing these into our game.

The examples I have seen (and that we use currently) is to have a single engine sound and then changing the pitch based on throttle settings (blended with a slight amount of velocity). This is ok, but not fantastic sounding

I was wondering if anyone could give some good hints or pointers to implementing the sound side of these files - this must be a generic problem for most vehicle games, but a quick search didnt result in anything useful.

#1
08/19/2006 (7:11 am)
I don't have the code solution for you but I drive in a racing sim called rFactor. I've taken a look at how they do the sounds. This is their BMW-Sauber F1 car. So a large degree of change from 3000 RPM to 18000 RPM here so though it was a good example. (The game is fully moddable, there are tons of tutorials for it, so posting their code bit here should be fine)

So basically how I see it is, they have their 5 sounds declared. (They do have a lot more but I cut it down - they have sounds for outside the car "power, shifting, inside/outside, etc.)

They later declare what sounds play at what levels of RPM, and then there is some sort of blending of the sounds between them.

Hopefully it can be food for thought for you. :)

VS_INSIDE_POWER_ENGINE_1=FBMWEngine\rF1V8_onidle.wav
VS_INSIDE_POWER_ENGINE_2=FBMWEngine\rF1V8_onverylow.wav
VS_INSIDE_POWER_ENGINE_3=FBMWEngine\rF1V8_onlow.wav
VS_INSIDE_POWER_ENGINE_4=FBMWEngine\rF1V8_onmid.wav
VS_INSIDE_POWER_ENGINE_5=FBMWEngine\rF1V8_onhigh.wav

// ATTENUTATION
EngineRange=100.0
EngineShape=1.00
EngineAmbient=6.00

ShiftRange=100.0
ShiftShape=1.00
ShiftAmbient=6.00

OtherRange=90.0
OtherShape=1.00
OtherAmbient=0.70

// ENGINE VOLUME MIX
playerEngineVolumeMinimum=0.8
playerEngineVolumeThrottleFraction=0.2
playerEngineVolumeRevFraction=0.0

non-playerEngineVolumeMinimum=0.3
non-playerEngineVolumeThrottleFraction=0.3
non-playerEngineVolumeRevFraction=0.4


// ENGINE THROTTLE-POSITION MIX
EngineLoadBlendInside=(0.1,0.7)   // power sound starts to blend in at 30% throttle, coast sound blends out at 70%
EngineLoadBlendOutside=(0.1,0.7)  // power sound starts to blend in at 30% throttle, coast sound blends out at 70%


// power inside
EngineRPMPowerInside=0
{
  MinimumRPM=1.00         // above zero, but low enough to hear engine stall
  MaximumRPM=5170.00     // must overlap properly
  NaturalRPM=4000.00   // engine RPM at which sample was recorded
}

EngineRPMPowerInside=1
{
  MinimumRPM=4385.00     // must overlap properly
  MaximumRPM=8070.00     // must overlap properly
  NaturalRPM=6000.00   // engine RPM at which sample was recorded
}

EngineRPMPowerInside=2
{
  MinimumRPM=6850.00     // must overlap properly
  MaximumRPM=11280.00     // must overlap properly
  NaturalRPM=8000.00   // engine RPM at which sample was recorded
}

EngineRPMPowerInside=3
{
  MinimumRPM=9690.00     // must overlap properly
  MaximumRPM=15600.00     // must overlap properly
  NaturalRPM=12000.00   // engine RPM at which sample was recorded
}

EngineRPMPowerInside=4
{
  MinimumRPM=13400.00     // must overlap properly
  MaximumRPM=22500.00     // must overlap properly
  NaturalRPM=18000.00   // engine RPM at which sample was recorded
}
#2
08/19/2006 (7:30 am)
Hi Thomas,

My suggestion would be to store and index the various engine sounds within one sound file. Then from script you can call upon which sound you need to be played.

Here's a screenshot to illustrate my point:

i5.photobucket.com/albums/y189/fjs/engineSounds.jpg
Have you seen this resource before?

Add pausing and seeking of audio

It may serve as a useful guide.

To really boost the quality of your airplane sounds I would implement EAX and use a doppler effect.

Air Ace was looking exceptional last I saw, keep up the good work!

- Tim
#3
08/19/2006 (1:14 pm)
Hey Thomas.

Yea the engine sound stuff in the Vehicle class blows goats. ;)

How we've done this in other racing games i've worked on is to have at least 3 sounds... low, medium, and high RPMs. Yes you do pitch shifting, but you also cross fade the volume from one sound to the other as the input RPMs change. The amount of overlap during the crossfade when two sounds are playing at the same time is more an art than a science. So that part you'll just have to tweak as needed.

Coincidentally i'm doing some work on this very soon. Maybe we can trade some code.
#4
08/20/2006 (3:22 am)
Cool responses - thanks guys.

Its more or less how I thought it would be - just wanted to make sure that I wasnt pursuing a deadend. Rather learn from others mistake if possible than reinventing wheels.