Portal 2

Portal 2

Not enough ratings
p0rtalmaster's Hammer Guide Series Part 03/19
By The Sojourner
Hello and welcome to part 03/19 of my series of mini-guides, designed to help you learn perhaps what is the biggest part of the Portal 2 Authoring tools: Hammer.

For a super-quick version of this series, please check out my other guide, Hammer for the Flustered.
   
Award
Favorite
Favorited
Unfavorite
Intro
This guide focuses on the sound aspects of the game. There are three main entities used to deliver sound:
  • ambient_generic
  • env_soundscape
  • logic_choreographed_scene
ambient_generic: the Main Sound Emitter
When in doubt, use this. It can play looping sounds, non-looping sounds, everywhere or from some point in your map (either the location of the entity itself or another object). As the title implies, it's useful or all sorts of sounds: explosions, stingers, special effects, music, voice, or even background sounds.

The two most common sound types I've heard out of Hammer maps are music and voice. Character voice is often controlled best with a logic_choreographed_scene (and a custom-made VCD file if you can script well). Music on the other hand really is fit for an ambient_generic. The only downside is that the in-game music slider will be broken. Even if you try to hide the sound inside one of those "game sounds," the script won't work even when you embed the game_sounds_manifest.txt file into your map, and thus the slider will still not work. The fixed solution involves the sv_soundemitter_flush command and a point_servercommand triggered by a logic_auto.

The ambient_generic entity has some options, including a "volume" and "pitch" option. A good starting point for volume is 5 or 6, NOT the default maximum of 10. This is yet another very common mistake! It is also not recommended to double up on the same sound perhaps in an effort to blow our speakers out.

To control the sound, give the ambient_generic a name, and use the PlaySound and StopSound inputs, typically controlled from something like the press of a button, or a trigger_once or trigger_multiple (common brush entities). Common looping sounds include background noises and music. If you use these, make sure that the "Start Silent" flag is checked, otherwise the looping sound will be uncontrollable.

If you want to use custom music, it is recommended that you consult josepezdj, as he came up with a fix for the problem of getting customg music to work in workshop maps. He'll tell you the secrets of soundscripts, so that you can make musical laser catchers/relays and faith plates that sync up with each other or the background music. He'll also point you in the right direction for musical sounds for hard light bridges and excursion funnels. If you already have a soundscript ready, here's a quick tip: use the console command sv_soundemitter_flush via a point_servercommand before using your game sounds. This will force the game engine to load your embedded soundscript.
env_soundscape Gives Off a Nice Feel in Your Map
This entity is neglected far more than it should be, and it's not even that hard to use! All you have to do is place one somewhere in your map where the player will enter its radius, and then the soundscape will play.

Why soundscapes, you may ask? First and foremost, a soundscape gives off a sense of realism — a sense of liveliness among Aperture. Can you imagine what Portal 2 would sound like without soundscapes? There would be moments of dead silence, as if the laboratory is somehow not operating like it should — it would be boring. Second, soundscapes are also much easier to use than a whole bunch of ambient_generics. Third, there are more soundscapes than there are musical pieces in Portal 2. Music is optional, and often omitted in test chambers, but soundscapes are a must-have.

Not sure where to begin? Try looking in the "scripts" directory for soundscapes (the relevant files will be headed with "soundscapes") or on the VDC Wiki. They can be tested individually via the playsoundscape console command.

Try it: build an empty room and place an env_soundscape near the player. Set the soundscape to room02.start, compile/run the map and listen. What do you hear?... Now type playsoundscape Nothing into the console. What do you hear now? Did you hear the soundscape transition to dead silence? Now try playsoundscape ug_cave_int_03 (type it into the console and hit Enter). Does this soundscape sound familiar? Where in the game did you hear it (there are several places)?

Now try this: move the env_soundscape in the empty room away from the player, but somewhere where you'll know where to go. Now compile/run the map and listen. Dead silence again, right? Now carefully approach the soundscape. As you get closer, at some point, you should hear the soundscape start up. This is how to change soundscapes.

You can also change soundscapes by using an env_soundscape_triggerable (point entity) and a trigger_soundscape (brush entity). Just be sure to name the former entity so that the trigger can refer to it.

How many soundscapes are needed per map? Generally, you'll only need one or two soundscapes for each puzzle map, 2-3 for underground-themed maps or large and divided test chambers. Maps outside of the testing spheres or test chambers generally have at least 4 different soundscapes. It's also a good idea to think about where the player can go and which soundscape you want to play in a certain area, as the number of soundscapes does not necessarily correalate to the number of env_soundscape entities that you'll need. I only used about 4 soundscapes for my map Still an Important Part of Science, but there were more than 8 env_soundscape entities, each of a different radius.
Creating Custom Soundscapes
The basic format for soundscapes is this:

