Adding custom sounds and music

From Heroes of Hammerwatch wiki
Jump to: navigation, search

Adding in custom sounds and music to your scenarios requires the usage of .sbnk files. While your computer likely doesn't recognize this file type, it is really a glorified text file and can be opened with any simple text editor, such as Notepad++.

The sound files themselves must be presented in any of the following formats: .wav, .ogg, .mp3, .mod, .it, .s3d, .xm. Each file format has its own benefits: .ogg files are relatively small, at the cost of some audio quality, while .wav files will take up more space but with good amount of quality. In the end, it is recommended to use .ogg for music, and .wav for sounds. An audio editing program such as Audacity can convert most common audio filetypes into most of these formats.

You can also use Fmod Studio to build your soundbank, that way you're not limited to the features of text-file sbnk files. This also allows you to add dynamic music, and add other kinds of effects to your sounds. See further in this article for more information.

Exporting sound files to .ogg

If your sound file is not already in any of the supported file formats, follow these steps to do so. Using Audacity, drag the sound file of your choice into the gray area. If successful, you will see the audio channel appear. You may now edit the sound file if you wish, otherwise, click the "File" tab and then the "Export" button. Select the file type you wish to use and export it to anywhere in your scenario folder, preferablly a dedicated folder called "sound". Continue to do this for all the sound files you need.

Creating the .sbnk file

With your sound files ready, you must now create an .sbnk file at which you can configure some parameters. Simply open a text editor like Notepad++, then copy this example code

<soundbank>
  <sound category="sfx" name="healgun_loop" volume="1" is3d="true" looping="true">
    <source res="sounds/healgun.wav" />
  </sound>
</soundbank>

You can edit the following parameters:

  • name: The name that the sound will appear in while using the editor.
  • volume: The volume of the sound file. 1 is the standard volume, but you can only make it quieter.
  • is3d: boolean. If set to true, the sound will only play in an area around the PlaySound WorldScript that it is assigned to. If false, it will play across the entire level.
  • looping: boolean. If set to true, the sound file will keep playing everytime it finishes. If false, it will only play once.

If you wish to add in more sound files, simply copy and paste the <sound> parameters and edit them accordingly. You can use as many as needed. When done, save the file as .sbnk.

Using the sound files in the editor

Open up a level, and navigate to the WorldScripts tab. Spawn in a PlaySound WorldScript. Select it, then in the "Sound" parameter, type in the name of your .sbnk file, or the name you gave the sound, and it will show up. You can do the same for the PlayMusic WorldScript.

Alternatively - use Fmod

The game uses Fmod internally to do all of its sounds. These kinds of sound effects start with the event:/ prefix instead of directly pointing to an .sbnk file. They are therefore found within a .bank file instead. It is possible to create your own Fmod Studio soundbanks for your scenarios.

Download Fmod Studio 1.10.8 from this page. Then, download this Fmod skeleton project to get your started. The reason this skeleton project is needed is because your settings must match ours exactly, which is what this does.

You will need to remove all the existing events and assets and create an additional mod_bank bank Add your events to your mod_bank. Export this and you'll be able to reference events from your bank in game using their GUID (which you can get in fmod by right clicking and event and picking Copy GUID)

for example:
 <string name="Music">{a78f74fa-fd1b-417d-a598-41c94e552470}</string> 

If using Fmod, you can dynamically control the sounds using parameters in your scripts. See Creating dynamic sounds with FMOD for more info.