Difficulty: Difficulty-5
Clock: 10-15 mins

**tutorial by GroxTheGreat**


This tutorial will go over how to utilize SoundHandler's Wavebank handling to have music played from wavebanks for custom biomes or npcs/bosses.

Getting the wavebankEdit

First things first, you need to make your Wavebank. This is the harder part of this tutorial and is rather long.To make Wavebanks, you use XACT, a program designed to make wavebanks. Click here to get the DirectX Software Development Kit, which includes XACT.

XACT is located wherever you installed the DSDK. (For windows users, it is usually located in C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\Tools\). The 'v4.0' can change depending on your XNA version.

Once you have found XACT, run it. You should have a window that looks like this:


Go to 'File -> New Project', name it whatever you like. Mine will be 'Biome.xap'. Save it wherever you like. Right-click on 'Wave Banks' and choose 'New Wave Bank'.  On the bottom-left corner you should see a little 'General' box. Inside that box is a property called 'Name'. Change that to whatever you named the project to. (in my case, 'Biome')

Your window should now look like this:


Now we can add your .wav files here! Right-click on the big white space to the right and choose 'Insert Wave File(s)'. You will get a browser, just choose all of your .wav files that you wish to add to the wavebank. Once you've added them all, they should appear in the window. Next, right-click on 'Sound Banks' and choose 'New Sound Bank'. Like before, go to the General box and change the Name property to whatever your project name is.


Now click on the name of your .wav file in the Wavebank menu and drag it to the 'Cue Name' menu. If done correctly, the .wav name in the Wavebank menu should turn green and in the Soundbank menu, it should show up as well. (Note you might need to move the windows around to drag it to the Cue Name menu)


We now have a basic Wavebank! We still need to do some work before it's ready to be used, however. Right-click on 'Compression Presets', and choose 'new Compression Preset'. Compression Presets are used to compress the .wav files into sizes that are manageable. You don't have to name this preset, but you can if you want to. You can also mess around with the stuff in the General box, but the defaults work well enough. Now that we have this, we need to apply it! Click on the wave bank you made (in my case, 'Biome') under the Wave Bank tab. In the General box, you'll notice a 'Compression Preset' drop-down list. Click it and chose the preset you just made.


Now we need to add a new Variable to this project. Right-click on 'Cue Instance' and choose 'New Cue Instance Variable'. A Variable Settings menu will pop up, you can close that because we can edit it in the General box. Name the variable 'Volume'. This variable is very important because without it your music will not fade in or out properly when played ingame. Change the 'Variable Range' from whatever it is to '-96' and '6'. It should look like the first image below. Now we need to implement this variable, and to do that we use RPC Presets! Right click on 'RPC Presets' and choose 'New RPC Preset'. A new window should appear, and looks the second image.


Click on the 'Variable' dropdown list, and choose 'Volume'. Next, go to the Object list and choose 'Sound', and finally in the Parameter dropdown list choose 'Volume'. The black box below should now have turned into a graph! On the bottom-right hand corner, you should see 2 Points in the graph. Change both points to have '-96' going to '-96' and '6' going to '6' instead of the ranges it gives. It should now look like this:


We are nearly finished! Now we need to connect this Preset to our wavs. Close the window in the image above and then Right-Click on the Preset we just made, and choose 'Attach/Deattach Sound(s)...'. In the screen that follows, simply choose all the sounds on the left and click 'attach >'. When all sounds are attached to the Preset, click 'OK'.

Congratulations, you've made a wavebank that is compatible with tConfig! The final thing we need to do is compile it. On the hotbar under the file bar, click the picture farthest over. (Looks like a block pyramid with a wave over it) This will compile the project. It will ask if you want a report, just keep it as none and click 'Finish'. It will now compile them all into the files we need.

When it finishes go to where your project was saved. There should be 2 new folders - Win and Xbox. You can ignore the Xbox folder, we're only interested in what's in the Win folder. Open the Win folder.

You should have 3 files: an .xgs, an .xsb and an .xwb. If done right, all 3 should be named the same. If they aren't, go back and repeat some steps, or it will not work!

Now go to your mod's folder and add a 'Music' folder, and put the 3 files in that folder. In my case, the mod is called 'WavebankMusic', so it would go in 'ModPacks/WavebankMusic/Music/'.

Calling the Wavebank for your BiomeEdit

Now that we have the Wavebank made and properly installed, we can now implement it to our biome. Add this to Global/Generic.cs:

public void OnLoad()


     string modName = "WavebankMusic"; //name of your mod

     int tileCount = 10; //How many tiles must be on screen for the biome to take effect.

     //the first List<int> is tiles in your biome. For testing I used 0 (dirt) and 1 (stone).

     Biome b = new Biome("TestBiome", new List<int>(){ 0, 1, Config.tileDefs.ID["CustomTile"] }, new List<int>(){ }, tileCount); //change "TestBiome" to the name of your biome.

     b.biomeMusicPriority = Biome.MusicPriority.Med; //the priority for the music. None = no music, Low = override little, Med = normal biome, High = meteor-like biome.

     b.GetMusic = () => 


          return new SoundHandler.MusicCustomBank("BiomeMusic", modName); //my .wav file was named BiomeMusic, put your .wav file's name here.




That's all! Compile your mod and test if the music plays when near your tiles.

Calling the Wavebank for your NPC/BossEdit

This is fairly simple, all you need to do is add this short line to your NPC's .ini file:

musicName=NPCMusic; name of the .wav in your wavebank

Once that's done, compile and test if the music plays when the npc is spawned.