dmidf.jpg (20235 bytes)
How to do it, why to do it, and why not to do it

INTRODUCTION

Recently, I have witnessed a mildly increased interest in implementing the digital background music in the Dark Forces missions, what made me try collecting all required knowledge for it into a compact article. It's target are primarily the beginners of Dark Forces editing, though some of the editing veterans will possibly find some useful hints here as well. For those who are still completely unfamiliar with the world of sounds in Dark Forces, I would recommend to first take a look at my article Sound editing, also here at DF-21. Since the sampled music is completely controlled by INF, it is neccessary as well to understand its basics, so if that's not the case, take advantage of the lots of INF-teaching stuff available on this website.

CHOOSING THE MUSIC

The first task will be to find the music you would like to use for your mission. Choose something what fits the mission mood. It's not a bad idea to try playing your level while simultaneously playing the desired music using WinAmp or your hi-fi, to see if it adds to the atmosphere. Although there are no strict rules, keep in mind that the instrumentals proved to be a good choice. Be careful: great music can drastically improve the level, but a bad one can same as drastically ruin it. For example, a very suitable, atmospheric music can be heard in the Detention Center; the bad examples don't even have to be mentioned, as most of us have already played lots of missions with Secret Base music where it perfectly destroys the mood.

Once you have decided, convert the music to the Dark Forces VOC format and trim it to make it sound good when looped (that process is thoroughfully described in the "Sound editing" article). Do not make it too short, because if it will repeat often, it will very soon become annoying.

SETTING UP A TRACK

Now, let's implement the desired music VOC in the level. The first task will be to disable the original MIDI music present in the level. Although this could be done by the player turning the MIDI music volume down in the game options, much better is to apply the silent MIDI track made by Barry Brien, downloadable at DF-21. Add it to your GOB file, with the name appropriate to the level you are working on (STALK-??). That will keep the MIDI music silent throughout the mission, regardless of the actual volume setting in the game options.

The VOC music has to be played by the page INF command, as it is the only way to play a sound whose volume is constantly maximum, regardless of how far is the player from the source. To make the music loop correctly, you need an elevator that will continuously restart the music each time when it comes to the end. For accomplishing that, you also need to know exactly how long does your VOC music clip last, but any sound-editing software will display that if you open your music in it. Now create a simple music-controlling dummy sector. For example, if the music is saved as requiem.voc and lasts exactly 110 seconds, the dummy sector's INF should look approximately like this:

item: sector      name: music1
     seq
        class: elevator move_floor
        speed: 0
        stop: 0 1
        stop: 1 109
            page: 1 requiem.voc
       sound: 1 0
       sound: 2 0
       sound: 3 0
     seqend

Of course, you can name that sector however you want, and the floor altitude of the stops is irrelevant. The above sector will start playing the file requiem.voc in the first second of the game, and keep on restarting it every 110 seconds (1+109) afterwards. If your intention is to have one VOC music track throughout the whole mission, this one sector is all you need.

SEVERAL TRACKS

As we have seen, it is relatively simple to create a sampled background sound that will repeat itself continuously. However, you might want to change the sampled background music from one VOC to another, in a certain moment when the atmosphere calls for it. That is also possible, though it requires some tricks that take advantage of the Dark Forces sound engine's limitations.

Changing tracks consists of three steps: stopping the curent "music elevator", stopping the music being played currently, and starting the new music-controlling elevator. Stopping the elevator is no problem, all what has to be done is to send a master_off message to it. Let's take a look at the second step – stopping the VOC music currently being audible.

Unfortunately, INF does not offer an "un-page" command that could stop a VOC being currently played. Therefore, the only way to stop the sounds being currently played is to overload the channels. The sound engine of Dark Forces consists of 8 (or less if specified so in the Setup program) channels, what means that the game can play at most eight spearate VOCs at once. If all eight are occupied while a new sound has to be played, the engine will stop the "oldest" VOC being currently played (that is, the one that is played already for the longest time), and assign the new VOC to be played to its channel. In other words, the way to stop all currently played VOCs (including our music) is to overload the engine with too many (that is, eight or more) sounds at once.

