- 1 A guide to adding Soundevents to your Environment
- 2 Using Soundevents
- 3 Troubleshooting
- 4 Extended Documentation
A guide to adding Soundevents to your Environment
First, sound files go in the content/youraddon/sounds/ folder.
With a text editor, open the provided file, "soundevents_addon.vsndevts" from the content soundevents folder. Do not rename this file to match your addon, just edit the contents.
You add soundevent definitions inside the existing curly braces already present in the file-
Replace 'soundname_01/02' with the name for your soundevent, this is what you will reference elsewhere in the tools to call your sound.
Replacing 'soundtype' inside the quotations with one of the two types explained below will determine the playback behavior of the sound.
An optional parameter requiring a float value, ideally set between 0.0 and 1.0, that acts as a multiplier on the sounds volume. If undeclared, it will default to 1.0.
An optional parameter requiring a float value, that determines the pitch at which the sound plays back. Ideally set it between 0.9 and 1.1 to avoid digital distortion from extreme pitch shifting, but feel free to experiment if you want some crazy sounds. If undeclared, it will default to 1.0.
An optional parameter requiring a float value, representing a millisecond delay between the soundevent being called to start and the sound file playing. If undeclared, it will default to 0.0.
An optional parameter, available only to the "destinations.simple_vr" soundtype explained below. By default this is a 1.0 for all soundevents, directing them to use the SteamAudio HRTF panning feature. To use regular/legacy panning, add this parameter and set it to 0.0.
The value here is the sound file you wish to play. Note for soundname_02, the square braces allow for multiple sound files to be added for one soundevent. When the soundevent is called to play, it will respond with one of the files chosen at random. Once a sound file is used it will not be chosen again until the list is exhausted.
Note: The .vsnd extension is for the compiled version of audio files in Source 2. When the sound first plays, it will get compiled into a .vsnd automatically. You don't need to change the audio file extension by hand, just use .vsnd in the script.
There are 2 main 'type' settings you can use for sound behavior control in environments.
For sounds with positional information and that require a falloff of volume against distance. Example usages - a bird call, dog bark, door closing.
For sounds without positional information, whose stereo information will be preserved no matter the orientation of the player. Example usages - non-diagetic music, ambience beds, atmospheric rumbles.
The simplest way of using soundevents is by the snd_event_point (or point_soundevent) entity in Hammer. Placing one and clicking the magnifying glass next to Sound Event Name in the Object properties presents a list of available soundevents.
See the turret tutorial for an example on how to wire up the snd_event_point to a trigger.
Soundevents can be attached to animation frames of custom models. To do so, select an animation in the Model Editor and click the plus sign next to Animation Events in the Property Editor, and a new event entry will appear. Expand it and select AE_CL_PLAYSOUND (or one of the other PLAYSOUND events) from the Event dropdown. Then type in the Frame to play on and finally the name of the sound event into the Data String.
Emitting from VScript
Soundevents can be directly played from VScript Lua scripts, for example for special effects on tools. There are functions available for both emitting sounds from certain locations and entities, as well as emitting non-directional sounds either to one player or all.
See the scripting API for the available functions: SteamVR/Environments/Scripting/API#Sound
Emitting from Panorama
Soundevents can be played on Panorama UI elements using the CSS
sound-out properties: Dota_2_Workshop_Tools/Panorama/CSS_Properties#sound
The sound asset
It is advisable to make sure that any sound files have been imported properly before troubleshooting the soundevent. The sound files should appear in the asset browser as .vsnd files, and play when clicked on. Note that the sound may not play if no map is running or the VR headset isn't tracking.
Make sure that the sound file is placed under the
\steamvr_environments\content\steamtours_addons\<addon_name>\sounds\ directory. While the sound file may be visible in the asset browser even if placed anywhere else in the add-on directory structure, the soundevent system expects it to be under
sounds\, and will fail to find it otherwise.
Note that the tools only see the sound file as a virtual .vsnd file, even though no such file exists in the directory. The actual file used for playback is created under
\steamvr_environments\game\steamtours_addons\<addon_name>\sounds\ as a compiled .vsnd_c file.
Soundevent files require a strict syntax and spotting errors in them can be difficult. The Developer Console will output any errors it finds when parsing the file. Re-save the file and look for new messages from the ResourceCompilerSystem. If the parsing failed, several error messages should appear. The first one should at least provide a hint on what the error is.
A common issue in soundevent scripts are sound assets referenced by their actual file names, instead of the filename of the virtual .vsnd file. Make sure the file extension .vsnd is used regardless of that the sound files actual extension is. For example the file
\steamvr_environments\game\steamtours_addons\<addon_name>\sounds\mymap\mysound.wav should be entered as
If the soundevent file passed compile, the
snd_sos_start_soundevent console command can be used to play it back. Typing in the command and pressing space should provide an autocomplete list of valid sound events. Note that the soundevent may not play if no map is running or the VR headset isn't tracking. If the sound still doesn't play, the issue is likely with the soundscript entry in the file.
|type||string||Using one of the sound types listed below will determine the playback behavior of the sound.|
|vsnd_files||string/array||The sound file(s) you wish to play. Using an array of strings enclosed in square braces allow for multiple sound files to be added for one soundevent. When the soundevent is called to play, it will respond with one of the files chosen at random. Once a sound file is used it will not be chosen again until the list is exhausted.|
|volume||float||1.0||A float value set between 0.0 and 1.0 that acts as a multiplier on the sounds volume.|
|pitch||float||1.0||A float value that determines the pitch at which the sound plays back. Ideally set it between 0.9 and 1.1 to avoid digital distortion from extreme pitch shifting, but feel free to experiment if you want some crazy sounds.|
|delay||float||0.0||A float value representing a millisecond delay between the soundevent being called to start and the sound file playing.|
|use_hrtf||float||1.0||A parameter available only to the 3D spacialized sound types. By default this is a 1.0 for all soundevents, directing them to use the SteamAudio HRTF panning feature. To use regular/legacy panning, add this parameter and set it to 0.0.|
|volume_falloff_min||float||200.0||A float value that determines at what distance the volume should start fading. Below this distance the sound will be played at the full volume.|
|volume_falloff_max||float||2000.0||A float value that determines the maximum distance the sound can be heard.|
|fade_in||float||0.0||Adds a fade in effect for the specified number of seconds.|
|fade_out||float||0.0||Adds a fade out effect for the specified number of seconds.|
To do: Sound types other than the main two may have more properties available. The properties are listed in .vsndstck_c files in the VPK archives.
|destinations.simple_vr||For sounds with positional information and that require a falloff of volume against distance. Example usages - a bird call, dog bark, door closing.|
|destinations.simple_2d||For sounds without positional information, whose stereo information will be preserved no matter the orientation of the player. Example usages - non-diagetic music, ambience beds, atmospheric rumbles.|
|destinations.advanced_vr||This type has more SteamAudio settings available.|
|destinations.drone_acc||The types below provide the dynamic pitch effects for the Drone and Cache Finder tools.|