I'm writing this Outline because it seems that there are alot of posts about this topic due to unclear previous Tutorials.
There are a couple different ways you can add sounds to your map, both .wav and .mp3. The following is only one way to do it. I'm going to show you how to add one of each in this tutorial. If any of this tutorial shows to be untrue, please post and correct it.
For reference, there are specifics your sounds should be before even beginning this tutorial. If your using any Default COD sounds, they will work fine, but any sounds outside of the game should be double checked to have the following properties.
-----
Wave Files = 44,100hz, 16 Bit, Mono, Uncompressed
Wave Files = 22,050hz, 16 Bit, Mono, Uncompressed
MP3 Files = VBR, 22,050hz, Stereo, MPEG Layer-3
MP3 Files = VBR, 44,100hz, Stereo, MPEG Layer-3
MP3 Files = 320-192, 44,100hz, Stereo, MPEG Layer-3
Wav files need to be Mono.
MP3 files can be VBR or 320 or anything under 320.
-----
Some things to think about!
- How do I want my sound to play in my map?
- As Ambience?
- As player triggered by using a radius?
Please NOTE that in this Tutorial, the name of the Example map will be called "mp_swamp"
----------
Section 1
----------
Files needed for this tutorial.
- mp_swamp.gsc -----> located in ( raw\maps\mp\mp_swamp.gsc )
- mp_swamp_soundfx.gsc -----> located in ( raw\maps\mp\mp_swamp_soundfx.gsc )
- mp_swamp.csv -----> located in ( raw\soundaliases\mp_swamp.csv )
Two of these files don't exist yet, you will create them later.
Once you have your sound files picked out you need to find a place for them, so your game can call them. If your using sounds not from COD4, then you must pack them in your .FF file. If you are using sounds from the COD4 game then you need to note their path.
I'm going to begin with a .wav file. This first file I'm using as example is a .wav file called
crickets.wav This file has the properties of
22,050hz, 16 Bit, Mono, Uncompressed. I'm going to place this file into the following path:
raw\sound\my_sounds. All I did was make a folder called my_sounds in the sounds dir. You can make any name you want for this folder.
Now I have a forest in my map, so I want the crickets to only play when a player is in the forest or near it. So the first thing I'm going to do is get some ( x,y,z ) coordinates from Radiant, so my sound has an Origin to emit itself from. Looking at my forest I right click the 2D screen and say
script/origin. You will notice an orange colored box appears. This will be our reference of where the sound will play from. I'm going to place this box near the terrain level, and in the middle of the forest. Remember, this script_origin is only used as a reference, it doesn't do anything other than help you remember where your sound is playing. Once you find where you want the sound to play from, press the
N key to bring up your Entity Editor. Note those (x,y,z) coordinates. Mine are:
2206.5, 3704.5, 233.
Note those coordinates. Now you want to know how large is your bubble for the player to be able to hear this sound from. A good way to do this is to use a
light. Right click your 2D screen and choose:
light. Move this light to the exact position of your script_origin you placed earlier. Hit the
N key to open your Entity Editor, and scroll down in the window till you see the lights properties of
radius. Since my forest is pretty large, I want my sound to start playing a little bit outside the forest, so that the crickets slowly get louder the closer I get to the forest. I'm going to change the default radius value of 200 to
700, so I can see about how bit the radius of the sound would be. You do not need to save your map with the light in it. The light is only used so we can find a good size radius to play our sound from. You can delete it once you find a good radius. You can save your map though if you like with your script_origin in it, it won't hurt.
Note the size of your radius and your x,y,z.
Radius = 700
x,y,z = 2206.5, 3704.5, 233
Now we are done in Radiant.
----------
Section 2
----------
Let's get our files together now. You will need to start with creating a file called:
mp_swamp.csv. Name it your map though! Navigate to "raw\soundaliases" and copy the file called
multiplayer.csv. Rename this copy to your map name. I will rename mine to
mp_swamp.csv. Open file with MS Excel.
Line 38 says # User Interface. highlight this line and everything below this line and delete it so the document is empty besides everything above this line. Once done, you have just created a soundalias file for your map. From here we can use this file to define sounds for our map to play.
Let's begin by adding our first sound. The crickets. Under
name I'm going to select the empty line 38 and give my sound an alias or nickname. I can call this sound anything I want, but to make it simple, I'll just call it
cricket_chirp.
NOTE: If you notice at the top of this document, each column is defined, what it does, and possible values can be added that the game understands.
So I have my alias defined now, I need to go to the
file column now and tell the game where my sound file is. Since I created a folder earlier called
my_sounds, I will add the following information into the space:
my_sounds/crickets.wav. Continue down the line to add the following values under the specified columns for your sound. Only fill in the headers I have here, leave the rest blank. Just change the NAME and FILE to fit your sound.
name
cricket_chirp
file
my_sounds/crickets.wav
vol_min
0.99
vol_max
1
vol_mod
element
pitch_min
0.95
pitch_max
1.05
dist_min
7
dist_max
700
channel
element
loop
looping
masterslave
0.5
loadspec
all_mp
startdelay
250
lfe percentage
0.2
If you notice under the header "dist_max" I put in the radius I found earlier here of 700. Outside this distance in inches, the sound is not started. If left blank or set to 0, the sound will play from any distance.
Ok, so now we have our alias set up for this sound. If your sound needs to be ambient (meaning everywhere), then change "vol_mod
element" to "vol_mod
ambience" and then change "channel
element" to "channel
ambient". If your sound is an MP3, then under the header "type" it needs to say
streamed.
Save this document and close. This document should be in "raw\soundaliases".
Now we need to make one more file. The file called:
mp_swamp_soundfx.gsc. Create this file in ( raw\maps\mp\mp_swamp_soundfx.gsc ). Make a new .txt file and then change the extension to .gsc. Place the following information into this new file:
Code:
main()
{
precacheFX();
ambientFX();
}
precacheFX()
{
}
ambientFX()
{
//My Forest Sounds
maps\mp\_fx::loopSound("cricket_chirp", (2206.5, 3704.5, 233), 1);
}
Here in this file I'm defining where my sound is going to play from. Here you will change "cricket_chirp" to your alias. and change the x,y,z coordinates to your own that you found earlier with your script_origin. The "1" at the end is the delay, can be anything greater than or equal to 1 I believe. Once you get one sound working you can copy this line and edit the line to add more sounds to your map that are being used by a player radius. Start with one sound and get one sound working then add more after. Save this file and close
----------
Section 3
----------
Open your file called:
mp_swamp.gsc. Your map of course. Located in (raw\maps\mp\mp_swamp.gsc). At the top of this file you need to call the soundfx file you just created. Call it like this, by adding this line.
Code:
maps\mp\mp_swamp_soundfx::main();
Save and Close.
Now go to your compiler and click
Update Zone File and add the following lines to your zone file.
Code:
sound,mp_swamp,,all_mp
rawfile,maps/mp/mp_swamp_soundfx.gsc
rawfile,sound/my_sounds/crickets.wav
SAVE.
If you notice any files added to your map, you need to call in the zone file. Only Mp3's don't need to be added because the aren't going to be packed into our .ff file. I'm also telling the map to play ALL SOUNDS in my soundalias to play in my map with the line: "sound,mp_swamp,,all_mp".
Now run your map, and see if the sound you did worked. Good LUCK!
If you get errors, you'll need to post them.
--------------
MP3 Sounds
--------------
Everything is the same, by following the same idea above, but your .mp3 needs to be placed in your map.iwd, with the same file structure defined in your alias. If the .mp3 was called "crickets.mp3" then in my .iwd I would have to make folders with the path of "sound\my_sounds\crickets.mp3". Mp3's do not get called in the zone file, and only gets placed in your .iwd. The only way to hear your .mp3 is to use your .iwd when running your map, obviously.
I hope I gave a decent outline for getting sounds to work in an MP map. Good luck guys, and I hope this is clear and simple.