Sound and Music Tutorial
From SRB2 Wiki
Custom sounds and music are common in SRB2 mods. This tutorial teaches you how to implement them into WAD files. If you want your music to be played on your custom level, then read the Level Header.
Contents |
Music WAD
These are WAD files created for the sole purpose of containing music for SRB2 to play in-game. Music WADs are often included in mods; music.dta (comes with SRB2) is an example. It can contain OGGs, MP3s, WAVs, S3Ms, MIDIs, MODs, XMs, and ITs. Music is either used for levels, credits, jingles, or the opening sequence and title screen.
As of August 2007, these types of WAD files are banned from release on the SRB2 forums.
What You Need
- Your sound file. If you're adding a sound effect, it must be a WAV file. If you're adding music, it can be an OGG, MP3, MIDI, or MOD file.
- A sound editor. Sound Recorder, which comes packaged with Windows, is a useful sound editor.
- A lump editor, such as XWE.
- Optional (required to use Loop Points): A media application capable of editing a file's information tags, such as Winamp.
Adding Sounds
Formatting the WAV file
First, you need to edit the properties of your WAV file, so that it plays at the format SRB2 recognizes: 8-bit Mono. In this step, we will format the WAV file into the proper format using Sound Recorder. Do note that you can use other programs too. Windows Vista does not use the same version of Sound Recorder that this article covers. If your WAV file already plays at 8-bit Mono, you may skip this step.
Open Sound Recorder, and open your WAV file. After you open the .wav in Sound Recorder, go to "File", and then "Properties". A new window will then pop up. Under the "Format Conversion" box, click "Convert Now..."
A second window will then pop up. Under "Attributes", select "48.000kHz, 8 Bit, Mono". Click "OK". On the first window, click "OK" again. After that, save the WAV file.
Finding what to name your sound lump
Second, you need to know what you'll name your sound lump when it's in a WAD file. Sound lumps are prefixed by DS, as in DSSPIN. There are freeslot sound lumps that you can use and point to in your SOCs, which are named DSFRE001, all the way through to DSFRE800. However, these will not replace any already existing sounds in SRB2. If you would like to replace a sound in SRB2, you must preview the sound lumps in SRB2.SRB and find the name of the one you'd like to replace.
In XWE, open SRB2.SRB. On the bottom, click the "Sound" button. This will filter the lumps so only the sound lumps are displayed. Note that when you select a sound lump, a new item on the top menu bar also appears, called "Wave". Select a lump. To play it, click on "Wave", and then "Play". Keep doing this for each lump, until you hear the one you want to change. Remember its name.
Importing the sound file into your WAD
Now you'll import your WAV file into your WAD as a sound lump. In XWE, open your WAD file.
Next, load your WAV file into XWE. When your WAD is opened, then on the top menu, select "Entry", and then "Load". Select your WAV file. It will then be loaded into XWE as a sound lump.
When loaded into XWE, you need to rename your new sound lump into the name you decided to use. After that, on the top menu, click "Wave", and then "Save as Doom Wave".
Done!
You're done! As XWE automatically saves after the last step, you can close it. Load your WAD in SRB2 and test the sound! If the old sound is not replaced, you might have named your sound lump incorrectly. Check the name of your sound lump.
Adding Music
The music file
First, you need to have your OGG/MP3/MIDI/MOD file. Unlike sounds, these don't need to be converted to a specific format. However, many people frown at the use of MP3, due to their big size. It helps to convert your MP3 to an OGG so your WAD's filesize will be smaller. Do note that if you choose to use the OGG format, your file must have a wavelength of 44,100 Hz to function properly.
This article will not cover how to convert to an OGG. Do note that MIDIs and MODs can't conventionally be converted to OGG. Regardless, if you have your music file all set, you can go on to the next step.
Finding what to name your music lump
Second, you'll need to know what to name your music lump. Most music lumps go by the name convention O_MAPxxM, with xx being the map number of the music lump. There are also special music lumps which go by their own naming convention, like O_CHRSEL. These music lumps are used for places which aren't maps, such as the character select.
The O_MAPxxM naming convention makes it very easy. Most music lumps correspond to the map they replace; for example, O_MAP01M is the music for MAP01, Greenflower Zone Act 1. To replace the music for GFZ1, just name it O_MAP01M.
For a list of currently used MusicSlots in SRB2, see MusicSlots.
Remember that you can preview the music lumps in music.dta to find which music you want to replace. Just select the music lump, and then go to "Entry", and then "Save As...". If your music lump starts with O_, you must save it as an OGG. Under "Save as type", select "All Files (*.*)", and then save your file as filename.ogg, making sure to add .ogg at the end of it like as shown. This will save it as an OGG file. When saved, open up the OGG file in a compatible player, such as Winamp.
Do note that MIDI only music lumps start with D_. OGG/MP3/MOD/WAV/S3M/XM/IT music lumps start with O_.
Looping -- a bonus for using digital music
If you choose to add digital music (OGG, MP3) to your wad, you can choose to have SRB2 loop the music to a defined point in the song as it finishes playing. In order to benefit from this feature, you must set up a Loop Point.
To set up a loop point, you need a media application that can edit the information tags of an OGG or MP3 file, such as Winamp.
Open up Winamp and activate the playlist editor (Alt+E). Drag your digital music file onto the playlist and right-click it. From the drop-down menu, select "View file info...". Locate the 'Comment' field and insert the loop point using the syntax LOOPPOINT=<value>.
How to calculate the value of the Loop Point
The Loop Point is measured in wave size. Multiply the position you wish for the track to loop to (in seconds) by the wavelength of the music file. Remember that if you wish to use an OGG file in SRB2, the wavelength must be 44,100 Hz.
An example calculation of a Loop Point: to loop a file with a wavelength of 44,100 Hz to a position of 30 seconds: 30 * 44100 = 1323000. So you would insert LOOPPOINT=1323000 in the Comment field.
Importing the music file into your WAD
Now you'll import your music file into your WAD as a music lump. In XWE, open your WAD file.
Next, load your OGG/MP3/MIDI/MOD file into XWE. When your WAD is opened, then on the top menu, select "Entry", and then "Load". Select your file. It will then be loaded into XWE as a sound lump.
When loaded into XWE, you need to rename your new music lump into the name you decided to use.
Done!
You're done! As XWE automatically saves after the last step, you can close it. Load your WAD in SRB2 and test the music! If the old music is not replaced, you might have named your sound lump incorrectly. Check the name of your music lump.


