The Binding of Isaac: Rebirth

The Binding of Isaac: Rebirth

!![REP/REP+]Music Mod Callback
cybershadow95  [developer] 18 Dec, 2021 @ 1:33pm
Example of sound jingle replacement in AddMusicCallback
Here is a code example of replacing the default Treasure Room jingles with the ones used in Antibirth:

local antibirthjingles = RegisterMod("Antibirth Treasure Jingles", 1) MMC.AddMusicCallback(antibirthjingles, function() local antibirthsound = Isaac.GetSoundIdByName("Treasure Jingle (antibirth)") return 0, nil, antibirthsound end, Music.MUSIC_JINGLE_TREASUREROOM_ENTRY_0, Music.MUSIC_JINGLE_TREASUREROOM_ENTRY_1, Music.MUSIC_JINGLE_TREASUREROOM_ENTRY_2, Music.MUSIC_JINGLE_TREASUREROOM_ENTRY_3)

Your content/sounds.xml file might look something like this:

<sounds root="sfx/"> <sound name="Treasure Jingle (antibirth)"> <sample weight="1" path="antibirth_treasure_jingle_1.wav" /> <sample weight="1" path="antibirth_treasure_jingle_2.wav" /> <sample weight="1" path="antibirth_treasure_jingle_3.wav" /> <sample weight="1" path="antibirth_treasure_jingle_4.wav" /> <sample weight="1" path="antibirth_treasure_jingle_5.wav" /> <sample weight="1" path="antibirth_treasure_jingle_6.wav" /> <sample weight="1" path="antibirth_treasure_jingle_7.wav" /> <sample weight="1" path="antibirth_treasure_jingle_8.wav" /> <sample weight="1" path="antibirth_treasure_jingle_9.wav" /> </sound> </sounds>

Important things to understand:
  • The custom sounds must be in .wav format
  • To return an existing sound effect, use the SoundEffect enum detailed in the lua docs
  • To return a custom sound effect, use Isaac.GetSoundIdByName() with whatever name used in the sounds.xml file
  • If you do not return a sound effect id as the third argument in your callback function, the MMC will play your first returned argument as music (interrupting all other music)
  • The only Music enums that can be replaced with sound effects are MUSIC_JINGLE_TREASUREROOM_ENTRY_0, MUSIC_JINGLE_TREASUREROOM_ENTRY_1, MUSIC_JINGLE_TREASUREROOM_ENTRY_2, MUSIC_JINGLE_TREASUREROOM_ENTRY_3, MUSIC_JINGLE_SECRETROOM_FIND, MUSIC_STRANGE_DOOR_JINGLE, MUSIC_JINGLE_DEVILROOM_FIND, and MUSIC_JINGLE_HOLYROOM_FIND
  • If you return a sound effect id as the third argument for one of these Music enums, the first argument you return will be ignored, but the second argument you return will NOT be ignored
Last edited by cybershadow95; 19 Dec, 2021 @ 9:27am