Tricks of the Windows Game Programming Gurus:Sounding Off with DirectSound and DirectMusic

All ITKnowledge Source Code Search Tips Advanced Search |

| Tricks of the Windows Game Programming Gurus by Andre LaMothe Sams, Macmillan Computer Publishing ISBN: 0672313618 Pub Date: 09/27/99

Search this book:

Previous | Table of Contents | Next

### Digital Recording: Tools and Techniques

Before I finish off the sound and music preceptor program, I want to give you some hints on recording sound and music for your games because I get millions of emails on the topic all the time. There are at least three ways to create digital samples:

  • Sample them from the real world with a microphone or outside input.
  • Buy sampled sounds in digital or analog format and download or record them for use.
  • Synthesize digital sounds with a waveform synthesizer like Sound Forge.

The third method may seem a little backwards, but it’s useful if you want to create pure tones with digital hardware and you don’t have a sound source that you can record. But the first two methods are the most important for us.

If you’re making a game that has a lot of speech in it, you’re probably going to have to sample your own voice (or the voice of a friend), tweak it with a piece of software, and then use it in your game. For games that use standard explosions, doors, growls, and so on, you can probably get away with generic sound clips. For example, just about everybody in this business has a copy of the Sound Ideas General 6000/7000+ sound library. It’s about 40 CDs full of thousands of sound effects, and it’s used for movies, so it has it all. But if I hear the Doom/Quake door sound one more time in a full release movie, I’m going to rip my ears off!

The only problem with professional sound libraries is the cost—about $2,500 for a decent license. So what should you do? Any computer store will have $5 CDs of sound effects. You may have to buy a few, but two or three will usually give you enough samples to work with—some cars, spaceships, monsters, and so on. However, since I’m a nice guy, I’m going to supply you with a complete set of cool sounds from one of my games. They’re on this book’s CD in the directory called `SOUNDS\`. They’re all in `.WAV` format, so you can use them directly in your games, but you might want to resample and tweak them because they’re mutant sounds from a number of different game products.

#### Recording Sounds

If you record your own sounds, I suggest the following settings: Create your originals with 16 bits per sample in 22KHz mono. Remember, no stereo. DirectSound works best with mono sound, so recording in stereo won’t help. Also, most sounds you can make or record will be mono anyway, so recording in stereo will be a waste of memory.

If you’re recording from a microphone plugged into your sound card, buy a good one. A good one will feel heavy. There is truth to the old saying, “If it’s heavy, then it’s good.” Also, do your recording in an enclosed room without background noise or interruptions. If you’re recording direct from a device, such as a CD player or radio, make sure that the connections are good and use high-quality audio connectors.

Finally, give your sound files reasonable names. Don’t be cryptic; you’ll never remember what’s what unless you’re organized. And for God’s sake, it’s almost the 21st century—use long filenames!

#### Processing Your Sounds

Once you’ve sampled your sounds with Sound Forge or a similar piece of software, you’ll probably want to post-process those sounds. Again, Sound Forge or a similar package can do all the processing. During processing you’ll want to crop out all the dead air, normalize the volumes, remove noise, add echoes, etc. However, I suggest that when you perform this step, you make backups of your sounds and don’t mess with the originals. Rename the processed sounds with numbers appended at the end or something. Once they’re gone, they’re gone!

While you’re processing sound, experiment with frequency shifting, echoes, distortion, and various other effects. When you find a cool effect, make sure to write down the formula to reproduce the effect. I can’t tell you how many times I had the perfect female computer voice (processed from mine) and I lost the formula.

Finally, when you’re done with all your sounds, write them all out in the same format, such as 22- or 11KHz mono with 8- or 16-bit. This will help DirectSound tremendously when it’s processing your sounds. If you have sounds with different sample rates and bits per sample, DirectSound will always have to convert to its native rate of 22KHz 8-bit.

> Tip: Technically, DirectSound’s native format is 22 KHz 8-bit stereo. But most sounds are mono in nature, and sending stereo data to DirectSound is a waste unless you’re recording with two microphones placed at different locales or have real stereo data.

Previous | Table of Contents | Next

Copyright © Macmillan Computer Publishing, Inc.

Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.