Sign in to follow this  
tekmoto

Car engine sound generation

Recommended Posts

tekmoto    156
Hi everyone, I am wondering what's the best way to generate the sound of an engine for my car game? I can't really load and play WAVs, because then it wouldn't sound continuous. Is there any good way to dynamically generate the sound of an engine revving up?

Share this post


Link to post
Share on other sites
flounder    100
i don't really know of a way, but i wanted to say (that rhymes) that a method a creating a sound of an engine on the spot has already been copyrighted (trademarked w\e). I dont know if whatever legal binds on it have expired now, but i remember seeing the notice on some game devlopement wikipedia site when i was looking for the .wav file format.

Share this post


Link to post
Share on other sites
killabi    180
Hey tekmoto,
You can accomplish the desired affect with a wav file of the normal engine sound that can be looped. You loop the wav file to generate the continuous effect you are after. Then to increase/decrease RPMs, you modify the frequency with which you are playing the sound so that it matches. This will raise/lower the pitch of the sound to simulate the roar of an engine.

I implemented this exact effect in a GTA2 clone that I made, and it went off without a hitch. You can even implement a simulated gear shifting effect by dropping the frequency back down to a low value that matches the rpms whenever the car shifts.

Share this post


Link to post
Share on other sites
Bob Janova    769
You either use a loopable WAV and resample it to change the frequency, or generate each section of your sound via a reverse Fourier transform with the appropriate primary frequency.

Share this post


Link to post
Share on other sites
spoulson    144
I imagine you could probably render some interesting engine sounds by starting with a single 'pop' combustion sound and mix multiple channels of the same sound in varying succession for a simulated n cylinder engine. As engine speed increases, you would need to keep the combustion sound at about the same frequency throughout, probably increasing slightly, but increate the number of fires per second.

If you know anything about cars, you know you'll need to take into effect certain dynamics that change the overall sound of exhaust. For example, most 4 cylinder engines have a 4-into-1 exhaust manifold or header. The sound will be generally a pretty consistent hum. A V8 will have two banks of 4-into-1 manifolds. Depending on the car, you could have two straight-back exhaust pipes, an H-pipe connecting the two, or a Y-pipe with one exhaust pipe to the back. Each of these three sound distinctly different because they vary in pressure and sound cancellation. Mustangs have an H-pipe configuration, which is what gives it the throaty rumble.

Of course there are lots of other variables in what makes an engine sound the way it does: spark advance, compression ratio, engine volume, air/fuel ratio, forced induction, fuel injected vs. carbuerated, headers vs. manifolds, cats/no cats, exhaust pipe dimensions, etc.

Share this post


Link to post
Share on other sites
Funkymunky    1413
As per the OP's question as to how to do it without wav's (although the replies have shown that is very feasible to do it with wav's) does anyone know how to generate sounds for use in applications like this?

I've played around with some software synthesizers, and that's what i'm really interested in. How do you produce the sound of a sine wave, or a square wave, or a triangle...etc, at an octave and whatnot?

Share this post


Link to post
Share on other sites
Adam Hamilton    271
I would say in my opinion that the legality that flounder mentions refers to a particular method of generating the car sound. As long as you devise another method, I am sure you that no one can hold you against it.

Just my opinion but do check this out for yourself.

I don't know if this would work but you could create a sine wave on the fly into a buffer and distort it somehow based on the RPM, gear and other engine parameters and just play the buffer you created

Share this post


Link to post
Share on other sites
tekmoto    156
Wow, so many good ideas, I'm not sure which one to pick.

I may end up doing with the WAVs after all, it seems easier.

Anyone know where I can download a copy of a seamless looping car engine WAV?

Share this post


Link to post
Share on other sites
Adam Hamilton    271
Just a simple idea I just came up with which may work well...

If you have a car or know someone with a car you could record a few samples of the engine noise at some known RPM...

Do a recording of idle speed - record the RPM (you can keep it for your idle noise)

Rev the car to about 2000 RPM and record. Rev the car to 4000 RPM and record.

Play around with the .WAV start and end positions to work out the best looping and trim the wave to those positions

Now at a certain RPM, say 3000, you increase the sampling rate of the pre-recorded 2000 RPM sound and decrease the sampling rate of the 4000 RPM sound and play them mixed together.

You should set some damping of the amplitude of one of the samples as it approaches the other RPM (So when you reach close to 4000 RPM, the 2000 RPM sound file will be low in volume so it doesn't sound weird)

If you play around with this idea I am sure it could work for you just brilliantly.

Good luck :)

Share this post


Link to post
Share on other sites
hplus0603    11356
Try the RayCar demo. It has a car engine sound that's made from looping a pretty short engine sound sample. The engine sound is controlled only through pitch bend for RPM (playback sample rate) and volume (basically amount of gas).

I took the sample at full RPM, and then loop it slower for idle and lower RPMs; this avoids the aliasing you'll get if you pitch something up from nominal.

Actually, try the MSI installer version of the demo; it's somewhat better than the ZIP version.

Btw: you can also get the source code for the RayCar demo on the same site. Re-use the source as you will. Joy and happy!

Share this post


Link to post
Share on other sites
Flarelocke    410
Quote:
Original post by Funkymunky
As per the OP's question as to how to do it without wav's (although the replies have shown that is very feasible to do it with wav's) does anyone know how to generate sounds for use in applications like this?

I've played around with some software synthesizers, and that's what i'm really interested in. How do you produce the sound of a sine wave, or a square wave, or a triangle...etc, at an octave and whatnot?


In theory, you'd specify the frequency you want and then generate a buffer (much like creating a lookup table) for it at a certain sample rate, and then you combine the pure tones (single frequencies) into more complex sounds by adding the values together (I think. It may be multiplication instead). Sounds tend to include harmonics of their fundamental frequency, so you'll have to add those in there. For the most part, what makes a sound distinct is the fundamental frequency, the relative magnitudes of the harmonics, and the way these change in time.

More complex systems (with better sounds) may forego generating pure tones at all because some sounds with time-varying fundamental frequency don't have a simple way of getting the sound from pure tones (could require an infinite number of pure tones, for instance).

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