SteamVR/Environments/Adding Sound/Soundevents
Contents
A guide to adding Soundevents to your Environment
First, sound files go in the \steamvr_environments\content\steamtours_addons\<addon_name>\sounds\
directory. If the sounds\
directory doesn't exist, create it.
With a text editor, open the provided file, "soundevents_addon.vsndevts" from the content soundevents\
directory. 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-
name
Replace 'soundname_01/02' with the name for your soundevent, this is what you will reference elsewhere in the tools to call your sound.
type
Replacing 'soundtype' inside the quotations with one of the two types explained below will determine the playback behavior of the sound.
volume
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.
pitch
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.
delay
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.
use_hrtf
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 3D panning feature. To use regular/legacy 2D panning, add this parameter and set it to 0.0.
vsnd_files
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.
Types
There are 2 main 'type' settings you can use for sound behavior control in environments.
"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-diegetic music, ambience beds, atmospheric rumbles.
Using Soundevents
snd_event_point
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.
Animation Events
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
and sound-out
properties: Dota_2_Workshop_Tools/Panorama/CSS_Properties#sound
Troubleshooting
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 in VR mode, the sound will not play if the VR headset is not tracking, or if SteamVR is standing by (displaying a hollow headset icon).
Make sure that the sound file is placed under the \steamvr_environments\content\steamtours_addons\<addon_name>\sounds\
directory (create the directory if necessary). 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.
The soundevent
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.
The soundevent file will not compile unless a map is running. If no ResourceCompilerSystem messages appear in the console when saving changes to the soundevent file, make sure a map is loaded. The map can be loaded either from the Hammer build dialog or from the console using the destinations_load_addon <addon_name> [<map_name>]
command.
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 "sounds/mymap/mysound.vsnd"
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.
Extended Documentation
Properties
Required properties
Parameter | Type | Default | Description |
---|---|---|---|
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. |
Optional properties
Parameter | Type | Default | Description |
---|---|---|---|
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. |
volume_falloff_limit | float | 0.0 | [Todo] |
Advanced properties
Parameter | Type | Default | Description |
---|---|---|---|
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. |
occlusion_amount | float | 0.0 | |
occlusion_loss | float | -12.0 | |
occlusion_source_radius | float | 20.0 | |
size | float | 0.0 | |
spread_min | float | 0 | |
spread_max | float | 0 | |
spread_min_value | float | 0.0 | |
spread_max_value | float | 1.0 | |
use_passed_position | bool | false | |
attachment | string_token | "<unknown>" | |
memory_type | float | 0 | |
mixgroup | string | "ambient" | |
event_type | float | 0.0 | |
draw_debug_on | float | 0.0 | |
minimum_volume | float | 0.5 | |
volume_filter_amount | float | 999.0 | |
block_stop | float | 0.0 | |
volume_input_01 | float | 1.0 | |
volume_input_02 | float | 1.0 | |
volume_input_03 | float | 1.0 | |
start | float | 1.0 | (2D only) |
volume_rand_min | float | 0.0 | (2D only) |
volume_rand_max | float | 0.0 | (2D only) |
pitch_rand_min | float | 0.0 | (2D only) |
pitch_rand_max | float | 0.0 | (2D only) |
Sound Types
Type | Description |
---|---|
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.randompos | |
destinations.simple_vr_scalable | |
destinations.voip | |
destinations.voip_simple | |
destinations.rand_pos_line | |
destinations.3line_rand_pos_3d | |
destinations.simple_vr_soundscapes | |
destinations.ambient_fixed_rotation | |
destinations.ambient_closest_pos_on_box | |
destinations.2d_w_falloff | |
destinations.envelope_2d | |
destinations.focuschange_2d | |
destinations.src1_2d | |
destinations.drone_acc | The types below provide the dynamic pitch effects for the Drone and Cache Finder tools. |
destinations.drone_dec | |
destinations.cache_finder_rate | |
destinations.cache_finder_progress | |
destinations.cache_finder_ping | |
destinations.cache_finder_progress |