TUTORIAL: Adding Your Own Sound Effects

I admit, I've made a grave omission in my last several tutorials - most of the time, we've just been borrowing the default Doom sound effects for our tutorial weapons. In this tutorial, I'll show you how to add your own. You'll probably want a sound editor like Audacity, though I won't be covering the actual creation of sound effects here, only how to get them working in your mod.

Not everybody has the skills to record and mix their own new weapon sounds. Personally, I remedy this with FreeSound, a site where you can obtain your own Creative Commons-licensed sound effects for any usage. With very few exceptions, all of these sounds are free for your use and modification, so have at 'em.

Once you have your sound effect (hopefully in a format that ZDoom supports), fire up SLADE and get a PK3 going (or open a previous one). For PK3 files, all sound effects need to be in a subfolder called "sounds" (sans quotes, obviously). You're free to use any kind of branching folder structure you like, for example, you could store all sounds relating to your shotgun in /sounds/shotgun, or all sounds relating to your new zombie in /sounds/monsters/zombie2 - the thing is, though, since ZDoom actually ignores most of that, try not to duplicate file names, and don't name your files any longer than 8 characters. Just a quick breakdown here:

/sounds/DSPISTOL - This is fine. However, in a PK3, you might want to leave the file extension on.
/sounds/DSPISTOL.ogg - This is also fine. However, it helps organization a lot if you have your things organized.
/sounds/pistol/DSPISTOL.ogg - This is ideal - keep your weapon sounds separate from everything else. I generally keep an individual folder for each weapon, a folder for pickup sounds, folders for every enemy, and a folder for just miscellaneous stuff like door sounds.
/sounds/pistol/PistolFire.ogg - This will not do, since ZDoom will only be able to see the first eight characters, i.e. it'll only be recognized if you're specifically searching for PISTOLFI.

Okay. At this point, I'll assume that you've got your sounds imported and organized where they ought to be. Sounds won't usually work unless you've defined them in SNDINFO. SNDINFO is actually a pretty simple "language" - at a very basic level, you really only need one line per sound. A basic SNDINFO definition consists of a "nice name" and a "logical name" - the "nice name" is what you will be referencing from Decorate. The "logical name" is the name of the sound as it's stored in your archive. Here's a sample of how we would define our above-mentioned pistol sound in SNDINFO.

weapons/PistolFire DSPISTOL

Granted, we don't necessarily need to define a sound named DSPISTOL (since ZDoom.pk3 has already taken care of that for us, as DSPISTOL is in Doom.wad already), but this just demonstrates the proper form. In your Decorate code, you'd reference the nice name ("weapons/pistolfire") either in the weapon's AttackSound, or through an A_PlaySound function.

There are some other things you can do with SNDINFO, such as making a bank of random sounds for ZDoom to choose. Here's an example of that:

$random Weapons/PulseFire { Weapons/PulseFire1 Weapons/PulseFire2 Weapons/PulseFire3 Weapons/PulseFire4 }
Weapons/PulseFire1 PULSE1
Weapons/PulseFire2 PULSE2
Weapons/PulseFire3 PULSE3
Weapons/PulseFire4 PULSE4

A $random statement first begins with the name you eventually want to reference in your code. Afterwards, there is an opening brace (or curly-bracket or whatever you want to call that), then from there you list the names of all the sounds that you want ZDoom to randomly choose between when the sound is called. Remember to close your brace when you're done. Then make sure the randomized sounds are also defined (since we can't make a $random statement reference file names, only nice names), and call the name you defined from $random whenever you need it.

There are many other things you can do with SNDINFO and Decorate, but I encourage you to read the Wiki entries I linked earlier in the tutorial and experiment with them yourself.