Currently viewing this thread:

Reus

Sloppy Dabber
Global Moderator
M&BWBNWWF&SVC
Modding Sound
Documentation


Disclaimer: This post contains documentation on modding sound. Documentation on modding music can be found in the second post in this thread. Table of contents can be found in the spoiler below.

1.1 Adding New Sounds
1.2 Defining New Sounds
2.1 Playing Sounds
2.1.1 Playing Voice Lines​
2.1.2 Playing Sound For Animations​
2.1.3 Playing Sound on the Campaign Map​
2.1.4 Playing Sound In Scenes​
2.1.5 Playing Sound For Particles​
3.1 Extracting Sounds From Native


1.1 Adding New Sounds

Any new sound files must be added to the module's ModuleSounds folder.
\Mount & Blade II Bannerlord\Modules\YourModule\ModuleSounds
For custom modules, a new ModuleSounds folder will need to be created. It is recommended to use .ogg or .wav file types for sound, but both have upsides and downsides. An .ogg file typically has a smaller file size but lower sound quality, while a .wav file has higher sound quality at the expense of a larger file size. Reserving .wav file types for priority sounds can help find the right balance between disk space and overall sound quality. Native seems to use .wav for sound effects, and .ogg for music tracks, however they do have more leeway in terms of disk space than mods do.



1.2 Defining New Sounds

After adding a sound, the module_sounds.xml file needs to be added to the ModuleData folder (simply copy paste it from Native). This file is used to define each sound and assign them a category in order to correctly lead them through the engine. The sound categories function as templates / mixer tracks that each apply different effects to the sounds, meaning that it's important to assign the correct category when adding a sound. Additionally, if a sound is not assigned a valid category, it won't be played in-game.
\Mount & Blade II Bannerlord\Modules\YourModule\ModuleData\module_sounds.xml
Example sounds can be found at the bottom of the file.
<module_sound name="example/combat/hit" is_2d="true" sound_category="mission_combat" path="example_sound_modders.ogg" />
To define a new sound, copy one of the example lines, paste it below, and modify it.

Each entry contains the following 4 properties:
name: The ID used to call the sound later on. Does not need to match the file name.

is_2d: See the list of sound categories and set true/false depending on usage of the sound.

sound_category: Assign the sound a category depending on what the sound will be used for.

path: The path and full name of the sound file, starting from the module's ModuleSounds folder. Child folders can be created to organize the sounds (e.g to separate ambience from voice acting or to organize separate voice actors).

Here's an extended list of all sound categories, including descriptions and examples:
mission_ambient_bed
(2D) Ambient loops played from no specific position in a scene.​
Examples: wind, rain, storms, room tone.

mission_ambient_3d_small
(3D) Ambient sounds, heard from a specific position in a scene, within short distance.​
Examples: torches, fireplaces, candles.

mission_ambient_3d_medium
(3D) Ambient sounds, heard from a specific position in a scene, within medium distance.​
Examples: smaller waves, medium fires, crickets.

mission_ambient_3d_big
(3D) Ambient sounds, heard from a specific position in a scene, within long distance.​
Examples: thunder, distant bird chirps, big waves, distant bells.

mission_material_impact
(3D) Material impacts on other materials.​
Examples: steel sword hits stone wall, iron spear hits wooden wall.

mission_combat
(3D) Non-voice impact damage sounds in combat.​
Examples: taking hits, others being hit.

mission_combat_trivial
(3D) Non-voice trivial impact damage sounds in combat.​
Examples: taking smaller hits, applying smaller hits.

mission_foley
(3D) Foley sounds for animations.​
Examples: weapon swings, movement, animal movement.

mission_voice
(3D) Voices for humans and animals.​
Examples: grunts for pain, death, weapon swings.

mission_voice_shout
(3D) Voices for humans and animals, heard from long distance.​
Examples: battle cries, victory yells, troop orders, multiplayer voice commands.

mission_voice_trivial
(3D) Voices for humans and animals, quiet vocalizations.​
Examples: jumping, climbing.

mission_siege_loud
(3D) Loud sounds to be used in siege scenes.​
Examples: gates breaking, siege weapons firing, ladders.

mission_footstep
(3D) Footsteps for humans and smaller animals.​

mission_footstep_run
(3D) Footsteps for humans and smaller animals, to be heard from longer distance.​

mission_horse_walk
(3D) Single footsteps for mounts - horses and camels.​

mission_horse_gallop
(3D) Galloping footsteps for mounts - horses and camels.​

