Realtime Sound Generation with Byte Array

Hi all,

I just tried to generate sound for my car game http://www.brasurf.com.au/CraigsRace/ and I didn’t do very well. ::slight_smile:

Problem is I don’t know how to generate the sound to make the correct sound effect. I fiddled around with combining sine waves to create an engine noise, with tyre skid effects, and I did some random noise for firing rockets, however, it really doesn’t sound very good.

Has anyone done anything like this before? Do most people use very short sound clips and modify them instead of generating the sound effect?

Any help would be much appreciated! :slight_smile:

Cheers,
Craig.

AFAIK, most racing games use samples. I know of only one or two that are based entirely on synthetic sounds (http://www.liveforspeed.net/). Don’t know how they do it, though sry…

If you’re looking to do pre-rendered sound clips, try this out:
http://www.imitationpickles.org/ludum/2007/12/13/sfxr-sound-effects-for-all/

As for car engine sounds… I did it once, and it was difficult. I mic’ed a Honda starting up, and then heavily edited it in Goldwave to make it sound deeper and to loop correctly. It was just “ok”… good enough for a game.

Awesome! That will do nicely for my rocket sounds! Thanks for the link. ;D

Cool. When you did it, do you remember if you loaded the sound into a byte array and directly modified the byte array to get different pitches (Ie: Different sound for different engine speed)? I tried loading a clip and modifying the FloatContol.Type.SAMPLE_RATE to get the different pitches, but Java said it wasn’t supported.

Use SourceDataLine for streaming the sound. You can adjust pitch by adjusting the rate you feed the samples (and interpolating the between values). You can also use more advanced tricks like using different samples for different revs (and again interpolating the between values).