Adding and playing Custom Sounds

edited September 2016 in Tutorials

Here's an step by step guide to custom sound events.

1 - Preparing the file

You want a file with mp3 extension, .wav might work but I haven't tried it. You can convert sounds to mp3 using any decent sound editor, I use Audacity, you can download it from here

If you want a sound from a youtube video, I recommend using this website: http://www.vidtomp3.com/

2 - Copy/Move the file to the content folder

Sound files to be compiled by Source2 dota need to be placed in the content\dota_addons\ADDON_NAME\sounds folder. If you don't have it, create one.

Folder structure:

img

3 - The Custom Sounds Valve Event

Also inside the content folder of your addon, there should be an soundevents folder:

img

Create one if there isn't. Here is the place where text files with the .vsndevts extension are located. You can name it as you want was long as you keep that extension. I usually use custom_sounds.vsndevts for all the addon's sounds, and make sure to precache this file somewhere (usually it's easier to do it once in Lua Precache(context) and forget about it).

The structure of the file is quite simple, it's a KV list with a sound string name as the first value of each sound block and then many values that control different properties of the sounds which aren't really important most of the times if you use this code:

"SoundStringName"
{
    "operator_stacks"
    {
        "update_stack"
        {
            "reference_operator"
            {
                "operator"              "sos_reference_stack"
                "reference_stack"       "dota_src1_3d"
                "operator_variables"
                {
                    "vsnd_files"
                    {
                        "value"
                        {
                              "value0"        "sounds/FileName.vsnd"
                        }
                    }
                    "volume"            {   "value"     "10.00000"  }
                    "pitch_rand_min"    {   "value"     "-0.05000"  }
                    "pitch_rand_max"    {   "value"     "0.050000"  }
                    "pitch"             {   "value"     "1.000000"  }
                    "soundlevel"        {   "value"     "100.00000" }
                    "distance_max"      {   "value"     "1600.000"  }
                    "event_type"        {   "value"     "1.000000"  }
                }
            }
        }
    }
}

First "SoundStringName", which is your desired sound string and will be used to Fire/Emit it

Last and most important, the "sounds/FileName.vsnd" contains a relative path to the sound files compiled valveSound. The sound you added on the step 2 was an mp3, the engine will convert this sound to .vsnd when the .vsndevts file is compiled/build.

In this whole block, the only lines you want to change when doing the new sound. Here's the whole CourierMadness' custom_sounds.vsndevts, as you can see, its basically a big copy paste of the same block, just changing those 2 lines.

You can change the volume/pitch of your sounds of course, play around the operator_variables for this.

Step 4 - Emitting and making sure the sound is being compiled

Once the sound event file is done, you need to force the game to compile it before calling the string with KV "FireSound" or any Lua EmitSound() variant.

For this, go into the Workshop Tools Asset Browser of your addon, type the name of your custom sound event and do a Full Recompile+Reload

img

Now, if you go into your game addon folder, there should be a sounds and soundevents folder, which should contain your _c compiled version of the files made in the content folder.

img

If this isn't the case, go into the Asset Browser again and instead of your sound event, type the name of your sound file, and click on it, if it starts playing, it has been properly compiled.


Thanks for reading, leave any questions below.

The concept of Modding Community doesn't go well together with Competitive Business
My Project Page || My GitHub Profile ||

Comments

  • edited June 2015 Posts: 1

    Hi, i have some trouble. I try compile a .vsndevts, but asset browser didn't see it. Is this method still works?

  • Posts: 12

    This method works. I also confirm that it works for WAV files.

  • Posts: 67

    Can see it through asset browser( so sad(

  • edited August 2015 Posts: 10

    Thanks for this tutorial!

    Could you also include the relevant line of code for precaching this sound, for clairty?

  • edited August 2015 Posts: 21

    nvm, saw my mistake

  • Crazyloon,

    PrecacheResource("soundfile", "soundevents/custom_sounds.vsndevts", context)
    

    assuming you named the file 'custom_sounds.vsndevts'. This goes into the Precache function in addon_game_mode.lua

  • Anyone has a Template for Hero Voice Soundevents ? Or where i can find the dota2 soundevents ?

  • Use the asset browser to find the sound that you want, then use D2Modkit or search the d2vpk github for the corresponding sound name and vsndevts file

  • edited August 2015 Posts: 21

    but there are no soundevents in the d2vpk github, only the single sound files, thats not what i need :/

    talking about files like that: soundevents/game_sounds_heroes/game_sounds_juggernaut.vsndevts

    i want to know how to name the single files inside the soundevent so it automatically takes the correct voiceline

  • In an effort to potentially save someone a massive headache in the future... make sure your soundevents folder is not inside your sound folder in the content directory

    I did this at first and it was really annoying trying to figure out what was wrong since the sounds would show up in the asset manager and would randomly sometimes work in the game.

  • Help pls, I've got such problem: enter image description here

  • @Brat_Boroda try Reload first and see if you can Recompile it after that. Also check to see if the file is in the correct folder. If it still isn't working, maybe there is a syntax error in there

  • edited January 2016 Posts: 1

    @ThirdToenailHair help please Where are mistakes in my script? I have the same problem like @Brat_Boroda

    "add.dire"
    {
        "operator_stacks"
        {
            "update_stack"
            {
                "reference_operator"
                {
                    "operator"              "sos_reference_stack"
                    "reference_stack"       "dota_src1_2d"
                    "operator_variables"
                    {
                        "vsnd_files"
                        {
                            "value"
                            {
                                  "value0"        "sounds/dire.vsnd"
                            }
                        }           
                        "volume"            {   "value"     "1.000000"  }
                        "pitch"             {   "value"     "1.000000"  }
                        "event_type"        {   "value"     "0"  }
                        "memory_type"        {   "value"     "0"  }
                    }
                }
            }
        }
    }
    
  • Posts: 1

    i have problem: when i click reload or full recompile Nothing happens! i think it's difficult for me. I will be grateful if any one can help me and convert to vsnd_c 20 files for me

  • edited April 2016 Posts: 1

    i have the same problem with CH453R.nothing happens when i click full recompile. it doesnt convert sound files. it would be nice if someone help me or share a tutorial video.

  • edited April 2016 Posts: 127

    The soundevents must be in content folder! Not any other. Something like: content/dota_addons/your_mod_name/soundevents

    Second, i think structure of the file must be somethink like this

    "TestEvent.TakeRune"
    {
        "operator_stacks"
        {
            "update_stack"
            {
                    "reference_operator"
                    {
                        "operator"      "sos_reference_stack"
                        "reference_stack"       "src1_3d"
                        "operator_variables"
                    {
                        "vsnd_files"
                        {
                            "value"
                            {
                                "value0"        "sounds/items/rune_dd.vsnd"
                            }
                        }
                        "volume_min"
                        {
                            "value"     "0.800000"
                        }
                        "volume_max"
                        {
                            "value"     "0.800000"
                        }
                        "pitch_min"
                        {
                            "value"     "0.950000"
                        }
                        "pitch_max"
                        {
                            "value"     "1.050000"
                        }
                        "chan_type"
                        {
                            "value"     "6"
                        }
                        "memory_type"
                        {
                            "value"     "0"
                        }
                        "soundlevel_min"
                        {
                            "value"     "84.000000"
                        }
                        "soundlevel_max"
                        {
                            "value"     "84.000000"
                        }
                        "mixgroup"
                        {
                            "value"     "Weapons"
                        }
                    }
                }
            }
        }
    }
    

    Or something like this:

    "Test_Hero.Spawn.Here"
    {
        "operator_stacks"
        {
            "update_stack"
            {
                "reference_operator"
                {
                    "operator"          "sos_reference_stack"
                    "reference_stack"           "dota_src1_3d"
                    "operator_variables"
                    {
                        "vsnd_files"
                        {
                            "value"
                            {
                                "wave0"     "sounds/misc/spawn_hero_test.vsnd"
                            }
                        }
                        "volume_min"
                        {
                            "value"     "0.600000"
                        }
                        "volume_max"
                        {
                            "value"     "0.600000"
                        }
                        "pitch_min"
                        {
                            "value"     "0.950000"
                        }
                        "pitch_max"
                        {
                            "value"     "1.050000"
                        }
                        "chan_type"
                        {
                            "value"     "6"
                        }
                        "memory_type"
                        {
                            "value"     "0"
                        }
                        "soundlevel_min"
                        {
                            "value"     "90.000000"
                        }
                        "soundlevel_max"
                        {
                            "value"     "90.000000"
                        }
                        "mixgroup"
                        {
                            "value"     "Stingers"
                        }
                    }
                }
            }
        }
    }
    
  • Posts: 1

    how to use the sounds for abilities?

  • Posts: 1,670

    ^

    KV "FireSound" or any Lua EmitSound variant, although some of them are broken as of late. There's also the a way to play it on the client only using Game.EmitSound

    The concept of Modding Community doesn't go well together with Competitive Business
    My Project Page || My GitHub Profile ||

  • Guys , i have 32 bit os. May you convert my sound files ?

    Workshop tools does not work on 32 bit :(

  • Posts: 40

    Hey ! I just keep getting this message

    [   AssetSystem ]: Reloading Resource [1/1]: soundevents/custom_sounds.vsndevts
    [   AssetSystem ]: Flushing persistent asset info to disk, 570.537 seconds since last, 1000 change delta
    [ W AssetSystem ]: AssetSystem unable to save persistent info to 'E:\SteamLibrary\steamapps\common\dota 2 beta\game\D2Cmods\tools_asset_info.bin'
    [   AssetSystem ]: AssetSystem saved persistent info for 1 layers / 63 assets in 0.011 sec
    

    In my Game/Dota_addons/Level1_Duel is created a soundevents directory which contains custom_soundevents.vsndevts_c

               REDI    μ   NTRO     DATA  Δ  P              Œ                                      œ                         /   dΔ-   soundevents/custom_sounds.vsndevts dota_addons/level1_duel     $           ___OverrideInputData___ BinaryBlobArg          IsChildResource                     ~_;TH   0Ae          H             Ϊ£ Έ[   bύνŒ          X          VSoundEventScript_t              Ϊ£ Έ   m_SoundEvents VSoundEvent_t    H                      <                     /                     m_SoundName m_GameData m_OperatorsKV                    Level1_Duel.AxeSound 
    {
        type = "dota_update_default"
        vsnd_files = 
        [
            "sounds/AxeSound.vsnd",
        ]
        volume_min = "1.000000"
        volume_max = "1.000000"
        pitch_min = "1.000000"
        pitch_max = "0.051000"
        chan_type = "6"
        memory_type = "0"
        soundlevel_min = "100.000000"
        soundlevel_max = "100.000000"
    } 
    
  • (Sorry if I sound like an idiot but I really want to know if this is possible or not) Is there a way to make a looping sound using these? (eg. the sounds that play on heroes endlessly and get louder when they move)