campaign_node
(3D) world map positional sounds. Played when close to specific world map entities.​
Examples: waterfalls, settlements, water, battles, sieges.

campaign_bed
(2D) World map ambient sounds. Played from no specific position on the world map.​
Examples: wind, atmospheric weather for different biomes.

ui
(2D) Sounds for UI and notifications.​
Examples: inventory, crafting, level up, button presses.

alert
(2.5D) Sounds for alerting the player from within medium distance.​
Examples: kingdom rallies and multiplayer alerts, flag captured, out of map.



2.1 Playing Sounds

This section will cover how to play sounds in various situations in-game. This will include documentation on playing voice lines as well as sounds in scenes, campaign map, animations, particles, and eventually from code and UI. This is work in progress and will change and be expanded upon over time.

2.1.1 Playing Voice Lines

The game uses voice lines for combat (grunts, pain, death, war cries), group identifiers (infantry, cavalry), orders (follow, charge, advance), formations (line, shield wall, loose), multiplayer chatter (help, thanks, sorry), and horse sounds (idle, neighs, collision grunts). Additionally, voices are also used for animal vocalizations such as pain, death, and idle.

When adding new voice lines to a module, the mission_voice, mission_voice_shout, and mission_voice_trivial sound categories should be used depending on the voice type (see 1.2 Defining New Sounds).

These sounds are defined in \Modules\Native\ModuleData\voice_definitions.xml where all voice types are listed at the top, and all of the character voices are listed in groups below. Each character voice is enclosed in a <voice_definition> tag, and within this tag, each voice line is defined with a <voice> tag. The properties of each tag are explained below:
name: The name / ID of the voice.

sound_and_collision_info_class: The race of the character. Human, horse, camel, dog, and more. These can be found in monsters.xml.

only_for_npcs: Setting to false will allow the player to select the voice when creating their character. Setting to true will reserve it for non-playable characters. As an example from Native, male_04, male_06, and male_07 are set to false, and represent the voices available when creating a male character in-game. Note, this line is not required for animals.

min_pitch_multiplier: This allows you to randomize the pitch of the voice lines when played in-game. This sets the minimum point of the pitch range where 1.0 is the original pitch of the sound. Native usually sets the minimum pitch at around 0.9 which means the game can pitch the voice down by up to 10%. This is different for every voice, so play around and see what works.

max_pitch_multiplier: The maximum point for the pitch. Native usually goes around 1.1 here which means the game can pitch the voice up by up to 10%. Again, set it according to what makes sense for the voice.
type: What the voice line is used for (grunts, jumping etc.). A list of voice types can be found at the top of the same document.

path: The name / ID of the sound file as assigned in module_sounds.xml.

face_anim: The face animation played with the sound. Can be found in voices.xml.

The gender of each voice is assigned in \Modules\Native\ModuleData\skins.xml (Examples: adult male voices on line 1033 and adult female voices on line 3322). In order to play new character voices in-game, they must be added to the relevant skins, allowing the game to select the correct voice for each character.

Here's a list of every Native skin and the voice_types they use:
  • Adult male: line 1033
    • male_02
    • male_03
    • male_04
    • male_05
    • male_06
    • male_07
  • Adult female: line 3322
    • female_01
    • female_02
    • female_03
    • female_04
    • female_05
  • Teenager male: line 4400
    • male_02
    • male_03
    • male_04
    • male_05
    • male_06
  • Teenager female: line 6180
    • female_01
    • female_02
    • female_03
    • female_04
  • Tween male: line 7268
    • male_03
  • Tween female: line 9024
    • female_03
  • Child male: line 10110
    • male_03
  • Child female: line 11802
    • female_03
  • Toddler male: line 12654
    • female_01
  • Toddler female: line 13522
    • female_01

Here's a tutorial on adding and playing new voice lines. This tutorial assumes that the sound files have already been added to the game (see 1.1 Adding New Sounds).
  1. Open voice_definitions.xml from \Native\ModuleData (If using a custom module, add the document).
  2. Copy a complete character voice such as male_06 (Take everything from start of <voice_definition> to the closing tag) and paste it below the others.
  3. Change the name of the <voice_definition> to something relevant.
  4. Set sound_and_collision_info_class according to the character (see family types in monsters.xml)
    • human if the character is human, horse if character is horse, etc.
  5. Set only_for_npcs to true if you want the player to be able to use the voice. Set to false if not.
  6. Set min_pitch_multiplier and max_pitch_multiplier according to the voice.
    • This requires you to play around and see which pitch ranges sound good for each voice, as every voice is different. Original pitch is 1.0.
  7. Replace the sound codes / paths of each voice type with the new sounds you wish to use (the name given to the sound in module_sounds.xml).
  8. Open skins.xml from \Native\ModuleData (If using a custom module, add the document).
  9. Find the <voice_types> tag within the skin you want to assign your voice to.
    • See the list of all skins and voice types in a spoiler above.
  10. Add a new line with the name of your character voice as assigned in voice_definitions.xml.
    • Example:
      <voice_type name="female_05" />
      <voice_type name="female_new_06" />

