Addon Sounds
The playing of sounds in Source 2 and Counter-Strike 2 addons are triggered by starting and stopping a sound event.
Sound events are started/altered/stopped by game code, map entities, animations or other soundevents by name.
Sound events are of a "type" and contain a collection of property values that correspond to that "type".
Adding sounds to your Addon
To add new sound events or change the contents of pre-existing soundevents from the base game you will need to:
- Ensure that the soundevents file "soundevents_addon.vsndevts" is in the addon's "soundevents" directory. This should be automatically created by the tools when a new addon is made and is a copy of the file located in "Counter-Strike Global Offensive\content\csgo_addons\addon_template\soundevents". If either the name or location of this file is altered, sounds will not be precached.
- Add your new sound files (.wav, .mp3, etc.) to your addon's "sounds" directory.
- Declare your soundevent(s) within "soundevents_addon.vsndevts" to point to your new sounds (the compiled .vsnd version).
- Compile all of these files (should be done automatically). If they do not compile, it is likely there is a syntax error within "soundevents_addon.vsndevts".
To override existing soundevents, that is all that is required.
To add new soundevents to a map, a snd_event_point entity is needed in the map. The entity can be started and stopped with entity triggers.
Add new sounds
Place sound files in the "sounds" directory inside the addon:
Define soundevents
Listed below are some examples of defining soundevents. More examples can be found in "soundevents_addon.vsndevts" located in "Counter-Strike Global Offensive\content\csgo_addons\addon_template\soundevents".
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
{
//Example music file that references a sound file named "example.mp3" located in "Counter-Strike Global Offensive\content\csgo_addons\testaddon\sounds\music\"
"music.example" =
{
type = "csgo_music"
volume = 1.000000
volume_convar = "snd_musicvolume"
vsnd_files = "sounds/music/example.vsnd"
}
//Example generic sound effect that references a sound file named "example.mp3" located in "Counter-Strike Global Offensive\content\csgo_addons\testaddon\sounds\sfx\"
sfx.example =
{
type = "csgo_mega"
volume = 1
pitch = 1.000000
mixgroup = "Ambient"
vsnd_files_track_01 = "sounds/sfx/example.vsnd"
distance_volume_mapping_curve =
[
[
0.000000,
1.000000,
0.000000,
0.000000,
2.000000,
3.000000,
],
[
4096.000000,
0.000000,
0.000000,
0.000000,
2.000000,
3.000000,
],
]
}
}
There are several different sound types you can use when creating new sounds:
- csgo_mega - Used for the majority of sounds
- csgo_music - Used for music. Volume will be affected by a client's snd_musicvolume setting
- csgo_3d - General ambient noises
Loading addon soundevents
Custom sounds are only precached from a soundevents file named "soundevents_addon.vsndevts" located within the addon's "soundevents" directory. In addition, the map must be loaded within a mounted addon (opened through tools or as a workshop submission); standalone .vpks launched with the "map" console command in an insecure CS2 instance will not automatically precache soundevents.
Another useful way to check the existence of your addon soundevents is by entering the “snd_list_soundevents” console command into the vconsole.
See also
Source2ZE's Map Porting Guide -- Guide on porting maps from Source 1 to Source 2. Includes a section on creating soundevents.
SteamVR/Environments/Adding_Sound/Soundevents -- additional reference on soundevents.