"<soundscape name here>"
{
"dsp" "1" // can be changed, but never is in Portal 2.
"fadetime" "1" // can also be changed. Controls the time it takes for the soundscape to (cross)fade in.

// soundscape stuff goes here
}

There are three basic rules in use for Portal 2 soundscapes: playlooping, playrandom, and playsoundscape.
  • playlooping plays background looping noises, such as wind or water sounds (or in the case of Portal 2, constantly running background machinery).
  • playrandom is used to add some random variation to otherwise boring background loops. For example, all those various metal clangs in Portal 2, as well as the bird sounds heard in the overgrown chambers.
  • playsoundscape simply plays another soundscape at a specified volume. It's often used for a mild layer of abstraction. Valve often created a soundscape of just random sounds, and then used this to (re)use the soundscape in others with a playlooping background sound.

Here are the basic formats for each one:

"playlooping"
{
"volume" "<number from 0.00 to 1.00>"
"pitch" "<number from 1 to 255*>"
"wave" "<name of a wave sound in the game's repository — check the sound browser in Hammer**>"
"origin" "<X, Y, Z>;"
"soundlevel" "SNDLVL_<multiple of 5>dB"
}

NB the last two attributes are only if you don't want the sound to play everywhere, such as the sound for a deadly goo/slime/acid pit. Most of the time you'll want to omit these attributes.

"playrandom"
{
"volume" "<lower bound>, <upper bound>" // these are numbers from 0.00 to 1.00
"pitch" "<lower bound>, <upper bound>" // these are numbers from 1 to 255*
"time" "<lower bound>, <upper bound>" // these are times, in seconds, between played sounds, shorter ones meaning that overlap may be possible (not a bad thing).
"position" "random" // optional but often used

"rndwave"
{
"wave" "<wave sound 1**>"
"wave" "<wave sound 2**>"
"wave" "<wave sound 3**>"
// etc.
}
}


"playsoundscape"
{
"name" "<name of a soundscape, yours or Valve's>"
"volume" "<number from 0.00 to 1.00>"
}


*100 plays the sound as its original pitch. 95-105 is often useful a useful range for playrandom, but other possibilities exist. You can also use this to transpose music sounds too.