Note: There is currently, what I presume to be, a bug that causes the panning of custom voice lines to go crazy when previewing the voice in character creation. Whether the sound is 2D or 3D doesn't seem to affect it, and neither does changing between mono and stereo.

2.1.2 Playing Sound For Animations

Playing sounds for animations originally happened through the animation XML files, however these have since been deprecated. The animations must instead be edited through the Resource Browser window in the Modding Kit. When opening an animation in the Resource Browser, the Inspector will open on the right side wherein the Sound code and Voice code properties can be found. For Sound code, the name / ID of any added sound file from module_sounds.xml (or native sound codes found in \Mount & Blade II Bannerlord\Sounds\GUIDs.txt) can be used. For Voice code, the voice types from voice_definitions.xml can be entered instead of the path of the sound file itself.

The Voice code property is typically used to play vocalizations for animals or mounts (idling, pain, and more as found at the bottom of voice_definitions.xml). It is also possible to use both a Sound code and Voice code at the same time. Native often does this for mounts in combat - for example the horse_kick animation playing a swing sound code for the horse kicking as well as the Neigh voice code from voice_definitions.xml. Another example is horse_run_collide playing a sound code for the horse charging as well as the Collide voice code.

When editing an animation, several flags can be selected to do with sound:
  • make_walk_sound
    • Adds a walk sound when playing the animation. Mostly used for walk animations.
  • make_bodyfall_sound
    • Adds a body fall sound when playing the animation. Mostly used for fall animations.
  • do_not_keep_track_of_sound
    • Unclear exactly what it does. Mostly used for bow and crossbow release animations.
Native animations can be found in the \Native\EmAssetPackages\animations folder within the Modding Kit for exploration purposes. These animations are protected, meaning that any changes to their values in the Resource Browser will not be saved. They will instead have to be overwritten by new animations.

Here's a short tutorial on adding sounds to animations:
  1. Open the Modding Kit, go to Window > Show Resource Browserand open the animation you wish to edit.
    • The inspector window will open on the right side of the Resource Browser.
  2. For Sound code, enter the name / ID of your sound as assigned in module_sounds.xml - or use a Native sound code.
    • You can find a list of all Native sound codes in \Mount & Blade II Bannerlord\Sounds\GUIDs.txt.
  3. The Voice code property allows you to play voice codes from voice_definitions.xml.
  4. Select the relevant flags depending on the sound.

2.1.3 Playing Sound on the Campaign Map

The world map uses sounds in 2D for ambience, such as wind or weather for different biomes. These sounds are not played from any specific position or entity.

It also uses sounds in 3D for water (oceans, rivers, lakes, and waterfalls) as well as settlements, battles, and sieges. This is usually done by adding the sound_emitter script to the entity which the sound should be played from. Since water is not an entity, an invisible entity is instead created to play sound from. Waterfalls usually have the sound attached to the waterfall's cliff / rock entity. For villages, different ambience is played depending on the village's resources (wheat, horses, mines, and more). In these cases, the sound_emitter script is attached directly to the resource's map icon rather than the village's map icon. Villages that don't have resources simply don't have ambience sound either. Certain resources, such as vineyards, currently do not have unique sounds, and therefore don't play anything despite having sound_emitter scripts attached. Any of this can, of course, be changed. Sound can be played form nearly any entity on the map, so there's a lot of freedom.

To make a sound play in a larger, asymmetrical area (seas and oceans) or to follow the path of a river, paths can be created to mark the area. The sound entity can then be hooked onto these paths by adding a path_converger script to the entity and linking it to the path. For rivers, these paths usually consist of one line following the center of the river, whereas oceans and seas often use paths to outline the edges of the water. Certain lakes are small and symmetrical enough that paths are not needed, and instead modify the value of Overrided Max Distance in the sound_emitter script to cover an area.

