L4D Custom Music Tutorial: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Rewrite due to secondary method discovery, which avoids nearly all the major drawback issues.)
Line 1: Line 1:
{{toc-right}}
{{toc-right}}


There are 7 steps to adding custom music to your campaign in Left 4 Dead:  
This tutorial will go over how to customize the Music Director for your campaign using the mymapname_level_sounds.txt file.
If you are planning on creating custom soundscripts as well, you should still follow this tutorial and append those scripts to the level_sounds.txt.
 
There is 2 methods for adding custom music to your campaign.
 
== PAKRAT Method ==
This method is the easyest, but often will lead to a much larger VPK file size due to duplicated WAV files across multiple BSPs as well you will need to repackadge your sounds after every map compile.
Use this method if you only have a few custom sound files or they are not used on multiple maps within your campaign.
 
There are 7 steps to this method of adding custom music to your campaign:  


# Create a text file called [your_exact_map_name]_level_sounds.txt in your addons maps directory.
# Create a text file called [your_exact_map_name]_level_sounds.txt in your addons maps directory.
Line 11: Line 20:
# Packadge your campaign into a [[L4D Campaign Add-on Tutorial|VPK]] and test it out ingame, your custom music should work!
# Packadge your campaign into a [[L4D Campaign Add-on Tutorial|VPK]] and test it out ingame, your custom music should work!


== _Master.Cache Method ==
This method is more size efficient since you won't be storing files within BSPs. As well when you recompile your maps during development, you wont need to repakadge custom sounds.
Unfortunately due to a bug with the VPK system, this method requires that your campaign be they very first campaign played when players load Left 4 Dead as once the game engine loads a campaigns cache file, it won't bother loading any others until the game is restarted.
{{Note|Valve is aware of this issue, and it may be fixed with the Match Making update coming out shortly after the Crash Course DLC}}
Use this method if you have tons of custom sounds/music that is used across multiple maps and you want to maintain a small VPK size.
There are 9 steps to this method of adding custom music to your campaign:
# Create a text file called [your_exact_map_name]_level_sounds.txt in your addons maps directory.
# Copy ALL the contents from my example soundscript into that file.
# In the missions file of your addon, find the NAME parameter, and pick a short name that has no spaces.
# In notepad, press CTRL + H, to find and replace XXXXX with the same name you used in missions.txt NAME field.
# Begin replacing any wav files you choose in the script to reference your own files. (Do not include sounds/ in the paths, it's assumed)
# Load up Left 4 Dead and turn off all addons except the one you are working on. (Other campaigns custom sounds will screw this step up if you don't)
# In the console, enter snd_rebuildaudiocache and wait about 5 mins for it to finish.
# Copy the _master.cache file from your maps/soundcache, place it in your addons maps/soundcache directory.
# Packadge your campaign into a [[L4D Campaign Add-on Tutorial|VPK]] and test it out ingame, your custom music should work!
{{Note|You will need to repeat the snd_rebuild steps whenever you add new sound files.}}
{{Note|Your campaign maps should have a valid nav mesh for many soundscript events to work properly.}}
{{Note|Your campaign maps should have a valid nav mesh for many soundscript events to work properly.}}


Line 18: Line 46:


It is a stripped version of the game_sounds_music.txt to only include the Events you need to edit for your campaign.
It is a stripped version of the game_sounds_music.txt to only include the Events you need to edit for your campaign.
Using it fixes a bug with soundscripts where zombies would play an alarm sound when killed with fire, amongst other things.
Using it fixes a bug with soundscripts where zombies would play an alarm sound when killed with fire.
It is also highly commented allowing a greater insight into what each section is for when deciding on what to change.
It is also highly commented allowing a greater insight into what each section is for when deciding on what to change.


Line 35: Line 63:
[[Image:L4dmissions2.jpg|center|500px]]
[[Image:L4dmissions2.jpg|center|500px]]


A custom intro song that we will call 'thriller.wav' correctly pathed and added into the bsp would look like this:
A custom intro song that we will call 'thriller.wav' when using method 1, correctly pathed and added into the bsp would look like this:
[[Image:L4dPakrat.jpg|center|500px]]
[[Image:L4dPakrat.jpg|center|500px]]


Heres how your sound script would look properly edited to make use of thriller.wav
Heres how your sound script would look properly edited to make use of thriller.wav
[[Image:L4dsoundscript.jpg‎|center|500px]]
[[Image:L4dsoundscript.jpg‎|center|500px]]
== Major Drawbacks ==
Unfortunately you must include custom music wav files in EVERY bsp that is part of your campaign.
This is due to technical issue with how sounds are handled in L4D that was introduced to the game a few weeks before release.
The only way to go around this is to store your sound files in the VPK's sound directory and request that downloaders of your campaign run the console command snd_rebuildaudiocache. This is not optimal, as many players will never run the command, it takes 5 mins to run if they do, and it overwrites sound manifest files on their client.
{{Tip|There is a potential work around to this. You may include sounds in your normal 'sounds' directory within your addon there by avoiding having to replicate sounds with every map. Simply use snd_rebuildaudiocache after you setup the soundscript and have all your wav's in their proper directorys 'outside' of the BSP. This will cause your _master.cache file to get updated. Simply include this file within your addon VPK. Your sounds will work without clients needing to type obscure commands, and without having to replicate sounds across BSP's. The drawback is that any campaign played that also doesn't include it's own _master.cache file will use yours instead if they just recently played your campaign. (Resets when they restart the game.)}}
The L4D SDK team is aware of both these sound issues, there is no ETA on when either technique will be fixed.
You must ALSO make a copy of the sound script file itself renamed to the same name of each of your bsp's in your campaign. As each map will reference only the script that has the same name as the map.
Custom soundscripts seem to only work when packadged completely as a VPK. Simply running off the addon folder isn't sufficient. This makes testing quick changes more cumbersome.