The easiest way to do that is to create a dummy elevator which will, when activated, simply stop all the playing VOCs. We will also need a "dummy VOC" that consists of about a second or two of silence. It is no problem to create an empty wave file in any sound-editing software. It will be used to fill up all the available channels. After you have created a sector, create a following INF (let's say your 2-second-silence file is labeled silence.voc):

item: sector       name: musicstop
     seq
        class: elevator move_floor
        speed: 0
        stop: 0 hold
        stop: 1 0.1
          
page: 1 silence.voc
        stop: 2 0.1
           page: 2 silence.voc
       
stop: 3 0.1
           page: 3 silence.voc
        stop: 4 0.1
           page: 4 silence.voc
       
stop: 5 0.1
           page: 5 silence.voc
        stop: 6 0.1
           page: 6 silence.voc
        stop: 7 0.1
           page: 7 silence.voc
        stop: 8 0.1
           page: 8 silence.voc
        stop: 9 hold
       sound: 1 0
       sound: 2 0
       sound: 3 0
     seqend

All what needs to be done is to send the next_stop message to the elevator musicstop, and all the currently played sounds will stop. It might, of course, stop also the other sounds being played at that time (such as enemy or elevator sounds), but that is not a huge problem. Obviously, silence.voc does not need really need to be silent to accomplish its task, but I think that's still the best solution.

The third step is to start the new music track. It is relatively easy: build a separate sound-controlling dummy elevator for it, exactly like it was done for the first VOC track, but which includes a master: off line. To start the soundtrack, send the master_on message to it, and the second VOC will kick in.

You can repeat this mechanism as many times as you like, but keep in mind that the VOC music files are relatively large, so using many soundtracks might make your GOB really huge.

UNWANTED STOPS

Now it's easy to notice that your VOC music will stop also if jusy any eight sounds accidentally simultaneously occur during the game. Although there is no way to make your level always 100% protected from that, you can try reducing the chances to the minimum while designing the level: avoid too many ambient sounds or many elevators moving simultaneously, as they can occupy many channels. If you follow these two rules carefully, the unwanted "sound-breaks" shouldn't really ever occur during a normal gameplay.

STEREO AMBIENT

Although this is not directly related to the sampled background music, there is one sound trick in Dark Forces worth mentioning – stereo ambient sounds. Despite the fact that all the VOCs are mono, it is possible to take advantage of the stereo panning in the game. For example, the sound sources positioned on the left side of the player will be panned towards the left stereo channel in the loudspeakers or headphones.

If you split your stereo audio file into two mono files (that is, make a wavefile of a left channel and right channel separately), you can assign them to two independent dummy sound elevators that loop them continuously. If a player gets between those two sound elevators, the left dummy elevator (playing the left channel VOC) will be panned towards the left, and the same happens with the right channel. Result: the player will hear a stereo sound.

The stereo ambient will be really effective only if the player is aiming at the elevators with his sides; otherwise the both dummy elevators will be panned towards the center, what will remove a stereo feeling. You can somewhat avoid this problem by putting the dummy elevators in the halls, where you know which direction can you expect the player to face.

Needless to say, the left and the right channel dummy elevators should be well synchronised. Therefore, it's a good idea to have them both trigged by a same event, or even have a third dummy whose task is to simultaneously trig both of the stereo channel dummies.

WHY TO DO IT AND WHY NOT TO DO IT

Now, as we have seen how to deal with the sampled music in Dark Forces, you might be eager to use its advantages. But as we have seen, its usage is far from elegant. As a final word, maybe the following list of its advantages and disadvantages can help your decision:

WHY TO DO IT WHY NOT TO DO IT
1) The music choice is extremely large (MP3, CD, MC,...)
2) Unlimited number of possible tracks in a mission
3) Possibility to change the tracks directly through INF
4) MIDI music doesn't work on some newer computers
5) Easier to apply effects to a wave than to a GMD
1) Awful sound quality (11kHz, 8-bit, mono)
2) VOC music files are relatively large
3) Complicated track handling
4) Possibility of an unwanted sound-break
5) No volume control

I hope you found this article useful. If you have any questions, comments or remarks, please contact me through DF-21. Happy sampling!

Fish <*)>< Vienna, 2003