Soundscape (Source 2): Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Created page with "{{stub}} {{tabsBar|main=s2|base=Soundscape}} == Storing and using custom soundscapes == Source 2 does away with the sound scripts model, and replaces those files with <code>soundevents_addon.vsndevts</code>. This is also an editable text file, and is where new user-created soundscapes and sound events can be entered. This file contains example soundscapes and sound events that can be copied or modified. The same key values and functions detailed earlier for scripts work...")
 
(Turned the Stub into a full article, updated some information on Source 2 specifics.)
Line 1: Line 1:
{{stub}}
{{LanguageBar}}
{{subpage|[[Sound and Music]]}}
{{tabsBar|main=s2|base=Soundscape}}
{{tabsBar|main=s2|base=Soundscape}}
A '''Soundscape''' is a type of audio script used to add ambience to maps. It can be used in any number of maps, requires only a single entity to implement, and does not generate any network traffic.  Soundscapes use a mixture of looped and randomly played sounds, all of which have the option to be emitted from one of eight assignable target locations; [[DSP]] and [[Soundmixer]] profiles can also be enforced.
Individual "Sounds" within a soundscape are called Sound Events. A soundscape script includes a listing of all Sound Events within the soundscape, and parameters on how the audio can be heard, played back, or otherwise manipulated. Beyond that, individual sound events can have their own parameters defined, which will function as written unless the parameters of the soundscape override those specific functions. The parameters that can be specified in a soundscape or sound event are theoretically option, as without defining them, they will revert to an engine "default".
Only one soundscape can be active at any given time, and the individual sounds used within it cannot be controlled via inputs, and must instead be addressed via invidiaul entities all pulling from the soundscape. When another soundscape is activated, the game will cross fade from one to the other.
{{tip|
* Cross fade time is defined by the [[cvar]] <code>soundscape_fadetime</code>, or <code>fadetime</code> in newer branches.
* Use the [[cvar]] <code>soundscape_debug</code> to examine which soundscape is active and why.
* Soundscapes and sound events can be configured to either load into memory upon being called (i.e. a player entering a soundscape radius), or they can be pre-loaded upon launch of the addon in-game. This is preferable for sound events that need to be as timely as possible (such as gunshots), but is unnecessary for sounds such as music or atmosphere. The delay to load into memory is minimal, but perceptible in some instances.}}
{{note|
* Sound files will not properly loop unless they have a cue point. See [[Looping a Sound]]. In Source 2, both .WAV & .MP3 files can be looped.
* At least one soundscape radius or [[trigger_soundscape|trigger box]] should cover the [[info_player_start]] or whatever game specific [[:Category:player spawn entities|player spawn entities]] you have, else the players will spawn without loading any soundscape until they trigger a Soundscape.}}
==Soundscapes==
===Browsing Soundscapes===
Soundscapes are typically located in the <code>scripts\</code> folder of a game, stored across multiple text files prefixed with <code>soundscapes_</code>. Each file is loaded via <code>scripts\soundscapes_manifest.txt</code>, which lists all soundscape scripts that should be mounted by the game. Soundscapes mounted through the manifest can be used anywhere in the game, even if they're only intended for a specific area.
Some Source 2 titles have done away with having many of the game files accessible as editable text files, and instead have many such functions packed into <code>.vpk</code> files. For others, these files can beaccessed through an addon's <code>Sounds</code> & <code>Sound Events</code> folders, and the <code>soundevents_addon.vsndevts</code> file.
At the bottom of this article you will find links to lists of soundscapes for individual games, along with attempts at describing them.
You can browse through all the available soundscapes in a current game first hand, using the in-game console command <code>PlaySoundscape</code>. After typing in the first letter as the commands parameter, the auto-complete feature will list them as suggestions. You can then scroll through this list using the arrow keys.
===Configuring Soundscapes===
Soundscapes can only be configured through the entity [[env_soundscape]].
There are other entities which can activate the soundscape, but these are the only entities which actually define soundscape properties. The other entities will point to these and use them as masters to remotely trigger the soundscape. (Such as [[point_soundevent]]).
Whenever these entities activate a soundscape, any positional audio will originate from the targets defined under their properties.{{tip| Many soundscapes define positions for sounds to emanate from, so it is always a good idea to peek into the soundscape entry and get a feel for what you can do. Most entries are found in the text files listed in the <code><addon>/Sound Events/soundevents_addon.vsndevts</code> file. To better understand soundscape entries, [[Soundscape#Custom_Soundscapes|see below]].}}
===Activating Soundscapes===
Any soundscape entity that is enabled and becomes triggered by the player, activates its - or its master's - specified soundscape. Soundscapes remain active until a map change occurs, or another soundscape is activated, even if the entity that originally activated it becomes disabled. {{tip|The <code>soundscape_flush</code> console command will cancel an active soundscape.}}
===Soundscape entities===
[[env_soundscape]] entities are themselves [[point_entities|point-based]], but trigger when the player enters their specified radius and the entity has a [[line of sight]] to them. This radius has no bearing on where and how the audio plays, only when it is triggered. A soundscape will ''not'' stop playing just because a player exits its radius or it loses line of sight to them.
As only one soundscape can be active at any one time, if one or more soundscape entities are triggered simultaneously, the closest one is given precedence.
{{tip|Use the [[cvar]] [[soundscape_debug]] to examine which entity is active and why.}}
===Soundscape Placement===
At first, a good rule is to place only as many soundscapes as you absolutely need. Try to choose from a similar set of soundscapes to be played, and then pick one that will be your primary soundscape. After that, place your secondary soundscapes at every contrasting location (e.g. house, generator room).  Make sure that every location with localized sound effects has its own master soundscape that is tied to the proper targets. 
Once you've gotten a general idea of where your soundscapes will be located, you'll then be able to start adding/configuring the entities that will trigger your soundscapes and create a kind of ''blueprint'' for how soundscapes will flow from one to another. In many cases, you'll be placing entities that block off all exits from your contrasting locations with triggers to your primary soundscapes. Basically, the goal is to anticipate the player's movement throughout the map, and to block off each area in such a way that it will always have the proper soundscape activated.
After your flow is organized, you'll be able to specialize your soundscapes/triggers to behave in complex ways (e.g responding to game events).
==Custom Soundscapes==
===Creation===
Soundscape scripts are very similar to [[soundscripts]], but still remain entirely different things.
Soundscapes require a few of their own rules, and are placed in plain text files that are separate from normal soundscript files. A typical soundscape file might be named <code>soundscape_mall.txt</code> and may contain anywhere from 5-30 different soundscapes that take on the following format.
{{bug|If a soundscape's name is too long, soundscape entities will not be able to trigger it, although it will still be triggerable through console. Character limit unknown.}}
{{pre|
<name>
{
<rule>
{
<keyvalue>
...
}
...
}
}}
===Common keyvalues===
;:{{Confirm|Which values maintain common syntax with Source 1 soundscripts, and all new possible keyvaleus available in Source 2.}}
===Rules===
;:{{Confirm|Which rules maintain common syntax with Source 1 soundscripts, and all new possible rules available in Source 2.}}


== Storing and using custom soundscapes ==
== Storing and using custom soundscapes ==
Line 110: Line 193:
===Storing Audio Files===
===Storing Audio Files===
In Source 2, Audio files that you would like to become sound events, triggerable as part of a soundscape, must be stored in the <code>sounds</code> folder, under the <code>content</code> directory of your addon. After you have placed files there, launch Hammer, and open your addon. This should cause the audio files to be auto-compiled into <code>.vsnd</code> files. Check the asset browser, or the <code>sounds</code> folder, under the <code>game</code> directory, to ensure they have been compiled. The <code>soundevents_addon.vsndevts</code> file can only read, and call on <code>.vsnd</code> files, rather than the raw <code>.wav</code> or <code>.mp3</code> files.
In Source 2, Audio files that you would like to become sound events, triggerable as part of a soundscape, must be stored in the <code>sounds</code> folder, under the <code>content</code> directory of your addon. After you have placed files there, launch Hammer, and open your addon. This should cause the audio files to be auto-compiled into <code>.vsnd</code> files. Check the asset browser, or the <code>sounds</code> folder, under the <code>game</code> directory, to ensure they have been compiled. The <code>soundevents_addon.vsndevts</code> file can only read, and call on <code>.vsnd</code> files, rather than the raw <code>.wav</code> or <code>.mp3</code> files.
==See also==
* [[env_soundscape]]
* [[env_soundscape_proxy]]
* [[env_soundscape_triggerable]]
* [[trigger_soundscape]]
* [[Notepad++ VDF languages]]
{{soundscape lists}}
[[Category:Sound System]]
[[Category:Level Design]]
[[Category:Plain text formats]]
[[Category:Plain text files]]
[[Category:Tutorials]] <!-- due to XBLAH's Modding Tool -->

Revision as of 14:09, 11 April 2025

English (en)Translate (Translate)

A Soundscape is a type of audio script used to add ambience to maps. It can be used in any number of maps, requires only a single entity to implement, and does not generate any network traffic. Soundscapes use a mixture of looped and randomly played sounds, all of which have the option to be emitted from one of eight assignable target locations; DSP and Soundmixer profiles can also be enforced.

Individual "Sounds" within a soundscape are called Sound Events. A soundscape script includes a listing of all Sound Events within the soundscape, and parameters on how the audio can be heard, played back, or otherwise manipulated. Beyond that, individual sound events can have their own parameters defined, which will function as written unless the parameters of the soundscape override those specific functions. The parameters that can be specified in a soundscape or sound event are theoretically option, as without defining them, they will revert to an engine "default".

Only one soundscape can be active at any given time, and the individual sounds used within it cannot be controlled via inputs, and must instead be addressed via invidiaul entities all pulling from the soundscape. When another soundscape is activated, the game will cross fade from one to the other.

Tip.pngTip:
  • Cross fade time is defined by the cvar soundscape_fadetime, or fadetime in newer branches.
  • Use the cvar soundscape_debug to examine which soundscape is active and why.
  • Soundscapes and sound events can be configured to either load into memory upon being called (i.e. a player entering a soundscape radius), or they can be pre-loaded upon launch of the addon in-game. This is preferable for sound events that need to be as timely as possible (such as gunshots), but is unnecessary for sounds such as music or atmosphere. The delay to load into memory is minimal, but perceptible in some instances.
Note.pngNote:
  • Sound files will not properly loop unless they have a cue point. See Looping a Sound. In Source 2, both .WAV & .MP3 files can be looped.
  • At least one soundscape radius or trigger box should cover the info_player_start or whatever game specific player spawn entities you have, else the players will spawn without loading any soundscape until they trigger a Soundscape.

Soundscapes

Browsing Soundscapes

Soundscapes are typically located in the scripts\ folder of a game, stored across multiple text files prefixed with soundscapes_. Each file is loaded via scripts\soundscapes_manifest.txt, which lists all soundscape scripts that should be mounted by the game. Soundscapes mounted through the manifest can be used anywhere in the game, even if they're only intended for a specific area.

Some Source 2 titles have done away with having many of the game files accessible as editable text files, and instead have many such functions packed into .vpk files. For others, these files can beaccessed through an addon's Sounds & Sound Events folders, and the soundevents_addon.vsndevts file.

At the bottom of this article you will find links to lists of soundscapes for individual games, along with attempts at describing them.

You can browse through all the available soundscapes in a current game first hand, using the in-game console command PlaySoundscape. After typing in the first letter as the commands parameter, the auto-complete feature will list them as suggestions. You can then scroll through this list using the arrow keys.


Configuring Soundscapes

Soundscapes can only be configured through the entity env_soundscape.

There are other entities which can activate the soundscape, but these are the only entities which actually define soundscape properties. The other entities will point to these and use them as masters to remotely trigger the soundscape. (Such as point_soundevent).

Whenever these entities activate a soundscape, any positional audio will originate from the targets defined under their properties.

Tip.pngTip: Many soundscapes define positions for sounds to emanate from, so it is always a good idea to peek into the soundscape entry and get a feel for what you can do. Most entries are found in the text files listed in the <addon>/Sound Events/soundevents_addon.vsndevts file. To better understand soundscape entries, see below.


Activating Soundscapes

Any soundscape entity that is enabled and becomes triggered by the player, activates its - or its master's - specified soundscape. Soundscapes remain active until a map change occurs, or another soundscape is activated, even if the entity that originally activated it becomes disabled.

Tip.pngTip:The soundscape_flush console command will cancel an active soundscape.


Soundscape entities

env_soundscape entities are themselves point-based, but trigger when the player enters their specified radius and the entity has a line of sight to them. This radius has no bearing on where and how the audio plays, only when it is triggered. A soundscape will not stop playing just because a player exits its radius or it loses line of sight to them.

As only one soundscape can be active at any one time, if one or more soundscape entities are triggered simultaneously, the closest one is given precedence.

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


Soundscape Placement

At first, a good rule is to place only as many soundscapes as you absolutely need. Try to choose from a similar set of soundscapes to be played, and then pick one that will be your primary soundscape. After that, place your secondary soundscapes at every contrasting location (e.g. house, generator room). Make sure that every location with localized sound effects has its own master soundscape that is tied to the proper targets.

Once you've gotten a general idea of where your soundscapes will be located, you'll then be able to start adding/configuring the entities that will trigger your soundscapes and create a kind of blueprint for how soundscapes will flow from one to another. In many cases, you'll be placing entities that block off all exits from your contrasting locations with triggers to your primary soundscapes. Basically, the goal is to anticipate the player's movement throughout the map, and to block off each area in such a way that it will always have the proper soundscape activated.

After your flow is organized, you'll be able to specialize your soundscapes/triggers to behave in complex ways (e.g responding to game events).


Custom Soundscapes

Creation

Soundscape scripts are very similar to soundscripts, but still remain entirely different things.

Soundscapes require a few of their own rules, and are placed in plain text files that are separate from normal soundscript files. A typical soundscape file might be named soundscape_mall.txt and may contain anywhere from 5-30 different soundscapes that take on the following format.

Icon-Bug.pngBug:If a soundscape's name is too long, soundscape entities will not be able to trigger it, although it will still be triggerable through console. Character limit unknown.  [todo tested in ?]
<name>
{
	<rule>
	{
		<keyvalue>
		...
	}

	...
}


Common keyvalues

Confirm:Which values maintain common syntax with Source 1 soundscripts, and all new possible keyvaleus available in Source 2.


Rules

Confirm:Which rules maintain common syntax with Source 1 soundscripts, and all new possible rules available in Source 2.


Storing and using custom soundscapes

Source 2 does away with the sound scripts model, and replaces those files with soundevents_addon.vsndevts. This is also an editable text file, and is where new user-created soundscapes and sound events can be entered. This file contains example soundscapes and sound events that can be copied or modified. The same key values and functions detailed earlier for scripts work within this file as well. The This file details potential uses for the preset base soundevents and soundscapes, and more information on implementing new content.

An example of a base Soundscape:

"ambient_example.outdoors" = 
{
	base = "amb.soundscapeParent.base"
	enable_child_events = true
	soundevent_01 = 
	[
		"ambient_example.outdoors.birds",
		"ambient_example.outdoors.airplanes",
		"ambient_example.outdoors.wind",
	]
}

An example of a base sound event:

"amb.base" = 
{
	type = "csgo_mega"
	mixgroup = "Amb_Common"
	occlusion_intensity = 0.0
	distance_effect_mix = 0.0
	restrict_source_reverb = true
	use_distance_unfiltered_stereo_mapping_curve = true
	use_time_volume_mapping_curve = true
	distance_volume_mapping_curve = 
	[
		[
			0.0, 1.0, -0.00394, -0.00394,
			2.0, 3.0,
		],
		[
			300.0, 0.0, -0.002991, -0.002991,
			2.0, 3.0,
		],
	]
	fadetime_volume_mapping_curve = 
	[
		[
			0.0, 1.0, -1.223776, -1.223776,
			2.0, 3.0,
		],
		[
			0.208571, 0.0, 0.0, 0.0,
			2.0, 3.0,
		],
	]
	distance_unfiltered_stereo_mapping_curve = 
	[
		[
			0.0, 0.0, 0.0, 0.0,
			2.0, 3.0,
		],
		[
			300.0, 0.0, 0.0, 0.0,
			2.0, 3.0,
		],
	]
	time_volume_mapping_curve = 
	[
		[
			0.0, 0.0, 0.0, 0.0,
			2.0, 3.0,
		],
		[
			0.297143, 1.0, 0.0, 0.0,
			2.0, 3.0,
		],
	]
}

While soundevents_addon.vsndevts is a text file, it has to be compiled by either Hammer, or the Game Engine before it will function correctly. If you have completed entered in all the parameters for your soundscapes and sound events in the text file, and they are not appearing in Hammer or playing in game, soundevents_addon.vsndevts can be recompiled either be re-openeing a build of the map in-game, or by selecting the file in the "Asset Browser", right clicking, and selecting Recompile > Full>.

To add Soundscape and sound event entries to soundevents_addon.vsndevts, they should be added directly after the soundscape templates in the file, just before the ///BASE SOUNDEVENT TEMPLATES header. An example Source 2 Soundscape:

"soundscape_name" 
{
	base = "amb.looping.stereo.base"
	volume = 0.2 
	pitch = 1.0
	mixgroup = "Ambient"
	use_distance_volume_mapping_curve = false	
	vsnd_files_track_01 = "sounds/soundevent_audio_file.vsnd"
	distance_unfiltered_stereo_mapping_curve = 
	[
		[
			0.0, 1.0, 0.0, 0.0, 2.0, 3.0,
		],
		[
			1000, 1.0, 0.0, 0.0, 2.0, 3.0,
		],
	]
}

This example uses a template soundevent base for many of its parameters when playing back the audio file, and then overrides a few of those parameters, such as the specified stereo mapping curve.


Storing Audio Files

In Source 2, Audio files that you would like to become sound events, triggerable as part of a soundscape, must be stored in the sounds folder, under the content directory of your addon. After you have placed files there, launch Hammer, and open your addon. This should cause the audio files to be auto-compiled into .vsnd files. Check the asset browser, or the sounds folder, under the game directory, to ensure they have been compiled. The soundevents_addon.vsndevts file can only read, and call on .vsnd files, rather than the raw .wav or .mp3 files.

See also