Music modding

From Europa Universalis 4 Wiki
Jump to navigation Jump to search
This page deals with music used in mods. For the music in the game, see soundtrack.

Requirements[edit | edit source]

First, a modder needs a music file to add to Europa Universalis 4. This may be acquired from other mods, the modder's own personal music library or from other Paradox titles. Adding music to Europa Universalis 4 won't change its checksum, so it's still possible to play on ironman mode. Please be conscious of copyrights when adding music to the game and remember to give credit to the artists!

The music file must be in the .ogg format (and presumably has to use the vorbis codec), otherwise it won't be played. The file should have 32 bits, a 44.1kHz frequency and a 192KB/s bit frequency, otherwise it may not play correctly within the game. One free piece of software to format your music tracks is Audacity. The desired export settings can be found under the quality tab in the settings menu.

If you want to make your music mod work with other music mods and the vanilla music you need to make a unique name for the .ogg, .asset and .txt files. To overwrite the vanilla music, name your .txt file songs.txt.

Music folder and supporting files[edit | edit source]

In your mod you must create a folder named "music". In this folder use your text editor to create a .asset file and a .txt file. The .asset file will tell the game where to find your music track and the .txt file will tell the game when to play it. Name each file with a unique name. Add your .ogg music tracks to the folder according to the file-property requirements listed above.

.asset file[edit | edit source]

Open the .asset file in your text editor of choice and type the following code for each song you want to add:

music = {
      name = "songname" #name of the song as you want it to appear in-game
      file = "filename.ogg" #exact filename of your music file
}

Note: # indicates a comment and everything typed in a line after a # is not executed in the code.

.txt file[edit | edit source]

Open the .txt file in your text editor of choice and type the following code for each song you want to add:

song = { 
       name = "songname" #name of your song as defined in your .asset file
       chance = {
              modifier = {
                     factor = 1 #Base chance to play for everyone
              }
              modifier = {
                     factor = <number> #Numbers entered here multiply with other factors to alter the chance of a song playing
                     <triggers> #add in triggers here. When the trigger conditions are met the factor will be applied to the overall chance to play
              }
              #add additional modifiers below as desired using the format above
       }
}

Songs can have any number of modifiers applied to their chance to play and any number of triggers can be used to apply them. The most important thing to note is that the factors are multiplicative with each other. If a song meets the conditions for a factor of 1.2 AND a factor of 0.5 the resulting chance of the song playing will be . This means a song can be prevented from playing by using a factor of 0, which is most commonly used with the is_at_war trigger to prevent songs from playing when at peace/war. Some examples of this process are given further below.


A complete video walkthrough of the music modding process can be viewed on Youtube.

When you have finished, your music folder should have all the music you added in .ogg format, a unique music.asset file (vutm_music.asset for example), and a unique .txt file (vutm_song.txt for example) with each song written there.

The music files themselves should have 32 bits, a 44.1kHz frequency and a 192KB/s bit frequency and must be in .ogg format.

Examples[edit | edit source]

The example below from vanilla EU4 shows how the song "theageofdiscovery" will have zero chance of playing when you are at war and a 1.5x higher chance of playing if you have at least one colonist.

song = {
	name = "theageofdiscovery"
	
	chance = {
		modifier = {
			factor = 0
			is_at_war = yes
		}	
		modifier = {
			factor = 1.5
			num_of_colonists = 1
		}			
	}
}


This is an example song entry which tailors this particular custom song track for the mod "VU - Thematic Music" to play at the starting game date of 1444 until 1527 for the Christian religious group, except for Orthodox, Coptic, Miaphysite and Bogomilist religions.

As seen in songs.txt
song = {
	name = "ain_spaniyelischer_hoff_dantz"
	
	chance = {
	    modifier = {
            factor = 0
            is_year = 1527
        }
		modifier = {
			factor = 0
			NOT = { is_year = 1444 }
		}
		modifier = {
			factor = 2
			is_year = 1444
		}
		modifier = {
            factor = 0
            OR { religion = orthodox religion = coptic religion = miaphysite religion = bogomilist_new }
        }
		modifier = {
            factor = 0
            NOT = { religion_group = christian }
        }
		modifier = {
			factor = 2
			religion_group = christian
		}
	}
}