An alternative to using both a sound_emitter and a path_converger is to simply use the SoundSpline script instead. This script is essentially a combination of the two scripts into one. The Native campaign map does not use this method, so it was presumably added after the creation of the map.

When playing a sound on the map, any custom added sounds can be used, as well as any sounds from the base game.
Below is a list of all native campaign map sound codes for usage:
Category: campaign_bed (2D constant ambient sounds)
event:/map/ambient/bed/aqua
event:/map/ambient/bed/arid
event:/map/ambient/bed/boreal
event:/map/ambient/bed/canyon
event:/map/ambient/bed/lush
event:/map/ambient/bed/mountain
event:/map/ambient/bed/snow

Category: campaign_node (3D positional sounds)
event:/map/ambient/node/settlements/cattleranch
event:/map/ambient/node/settlements/docks
event:/map/ambient/node/settlements/farms
event:/map/ambient/node/settlements/horseranch
event:/map/ambient/node/settlements/lumberjack
event:/map/ambient/node/settlements/mines
event:/map/ambient/node/settlements/orchard
event:/map/ambient/node/settlements/plantation
event:/map/ambient/node/settlements/sheepfarm
event:/map/ambient/node/siege/ballista_fire
event:/map/ambient/node/siege/ballista_hit
event:/map/ambient/node/siege/boulder_hit
event:/map/ambient/node/siege/mangonel_fire
event:/map/ambient/node/siege/trebuchet_fire
event:/map/ambient/node/battle
event:/map/ambient/node/battle_raid
event:/map/ambient/node/battle_siege
event:/map/ambient/node/battle_siege
event:/map/ambient/node/lake
event:/map/ambient/node/river
event:/map/ambient/node/sea
event:/map/ambient/node/waterfall
event:/map/army/caravan
event:/map/army/horse
event:/map/army/horse_slow
event:/map/army/infantry

How sound is played for parties, sieges, and towns is currently unknown. I have searched every map icon entity for towns and siege camps, but not found any scripts playing sound. Playing sound for parties presumably happens through modifying files, however I have not found this yet.

Here's a tutorial on playing sound on the campaign map:
  1. Open the Modding Kit, enter Edit Mode, go to File > Open Scene > Open Other Scene.
  2. Go to the SceneObj folder, find Main_map, and open the scene.xcscene.
  3. Select the entity you want to play sound from (the inspector will open on the far right side).
    • For water, create a new invisible entity by pressing Add Empty Entity in the toolbar, then move it on top of the water.
  4. Open the Scripts tab, add a new script, and select sound_emitter towards the bottom of the list.
    • If you plan to attach it to a path later, use the SoundSpline script instead. This is explained in the optional steps later in this tutorial.
  5. Open the new sound_emitter tab within Scripts and enter the name of the sound you wish to play in Event Path (use a custom sound or see list of Native campaign map sounds above).
  6. Enable Play On Startup (unless you want a custom trigger) and enter the desired minimum and maximum distances for the sound to be heard from. You can also change the volume and pitch. These all have default values to begin with, so changing the values will just override.
Optional steps to set a path for the sound:
  1. Select the entity and set Mobility to Dynamic in the inspector.
  2. Press Add Path in the toolbar, name it, and select it (should be selected by default).
  3. Press Add Path Point in the toolbar and place the points to draw a path.
    • Note: The first and last path points cannot be connected, only placed on top of each other. Make sure the path is selected when you add the points.
  4. Select the sound entity created earlier and add the path_converger script.
  5. Enter the name of the created path in Path Name.
    • When moving the camera, the sound entity will now follow the path of the path it is linked to and play sound along it.
  6. Alternatively, instead of adding a path_converger on top of a sound_emitter, you can simply delete the sound_emitter and instead use the SoundSpline script which contains the properties of both scripts combined in one.

2.1.4 Playing Sound In Scenes

Playing sound in a scene is essentially the same as adding sound to the campaign map except different scripts may be used. Native scenes often play ambient sounds in settlements by adding the AmbientSoundEmitter script to various entities in a scene. City scenes, for example, create an invisible market_ambient_sound entity in the middle of the market, a city_ambient_sound entity in the middle of the city, and a plains_ambient_sound in the middle of the area outside of the walls. Villages create a village_ambient_sound entity, and castles just use plains ambience as well.

These entities play the following sound codes:
  • market_ambient sound
    • event:/mission/ambient/area/market
  • city_ambient_sound
    • event:/mission/ambient/area/city
  • plains_ambient_sound
    • event:/mission/ambient/area/plains
  • village_ambient_sound
    • event:/mission/ambient/area/village
