Soundscape: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Added link to Episode 2 soundscapes)
No edit summary
Line 50: Line 50:
  }
  }


All must be stored in text files listed by <code>game\scripts\soundscapes_manifest.txt</code>. Each must have a globally unique name.
All must be stored in text files listed by <code>game\scripts\soundscapes_manifest.txt</code> with the exception of [[creating custom soundscapes]]. Each must have a globally unique name.


{{tip|Mappers can create <code>scripts\soundscapes_<map name no extension>.txt</code> to use new soundscapes without modifying the manifest.}}
{{tip|Mappers can create <code>scripts\soundscapes_<map name no extension>.txt</code> to use new soundscapes without modifying the manifest.}}

Revision as of 03:08, 17 August 2009

Soundscapes are audio scripts that create background ambience in maps. Sound clips can be looped or played randomly, and can be emitted evenly or from specific locations. A soundscape can also enforce DSP and Soundmixer profiles.

A soundscape can be used in any number of maps, requires only a single entity to implement, and does not generate any network traffic. However, the sounds it plays cannot be precisely controlled and only one soundscape can be active at any given time.

Soundscapes will crossfade between each other over a default of three seconds. Configure this from the console with soundscape_fadetime.

Implementing

env_soundscape

Soundscapes are generally implemented with env_soundscape. Its keyvalues, inputs etc. should be self-explanatory.

The active env_soundscape is the one that the player:

  1. Has direct line of sight to
  2. Is in range of
  3. Is closest to (in case of a tie)

When an env_soundscape ceases to be active, the soundscape it began persists until another one is begun or the map changes.

Tip.pngTip:Use the convar soundscape_debug examine which entity is active and why.

trigger_soundscape

The other method is trigger_soundscape. The associated env_soundscape_triggerable will be played when the player is inside the trigger volume.

Note.pngNote:Unlike env_soundscape, trigger_soundscape's soundscapes do not persist once the player leaves its influence.

Finding a soundscape

Hammer doesn't list available soundscapes. The best way of finding one is loading up a map and using the concommand playsoundscape (which does know what's available and will autocomplete while you type) to start one up.

Creating

Example

Soundscapes work like this:

<name>
{
	<rule>
	{
		<keyvalue>
		...
	}

	...
}

All must be stored in text files listed by game\scripts\soundscapes_manifest.txt with the exception of creating custom soundscapes. Each must have a globally unique name.

Tip.pngTip:Mappers can create scripts\soundscapes_<map name no extension>.txt to use new soundscapes without modifying the manifest.

Common keyvalues

wave <string>
The path and filename of the sound to play, relative to game\sound\.
volume <normal>
1 is full power, 0 is silent.
pitch <integer>
Percentage value. +/-30 is the useful range.
position <0-7>
One of eight locations in the world (defined by the mapper) from which a sound can be emitted.
position random
As above, but the sound emits from a completely random location near the player.
attenuation <float>
How quickly the sound's volume drops as the camera moves away from it. Only relevant with a position specified.
Todo: What are the rules?
soundlevel <string>
Can be used instead of attenuation. Accepts one of the engine's pre-set values.
Warning.pngWarning:Remember to enclose any values with space characters in "quote marks".

Randomised values

Some rules accept 'upper' and 'lower' parameter values. For example:

pitch	80,120

Whenever the rule is executed the value will be randomly selected within the given range.

Rules

playlooping

Plays a sound constantly. Does not allow random values.

Note.pngNote:Sound files will not properly loop unless they have a cue point. See Looping a Sound.

playrandom

Plays a sound after given number of seconds. Allows random values.

Playrandom requires all wave KVs to be inside rndwave (even if there is only one). A random selection will be made every time the rule is executed.

playrandom
{
	time	1,4
	volume	0.4,1
	pitch	90,105

	rndwave
	{
		wave	ambient/wind/wind_med1.wav
		wave	ambient/wind/wind_hit1.wav
	}
}

playsoundscape

Plays a complete soundscape. DSP presets in the 'sub-scape' are ignored.

name
Name of the soundscape to play.
position <int>
Offsets each position index of the sub-scape.
Todo: What does that mean?
positionoverride <int>
Forces all positioned sounds in the sub-scape to emit from one location.
ambientpositionoverride <int>
Forces all unpositioned (i.e. ambient) sounds in the sub-scape to emit from one location.
SubScape
{ 
	playsoundscape
	{ 
		name	GenericIndoor

		// Overall sub-scape volume to 50% 
		volume	0.5

		// Emit all positioned sounds from position 0
		positionoverride	0

		// Emit all ambient sounds from position 1
		ambientpositionoverride	1
	} 
}

dsp

Overrides the current DSP preset (which would otherwise be derived from the $surfaceprop of nearby materials).

For a list of values, open scripts\dsp_presets.txt. You may need to extract this from the relevant engine GCF with GCFScape. To preview a DSP preset, submit room_type <int> to the console.

Note.pngNote:Be careful when setting presets in soundscapes that could be used in many different locations.
// Disable DSP and play no ambient sounds 
Empty
{ 
	dsp	0
}
Todo: What is dsp_volume? Does it actually exist?

soundmixer

Selects a custom soundmixer. Soundmixers manage the priority and volume of groups of sounds; create new ones in scripts\soundmixers.txt (ALWAYS use Default_Mix as a template).

quiet
{
	soundmixer	Citadel_Dialog_Only

	...
}

See also