Music
Author(s): benevolusgoatTags:
Crash course table of contents
The crash course is still a work in progress!
- Creating a mod.
- Creating a passive item.
- Creating an active item.
- Adding to item pools.
- Making costumes.
- Creating a character.
- Creating entities.
- Adding sounds.
- Adding music.
- Making pocket items.
- Creating challenges.
- Structuring your mod.
- Conclusion.
Isaac has a robust OST, having music tracks for every stage, special rooms, and cutscenes. Adding custom music for your own mod can make it stand out when adding something of similar nature.
Video tutorial⚓︎
(This tutorial covers both sounds and music)

Adding custom music⚓︎
The game's music files are all in the .ogg file format, unlike sounds which use the .wav format.
All custom music is defined in a music.xml file, located in the content folder at the root of your mod folder. In this file, there must be a root music tag. This tag has a root property, which should point to the root directory of where your music is stored starting from your mod's resources folder. The vanilla game calls this folder "music".
1 2 3 | |
When defining a new music track, you use a track tag with a name property declaring the name for your music track. You'll use the track's name to grab its id later.
Music tracks can be customized with intros, layers, and more. Many tracks in the vanilla game are composed of several .ogg files that come together to form the full song in-game.
track tag variables
Note
name and path are the only required variables. intro is only needed if you plan to loop the music at a certain point in the track. A few layer-related variables are not listed here; see the Layer section below.
| Variable Name | Possible Values | Description |
|---|---|---|
| name | string | The name of the track |
| intro | string | The file path to the intro of this track, strating from the root. Plays exactly once at the beginning of the song. |
| path | string | The file path to the main music file, starting from the root. Plays after the intro. |
| loop | bool | Default: false. Whether or not the main track should loop indefinitely. |
| mul | float | Default: 1. Volume percentage of the music track, represented as a float value (e.g. 0.5 is 50% volume). |
| layermode | int | Default: 1. 1: Layer overlaps with the base track. 2: Layer plays instead of the base track. |
| layerfadespeed | float | Default: 0.08. The speed at which the music transitions between the main track and its layers, acting as the percentage amount of its progress every render frame (60 frames per second). |
Below is an example XML named "Chocobo":
1 2 3 | |
Layers⚓︎
Layers are additional music tracks that can be defined under the main music track. Layers can play on top of the main track or replace it, depending on what layermode is set to in the XML. They are not played by default and must be manually triggered with Lua. There are two ways to add layers:
One way is to use the track tag, which contains the layer, layerintro, and layermul variables, analogous to path, intro, and mul respectively. This is restricted to only being able to define information for one layer.
1 2 3 | |
Another way is to add the layer child node. It's added under the track node, having intro, path, and mul as possible variables. You can add more than one layer to a track, allowing for expanded customizability. Remember to open up the track node similarly to the root music note so that it can accept layer nodes.
1 2 3 4 5 | |
Playing music with Lua⚓︎
To play music, you'll need to use the MusicManager object, which you can instantiate with MusicManager(), and then use the Play function.
The track will play at full volume by default, ignoring your music volume setting. This can be fixed by either using Options.MusicVolume for the Volume parameter or using MusicManager:UpdateVolume after playing the music. Note that the latter option will cancel any fade actions and instantly update the music to play at its expected volume.
As a simple method of testing the music, we'll be using Input.IsButtonTriggered to detect a specific keyboard input.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
To play a custom music track, get its id with Isaac.GetMusicIdByName.
1 2 3 4 5 6 7 8 9 10 11 | |
Layers must be enabled through MusicManager:EnableLayer. The layer id corresponds to the order the tracks were created in inside the music.xml, starting from 0.
When enabled, layers will fade in unless the Instant argument is set to true. Layers are also synced with the main music track, so it will play the layer track at whatever point the main track is at in its duration.
Use MusicManager:DisableLayer to disable a layer. As layers are connected to a main track, any modifications made to the main track such as fading in/out, pitch, etc, will also affect its layers.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Jingles⚓︎
Jingles are very brief music tracks, typically a few seconds long, for indicating specific events. Common examples of this are entering a treasure room or finding a secret room.
Playing a jingle causes the the main track to fade to a low volume before playing the jingle, afterwards fading the main track back in. Utilizing jingles yourself is exclusive to
REPENTOGON, where it's as simple as using MusicManager:PlayJingle.