Importing Custom Sounds

Avatar
TripleG10
107 Posts
Posted Aug 24, 2011
Hello guys! I just wanted to know how to import custom sounds into a map, or at least into to portal 2 files. I've seen parts of some tutorials, but they all have very complicated methods involving the use of notepad. If there is no other way though, could someone provide a link to a good tutorial? OH and one more thing- does the sound have to be a specific file? I would like to use wav files, but if not I could hopefully convet it somehow...
Thanks in advance!
Advertisement
Registered users don’t see ads! Register now!
Avatar
Killerblonde
60 Posts
Posted Aug 24, 2011
Replied 1 hour later
Here's my method for importing custom sounds.

  1. First, get the sound that you want. If the sound is already a .wav file and has a rate of 44100 HZ, skip to step 4.
  2. Load the sound in audacity (free program, download here http://audacity.sourceforge.net/download/ ) and change rate to 44100 HZ.
  3. Export as a .wav file.
  4. Open up your portal 2 directory, go to sounds, and then make a folder called "custom" without the quotes, (or whatever name you want.) Stick the sound file in there.
  5. Open hammer editor, open your map, and make an ambient_generic with a trigger to make it play the sound.
  6. Go to the ambient generic, sound name property, and then it's either under raw or game sounds, (I can't remember.) Set the filter to "custom" without the quotes, (or whatever you called the folder,) and hit refresh sounds.
  7. Select your sound, listen to it to make sure it works and is the right one, and apply the changes. Compile your map.
  8. Launch Portal 2.
  9. Launch your map.
  10. Type in console "snd_rebuildsoundcache" without the quotes. Every time you add a new sound to Portal 2, you must do this. (So if you're planning on adding a bunch of sounds, put them all into the sounds folder, then run this command, instead of doing it for every single sound. It takes a few minutes.)
  11. Wait for it to complete.
  12. Your map will restart, and you custom sound should work!

I'm not a pro mapper, so if anyone finds something wrong with this tutorial, please say so. It should work though. Tell me how it turns out!

Avatar
Skotty
671 Posts
Posted Aug 25, 2011
Replied 13 hours later
Do what Killerblonde wrote, but stop with point 8. Don't start Portal.
If you would use the snd_rebuildsoundcache, you would have to do it every time again for a new sound and it wouldn't help if you want to share the map, because others won't have a rebuilded cache.
Use VPKs instead.
Read this: http://developer.valvesoftware.com/wiki ... rtal_2_Map
Now just pack your custom sounds into the VPK, keep the folder structure, and put your VPK to portal 2\portal2\addons\
If any new sound file is in a VPK, the game won't need any cache rebuilding and you can give anyone this VPK (in the final version with your map included) and everyone will hear the sounds by just starting the map :wink:
Avatar
TripleG10
107 Posts
Posted Aug 25, 2011
Replied 1 hour later
Thanks you two! This really helped me, as I've been recording and modifying my voice to put in some maps. Expect new ones soon!
Avatar
Killerblonde
60 Posts
Posted Aug 25, 2011
Replied 3 hours later
VPK's are the way to share your sounds, for sure. I guess they could work with testing your maps too, I never thought of that. I just stick all my custom stuff in there, and do the console command; VPK's I save for last.

Anyhow, thanks Skotty for offering a better way to do it. I'll look forward to hearing your beautiful voice TripleG10!

Avatar
Fracture
797 Posts
Posted Jun 08, 2012
Replied 9 months later
wouldnt pakrat work?
Avatar
Brainstone
401 Posts
Posted Jun 08, 2012
Replied 18 minutes later
Wait, wait, wait!

I thought anyone here agreed that .vpks were broken in Portal 2 since the appearance of DLC1. So it is impossible to get it to work, isn't it?

I have no experience with implementing custom sounds, but I was gonna do this, and I thought the only possibility would be to use pakrat to pak them into your map and then command "snd_updateaudiocache" instead of "snd_rebuildsoundcache".

Avatar
Lpfreaky90
2,842 Posts
Posted Jun 08, 2012
Replied 6 minutes later
the portal 2/portal2/addons won't help right now because of the bug
What you can do is create a portal 2/portal2_dlc3, name your vpk pak01_dir.vpk and put it in there.

Note it needs to be this folder and this file name.
Basically you're telling the game that there's new dlc :razz:

Avatar
Lpfreaky90
2,842 Posts
Posted Jun 08, 2012
Replied 2 minutes later

Brainstone wrote:
Wait, wait, wait!

I thought anyone here agreed that .vpks were broken in Portal 2 since the appearance of DLC1. So it is impossible to get it to work, isn't it?

I have no experience with implementing custom sounds, but I was gonna do this, and I thought the only possibility would be to use pakrat to pak them into your map and then command "snd_updateaudiocache" instead of "snd_rebuildsoundcache".

Note that this is a post from august 2011, before the dlc came out.

@Fracture:
The problem is with sounds in a bsp you need to rebuild the audio cache, if you would have read the previous posts you would've known.
Ps: Why are you bumping a thread from august 2011?

Avatar
greykarel
225 Posts
Posted Jun 08, 2012
Replied 5 hours later

Lpfreaky90 wrote:
The problem is with sounds in a bsp you need to rebuild the audio cache

Well, I must say something has changed.
In my last map Hard Light I used some Portal 1 glados lines. May be there is a better way, but I used it as custom
sounds (extracted .waw files from portal 1 .gcf, placed them in portal2/sound/hard_light). Hammer finds and
playes them ok, but in game I couldn't hear them until I packed them into .bsp with Pakrat. So I didn't rebuiled
sound cash (I just didn't know I should) and I don't think anyone who played the map did it, but the lines played for them allright.

Avatar
Skotty
671 Posts
Posted Jun 08, 2012
Replied 1 hour later
The reason could be: The sounds are loaded with the map, like they are cached with the map itself.
But I never tested this.
Avatar
Lpfreaky90
2,842 Posts
Posted Jun 08, 2012
Replied 57 minutes later

greykarel wrote:
Lpfreaky90 wrote:

The problem is with sounds in a bsp you need to rebuild the audio cache

Well, I must say something has changed.
In my last map Hard Light I used some Portal 1 glados lines. May be there is a better way, but I used it as custom
sounds (extracted .waw files from portal 1 .gcf, placed them in portal2/sound/hard_light). Hammer finds and
playes them ok, but in game I couldn't hear them until I packed them into .bsp with Pakrat. So I didn't rebuiled
sound cash (I just didn't know I should) and I don't think anyone who played the map did it, but the lines played for them allright.

I'm not entirely sure what the cache does, but if it says "this file is a song" it will still find the file, because it's still in the same (overwritten) location. If you add a new sound the cache needs to know which files are sounds again so you will need to re-build the cache.

Avatar
FelixGriffin
2,680 Posts
Posted Jun 08, 2012
Replied 10 minutes later
The cache holds the first 150 ms of each sound. Instead of loading all the files at once, that little bit should be long enough that it can load the rest once it starts playing.
Avatar
Fracture
797 Posts
Posted Jun 08, 2012
Replied 1 hour later
this is all one big headache to me @_@

I dont even know how to use VPK

Avatar
Lpfreaky90
2,842 Posts
Posted Jun 08, 2012
Replied 25 minutes later
Just read my post, and use vpk.exe in the portal 2/bin folder to create a vpk :wink:
Avatar
Fracture
797 Posts
Posted Jun 09, 2012
Replied 10 hours later

https://developer.valvesoftware.com/wik ... ng_the_VPK
I dont understand what they want to me to do on number 2

Avatar
Lpfreaky90
2,842 Posts
Posted Jun 09, 2012
Replied 3 hours later

Fracture wrote:
https://developer.valvesoftware.com/wiki/Releasing_A_Portal_2_Map#Creating_the_VPK
I dont understand what they want to me to do on number 2

simple if you want a texture, you place them in portal 2/portal2/materials/<>
If you want them in a vpk:
create a materials folder and then put the texture in the correct location

example:
portal 2/portal2/materials/lp/test.vmf should also go into
materials/lp/test.vmf in the vpk.

same for sounds
sounds/lp/test.wav should go to sounds/lp/test.wav in the vpk too.

Avatar
Fracture
797 Posts
Posted Jun 09, 2012
Replied 11 hours later
Okay i THINK I managed to cram it in there. I modified my first map for this and added the sound down in a ratman den. Let me know if it is working for you. I have a feeling I may have fudged it.

The Boxed Arm v.6

&

Avatar
falconfetus8
5 Posts
Posted Jun 12, 2012
Replied 3 days later
Is there any way to do that that's compatible with the steam workshop?
Advertisement
Registered users don’t see ads! Register now!
Avatar
spongylover123
944 Posts
Posted Jun 12, 2012
Replied 3 minutes later

pack it in the bsp. using pakrat or bspzip.

https://developer.valvesoftware.com/wiki/BSPZIP

https://developer.valvesoftware.com/wiki/Pakrat