Music

This article about adding any track to any mod.

## Some information about engine

The hardcoded limit for adding tracks is 256. This information is from old post of cmpxchng86 and may be outdated.
If music is switching too many times in small amount of time then memory will be consumed a lot.
Definitive list of FMOD importing audio files: .wav, .mp3, .ogg, .aif, .aiff, .wma, and .flac.
https://www.fmod.com/resources/documentation-studio?version=2.01&page=managing-assets.html#importing-audio-files

## Tutorial

What you need:

You need a windows 7 calculator. Switch in programming mode.
header\_music.py expanded with explanation and binary codes

```
###################################################
# DO NOT EDIT THIS FILE!
###################################################

mtf_culture_1                = 0x00000001  ## 0000 0000 0000 0000 0000 0000 0000 0001  Kingdom of Swadia
mtf_culture_2                = 0x00000002  ## 0000 0000 0000 0000 0000 0000 0000 0010  Kingdom of Vaegirs
mtf_culture_3                = 0x00000004  ## 0000 0000 0000 0000 0000 0000 0000 0100  Khergit Khanate
mtf_culture_4                = 0x00000008  ## 0000 0000 0000 0000 0000 0000 0000 1000  Kingdom of Nords
mtf_culture_5                = 0x00000010  ## 0000 0000 0000 0000 0000 0000 0001 0000  Kingdom of Rhodoks
mtf_culture_6                = 0x00000020  ## 0000 0000 0000 0000 0000 0000 0010 0000  Sarranid Sultanate
mtf_culture_all              = 0x0000003F  ## 0000 0000 0000 0000 0000 0000 0011 1111  ALL

mtf_looping                  = 0x00000040  ## 0000 0000 0000 0000 0000 0000 0100 0000
mtf_start_immediately        = 0x00000080  ## 0000 0000 0000 0000 0000 0000 1000 0000
mtf_persist_until_finished   = 0x00000100  ## 0000 0000 0000 0000 0000 0001 0000 0000

mtf_sit_tavern               = 0x00000200  ## 0000 0000 0000 0000 0000 0010 0000 0000
mtf_sit_fight                = 0x00000400  ## 0000 0000 0000 0000 0000 0100 0000 0000
mtf_sit_multiplayer_fight    = 0x00000800  ## 0000 0000 0000 0000 0000 1000 0000 0000
mtf_sit_ambushed             = 0x00001000  ## 0000 0000 0000 0000 0001 0000 0000 0000  enemies are 2 times more
mtf_sit_town                 = 0x00002000  ## 0000 0000 0000 0000 0010 0000 0000 0000
mtf_sit_town_infiltrate      = 0x00004000  ## 0000 0000 0000 0000 0100 0000 0000 0000
mtf_sit_killed               = 0x00008000  ## 0000 0000 0000 0000 1000 0000 0000 0000
mtf_sit_travel               = 0x00010000  ## 0000 0000 0000 0001 0000 0000 0000 0000
mtf_sit_arena                = 0x00020000  ## 0000 0000 0000 0010 0000 0000 0000 0000
mtf_sit_siege                = 0x00040000  ## 0000 0000 0000 0100 0000 0000 0000 0000
mtf_sit_night                = 0x00080000  ## 0000 0000 0000 1000 0000 0000 0000 0000
mtf_sit_day                  = 0x00100000  ## 0000 0000 0001 0000 0000 0000 0000 0000
mtf_sit_encounter_hostile    = 0x00200000  ## 0000 0000 0010 0000 0000 0000 0000 0000
mtf_sit_main_title           = 0x00400000  ## 0000 0000 0100 0000 0000 0000 0000 0000
mtf_sit_victorious           = 0x00800000  ## 0000 0000 1000 0000 0000 0000 0000 0000
mtf_sit_feast                = 0x01000000  ## 0000 0001 0000 0000 0000 0000 0000 0000
mtf_module_track             = 0x10000000  ## 0001 0000 0000 0000 0000 0000 0000 0000

```

## Adding new tracks

When you open file music.txt you will see

```
fight_1.ogg 7168 7168
fight_2.ogg 7168 7168
fight_3.ogg 7168 7168

```

Copy that number and paste it in calculator. You will see bits.

By this bits we determine that this track is played in fights, multiplayer and fights when enemies 2 times more (ambushed).

If tracks are placed in the module folder you will see mtf\_module\_track bit.

You don't need to add mtf\_module\_track bit. Without it game engine first search in module folder for that track and if it doesn't found than it will look in Warband folder.

So to add new track just paste in the end of the music.txt file:

```
btl_new_track.mp3 7168 7168

```

When you have finished look in the begining of the file for counter. Native is 74. Look how many strings you have in the file in advanced txt editor. Change counter 74 to (Number\_of\_the\_strings - 1).

## First and second number

The first number is determine in witch situations track can start to play. The second determine in witch situation this track can continue to play. If situation is changed then this bits will be checked.

## Changing header\_music.py

You can't add new cultures but you can add new 3 situations in the free bits.

```
mtf_situation1      = 0x02000000  ## 0000 0010 0000 0000 0000 0000 0000 0000
mtf_situation2      = 0x04000000  ## 0000 0100 0000 0000 0000 0000 0000 0000
mtf_situation3      = 0x08000000  ## 0000 1000 0000 0000 0000 0000 0000 0000

```

Also you can change existing situations freely. This changes you need to adapt in module system.