Editing Music and Sounds

From Mod Wiki

Contents

S.T.A.L.K.E.R. Sound Basics

STALKER uses mono sound files (44.1khz, 16 bit, .ogg) which are separated into two different channels, Left and Right. However, the separated channel rule only applies to in game music. (Main Menu music, bar music, etc.) Weapons, weather, and everything else only uses one file.

S.T.A.L.K.E.R. Music

First, get a program that can convert your music from its current form to .wav, mono form, 44.1 kHz, 16 bit. Place it in X:\Program Files\X-Ray SDK\level_editor\rawdata\sounds (X for your drive letter) Now launch the level editor using the .bat file LevelEditor.bat and go to the sounds menu, sound editor. You may need to press refresh environment library for your sound to show up. The names are self explanatory, but for game music, select "World Ambient". Set the quality to 1.00, make sure the volume is 1.00 (You can adjust to make it higher or lower though) and press OK. It may take a moment for the editor to do its thing, so don't worry if your screen freezes. It will eventually come back, at that point you can properly close the editor.

Your finished piece of sound is now located in level_editor\gamedata\sounds. An extra step is needed if the piece of sound you just made is game music though. Add an _l to the end of the name of your song, so let's say song.ogg, now it's song_l.ogg. Now copy it, and make one called song_r.ogg. Now place them in your STALKER gamedata\sounds\music folder.

Sound Editor Settings

When you open the Sound Editor, found within the MP SDK Level Editor, you will see a small pop-up window:

Sound Editor pop-up window example.

Once you select a sound file, a list of attributes will be displayed in the right-hand side of the window. These attributes are what will be commented into the metadata of the finalized, compressed .ogg file for use within the game. Each of these attributes will have an impact on how the audio file will sound within the game, how NPCs will react to the sound and how the game engine will treat the sound as well.

Quality - this setting affects the overall audio quality of the compressed .ogg, and as well directly affects the file size of the audio file. The lower the value, the smaller the final file size will be, but at a much poorer audio quality level.

Min Dist - this is the minimum distance from the audio source, in meters, that the sound can be hear by the player at normal, full volume. As the player's distance from the audio source passes this minimum setting, the sound will start to fade out.

Max Dist - this is the maximum distance from the audio source, in meters, that the sound can still be heard by the player. Once the player passes this maximum setting, the sound will no longer be heard by the player at all.

Max AI Dist - this setting is the maximum distance from the audio source, in meters, that AI will "hear" and, if need be, react to the sound. Setting this value too high or too low can cause strange NPC behaviour and reactions.

Base Volume - the baseline volume setting for the sound. The game engine will adjust the sound volume higher or lower in-game based upon other sounds currently being played, and what types of sound they are.

Game Type - defines what type of sound the file is. Defining the audio type has a direct impact on how NPCs will react to the sound itself (e.g. setting "world ambient" will cause NPCs to ignore the sound, but setting the file as "NPC attacking" will cause NPCs to react if they're within the Max AI Dist setting). Also, the game appears to prioritize sounds based on their type, and certain types of sounds are more likely to be drowned out when the player is within range of many other sounds (e.g. "world ambient" sound volumes are lowered if there are many "weapon attacking" or "NPC attacking" sounds being played at the same time).

Attenuation - this diagram can not be directly edited, it's simply a line graph used to give a visual example of how the sound will be attenuated (faded out over distance). To the upper-left of the graph is where the sound will still be played at full volume; at the point that the line starts to fall and curve towards the bottom right, is representative of the "Min Dist" setting. The bottom right is representative of the "Max Dist" setting, and height of the line, relative to the bottom of the graph, represents the lowest volume that the sound will be played at when the player is furthest away from the audio source. If the line ends at the very bottom right corner, it will fade out naturally - if the line is above the bottom corner, the sound will still be quite audible at it's maximum distance, which will have the result of the sound just "cutting out."

Auto Att - these two buttons will automatically set either the "Min Dist" or "Max Dist" setting, based upon their opposite setting, to have the sound gradually fade out naturally. Selecting By Min will set the "Max Dist" based upon the value entered for "Min Dist." Selecting By Max will set the "Min Dist" based upon the value entered or "Max Dist."

File Length - after having converted the audio file from .wav to .ogg, this will display the file size, in Kb, of the commented, finalized .ogg

Total Time - after having converted the audio file from .wav to .ogg, this will display the total play length of the commented, finalized .ogg

Control - after having converted the audio file to .ogg, these buttons will allow for sampling how the finalized .ogg will sound. Play will play the file from it's beginning, Stop will stop the audio playback.

Auto Play - if set to On, will automatically start playback of an audio file once selected, and if has already been converted to .ogg. If set to Off, auto playback is prevented.

CS SDK Sound Editor

CS SDK Sound Editor pop-up window example.

The CS SDK brings a few small changes for the Sound Editor, and there have also been some changes to folder directories. Raw .wav sounds should be placed in x:\\...\X-Ray SDK_CS\editors\rawdata\sounds\ and the converted .ogg files will be found in x:\\...\X-Ray SDK_CS\editors\gamedata\sounds\

The CS SDK Sound Editor can now process 2-channel stereo sounds without causing errors, but the raw but .wav sounds should still adhere to the 16-bit/44.1kHz format. Stereo .ogg files are for use as some ambient background, level music and engine-called sounds in Clear Sky.

A new button is now available in the Sound Editor pop-up window:

MANAGE - by clicking on the button labeled SyncCurrent, the Sound Editor will process any changes that have been made to the above comment settings, and convert and comment the audio file without closing the Sound Editor window.

Script and LTX Editing

Now we have the music done, but we need to tell the game to use it. If you just made ambient music for a level, all you'll need to do is edit game_levels_music.ltx, located in your gamedata\config folder. However, if you want the music to appear at the bar or over loud speakers, you'll need to edit a script file called sound_theme.script, located in gamedata\scripts.

To make your sound appear as a level ambient, just add the name of your music under the other musics in the specified level (Without the _l or _r, so you would add just song to the list if your music name was song.)

Example Code:

The numbers shown are the coordinates. The ones highlighted put the music in the center of the level, which can be heard within the range you specified in the level editor.

Clarification of values in game_levels_music.ltx:

[level_name]
file_path\sound_name = (hour of day to start playing level music), (hour of day to stop playing level music), (level music base volume), (unknown value), (unknown value)

For script editing, just look around the file and decipher what does what, most of the time the code refers to self-explanatory situations.

Example Code:

In this example I placed two music files, song_l.ogg and song_r.ogg into gamedata\sounds\characters_voice\scenario\bar\radio_music, then referred to it as song in the script. Now, whenever I am in the bar there is a chance that my new music will be randomly selected to be played.