Soundscape (Source 2)

From Valve Developer Community
Revision as of 13:56, 5 April 2025 by SirYodaJedi (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Stub

This article or section is a stub. You can help by expanding it.

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.