These may change depending on the scene's environment (e.g. desert scenes use desert ambience instead of plains ambience).

With the AmbientSoundEmitter script, different sound codes can be set for the various seasons as well as whether the scene is in a siege state. The game will dynamically switch between these sound codes depending on which factors are true at the time. Native city scenes often use this to switch to winter ambience (event:/mission/ambient/area/winter) in the winter season while playing the default city ambience in the other seasons. For sieges, it changes to plains ambience in order to make the city sound less alive during a time of war.

Entities using the AmbientSoundEmitter script can, of course, also be hooked up with a path_converger script to make the sound follow a path and cover a larger area (see 2.1.3 Playing Sound on the Campaign Map for more information on this).

Examples of other exterior scene ambience uses are arenas, rivers, and forests. For interior ambience, there are sounds for caves, dungeons, keeps, shops, taverns, and more. Other than ambient loops, there is also ambience for details such as fountains, windmills, and certain buildings. Particles for torches, fireplaces, and similar entities are also played in scenes. These are, however, not added directly to the entity, so they will be covered in the next part (2.1.5 Playing Sound For Particles).

Below is a list of all scene ambience loops from Native.
These can also be found by searching for "event:/mission/ambient/" in \Mount & Blade II Bannerlord\Sounds\GUIDs.txt.
Exterior scenes
event:/mission/ambient/area/_rain
event:/mission/ambient/area/_snowstorm
event:/mission/ambient/area/_template
event:/mission/ambient/area/arena
event:/mission/ambient/area/city
event:/mission/ambient/area/desert
event:/mission/ambient/area/forest
event:/mission/ambient/area/lake
event:/mission/ambient/area/market
event:/mission/ambient/area/mediterranean
event:/mission/ambient/area/plains
event:/mission/ambient/area/sea
event:/mission/ambient/area/taiga
event:/mission/ambient/area/village
event:/mission/ambient/area/wetlands
event:/mission/ambient/area/winter
event:/mission/ambient/area/winter_desert

Interior scenes
event:/mission/ambient/area/interior/cave
event:/mission/ambient/area/interior/dungeon
event:/mission/ambient/area/interior/generic
event:/mission/ambient/area/interior/keep
event:/mission/ambient/area/interior/shop
event:/mission/ambient/area/interior/tavern

Multiplayer scenes
event:/mission/ambient/area/multiplayer/city_mp_01
event:/mission/ambient/area/multiplayer/city_mp_02
event:/mission/ambient/area/multiplayer/desert_town_mp_01
event:/mission/ambient/area/multiplayer/forest_mp_01

2.1.5 Playing Sound For Particles

The game mostly seems to play sound for fire particles (e.g torches, fireplaces, fire on buildings in sieges). These particles can be found in the various particle_systems XML files in \Modules\Native\ModuleData. A sound can be assigned to specific particles by adding a sound_code in the particle effect's code.

A quick example of this is line 2 in particle_systems_basic.xml.

<effect name="invalid_particle" guid="{39cdecb3-046b-4a8b-8e71-533bb7f6c882}" sound_code="event:/mission/ambient/detail/fire/fireplace">

Not all Native particles play sounds, but simply adding a sound_code to the effect tag will allow it to play a sound. As with playing a sound anywhere else, this sound_code can be set to the name / ID of any custom or Native sound. It will then be built into the particle when it's added to a scene in-game.



3.1 Extracting Sounds From Native

TaleWorlds uses FMOD software which has been integrated into the game for the developers to use. This means that mostly all sounds used in the game can only be found in .bank files and not easily be opened. The game's sounds are found in \Mount & Blade II Bannerlord\Sounds which contains the following items:
  • PC = Folder containing the main sound assets in .bank files.
  • VO = Folder containing story mode voiceovers in .ogg files.
  • GUIDs.txt = Document defining all Native sounds and their sound codes.
The .banks containing the sound assets are found directly in the PC folder. These are separated in categories such as combat, ambience, music, voice, footsteps, and more. The game loads these banks in \Modules\Native\ModuleData\soundfiles.xml. Banks can also be unloaded by removing their lines in this document, replacing any instances of that bank's sounds with silence. Nothing is gained by doing this, however, as individual sounds can easily be replaced through other files, and no disk space is saved by unloading banks. Think of it as a fun fact except there's nothing fun about it. Though the voice bank lines can be deleted, effectively turning every character mute. Maybe that makes the fact more fun.

