Menu
 

How to convert game music to new sound sets

Started by Norrin Radd, July 27, 2008, 12:46AM

Previous topic - Next topic
July 27, 2008, 12:46AM Last Edit: October 07, 2008, 05:36PM by Norrin Radd
This describes how to convert music from the games MUA or XML2PC to custom sound sets. These are specifically meant for level sound files. The music sounds have the following hashes: music/XXX_c where XXX is the name that is referenced in the level eng/xml files on the line '   soundfile = XXX ;').

Required tools:
ZSM Editor 2.3 by Winstrol
Hex editor (example XVI32)

Step 1 Build custom sound set
You probably want to make the soundset a XXX_v.zss file if you're using your sound set for MUA, or XXX_c.zss if you're using XML2. Include all the files in your sound set using Zsm Editor. You can save yourself some time later if you put the _c music file as the first file on the list. It should be ID 00 (in the Files tab look under ID, and look for your YYY_c.wav file, where YYY is the name of the file where you are importing the music from). Since you imported the music from YYY, you may want to change the filename from YYY_c.wav to XXX_c.wav to avoid confusion later. You can change the name by clicking a few times on the part under the Files tab under 'File'.

Now you'll need to change the hash for the music file (and possibly many of the other files you imported, but that is beyond the scope of this 'how-to'). Using Zsm Editor, click 'Tools' then 'Text to hash'. This will allow you to get what your new hash should be. Where it says 'Input text' enter 'music/XXX_c' where XXX is the name that will be referenced by the level. Then click 'Convert' and a number will appear. Copy that number. Now get the ID of your XXX_c.wav file from the 'Files' tab. Go to the 'Events' tab and look for that same ID. Click on it, and paste your new hash over the old Event/Hash by double clicking or entering it in the tab below and clicking 'Add'.

Go to the 'Files' tab and mark down the 'Size' of the XXX_c.wav file. You will need it for Step 2.

Now save your new sound set.

Step 2 Copy game sound set data
Because Zsm Editor does not handle 41kHz stereo files, you will need to copy the data directly from its source. Open the sound set (with a hex editor) from where you imported the YYY_c.wav file. Search for 'YYY_c.wav' in the text portion (e.g., using cntrl+f for XVI32). If you go 8 bytes back you will see the file size (that you should have marked down before) in hex, and in little endian (so if it is 10 56 then the file size is 56 10 in hex). If you go four bytes before that (so 12 before the filename) you will see the offset to the data. Mark this number down (make sure to account for the endianness). Now go to that location in the file (the offset is the absolute value of which byte you should go to in the file).

You will now need to copy the data. You can block the set of bytes you need and then copy them. The amount of bytes you should block is the file size which you should have marked down.

Step 3 Paste game sound set data
You will now need to paste the sound set data into your custom sound set. Open your custom soundset with a hex editor. Using the same techniques described in step 2, find the offset for the data and go there. Now you will need to delete the number of bytes equal to the file size to remove the data which Zsm Editor included in the file. You then need to paste the data which you copied in step 2. If you don't want to delete, you can overwrite them instead, whatever you do, make sure the total file size of your sound file does not change. If it does, something wrong happened.

Step 4 Modifying parameters
You will now need to modify the parameters in your custom sound set to allow the sound to work correctly. Hopefully you put the XXX_c.wav file as ID 00. If yes, then in a hex editor, go to the beginning of the file and search for the hex string (not text) 22 56 00. It should be surrounded by other 22 56 00 entries after it (but not before it), like in the picture below. If you have put the XXX_c.wav file as ID 00, then the first one is the one you need to modify. If not, you will need to find the one you want to modify by using/matching the numbers beside the 22 56 00 entries and where you placed it in the file (as you can see in the picture, 4 bytes before the 2256 indicates the placement).



Once you find the one you need to edit, go back two bytes. Overwrite the 00 with 22 (note that for looping sounds in the _m level sound files, like for fires, put 01 instead of 22). If the music you took from the original game file is 41kHz, you will also need to change the 2256 to 28A0 (changing it from 22050Hz to 41kHz). If you're not sure you can try 2256 and run the game. If the music is really slow, bump it up to 28A0. It is also possible to check in the file where you imported the music from, that file should also have a 28A0 entry.

Now save the custom sound set, and you should be good to go.

Good luck