Custom Sounds in a Map

- By Raeven0
This tutorial was last updated on Aug 16, 2005.

Let's add a custom sound to our map. To be used as music from a radio, perhaps, or a siren.

If your sound is on a CD (as songs tend to be), rip it. Note that distributing the song with your map is most certainly a violation of copyright law. Don't blame me if agents from the music industry show up at your front stoop.

A good audio editor is necessary for this. Audacity is my favorite, and it's free, but it can't be used to make sounds loop. GoldWave is also free and good, and it can make sounds loop. Windows Sound Recorder can be used, but it can't save MP3s and can't make a sound loop.

The sound file must be saved in the right format in order for HL2 to play it. Use your chosen sound editor to save the sound (usually File --> Save As) as either a standard PCM WAV file, with whatever properties you want, or an MP3 with a sample rate of at most 44.1KHz. The MP3 will generally result in a smaller file, but it will take extra work to make it loop infinitely. Use your discretion when deciding whether your sound is too long; if you think it is, it probably is. Lower the quality of the WAV/MP3 to compensate, or just make the sound shorter.

If you want the sound to play once, not loop, then simply save the file to some subdirectory of Steam/SteamApps/<account>/<game>/<mod>/sound (you will need to create the sound folder if it does not exist). For instance, I could have a file E:\Steam\SteamApps\Raeven0\half-life 2\hl2\sound\rae\s3.wav.

Next, either restart Hammer or choose "Reload Sounds" from the File menu. Place an ambient_generic entity in your map, and select the Sound Name property. Opt to Browse, set the Sound Type to "Raw," and enter part of the sound name in the Filter field. Select your sound and click Ok.



Modify the properties of the ambient_generic as you see fit. I recommend checking the Start Silent and Is NOT Looped flags.

All you need, then, is for the sound to be played by some act of entity I/O. If you give the ambient_generic a name, you can use a trigger_multiple or pretty much any other entity to send it a PlaySound input, which will cause the sound to be played.

If you want the sound to loop, and it's a WAV, you will need to add a cue point to the file. In GoldWave, under the Tool menu, there is a Cue Points feature with which you can create a New... cue point At Start (most positions should work, but the start is convenient) with any name you like. Save the WAV with the cue point and uncheck the ambient_generic's Is NOT Looped flag. You will find that the sound now loops infinitely in-game.

If you want the sound to loop, and it's an MP3, you'll have to make a logic_timer with a refire delay equal to the length of the sound. Add this output to the logic_timer:

- output OnTimer; target NameOfAmbientGeneric; input PlaySound

The logic_timer will force the ambient_generic to play every [Refire Interval] seconds.

This custom sound will need to be embedded into the BSP or otherwise forced onto the client's computer whether it's set to loop or not.



Still need help? Ask your questions in one of our HELP FORUMS
Post A Comment
Name:
Email: Links Not Allowed In Comments
Comment:
What is the capital of France? Need Help?
Comments
jngdwe - Aug 4, 2010
My mp3 won't loop with the logic_timer. any help?
Troy - Apr 25, 2010
FUCK COPYRIGHT LAWS!
Liane - Mar 27, 2010
Quote:

"haha the copyright thing.. I had like 4 songs on my map So I made a spray that said "I only made the map and in no way am i associatable or taking credit for the music, the artists are to take full credit for the songs." And posted it like 4 spots on my map... think that'll take care of that? lawl"

- Actually no. No matter how much you disclaim that it is your music, you are still violating copyright law, as you are using something that isn't yours and is copyrighted. They only right way to do it, is for the owners to give you the rights, and you can freely use it in anyway you want to.

However, if you are using it in a map that you do not earn any kind of profit on, but only play with your friends, it is possibly as close as you can get to legal. However, putting in commercials for any website in the map, WITH the copyrighted song, can give a serious bunch of fucking problems.

If you earn any profit on the map, like someone payed you to make the map, and you use a copyrighted song, you're screwed if they find out. Trust me they will.. :-x
Thizda - Jan 19, 2009
Hey thx for the gr8 tut, why does it have to be a .wav?
lol...
h4xo|2 - Aug 3, 2008
haha the copyright thing.. I had like 4 songs on my map So I made a spray that said "I only made the map and in no way am i associatable or taking credit for the music, the artists are to take full credit for the songs." And posted it like 4 spots on my map... think that'll take care of that? lawl
Ben Gough - Mar 16, 2008
I have done that you have said i have a wav file at 44.1Khz and its is in the file /steamapps/name/halflife2/hl2/sound but its wont apear in my sdk please help
[11 extra comments]
All original content ©2006 EditLife.net. All Rights reserved. All files property of their rightful owners.
Get Firefox! Get Thunderbird! Get Notepad++!