To extract .bank files, a tutorial can be found here ("Getting audio files from .bank and .fsb files" on YouTube). This can be useful for exploring file naming, formats, bitrates, bit depths, mixing, and more.

 
Last edited:

Reus

Sloppy Dabber
Global Moderator
M&BWBNWWF&SVC
Modding Music
Documentation


Disclaimer: Modding music currently lacks support and is therefore very limited. I will share what I've found so far, but it's not a finished guide at this time. Table of contents can be found in the spoiler below.

1.1 Adding New Music
2.1 Modular Music
2.2 Playing Music


1.1 Adding New Music

Adding new music is not officially supported at this time, but tools for it will be released at a later stage. It is, however, possible to replace music in the base game by replacing files in \Mount & Blade II Bannerlord\music\PC or by changing the paths to tracks in \Mount & Blade II Bannerlord\music\soundtrack.xml.

Some of the Native music can be found in loose .ogg formats in \Mount & Blade II Bannerlord\music\PC. Other music is found in \Mount & Blade II Bannerlord\Sounds\PC\music.assets.bank (see 3.1.1 Extracting Sounds From Native).

In the base game, the music is defined through \Mount & Blade II Bannerlord\music\soundtrack.xml. This document, however, is overwhelmingly big and unmanageable, containing 25.000 lines with no real syntax highlighting, so enter at your own risk. Though it is very useful for studying how the game handles music.


2.1 Modular Music