== See also ==
== See also ==

Revision as of 21:39, 16 September 2009

This tutorial will go over how to customize the Music Director for your campaign using the mymapname_level_sounds.txt file. If you are planning on creating custom soundscripts as well, you should still follow this tutorial and append those scripts to the level_sounds.txt.

There is 2 methods for adding custom music to your campaign.

PAKRAT Method

This method is the easyest, but often will lead to a much larger VPK file size due to duplicated WAV files across multiple BSPs as well you will need to repackadge your sounds after every map compile. Use this method if you only have a few custom sound files or they are not used on multiple maps within your campaign.

There are 7 steps to this method of adding custom music to your campaign:

  1. Create a text file called [your_exact_map_name]_level_sounds.txt in your addons maps directory.
  2. Copy ALL the contents from my example soundscript into that file.
  3. In the missions file of your addon, find the NAME parameter, and pick a short name that has no spaces.
  4. In notepad, press CTRL + H, to find and replace XXXXX with the same name you used in missions.txt NAME field.
  5. Begin replacing any wav files you choose in the script to reference your own files. (Do not include sounds/ in the paths, it's assumed)
  6. BSPZIP or Pakrat your custom music into the map .bsp file. (The paths for each wav file within the bsp should be sounds/music/your_custom_folder)
  7. Packadge your campaign into a VPK and test it out ingame, your custom music should work!

_Master.Cache Method

This method is more size efficient since you won't be storing files within BSPs. As well when you recompile your maps during development, you wont need to repakadge custom sounds. Unfortunately due to a bug with the VPK system, this method requires that your campaign be they very first campaign played when players load Left 4 Dead as once the game engine loads a campaigns cache file, it won't bother loading any others until the game is restarted.

Note.pngNote:Valve is aware of this issue, and it may be fixed with the Match Making update coming out shortly after the Crash Course DLC

Use this method if you have tons of custom sounds/music that is used across multiple maps and you want to maintain a small VPK size.

There are 9 steps to this method of adding custom music to your campaign:

  1. Create a text file called [your_exact_map_name]_level_sounds.txt in your addons maps directory.
  2. Copy ALL the contents from my example soundscript into that file.
  3. In the missions file of your addon, find the NAME parameter, and pick a short name that has no spaces.
  4. In notepad, press CTRL + H, to find and replace XXXXX with the same name you used in missions.txt NAME field.
  5. Begin replacing any wav files you choose in the script to reference your own files. (Do not include sounds/ in the paths, it's assumed)
  6. Load up Left 4 Dead and turn off all addons except the one you are working on. (Other campaigns custom sounds will screw this step up if you don't)
  7. In the console, enter snd_rebuildaudiocache and wait about 5 mins for it to finish.
  8. Copy the _master.cache file from your maps/soundcache, place it in your addons maps/soundcache directory.
  9. Packadge your campaign into a VPK and test it out ingame, your custom music should work!
Note.pngNote:You will need to repeat the snd_rebuild steps whenever you add new sound files.
Note.pngNote:Your campaign maps should have a valid nav mesh for many soundscript events to work properly.

Custom Music Script File

This is the example soundscript you need to copy.

It is a stripped version of the game_sounds_music.txt to only include the Events you need to edit for your campaign. Using it fixes a bug with soundscripts where zombies would play an alarm sound when killed with fire. It is also highly commented allowing a greater insight into what each section is for when deciding on what to change.

You may also opt not to change anything in the file, which will give your campaign the default music cues associated with the Airport campaign.

http://www.evolvedant.com/soundscript/example_script.zip

Note.pngNote:There was a slight typo in the previous file.. if intro music wasn't working for you, redownload this file.

Example Tips

If your campaign is called 'Awesome' and contains maps such as l4d_awesome_forest, l4d_awesome_campsite, etc... Your addons maps directory should contain l4d_awesome_forest_level_sounds.txt

L4dMapDir.jpg

The NAME parameter in your missions.txt would be 'awesome' and look like this:

L4dmissions2.jpg

A custom intro song that we will call 'thriller.wav' when using method 1, correctly pathed and added into the bsp would look like this:

L4dPakrat.jpg

Heres how your sound script would look properly edited to make use of thriller.wav

L4dsoundscript.jpg

See also