#Also, the entry above needn't be any more complex as the entered modifiers allow it to work perfectly. Below are examples of entries that can be found in the songs.txt:

 chance = { #Here is the "chance" for the music to be played on EU4, let's use, as an example the music you want to be played more to some culture group in-game.
   modifier = {
    factor = 1 #0 would mean it would never be played, 1 means it'll always play to anyone, this is a must to the file unless you want it to be exclusive to any of the examples below.
   }
 
   #totally optional from here
   modifier = { #Music will never play to a nation whose culture isn't in the British culture group.
    factor = 0
    NOT = { culture_group = british } 
   }
 
   modifier = { #Music will play more often for nations whose culture is in the British culture group.
    factor = 2
    culture_group = british 
   }

   modifier = { #Music will never play after once the date in-game reaches 1527.
    factor = 0
    is_year = 1527
   }
 
   modifier = { #Music will play more often after 1500.
    factor = 1.5
    is_year = 1444
   }
 
   modifier = { #Music won't be played while at war.
    factor = 0
    is_at_war = yes
   }
   #End of options
  } 
 }

#Remember to check if you closed your brackets, otherwise, it won't work.


A more complex example of modifier and trigger use can be found in the Themes of the Old World music mod:

song = {
	name = "Land of Admiralty (War)" 
	chance = {
		modifier = { factor = 1 }
		modifier = { factor = 0 is_at_war = no } 
		modifier = {
			factor = 0
			NOT = {
				OR = {
					#own any province in an accepted culture group
					num_of_owned_provinces_with = {
						value = 1
						OR = { 
							has_owner_accepted_culture = yes
							has_owner_culture = yes
						}
						OR = { 
							culture_group = british
							culture_group = gaelic
						}
					}
					#own 10 provinces in a non-accepted culture group
					num_of_owned_provinces_with = {
						value = 10
						OR = { 
							culture_group = british
							culture_group = gaelic
						}
					}
					#WAR PARTICIPANT MEETS REQUIREMENTS
					any_known_country = {
						is_in_war = {
							participants = ROOT
						}
						OR = {
							#1 accepted culture province
							num_of_owned_provinces_with = {
								value = 1
								OR = { 
									has_owner_accepted_culture = yes
									has_owner_culture = yes
								}
								OR = { 
									culture_group = british
									culture_group = gaelic
								}
							}
							#10 cultured provinces
							num_of_owned_provinces_with = {
								value = 10
									OR = { 
									culture_group = british
									culture_group = gaelic
								}
							}
						}
					}
				}
			}
		}
	}
}

In this example, the music is eligible to play if you are at war and either:

  • You have a British/Gaelic culture province and have accepted the culture of that province.
  • You have 10+ British/Gaelic culture provinces and have NOT accepted the culture of those provinces.
  • You are in a war with a country that meets either of the above two conditions.

Known working triggers[edit | edit source]

As shown on the example above, you can add some modifiers for the music chance. Most standard triggers and scopes should work.

It isn't known which triggers will or will not work with music, this is just a list of triggers known to work.