The music for Bannerlord is modular, meaning that the game will dynamically switch between different tracks depending on certain factors in-game. Audio data is assigned to each track, applying logic to how the game should use them (when each track can be transitioned, which tracks they should/shouldn't transition into, and more).

Music is organized into themes, groups, and segments via soundtrack.xml. These are essentially categories branching into smaller categories. The theme is the main category which can contain multiple groups. Each group functions as a full track and can contain multiple segments to split tracks into separate snippets / files. Segments are then where the actual music files are being played. For the Campaign Standard theme, each group only contains one segment because its groups are each playing a full track rather than smaller snippets. For the Combat A theme, however there is only one group which instead contains several segments. This is because instead of playing a single track for combat, the game queues 16 different snippets of different intensity levels to form a track. These segments can then be manually linked to each other in order to queue them up, or manually blocked from each other.

To study this, find the Combat A theme in soundtrack.xml and listen to the COMBAT_A_ tracks in \Mount & Blade II Bannerlord\music\PC.

The music is sorted into different themes (overland campaign music for each kingdom, battle music, siege music, battle victories, battle defeats, and more). Each theme contains groups and segments relevant to the theme.

As an example, the Campaign Standard theme contains groups / tracks such as:
  • The Maiden (medieval_04_DG2_ARO_the_maiden.wav)
  • Open The Gates (renaissance_03_DG2_open_the_gates.wav)
  • Ancient Fields (world_adventure_07_MKS_ancient_fields.wav)
These groups each contain only one segment, because they are playing full tracks instead of smaller snippets. Each of these tracks are assigned IDs within their respective segments, and audio data such as BPM, pre beats, post beats, sample rates, and the path to the sound file is entered. The intensity of the track is also defined, along with whether the start, middle, and end of the track are usable (this presumably helps decide which parts of the track are suitable for transitions). Different groups and segments can also be linked in order to allow them to transition into each other. There's a lot more to this document, so I do recommend studying it for research purposes, even if we can't use it for much currently.

The paths used for tracks in soundtrack.xml begin in the \Mount & Blade II Bannerlord\music\PC folder where the music files are also found.


2.2 Playing Music

Playing music lacks support and official documentation at this time.

Themes are being managed by MBMusicManager.cs while tracks (groups) and snippets (segments) are managed by PSAI. This is currently locked.
 
Last edited:

thefirst1nvad3r

Section Moderator
M&BWBWF&SNWVC
Awesome work! A very detailed guide, easy to read and full of useful information! Even if I'm not good at all with this kind of stuff I understood very well how to follow the various steps!
I think this will really help many users!
 

Reus

Sloppy Dabber
Global Moderator
M&BWBNWWF&SVC
I have updated the music documentation after learning some more from Kabraxis (thanks again) about how music is being handled. It's still work in progress though, as we don't have access to the necessary tools for music yet.

Awesome work! A very detailed guide, easy to read and full of useful information! Even if I'm not good at all with this kind of stuff I understood very well how to follow the various steps! I think this will really help many users!
Thanks, I appreciate it.
 

XDaron

Knight at Arms
do you guys know the ID for ModuleSounds.xml and voice_definitions? I'm trying to create a submodule, this has been very helpful, thanks!

<Xmls>
<XmlNode>
<XmlName id="Voice" path="voice_definitions"/>
<IncludedGameTypes>
<GameType value = "Campaign"/>
<GameType value = "CampaignStoryMode"/>
<GameType value = "CustomGame"/>
</IncludedGameTypes>
</XmlNode>
<XmlNode>
<XmlName id="skin" path="skins"/>
<IncludedGameTypes>
<GameType value = "Campaign"/>
<GameType value = "CampaignStoryMode"/>
<GameType value = "CustomGame"/>
</IncludedGameTypes>
</XmlNode>
<XmlNode>
<XmlName id="Sound" path="module_sounds"/>
<IncludedGameTypes>
<GameType value = "Campaign"/>
<GameType value = "CampaignStoryMode"/>
<GameType value = "CustomGame"/>
</IncludedGameTypes>
</XmlNode>
</Xmls>
 
Last edited:

XDaron

Knight at Arms
do you know any way to assign multiple voice lines to a command like ''hold fire'', so my character can choose from a random pool of voice lines instead of always playing the same one? I really wanted to make a custom voice mod but hearing the same yell everytime is a bit repetitive
 

Bloc

Duke
WB
do you know any way to assign multiple voice lines to a command like ''hold fire'', so my character can choose from a random pool of voice lines instead of always playing the same one? I really wanted to make a custom voice mod but hearing the same yell everytime is a bit repetitive
I think there is no out-of-the-box solution for that. But you can do the following: overwrite the order function ( via reflection ) or simply set shout mode to false and make it silent. Then once the hold fire command is called, play sound randomly from your own pool. You can hardcode it or simply add a JSON config for that. It really up to your creativity.
 

XDaron

Knight at Arms
I think there is no out-of-the-box solution for that. But you can do the following: overwrite the order function ( via reflection ) or simply set shout mode to false and make it silent. Then once the hold fire command is called, play sound randomly from your own pool. You can hardcode it or simply add a JSON config for that. It really up to your creativity.
I think I ate more then I can chew here, thanks for the help
 

bestmods168

Sergeant
Does this still work? I've done what the tutorial states and no sound comes out. Doing some gun sounds. I've tried to attach custom sound to the new/override animation in both the voice and sound slot. The name/id of my sound does not show up in the particle effect editor also.
 

Reus

Sloppy Dabber
Global Moderator
M&BWBNWWF&SVC
Does this still work? I've done what the tutorial states and no sound comes out. Doing some gun sounds. I've tried to attach custom sound to the new/override animation in both the voice and sound slot.
Should be working, as far as I'm concerned. You can try going into module_sounds.xml and changing the name of your custom sound to "event:/mission/combat/missile/foley/bowrelease" to directly override Native's bow release sound. Then head in-game, fire a bow, and see if it plays your custom sound. If it does, then the issue lies somewhere in animation editing, but if it doesn't then your sound probably isn't being loaded correctly.

The name/id of my sound does not show up in the particle effect editor also.
Same for me, so it's possible that modding sound through the particle editor isn't fully functional at this point. I'm not sure if the particle XML files are deprecated yet, but you can try using those.
 

bestmods168

Sergeant
Should be working, as far as I'm concerned. You can try going into module_sounds.xml and changing the name of your custom sound to "event:/mission/combat/missile/foley/bowrelease" to directly override Native's bow release sound. Then head in-game, fire a bow, and see if it plays your custom sound. If it does, then the issue lies somewhere in animation editing, but if it doesn't then your sound probably isn't being loaded correctly.

Tried it. Only the native bow sound comes out. Perhaps the tutorial is missing something? I'm on the modding discord often and it seems no one has been able to get it to work either.

Sounds are in the modulesounds folder in .wav format.
Names follow the examples. etc.
 

Alemismun

Recruit
M&BWBWF&SNWVC
What about playing sound through code (so for stuff such as UI)?
I have tried everything and I still cant get it to work ;-; !

Below is my best guess, but its clear my best is not good enough. Any ideas?
C#:
SoundEvent.PlaySound2D(SoundEvent.GetEventIdFromString("hl1scientistdeathscream"));
 

Bloc

Duke
WB
What about playing sound through code (so for stuff such as UI)?
I have tried everything and I still cant get it to work ;-; !
Normally this is how you can do it
C#:
SoundEvent yourSoundEvent = SoundEvent.CreateEvent(SoundEvent.GetEventIdFromString("event:/mission/ambient/detail/fire/fireplace"), Mission.Current.Scene);
yourSoundEvent.PlayInPosition(yourCoolPositionVector);
However, this is only working for native sounds as far as I can see.

I wasn't able to play any of my custom sounds with this ( even though my XML's were fine ) so I'm assuming, even if you want to do something purely code-based, you still need modding tools and somehow add these "sounds" inside of your module. Perhaps Reus can say something about this if he tried it.
 

