Joining the project
In February of 2024, I was contacted by producer at Lunar Forge, Katie Millar, about composing music for a proof-of-concept video of a rhythm game they were planning to make. They had come across my portfolio, and felt I might be a good fit to compose music for them. I also took on sound design for the project. Lunar Forge is the gamedev-focused offspring of renowned art outsourcing company Mooncolony.
The game takes place in a gothic setting, with a dark vibe but cartoony look. Inspired by games like HarmoKnight, the goal was to couple the gameplay closely to the music.
Proof of concept video (2024)
During the first half of 2024, we completed the proof-of-concept video. After listening a whole bunch to the excellent Castlevania soundtracks, I tried to approximate the style while keeping in mind that the beat should be distinct and easy to follow.
We also played around with musical stingers when the player performs certain actions, like a bell tone played in the key of the music when collecting an orb, or a guitar power chord when smacking an enemy.
While working on this project, I gained a new appreciation of the music in the Castlevania series. Some of my favorites:
- Beginning and Deja Vu from Castlevania 3 (Famicom)
- Distant Triumphant Return from Castlevania: Dracula X Chronicles
- Fog-enshrouded Nightscape from Castlevania: Lament of Innocence
- Stage 4 Other Side BGM from Castlevania: Rondo of Blood
Playable demo (2025)
After the video was finished, Lunar Forge decided to move forward and produce a playable demo. The technical work was outsourced, and after some deliberation N-ix got the gig, and quickly had a Unity project up and running.
At first, my role was delivering audio assets - but after a few months it was clear that the project would benefit from having someone with audio expertise. There were some issues with synchronizing the gameplay to the beat, and the workflow for level design needed to be improved.
Our approach to rhythm game level design
One of the first things I did was to establish a timeline to use as a base for the layout of the level. Ideally, every other system would use it as a reference. By setting bpm and unitsPerBeat manually, we can draw the timeline accurately in world space using Unity's OnDrawGizmos() method. During gameplay, we draw a white line indicating the playback position of the AudioSource; this way we can immediately identify sync issues between the gameplay and the music. It's also our anchor, where the player character should always be on the X-axis.

The timeline is visualized in world space using Unity's gizmos.
Since I'd already written a C# class that can read cues from WAV-files, I figured using it here would improve the workflow. The timeline is populated with markers to indicate emphasized beats, and in my DAW, I can add a name to each of them that the level designer knows the context. For example, we wanted a part near the end where the player uses their hook three times. The music has three distinct beats, and by using markers we can clearly see where the player is at those exact moments.
This Unity forum thread documents my journey into the wav-file specification, and contains a downloadable version of the C# class.

Markers act as handy guides for placement of obstacles and collectables.
Our player character moves around the world using physics, which means he'll veer off the timeline eventually. Converting to a more deterministic method was not viable in the time and budget we had remaining for the demo. The solution we landed on to secure synchronization was to snap the player to the target x-position every few seconds. The player might see the character teleport slightly sometimes, but it's better than being out of sync.

The white line shows the playback position of the audio source, giving us a visual way to confirm that the player character is synced to the beat.
Minigame remake
The demo has a few minigames, where the player is tasked with cooking food by pressing a button to the rhythm. We ended up completely remaking these, using the new timeline system.
Programming-wise, the timeline implementation makes use of the Observer pattern, with events that other classes can subscribe to;
OnPlaybackStart,OnBeatandOnPlaybackEnd. This way, the timeline doesn't care what we do with our beats - it just does its thing. This lets us reuse the timeline logic for both the main gameplay level and the minigame, even if they do completely different things with the beats.
General notes on audio timing
Unity has some quirks when it comes to audio, that might be useful to know in the context of a rhythm game.
Accurate timing between clips
Unity's built-in Time.time float value and its variants are accurate enough for most things, but when dealing with audio we'll generally want to use AudioSettings.dspTime instead. For example, we stitching together loops of music, we need to use PlayScheduled(dspTime) to avoid noticeable gaps or pops.
Playback delay
If you create an AudioSource, assign an audio clip to it and then play it, there is a slight delay the first time it plays. There are a few ways around this:
- To force preparation, we can call
Play()and then immediately callPause(). Later on, callingResume()orPlay()will immediately start playing the sound. - We can use the aforementioned
PlayScheduled(dspTime), given enough of a delay to let it prepare. - We can call
audioClip.LoadSampleData()on all the clips we need before playing. By checkingaudioClip.loadState, we can write a coroutine to finish only when all our clips are loaded.
Input lag and audio output delay
All players have different audio setups, which needs to be accounted for. As far as I can tell, there are two different timing issues here:
- Input delay: From the user pressing a button to the visuals updating.
- Audio delay: From the visuals appearing on screen to the audio being physically audible.
To compensate for input delay, we can add a delay to the "grace period" required for a successful input. For audio delay, we can delay the visuals. Most games include a calibration tool, measuring the average time offset of the input versus the exact beats, and adjusting the visuals and audio accordingly. Fortunately, most screens have very low input delay, so realistically only input delay compensation is needed.
For reference, when using a MacBook M1 with the built-in laptop speakers, I had to add 70ms of input and visual delay compensation for the gameplay in my test scene to feel good. With a JBL bluetooth headset, about 200ms of delay felt right.
I made a dedicated project for testing timing issues more in-depth.
After the demo
Parsing MIDI files
After we wrapped up the demo, I started researching how we could improve the workflow for a full release. Using MIDI files, we could encode not only timed markers, but musical context like notes, chords and tempo. I started implementing a MIDI file parser using the MIDI file spec. Thanks to Anthropic's Claude, I had an initial implementation up and running in no time - although it took me a few days to get it complete and optimized.
Like many other file formats, MIDI files are laid out in chunks. Each chunk has a header describing the content that follows, usually including an ID and the length of the chunk. From that, we can traverse through each chunk, saving the info we need into a C# object.
MIDI content is separated into tracks, with each track containing events like notes, markers, etc. For multi-track files (file type 1), the first track is reserved for meta-events like tempo markers or text cues.

A MIDI file, visualized as a timeline in a Unity scene.
The trickiest part of the parsing is handling tempo changes accurately. MIDI files are described in "ticks" (or pulses), and the file header chunk contains a given pulses per quarter note (PPQN). Tempo is described in microseconds per quarter note. For our MIDI events, we want the time in seconds, which means that we have to check the entire track from beginning to end. Each tick needs to be accounted for, because when the tempo changes, so does the time between each tick.
The parser traverses the file, byte by byte, taking into account any tempo changes (which are stored in the first track). These are cached for subsequent tracks, which lets us calculate the time in seconds between each tick as we read through the events of the track. Internally, double values are used for more accuracy, since small rounding errors would otherwise build up throughout the tick traversal. I noticed that Reaper tends to round final timing values to the nearest three decimals, so I opted to do the same - storing them as floats.

The inspector of an imported MIDI file.
Finally, I added a ScriptableObject class to hold the MIDI data, and a ScriptedImporter to automatically parse MIDI files as they are imported into the project and create an instance of the ScriptableObject. From there, we can add a SerializedField and drag the ScriptableObject in via the inspector - just like any other object.
After going through this whole ordeal, I discovered several ready-made MIDI importer solutions for Unity, made by other community members. Still, I learned a lot while researching MIDI, and ended up with a solution that will definitely be useful down the road.
Where the project ended
After the demo, Lunar Forge decided not to develop a full version of the game, so Glideout ended as a prototype.