The Binding of Isaac: Rebirth

The Binding of Isaac: Rebirth

Soundtrack Menu
☢ Nato Potato ☢  [developer] Mar 8, 2023 @ 2:08am
Having variations on a music track or jingle
The soundtrack menu supports having different versions of the same track, if it's a jingle the mod will pick one at random when it plays, for room/floor music the mod will pick a variant when the floor loads and will use the chosen version whenever this track type should play for your soundtrack for the rest of the floor.
The xml entries should look something like this.
<track name="SOUNDTRACK Basement 1" path="basement1.ogg" loop="true" /> <track name="SOUNDTRACK Basement 2" path="basement2.ogg" loop="true" /> <track name="SOUNDTRACK Basement 3" path="basement3.ogg" loop="true" />
There must be a space and then a number after the track type in the name.
If there is a gap in the numbers (1,2,3,5,6) any entries after the gap won't be loaded.
There is a limit of 99 variants per track, in case anyone felt like making a soundtrack mod that takes half an hour for the menu to load.

This also works for jingles, including the treasure room jingles, for example.
<track name="Test Secret Room Find (jingle) 1" path="secret1.ogg" loop="false" /> <track name="Test Secret Room Find (jingle) 2" path="secret2.ogg" loop="false" /> <track name="Test Secret Room Find (jingle) 3" path="secret3.ogg" loop="false" /> <track name="Test Treasure Room Entry (jingle) 1" path="treasure1.ogg" loop="false" /> <track name="Test Treasure Room Entry (jingle) 2" path="treasure2.ogg" loop="false" /> <track name="Test Treasure Room Entry (jingle) 3" path="treasure3.ogg" loop="false" /> <track name="Test Treasure Room Entry (jingle) 4" path="treasure4.ogg" loop="false" /> <track name="Test Treasure Room Entry (jingle) 5" path="treasure5.ogg" loop="false" /> <track name="Test Treasure Room Entry (jingle) 6" path="treasure6.ogg" loop="false" /> <track name="Test Boss (jingle) 1" path="bossintro1.ogg" loop="false" /> <track name="Test Boss (jingle) 2" path="bossintro2.ogg" loop="false" />
Though of course the game still uses 4 treasure room jingles by default, so if you have less than 4 some treasure rooms will use regular rebirth jingles.

You can check the music.xml of The Swinging of Isaac or Darkest Dungeon soundtracks for reference.

If you have Jukebox titles in your soundtrack you can add the variants to the list as well, for example.
Tracklist = { "Basement", {"Cellar 1", "Cellar 2", "Cellar 3", "Cellar 4"}, "Burning Basement", etc
Though treasure room jingle titles are a little different, as they still need the base 4 in order to register, they cycle in 4 groups so it looks something like this.
"Angel Door Appear Jingle", "Secret Room Discover Jingle", {"Treasure 1", "Treasure 5", "Treasure 9", "Treasure 13"}, {"Treasure 2", "Treasure 6", "Treasure 10", "Treasure 14"}, {"Treasure 3", "Treasure 7", "Treasure 11"}, {"Treasure 4", "Treasure 8", "Treasure 12"}, "Challenge Start Jingle",







Alternatively, if you want more specific control over when a variation of a track should be played rather than it just being chosen at random you can add some lua code in your mod to take advantage of Repentence's layermode 2 (though this doesn't work with jingles), by using layers you can control the music while the soundtrack menu (and other mods) will still see it as the same music track.

The code in xml for the specific track that has these variations is like this.

<track name="SOUNDTRACK Basement" path="Basement1.ogg" loop="true" layermode="2"> <layer path="Enemies Layer.ogg" /> <layer path="Basement2.ogg" /> <layer path="Basement3.ogg" /> <layer path="Basement4.ogg" /> <layer path="Basement5.ogg" /> <layer path="Basement6.ogg" /> </track>

The enemies layer is meant to fade in and out based on the enemies in the room if none of the other layers are playing, so enabling that layer via code usually results in it immediately fading back out, so we don't use it here, unless you do actually have something you want to fade in and out when fighting gets tough, otherwise just set it to a silent file or to the same ogg file as the 'default track'

If you want you can set layerfadespeed="0.5" with whatever number you like in the track settings after the layermode="2" to control how quickly the layers can change, smaller number = longer fade.


To control when each variation is used you basically just see if the track is playing and then select the variation, in this example I'm just doing it by room ID number but you could use any method of determining which layer to use.

local CustomMusic = Isaac.GetMusicIdByName("SOUNDTRACK Basement") local Music = MusicManager() local NumOfLayers = 6 --this includes the base/default track local CurrentLayer = 0 function mymod:update() if SoundtrackSongList then if Music:GetCurrentMusicID() == CustomMusic then --get layer to use local LayerID = Game():GetLevel():GetCurrentRoomIndex() % NumOfLayers --if we're not already playing the right layer if LayerID ~= CurrentLayer then --disable all layers for i = 0, NumOfLayers do Music:DisableLayer(i) end --enable selected layer --if default (0) is selected we don't need to enable any layers) if LayerID > 0 then Music:EnableLayer(LayerID) end end CurrentLayer = LayerID --remember the layer end end end mymod:AddCallback(ModCallbacks.MC_POST_UPDATE, mymod.update);

Basically the LayerID starts at 0 and caps at 1 less than the number of variants, so a LayerID of 0 means play the default 'basement1' track, while a LayerID of 3 means play 'basement4'.
Last edited by ☢ Nato Potato ☢; Aug 11, 2024 @ 9:58pm
< >
Showing 1-2 of 2 comments
Koduckushi Mar 9, 2023 @ 1:21am 
This is so awesome! Thanks so much for the quick response. Off into the sunset I ride! ~now with even more music~
☢ Nato Potato ☢  [developer] Aug 9, 2024 @ 6:51pm 
updated so now simple variations are supported by default and can be included without needing any extra lua code in the soundtrack, especially useful for jingle variations
Last edited by ☢ Nato Potato ☢; Aug 9, 2024 @ 9:21pm
< >
Showing 1-2 of 2 comments
Per page: 1530 50