Alemismun

Recruit
M&BWBWF&SNWVC
However, this is only working for native sounds as far as I can see.
Indeed, it would seem that way.

Whats strange is the fact that the "module_sounds.xlm" file implies you should be able to play custom sounds as long as they follow proper formatting.
[Sample code from the xlm file]
C#:
//example:
        int soundIndex = SoundEvent.GetEventIdFromString("example/voice/charge");//to avoid string operations in runtime soundIndex can be cached.
        if (playOneshot)
        {
            MakeSound(soundIndex, MainAgent.Position, false, true, -1, -1);//plays oneshot sound at position with given parameters.
        }
        else
        {
            SoundEvent eventRef = SoundEvent.CreateEvent(soundIndex, Scene);//get a reference to sound and update parameters later.
            eventRef.SetPosition(MainAgent.Position);
            eventRef.Play();
        }
Even more strange, this code does not even work as far as I can tell either (MakeSound is not valid and I was unable to find a single reference to it via dotpeek). My assumption here is that it must be an outdated comment.
 

bestmods168

Sergeant
Normally this is how you can do it
C#:
SoundEvent yourSoundEvent = SoundEvent.CreateEvent(SoundEvent.GetEventIdFromString("event:/mission/ambient/detail/fire/fireplace"), Mission.Current.Scene);
yourSoundEvent.PlayInPosition(yourCoolPositionVector);
However, this is only working for native sounds as far as I can see.

I wasn't able to play any of my custom sounds with this ( even though my XML's were fine ) so I'm assuming, even if you want to do something purely code-based, you still need modding tools and somehow add these "sounds" inside of your module. Perhaps Reus can say something about this if he tried it.
I've discovered on my end, that module_sounds.xml cannot be named anything else. Its weird, but this seem to have solved my sound issue.
 

Bloc

Duke
WB
I've discovered on my end, that module_sounds.xml cannot be named anything else. Its weird, but this seem to have solved my sound issue.
That's also what I'm using a name. Not working. Did you use Modding Tools? Or plain XML + .dll coding?

Even more strange, this code does not even work as far as I can tell either (MakeSound is not valid and I was unable to find a single reference to it via dotpeek). My assumption here is that it must be an outdated comment.
Yes. It's outdated. If I recall it right, MakeSound method is ( presumably ) moved to Agent. So you can use something like "Mission.Current.MainAgent.MakeSound(...)" or similar for any other agent.
 

bestmods168

Sergeant
That's also what I'm using a name. Not working. Did you use Modding Tools? Or plain XML + .dll coding?


Yes. It's outdated. If I recall it right, MakeSound method is ( presumably ) moved to Agent. So you can use something like "Mission.Current.MainAgent.MakeSound(...)" or similar for any other agent.
I'm just using xml. What type of sounds are you trying to play?
 

Bloc

Duke
WB
I'm just using xml. What type of sounds are you trying to play?
Ah, I read your comment, I think you were only trying to replace native sound? That's not what I'm doing. I'm trying to add a new sound and play it from the code side. It's not playing or finding the sound even though XML is correct - according to documentation.
 

Reus

Sloppy Dabber
Global Moderator
M&BWBNWWF&SVC
Sorry about the delayed response. I spent hours troubleshooting only to find out (with helpful debugging by Sakirma and Ster) that functionality may actually be broken after the recent patch. When I initially wrote the documentation, I tested it by modifying Native files so that I didn't have to worry about the game not being able to load the files. This is also why the post is missing a section on loading XMLs such as module_sounds, voice_definitions, and skins. These files aren't loaded normally through SubModule.xml, but on the C++ side of things through the project.mbproj file. I'll be updating the documentation with this once I can get the game to load the files again. I'll also add a segment about the sound prefabs that Native uses for playing sound in scenes, since I forgot to mention those the first time around.

I haven't attempted anything with playing sound through code yet, so unfortunately I'm not of much help there.
 
Top Bottom