**Many good sounds used for soundscapes are located in the "ambient" or "playonce/ambient" directories in the Sound Browser (make sure you have "Raw" selected to preview them fresh).
logic_choreographed_scene: Make GLaDOS and Wheatley Talk and Move
This entity also does sound, but it also does more. For example, it makes Wheatley move on his screens — something an ambient_generic fails to do. It can make GLaDOS move in her chamber without having to use a bunch of logic_relays and ambient_generics (which don't always guarantee synchronization). If you have only voice lines, then you might be able to get away with ambient_generic, but logic_choreographed_scene works well too.

logic_choreographed_scenes don't run on sound files or game sounds. They run on specialized script files called VCD files (Valve Choreography Data). I won't go over how to make one, as scripting these is not an easy task — even making a custom soundscape is easier. However, if you know what you're doing, you can write your own custom VCD files and embed them into workshop maps and they should work OK (assuming they are properly embedded, put into the "scenes" folder).

To control these entities, give them a name and simply use the Start input, typically controlled from something like the press of a button, or a trigger_once or trigger_multiple (common brush entities). Be wary of using multiple logic_choreographed_scenes though, because if they are triggered simultaneously, in succession, then there will be a slight, awkward pause between the voice lines or scenes.
Mistakes to Avoid & More Information

  • The biggest mistake of all is not to use a soundscape. PLEASE ADD ONE!! IT WILL MAKE YOUR LEVEL FEEL MORE ALIVE IF YOU DO!
  • Using sounds that are too loud. Crank down the volume on those ambient_generics to about 5 and don't use multiple ambient_generics to double up on sound! It may also help to use game sounds instead of "raw sounds." Game sounds are coded to add special variations too.
  • Sometimes, using an ambient_generic instead of a logic_choreographed_scene can be detrimental, especially (for example) if we can see Wheatley and/or GLaDOS.

More information from the VDC Wiki:I thought I'd provide some deeper detail about what each of the categories on this page (the list of soundscapes) is. First off, some soundscapes just contain random sounds — so-called "utility" soundscapes. They weren't designed to be played up-front, but instead they were meant to supplement other soundscapes with looping sounds. So, unless otherwise noted, use of "utility" soundscapes is discouraged.
  • TestChamber_Destruction: these soundscapes were used in the overgrown chambers. The following are "utility" soundscapes:
    • TestChamber_Destruction.DestructionBase
    • TestChamber_Destruction.DestructionBeauty
    • Testchamber_Destruction.Grain_Click
    • TestChamber_Destruction.MetalGroan_01
    • TestChamber_Destruction.MetalPipe_01
    • TestChamber_Destruction.WaterDrip_01
    • TestChamber_Destruction.WindEerie_01 (this one can stand alone OK)
  • TestChamber_Industrial: these soundscapes were used in the incinerator room and the intro sequence (i.e. the container ride). "Utility" soundscapes:
    • TestChamber_Industrial.BowedMetal_01
    • TestChamber_Industrial.BubblingGoo_01 (this one can stand alone OK)
    • TestChamber_Industrial.WarehouseImpact_01
    • TestChamber_Industrial.WarehouseImpact_02
    • TestChamber_Industrial.WarehouseImpact_03
    • TestChamber_Industrial.WarehouseMotor_01 (this one can stand alone OK)
    • TestChamber_Industrial.WarehousePower_01 (this one can stand alone OK)
    • TestChamber_Industrial.WarehouseWronk_01
    • TestChamber_Industrial.WarehouseWronk_02
  • TestChamber.Industrial and Turretchamber: these soundscapes should not be confused with the above, as they were used in the clean/late reconstructing themes, as well as Wheatley's chambers. There are no "utility" soundscapes in these categories.
  • The TestChamber_01, TestChamber.clean, TestChamber.fizzler_01, TestChamber.liquid, TestChamber_med, TestChamber.paint, TestChamber_paint, and TestChamber_transition categories are all non-"utility" soundscapes. These were used in the reconstructing chambers.
  • TestChamber_BTS.Drone is non-"utility", but the rest of the TestChamber.BTS soundscapes are (they should stand alone OK though). This soundscape was used in only one place: before you re-awaken GLaDOS.
  • The TestChamber_Vegetation series was used — where else — the overgrown maps. The following are "utility" soundscapes:
    • TestChamber_Vegetation.AfricanBirds
    • TestChamber_Vegetation.BirdsInsects
    • TestChamber_Vegetation.Crows
    • TestChamber_Vegetation.Insects_01
    • TestChamber_Vegetation.Insects_02
    • TestChamber_Vegetation.Insects_03
    • TestChamber_Vegetation.WaterDrips
  • The sab, sabotage, and warehouse categories were used in Chapter 5 ("The Escape"), in the major behind-the-scenes areas. tube.spawn was also in Chapter 5, during the great tube ride. These categories have no "utility" soundscapes.
  • The ug category was used in the underground-themed/old Aperture maps. The ug_sphere sub-category was designed for maps to take place inside of the enrichment spheres; everything else is "underground behind-the-scenes" — rocky caverns, pits of trash, abandoned offices and gel pump stations, and a deadly lake. The ug category has no "utility" soundscapes.
  • The portal category of soundscapes contains the soundscapes that were used in the original Portal, and originally they were context-sensitive, unlike in Portal 2. There is a separate page on the VDC Wiki describing each one. This category has no "utility" soundscapes.
  • The finale category features soundscapes from Chapter 9 in the main campaign (The Part Where He Kills You), so you may find them useful in wide open behind-the-scenes areas. This category has no "utility" soundscapes.
  • The core (used at the end of Act 5, when you're back with GLaDOS), jb, jb2, jb3 (all variants used after GlaDOS' Test Chamber 21), PD ("Portal 2 Demo"), and return (very beginning of Chapter 8, "The Itch") soundscape sets are all non-"utility."
  • Miscellaneous, non-"utility" soundscapes used in Wheatley's chambers (in chronological order): tbeam_chamber_01, tbeam_chamber_02, trust_chamber_01, tb_wall_chamber_01, tb_pol_chamber_01, tb_catch_chamber_01, laser_chamber_*, laser_catapult_01, laser_plat_*, catch_chamber_01, and jump_chamber_lg_01.
  • coop.silence, anything ending in .instance, as well as all of the room soundscapes belong to the original coop campaign. These categories have no "utility" soundscapes.
  • The EntryExitElevator category of soundscapes were used in the elevator rooms. This category has no "utility" soundscapes.
    • One of the soundscapes, industrial_gel_01, is identical to EntryExitElevator.IndustrialStairs. We hear it all the time in singleplayer PeTI maps, so I would not recommend using it.
  • trust_ratman_01, gap.ratman_01, and rug_ratman_01 are all soundscapes used in Rattman's dens (order is chronological). No "utility" soundscapes here.
  • The BR, train, and traincar categories belonged exclusively to the Super 8 trailer map. I wouldn't use them unless you really know what you're doing.
  • colo_chamber_01, colo_chamber_02, goalie_interior_01, hall01.paint_longjump, and preTestChamber.Industrial_muffled_01 were used in Portal 2 Demo/Promo maps.
    • And finally, here at the bottom are the util and utility soundscapes. As you might expect, all of these are "utility" soundscapes and won't really sound all that exciting if played on their own.
Master Guide List
Please note that there are still some works in progress. This section will be updated as I finish more guides for you!

You are currently viewing part 03/19 in the series.

| 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |

Previous Guide (about textures and lighting in Portal 2: observation rooms and light strips.)
Next Guide (about activators (e.g. buttons) and how to make them look pretty and such)

Please feel free to leave a well-reasoned question or comment below. Either I or a qualified Test Chamber Associate (you'll know because they make all the good maps on the workshop) will respond. If your question or comment is not well-reasoned, I recommend reading over my guides again until you understand them 100%. No further information is required here or will be provided, and you will become an excellent Test Chamber Designer — using Hammer!

18 Comments
BBQ DAWGZ 29 Jun, 2023 @ 11:41pm 
I'm pretty sure the sound script file you were looking into was the right way to go, you must just have to dig a lot deeper. Valve has so many dummy files to patch over very specific things though, and in multiple places. I have no clue how most of them work but I'm sure you can figure it out, you just gotta find the right files.
Sheepy 25 Apr, 2023 @ 8:14pm 
as i was waiting for this answer i went and looked at sound scripts which seem to fit what i am looking for, but issue is i have tried to do everything and i barely know how they work let alone know if you can make one yourself as the documentation that exists is very complicated for me to understand, so it seems complicated and out of the scope of these guides for sure, but yea its a soundscript that is needed for that and i think the PTI music was even meant to include it as looking in its soundscript file it includes propulsion gel music but its just commented out and when i uncomment it, does nothing. anyways enough of my ramblings hopefully someone out there can make sense of it and make a proper tutorial on how they work. (sorry for the really long reply)
The Sojourner  [author] 25 Apr, 2023 @ 6:49pm 
I know exactly what you're talking about. In fact I wondered the very same thing when I was first making maps. A quick look at Valve's included VMF for that one Propulsion Gel intro map didn't reveal anything (iirc), which means there may be some additional scripting at work. Unfortunately, that is outside the scope of this series (and unfortunately even I myself don't know, but someone else might).
Sheepy 21 Apr, 2023 @ 10:03pm 
how do i get the propulsion gel music to play when the player runs on the propulsion gel? like how in valves maps do they get music to play as you're running on it, I've sort of figured out a way but it doesn't stop the sound as i am using a trigger_catapult set to threshold check. (sorry if i haven't explained it well enough, i am bad at explaining things)
mystqfae 24 Dec, 2021 @ 1:38pm 
thank you :)
The Sojourner  [author] 24 Dec, 2021 @ 1:24pm 
None taken :p2chell: The relevant script files are located in ..\common\Portal 2\portal2_dlc2\scripts (or ..\common\Portal 2\portal2_dlc1\scripts for soundscapes), and there are special scripts for game sounds and soundscapes. However in order to use them in custom PeTI maps, you have to embed them into your map using a tool suck as PakRat or VIDE.
mystqfae 24 Dec, 2021 @ 1:11pm 
please don't take offense, but I didn't see where you would access the file to add the custom sound script. I am just learning and so to me, it wasn't obvious where the scripts are to be entered. Also, I am aware this guide is really old and I'm just hoping someone sees this who can help me out.
cupofspiders 14 Oct, 2021 @ 9:12pm 
what's a nice sounding, not too creepy generic test chamber soundscape?
BezaoBuilder 13 Jul, 2021 @ 9:17am 
idontknow, create a nodraw box in the void, get a generic_actor inside that box, set the actor's model to models/props/metal_box.mdl, set the render mode to "don't render", name it "@glados".
idontknow 8 Oct, 2020 @ 3:11am 
Hello, the log says the actor named @glados do not found. how can i fix this? Thank you