# Adding Custom Music - An Updated Tutorial

Posted in Support
With the release of the RMS builder, adding custom music has become a lot simpler. I thought I might as well write a tutorial on how to do this, as it is a little bit unclear at first glance.

STEP 1: Extracting the Files

The first file you want to look at is music01.rcf. It is located in the game's root folder. To open it you need the RCF Explorer. Once in the file, you can navigate to the "music" folder. Inside there should be 7 files, all ending in .rms

Extract the file that corresponds to the level which you want to edit by right clicking it.

STEP 2: Converting the file

The .rms file in its current state cannot be edited, so the new RMS builder is used to convert it to an editable format. To convert the .rms file, drag it onto the RMS builder's EXE file.

Doing so will give you an l1_music.xml file. This can be opened in Notepad, Notepad++ or any decent word editor.

STEP 3: Creating the music file

Now it's time to create the actual music file. This is relatively simple to do and shouldn't take too long.
First we need to resample the audio file. This can be done easily in Audacity by heading down to the bottom left corner where it says "Project Rate (Hz)"

Make sure this reads 24000Hz. If it does not, click on it and change it to 24000Hz.
Now, there are three main formats that can be used for custom music: OGG, FLAC and RSD. They each require a slightly different setup, so please follow the instructions for the respective format.

OGG (recommended) Or FLAC

First, export the file in the format you would like. OGG is, in 99% of cases, the best format to use since it has much lower filesizes than the other formats. If however you experience noticeable compression, you may want to consider FLAC instead. Save the file in CustomFiles\sound\music\musicname.ogg/flac The filename can be whatever you like, however if it is the same as the filename of a song in the vanilla game then issues may arise.

Next, open up the Meta.ini of your mod. In the Required Hacks section, paste the following line of code in:
RequiredHack=OggVorbisSupport

Or
RequiredHack=FLACSupport

Obviously, just copy and paste the one that applies to whatever format you're using. If you're using both then you can also copy and paste both lines of code.

RSD (the vanilla format)

RSD is the format used by the vanilla game, and is generally not recommended because it has the highest filesize and is the most complicated. To begin, export the file in the WAV 16-bit signed PCM format. Make sure it is that exact format or else the RSD converter will not be able to read it.

First of all, open up an existing music RSD file using the RSD Converter. You can extract one in the same way you extracted the RMS file. From there, press the 'Import' button and select the .WAV file you saved earlier. You can now save the file in CustomFiles\sound\music\musicname.rsd The filename can be whatever you like, however if it is the same as the filename of a song in the vanilla game then issues may arise.

STEP 4: Editing the .XML

Next up is the hard part, editing the file. It isn't too hard once you get used to it but if you mess anything up then your mod will likely break.
The first thing you want to do is add an RSDFile code (this applies even if you use OGG or FLAC). The code you need to add is:
<RSDFile FileName="Music_File_Name"/>

Of course, replace Music_File_Name with the name of your music file. However do not include the file extension in the name. You'll notice that this is much shorter than the other RSDFile codes in the file, but this is fine because the BAT file will automatically add the other info needed.

Next we need to add a Stream entry. This is a very similar process. The code you need is:
<Stream Name="Music_File_Name" RSDFile="Music_File_Name" Streamed="true" TempoTrack="172 4/4" TempoTrackStartBeat="1" />

Again, replace both instances of Music_File_Name with the name of your music file. The 'TempoTrack' and 'TempoTrackStartBeat' sections don't appear to do anything, so the values in them shouldn't matter.

Next we need to add a region code. This is the most important piece because it defines everything about the way the music will play. The code needed here varies a bit, so you may need to change it to suit your needs:
	<Region Name="Region_name" Volume="1">
<Layer Name="l" Constant="true" Volume="1">
<LogicRepeatEvent>
<StreamEvent Name="Music_File_Name" />
</LogicRepeatEvent>
</Layer>
</Region>

Replace "Region_name" with the name you want it to be referenced by in other scripts, and again replace Music_File_Name with the name of your music file.

Now it's on to events. For this you will need to edit an existing code so that the game knows which event it triggers. For example, if I wanted my custom music to play in Mission 1 I would find the following code:
	<Event Name="M1_start">
<PlayRegionAction Region="M1_start_region" RegionResumeType="Resume" />
</Event>

And I would change "M1_start_region" to my region name that was specified in the previous segment.

STEP 5: RSDFile information
Now everything inside the .XML is finished, but we're not done yet. In order to set up the RSDFile information correctly without needing to do it manually, which can often result in mistakes, we need to create a .bat file. Making one is easy, just open Notepad and save the file as a .bat instead of a .txt.

Next we need to put the following code inside that .bat file, making adjustments as we need to.
@"C:\path\to\LRMSB.exe" -inputxml "%~dp0XML_FILE_NAME.xml" -outputrms "C:\path\to\YourMod\CustomFiles\sound\music\l1_music.rms" -rsdpath "C:\path\to\YourMod\CustomFiles\sound\music"

There's a lot in here that needs to be changed. First change "C:\path\to\LRMSB.exe" to be the correct path. You can easily find your path by holding SHIFT and right clicking on LRMSB.exe.

Next change XML_FILE_NAME.xml to be the file name of your modified .xml file. Make sure you do not delete the %~dp0 before the filename, otherwise it will not work. The .xml and the .bat also must be in the same folder.

Now change "C:\path\to\YourMod\CustomFiles\sound\music\l1_music.rms" to refer to where your .rms file will appear.

Lastly change "C:\path\to\YourMod\CustomFiles\sound\music" to refer to your music folder inside your CustomFiles directory.

For example, my .bat would look like:
@"C:\Users\Colou\Documents\LRMSB.exe" -inputxml "%~dp0l1_music.xml" -outputrms "C:\Users\Colou\Lucas' Simpsons Hit & Run Mod Launcher\Mods\Road Rage Music\CustomFiles\sound\music\l1_music.rms" -rsdpath "C:\Users\Colou\Lucas' Simpsons Hit & Run Mod Launcher\Mods\Road Rage Music\CustomFiles\sound\music"


Now just run the .bat and it should output an RMS file to your music folder. If it shows an error, then there is likely something wrong with your .xml. The error messages are generally very descriptive so you should look at what it says and figure out the problem.

And that's you done!
I hope this tutorial helped you create a working music mod. Since the release of this tool music modding has changed drastically so I hope this has helped you get to know the new tool a bit better.

USEFUL SOURCES: