This article relates to the game "Half-Life: Alyx". Click here for more information.
This article relates to the workshop tools for "Half-Life: Alyx". Click here for more information.
This article's documentation is for Source 2. Click here for more information.

Sound

From Valve Developer Community
Jump to: navigation, search

Custom Sounds

Custom sounds can be added to your maps by adding .wav or .mp3 files to `content\hlvr_addons\<addon name>\sounds\`. Create this directory if it doesn't exist.

When a sound file is added to that directory, the Workshop Tools will automatically convert them into .vsnd files. For example, if you add a file named "hello.wav" to your sounds folder, it will be converted to "hello.vsnd". You can even preview this file from within the Asset Browser.

Sound Events

If you want sounds to play from scripts or triggers, you can use sound events.

As an example, add a `point_soundevent` entity to your map. In the Object Properties panel, look for the Sound Event Name property. Use the picker to browse through the list of available sound events.

To use your own custom sound events, start by creating a directory in your addon named `soundevents`. Within it, create a file named `soundevents_addon.vsndevts`.

Vsndevts example.PNG

The parameters are mostly the same as described in the SteamVR tutorial, however, the types allowed are different.

For a 3D sound source, you would write `type = "src1_3d"`.


Make sure the `vsnd_files` parameter references the .vsnd file, not the original WAV/MP3.

Once you save this file, go back to the Asset Browser to recompile it.

You'll know if you've set up your resource file correctly if you can find it in the Sound Event Picker.

Soundeventpicker.PNG

Select your custom sound event.

See Also