[quote]I have been trying to add some sound to the game, but not really been able to get anything to sound well, or be small… Does anyone have any examples of how to make that happen? I think that generating sound from code should do the trick, but really making it sound like skis against snow, and how to change the volume of it? I have been looking a bit at Defender 4000 sound routine. Think it would be good enough to just have a loop and adjust vol according to how much player is sliding * speed. Any help greatly appreciated.
[/quote]
A fan of my sound scheme! Well, step right up and I’ll tell you what I know! It’s been awhile since I dug into this stuff, but here’s what I remember:
Non-signed PCM data is encoded in such a way that the waveform will continue to increase until a zero is found. At that point the wave will reverse and begin to descend. Again, it will keep descending until a zero is reached, at which point it will reverse again.
Constant zeros produce silence.
My thought on producing a “skiing” sound would be to produce white noise of a given maximum amplitude. You should be able to accomplish this by producing random numbers between 1 and MAX, where MAX is less than 255. By increasing MAX as you speed up, you can make the noise louder, thus giving the impression of speed. Make sure you insert zeros at regular intervals to ensure the wave stays at a high enough frequency.
That’s my theory anyway. You’ll probably want to rip the Defender 4000 sound code out and play with a few sound algorithms. Keep messing with it until you find something that sounds right. Also, don’t be afraid to ask Google about PCM data, and generating sound effects. Here’s a few links to get you started:
http://show.docjava.com:8086/book/cgij/doc/sound/Oscillator.java.html
http://www.softsynth.com/jsyn/