Here's a brief list of triggers that are known to work:

  • alliance_with (for example: alliance_with = DAN if you want the song to play for countries allied to a specific country tag like Denmark "is rumored to not exist hehehe jk!" 😏 You can alternatively use ROOT/root or FROM if preferred)
  • has_institution (for example: has_institution = feudalism if you want the music to play for a certain institution)
  • primary_culture (for example: primary_culture = english if you want the song to play for all countries with a specific culture as their primary culture)
  • culture (for example: culture = dutch if you want the song to play for a specific culture and not an entire group)
  • culture_group (for example: culture_group = iberian if you want the song to play for a specific culture group)
  • exists (for example: exists = BUR if you want the song to play for a specific country tag that exists. You can alternatively use NOT = { exists = BUR} if preferred)
  • knows_country (for example: knows_country = CSU if you want the song to play for a specific country that knows a specific country tag such as the one shown. You can alternatively use ROOT or PREV/prev if preferred)
  • religion_group (for example: religion_group = christian if you want the song to play for a specific religious group)
  • religion (for example: religion = confucianism if you want the song to play for a certain religion and not for an entire religious group)
  • is_great_power (for example: is_great_power = yes if you want the song to play for any country tag classed as a Great Power. You can alternatively use is_great_power = no if preferred)
  • is_year (for example: is_year = 1444 if you want the song to start at a specific date)
  • is_at_war (for example: is_at_war = yes if you want the song to play for any country at war. You can alternatively use is_at_war = no if you prefer)
  • is_in_war (for example: is_in_war = { participants = TUR } if you want the song to play for any country in a war with a specific country/tag (in this case the Ottomans) - similar to war_with below, but allows for countries that are on the same side of a war)
  • is_part_of_hre (for example: is_part_of_hre = yes if you want the song to play for country tags inside the Holy Roman Empire. You can alternatively use is_part_of_hre = no if preferred)
  • num_of_colonists (for example: num_of_colonists = 2 if you want the song to play for countries that have 2 or more colonists)
  • num_of_owned_provinces_with (for example: num_of_owned_provinces_with = { value = 12 culture = french } if you want the song to play when you own a number of provinces of a certain culture)
  • real_month_of_year (0 to 11, 0 being January) Refers to real-life time, not game time. In vanilla, this is used for the Christmas music DLC.
  • has_country_modifier (for example: has_country_modifier = eng_court_star_chamber if you want the song to play for a country tag that has the following country modifier)
  • has_discovered (for example: has_discovered = 28 if you want the song to play for any country that has the discovered (map visibility) the province with ID 28 (Helsinki)
  • has_regency (for example: has_regency = yes if you want the song to play for countries that have a regency. You can alternatively use has_regency = no if you prefer)
  • any_owned_province (for example: any_owned_province = { continent = north_america } if you want the song to play for countries owning provinces in North America)
    • is overseas (for example: is_overseas = yes if you want the song to play for countries owning provinces outside their home region such as colonial regions. You can alternatively use is_overseas = no if preferred)
  • government (for example: government = monarchy if you want the song to play for a specific government type)
  • government_rank (for example: government_rank = 3 if you want the song to play for countries with a certain government rank (1 = duchy, 2 = kingdom, 3 = empire)
  • tag (for example: tag = FRA if you want the song to play for a specific country tag like France)
  • war_with (for example: war_with = ENG if you want the song to play for a specific country tag that's at war with England)
  • owns (for example: owns = 1 if you want the song to play when owning a specific province like Stockholm)
    • owns_core_province will also check if you have a core on the province
    • owns_or_non_sovereign_subject_of will also check if your subjects own the province
  • technology_group (for example: technology_group = western if you want the song to play for a country tag with the western tech group)
  • total_development (for example: total_development = 1000 if you want the song to play for countries with 1000 or more development)
  • capital_scope (for example: capital_scope = { superregion = europe_superregion } if you want the song to play for any country tag who's capital is located in Europe)
    • region (for example: region = austria_region if you want the song to play when the capital is within the Austrian region)
    • superregion (for example: superregion = china_superregion if you want the song to play when the capital is within the superregion of China)
    • continent (for example: continent = asia if you want the song to play when the capital is within the continent of Asia)

Main theme loading music[edit | edit source]

To change the loading music when you start up the game, simple rename your .ogg music track to "maintheme.ogg". It will automatically replace the vanilla EU4 theme song when loading the game and you do not need to define the track within the .asset or .txt files. Note that the main theme music, by default, does not appear in the in-game music player.


#Last updated by San_Felipe aka Darth Modus - Victorum Universalis & EU4 modder. Feel free to add or modify any of the above in case I've missed something. Many thanks to Paradox Interactive for creating this EU4 Wiki and to the multitude of people who contribute to it.

#Further updates and additions by Runite Drill - Indie EU4 composer & modder.

Documentation EffectsTriggersModifiersScopesVariablesLocalisationCustomizable localizationRun files
Scripting Scripted functionAdvisorsAgesBookmarksBuildingsCasus belliColonial regionsCountriesCultureDecisionsDefinesDiplomatic actionsDisastersEstatesEventsFactionsGovernmentGreat projectsHistoryIdea groupsInstitutionsMercenariesMissionsModifiersNation designerHoly Roman EmpirePoliciesReligionRebel typesSubject typesTechnologyTrade companiesTrade goodsUnits
Map MapNation designerRandom New WorldTrade nodes
Graphics 3D ModelsInterfaceGraphical AssetsFontsParticlesShadersUnit models
Audio MusicSound
Other Console commandsChecksumJoroDox mod making toolMod structureTroubleshootingThe ValidatorRun files
Guides Adding a provinceSave-game editing