Results 1 to 20 of 22

Thread: El Monstero's Definitive Guide to Modding Med 2's Music

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    El Monstero29's Avatar Semisalis
    Join Date
    Sep 2013
    Location
    St. Louis, USA
    Posts
    436

    Default El Monstero's Definitive Guide to Modding Med 2's Music

    Hello fellow Med 2 modders!

    The aim of this tutorial is to gather together all available information on the subject of adding and modifying Med 2's music. Currently, there is no single guide one can follow to learn how to do everything that is possible. As it stands, finding all the relevant information that's out there can be quite frustrating and time consuming. I aim to change that I intend to make this guide as easy to follow, clear, and concise as possible. I will start from the most basic steps on up to the more advanced stuff. Feel free to skip ahead to sections you find relevant to your needs.

    Before we start I will thank all those that have come before me and shared their knowledge and findings on these matters such as Trajan, Gigantus, and Space_Ed. Without them this guide would not exist. I will link to all my sources at the end. Credit where credit is due.

    This stuff can get pretty complicated so in order to hopefully make it a little bit less confusing to someone coming into this with no prior knowledge of Med 2 modding I have created a legend for the various meanings behind the differently colored text used throughout this guide:

    Legend

    Green text - refers to text files
    Red text - refers to .dat and .idx files
    Dark blue text - refers to music_type
    White text - refers to region names
    Courier New font- refers to file paths and names
    Bolded/underlined text - refers to example factions



    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Section 1: Finding the appropriate files

    Spoiler Alert, click show to read: 
    First thing's first. How do you find the music and associated text files?

    Steam Version:

    1. Go to your Steam library and find Med 2.
    2. Right click Med 2 and select "properties" at the bottom of the drop down menu that opens.
    3. In the new menu that pops up click the "Local Files" tab and then "Browse Local Files." This will pull up Med 2's main directory. Ex. C:\Steam Library\steamapps\common\Medieval II Total War
    4. From the main directory, you would navigate to the "mods" folder and choose which ever mod you are editing.
    5. Once the appropriate mod has been chosen you need to navigate to data/sounds. The files you need are Music.dat/Music.idx and Events.dat/Events.idx. The other file you will need is located in the data folder: descr_sounds_music.txt.
    6. If you plan on making faction specific music then you will need descr_sounds.txt, found in the data folder. You will also need to navigate to data/world/maps/base and find descr_sounds_music_types.txt. Another file that may prove to be very useful to have on hand is descr_strat.txt, located in data/world/maps/campaign/imperial_campaign.
    7. Go ahead and create a backup of all of the text files you plan to edit before you do anything else. The sound extractor I will link below will make a backup of your sounds folder, but it's still a good idea to make another backup somewhere else you can access easily just in case.
    8. Use Notepad++(https://notepad-plus-plus.org/download/v7.5.4.html) to edit those text files. Never use the regular version of notepad to edit these things! Your game WILL crash constantly afterwards!


    Disc Version:
    Ideally, you will remember which drive you installed the game on. Once you locate the appropriate drive the game will most likely be in a location similar to this: C:\Programs\SEGA\Medieval II Total War

    From there simply follow the instructions above starting at step 4.


    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Section 2: Extracting the music

    Spoiler Alert, click show to read: 
    I suggest you use Withwnar's "Sound Extractor v1.2" to extract the music. It is very easy to use and is a welcome upgrade to the original XIDX tool. I will copy and paste his instructions on how to use this tool below. However, you will need to download the tool itself from his page. You may want to throw some rep his way while you're there


    Instructions
    These instructions use the Third Age mod as an example only:
    • TATW mod folder = something like C:\Programs\SEGA\Medieval II Total War\mods\Third_Age

    Use the appropriate folder for the mod you are running this for. Or the root installation folder if you are running this for vanilla (e.g. C:\Programs\SEGA\Medieval II Total War).

    NOTE: you will need a fair amount of free hard drive space! Go to the mod's sounds folder (e.g. C:\Programs\SEGA\Medieval II Total War\mods\Third_Age\data\sounds) and get the sum total of all of the *.dat and *.idx files (select them all, right click > Properties). You will need about twice that amount of free space. e.g. If the total is 400MB then you will need 800MB of free space: probably a bit more.

    Instructions:
    1. Download the attachment and extract it to the mod folder:
      • NOTE: Extract it such that it extracts directly into the folder (e.g. "Extract Here") rather than into a new subfolder (e.g. "Extract to SoundExtractor...")
      • There should now be a SoundExtractor folder under the mod folder. e.g. C:\Programs\SEGA\Medieval II Total War\mods\Third_Age\SoundExtractor
      • i.e. SoundExtractor.bat should be located here: {mod folder}\SoundExtractor\SoundExtractor.bat, not here: {mod folder}\SoundExtractor\SoundExtractor\SoundExtractor.bat

    2. Run (double-click) SoundExtractor.bat
      • NOTE: For Vista/Windows7/later users you might need to run it as an administrator: right click > Run as administrator

    3. A command window opens and shows you the progress: it will tell you when it has finished
    4. Now you may install the files for the submod that this SoundExtractor is being used for. Do not start the game until the submod is installed.

    After it has finished you should see this in the sounds folder:
    • Music, SFX and Voice subfolders
    • A "backup" subfolder with today's date: inside that are dat/idx files
    • No dat/idx files in this sounds folder


    Once you have finished installing the submod (not this SoundExtractor: the submod that this SoundExtractor is being used for) start the campaign. This will rebuild the dat/idx files in the sounds folder - this is what the game uses. The other folders are now no longer needed so you may delete them (freeing up a lot of hard drive space). i.e. You may delete the Music, SFX and Voice subfolders and the "backup" subfolder. NOTE: if you are merging multiple submods then read below before deleting anything: you might still need them.


    For our purposes you may as well just copy and paste the backup copies of SFX.dat/SFX.idx and Voice.dat/Voice.idx from the backup folder that was created in the sounds folder and put them back. You can delete the extracted version of these files as they are not relevant to what we're doing. You can also choose to ignore them for now. They will be taken care of the first time you load the game up as mentioned in Withwnar's instructions.


    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Section 3: Adding your own music into the game

    Spoiler Alert, click show to read: 
    At this point I would suggest you make a copy of the extracted Music folder that has been created and place that copy somewhere else on your pc. It would be a good idea to create a folder from which you can do the entire editing process, preferably outside of your actual game files. This will just allow you to keep everything tidy. I would suggest you create two folders inside this new folder. One which will hold all the files you are editing and one for the music you intend on adding to the game. I would recommend you set up the first folder in such a way that you can simply drag and drop it into your Med 2 game files and it will just copy over and put all the files in the appropriate place. This will make things much easier later down the line. To do this make a yet another folder and name it data. Place descr_sounds_music.txt and descr_sounds.txt in this folder and now also create a Sounds folder. You will also need to make a folder called world with another folder called maps with another folder named base. In that last folder you can place your copy of descr_sounds_music_types.txt. Remember that this part is optional but I can't emphasize enough on how much time this will save you. If you ignore this part then you will need to add all of the green text files back to the appropriate sections manually each time you edit them.

    For all examples below I will use the Divide and Conquer submod for Third Age. Your files won't look exactly like this unless you are using that mod. The relevant files you will need for this part are as follows: The extracted Music.dat folder, descr_sounds_music.txt, descr_sounds_music_types.txt, and possibly descr_strat.txt.

    So how do you actually add your music into the game?

    1. The first thing to do is to open up all the green text files listed above in notepad++. You can have all of them open at once which will prove very useful.
    2. You need to figure out the internal file name of the faction you're looking to modify. To do this, do a control+f search for the faction in question. Depending on the mod you're playing the internal file name might not have anything to do with the name of the faction in-game. For example: If I search for Mordor in Divide and Conquer's descr_strat.txt I will find first all of the resource entries for Mordor(bolded underlines added by me), but if I keep clicking "find next" eventually I find that they are actually listed as england.
      Code:
      ;###########################
      ;##### Faction: Mordor #####
      ;###########################
      
      faction    england, fortified knud
      ai_label default
      ;ai_label        evil
      denari            6000
      denari_kings_purse    850
    3. Now that you have that information you need to find out which music_type your faction is listed under in descr_sounds_music_types.txt. So I will now control+f in this file for england and find that their are part of the eastern_european music group:
      Code:
      music_type eastern_european
      
          regions Gorgoroth_Province Gorgoroth_South_Province East_Gorgoroth_Province Carnen_Province Udun_Province
          regions Morgul_Vale_Province Morgai_Province Cirith_Province Orc_Province Nan_Curunir_Province Angsul_Province
          regions High_Pass_Province Central_Mountains_Province East_Deep_Mirkwood_Province Brethil_Province
          regions Grey_Mountains_Province Carn_Dum_Province Mt_Gram_Province Mt_Gundabad_Province Ettenmoors_Province
          regions Litash_Province Grey_Foothills_Province Arthedain_Rammas_Province Isenmouthe_Province Rhudaur_Province
      
          factions england poland france hre portugal
    4. Now let's find the relevant section of descr_sounds_music.txt. So, let's control+f in this file for music_type eastern_european. We will find that they are listed under the generic title of "Orcs" followed by a ton of other stuff:
      Code:
          ; Orcs
      
          music_type eastern_european
              state MUSIC_BATTLE_BATTLE
                  event
                      folder data/sounds/Music
                      orcs_battle_01.mp3
                      orcs_battle_02.mp3
                      orcs_battle_03.mp3    
                      orcs_battle_04.mp3
                      orcs_battle_05.mp3
                      orcs_battle_06.mp3
                      orcs_battle_07.mp3
                      orcs_battle_08.mp3
                      orcs_battle_09.mp3
                      orcs_battle_10.mp3
                      orcs_battle_11.mp3
                      neutral_battle_01.mp3
                      neutral_battle_02.mp3
                      neutral_battle_03.mp3
                      neutral_battle_04.mp3
                      neutral_battle_05.mp3
                      neutral_battle_06.mp3
                      neutral_battle_07.mp3
                  end
          etc...
    5. The entries in this section determine which songs in the Music.dat folder will play for the factions listed under the music_type in question. It is broken down in several sections which I will explain in detail below. The major gist of it should be pretty obvious once you look at it. It's mainly broken down between battle and stratmap.
    6. You can now add your songs into the extracted Music folder. Make sure they are in mp3 or wav format! Non mp3 or wav format songs will simply not play in game. There will be silence in their place. Mp3 songs are going to be smaller (in regards to file size) than wav so it's pretty much always worthwhile to convert any songs to that format A free music file converter I personally recommend would be Switch Sound File Converter
    7. Now enter the text entry for each song you add to the extracted Music folder. For example we'll pretend we added a song called new_music_01.mp3:
      Code:
      music_type eastern_european
              state MUSIC_BATTLE_BATTLE
                  event
                      folder data/sounds/Music
                      orcs_battle_01.mp3
                      orcs_battle_02.mp3
                      orcs_battle_03.mp3    
                      orcs_battle_04.mp3
                      orcs_battle_05.mp3
                      orcs_battle_06.mp3
                      orcs_battle_07.mp3
                      orcs_battle_08.mp3
                      orcs_battle_09.mp3
                      orcs_battle_10.mp3
                      orcs_battle_11.mp3
                      new_music_01.mp3
    8. Make sure you include the ".mp3" part in every entry as it won't recognize your songs if you don't. Also, Make sure you hit save on each and every tab of your files open in notepad++ to ensure your changes carry over. However, ensure you don't save any edits to descr_strat.txt as that could potentially screw you over!
    9. After you're finished adding your music and editing the text files you are ready to copy and paste everything back into your actual game(assuming you've been working in a seperate file.
    10. Navigate back todata/sounds in your mod. You want to ensure that you only have the extracted Music folder in there. As stated before you should have put SFX.dat/SFX.idx and Voice.dat/Voice.idx back. Those files are fine. You do also want to delete the extracted effect_evt file as this needs to be rebuilt along with the Muisc folder.
    11. To rebuild the music launch the mod you are editing. It may or may not crash before getting to the main menu. This is fine. Quit after getting to the main menu if your game does make it that far, as you will crash if you try to load into a campaign at this point. If you go back to the data/sounds folder you will find that Music.dat/Music.idx and Events.dat/Events.idx have been completely rebuilt and now your music is in the game!
    12. Launch the game once again and bask in the glory of your own music.


    What does each section in the descr_sounds_music.txt denote?

    state MUSIC_BATTLE_BATTLE - Songs in this section play when your units actually engage the enemy on the battlemap

    state MUSIC_BATTLE_MOBILIZE - These play when you give movement orders in a battle but haven't actually engaged the enemy yet

    state MUSIC_BATTLE_TENSION - These songs play during the deployment phase and/or during a lull in the battle

    state MUSIC_CAMPAIGN_LOADING - Plays during the loading screen between choosing your faction in the faction selection screen and the campaign map.

    state MUSIC_CAMPAIGN_VICTORY - The song that will play after a campaign victory is achieved

    state MUSIC_CAMPAIGN_DEFEAT - Plays if you manage to lose a campaign

    state MUSIC_CREDITS1 delay 3 - Plays during the credits scene that will play after either campaign victory or defeat

    state MUSIC_CREDITS2 - Not sure what the difference is between this one and the one above

    state MUSIC_FRONTEND - This is the song that plays on the main menu. NOTE that you can have more than one song in this category! However, the game will pick one song that it will favor over the others. For example, if you make 3 songs in this category then the game will favor the second song over the other two. I couldn't tell you why, it's just the behavior I've observed in my testing. Also worth noting that you can make each music_type have it's own set of main menu music. However, I don't actually know how that works out in game as I've never tested that.

    state MUSIC_PREBATTLE_SCROLL - The song that will play when the battle scroll is first initiated on the campaign map.

    state MUSIC_RESULT_DRAW, MUSIC_RESULT_LOSE_AVERAGE, MUSIC_RESULT_LOSE_CLOSE, MUSIC_RESULT_LOSE_CRUSHING, MUSIC_RESULT_WIN_AVERAGE, MUSIC_RESULT_WIN_CLOSE, MUSIC_RESULT_WIN_CRUSHING - These are the songs that will play while the player is viewing the after battle report while still on the battlefield based on the outcome of the battle.

    state MUSIC_RESULT_STRAT_DRAW, MUSIC_RESULT_STRAT_LOSE_AVERAGE, MUSIC_RESULT_STRAT_LOSE_CLOSE, MUSIC_RESULT_STRAT_LOSE_CRUSHING, MUSIC_RESULT_STRAT_WIN_AVERAGE, MUSIC_RESULT_STRAT_WIN_CLOSE, MUSIC_RESULT_STRAT_WIN_CRUSHING - These are the same as above except they play when you get back to the campaign map after a battle.

    state MUSIC_STRATMAP_SUMMER - These songs will play during the Summer season on the campaign map

    state MUSIC_STRATMAP_WINTER - These play during the Winter Season on the campaign map



    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Section 4: Creating faction specific music

    Spoiler Alert, click show to read: 
    You know how to add music into the game, but what if you want to split up the various music_types? What if you want every faction to have their own separate playlist? Can these things be achieved? Absolutely!

    You will need all of the files that have been mentioned thus far for this process: the extracted Music file, descr_sounds_music.txt, descr_sounds.txt, descr_sounds_music_types.txt, and descr_strat.txt. If you need help locating these files refer to section one of the guide.


    1. You will need to know the internal file name of the faction in question. This can be found in the descr_strat.txt file. For detailed instructions on this refer back to Section 3 of the guide.
    2. With the true name of the faction in hand you must now refer to descr_sounds_music_types.txt. You want to first remove that faction from whatever music_type it is currently a part of. I will use Mordor(with the internal file name of england) from the Divide and Conquer submod as my example once again.
      Code:
      music_type eastern_european
      
          regions Gorgoroth_Province Gorgoroth_South_Province East_Gorgoroth_Province Carnen_Province Udun_Province
          regions Morgul_Vale_Province Morgai_Province Cirith_Province Orc_Province Nan_Curunir_Province Angsul_Province
          regions High_Pass_Province Central_Mountains_Province East_Deep_Mirkwood_Province Brethil_Province
          regions Grey_Mountains_Province Carn_Dum_Province Mt_Gram_Province Mt_Gundabad_Province Ettenmoors_Province
          regions Litash_Province Grey_Foothills_Province Arthedain_Rammas_Province Isenmouthe_Province Rhudaur_Province
      
          factions england poland france hre portugal
    3. So, I will remove england from that list but I also need to remove the regions associated with Mordor from that section. These regions are marked in white in the above example You will need to refer to descr_strat.txt once again for this information. So after I finish that the entry will look like this:
      Code:
      music_type eastern_european
      
          regions Nan_Curunir_Province Angsul_Province
          regions High_Pass_Province Central_Mountains_Province East_Deep_Mirkwood_Province Brethil_Province
          regions Grey_Mountains_Province Carn_Dum_Province Mt_Gram_Province Mt_Gundabad_Province Ettenmoors_Province
          regions Litash_Province Grey_Foothills_Province Arthedain_Rammas_Province Rhudaur_Province
      
          factions poland france hre portugal
    4. I will now create a totally new section at the bottom of descr_sounds_music_types.txt for Mordor. We need to create a new music_type, which I will very creatively name mordor. We also need to re-add all those regions we just deleted from the old entry. Finally, don't forget to add the "factions" section at the bottom of your new entry. It should look something like this:
      Code:
      music_type mordor
      
          regions Gorgoroth_Province Gorgoroth_South_Province East_Gorgoroth_Province Carnen_Province Udun_Province
          regions Morgul_Vale_Province Morgai_Province Cirith_Province Orc_Province Isenmouthe_Province
          
          factions england
    5. Next you need to open up descr_sounds.txt and add the new music_type to the list. Control+f is the easiest way to find it although you can just scroll down too, it's quite close to the top. This is what it should look like after you're done:
      Code:
      ;################################
      ;##### SOUNDS - MUSIC TYPES #####
      ;################################
      
      music_types_enum northern_european eastern_european southern_european middle_eastern mesoamerican greek gondor milan mordor
    6. Almost done! Next you need to create a new section in descr_sounds_music.txt. In this case, I will simply use the music_type eastern_european as a template and copy/paste that entry into the bottom of the document. I must simply remember to swap out music_type eastern_european with music_type mordor. Like so:
      Code:
       music_type mordor
              state MUSIC_BATTLE_BATTLE
                  event
                      folder data/sounds/Music
                      orcs_battle_01.mp3
                      orcs_battle_02.mp3
                      orcs_battle_03.mp3    
                      orcs_battle_04.mp3
                      orcs_battle_05.mp3
                      orcs_battle_06.mp3
                      orcs_battle_07.mp3
                      orcs_battle_08.mp3
                      orcs_battle_09.mp3
                      orcs_battle_10.mp3
                      orcs_battle_11.mp3
                      neutral_battle_01.mp3
                      neutral_battle_02.mp3
                      neutral_battle_03.mp3
                      neutral_battle_04.mp3
                      neutral_battle_05.mp3
                      neutral_battle_06.mp3
                      neutral_battle_07.mp3
                  end
           etc...
    7. Now all that's left is to add your music to this new faction like we did in Section 3. That's it!



    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Section 5: Known limitations and (not so) frequently asked questions

    Spoiler Alert, click show to read: 
    1. There DOES NOT appear to be a limit to the amount of music you can have. I currently have a music.dat file that is 2.05gbs and everything works as intended!

    2. One limitation is that each region of the campaign map can only have one music_type associated with it in the descr_sounds_music_types.txt file. Meaning that only one set of battle music of one music_type can play in a single region no matter which faction the player is in control of.

    (not so)F.A.Q.


    When should I rebuild the Music.dat and Music.idx file?
    You need to rebuild both Music.dat/idx and Events.dat/idx anytime you make a change in the relevant text files. Failing to do so will mean your most recent changes aren't carried over into the game.

    Do I need to rebuild Events.dat and the idx file everytime I rebuild Music.dat? Yes.
    Are spaces, indents, and other bits of formatting important? YES! Messing up any formatting anywhere can and will cause you problems. Whether those problems manifest right away isn't alway guaranteed, but generally you should try to be as precise and clean with your formatting as you possibly can.

    How many songs can I include in Music.dat? In my testing I managed to get up to 344 songs with no problems. So long as you stay under the size limit mentioned above you'll be fine.

    Does the bitrate(kbps) of the music matter? Not that I can tell. I ended up using songs that were all over the place in terms of bitrate anywhere from 160 to 246kbps. The only thing to keep in mind is that higher bitrate equals larger file size, but also better audio quality.

    Can I add a single region to multiple music_types? No.

    Can I name my music_types anything I want? Yes, you could create a music_type potato_salad if you wanted. So long as you make sure you are consistent with your naming scheme in all the relevant files.

    I'll add any other questions here if you guys have any


    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Section 6: Resources and credits

    Spoiler Alert, click show to read: 
    Royalty Free Music courtesy of GrnEyedDvl
    Remixed Medieval Music courtesty of Reimu Hakurei

    Sources for this guide:
    Trajan's OG guide
    Space_Ed's Faction specific music guide
    Special shoutout to Gigantus for the dozens upon dozens of helpful comments he's made over the years that are scattered all about!
    Another shoutout to Withwnar for exemplary excellence in expanding our knowledge on this subject!


    That's all she wrote! Hopefully this guide will still be useful even if the game is closing in on 12 years old.... At least now you won't have to read through several different threads and page after page of comments to get answers to your questions.

    Enjoy and good luck out there!
    Last edited by El Monstero29; July 04, 2020 at 08:48 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •