← All Dispatches
Aug 31 2026
Gobs & Gears

The Score Knows Where You Are

INTENSITY: ████████░░ CLIMBING

FACTORY FLOOR is where I open up Gobs & Gears and show you how a specific thing actually works. Real code out of my self-hosted SVN repo.

The sound and music on Gobs & Gears is by Megahammer Studios. Working with Donovan has been one of the genuine pleasures of this whole project.

I want to explain what Donovan delivered, because "he did the music" undersells it by a large margin. What I asked for was not just a song.


The score is six tracks that play simultaneously, forever, from the moment you start a run.

music_game     main            (M)   — always playing at full volume
music_stem_0   calm            (C)
music_stem_1   active          (A)
music_stem_1_1 active extra    (AE)
music_stem_2   intense         (I)
music_stem_3   super intense   (SI)

source/game/lr_music.h

All six are running at all times. What changes is the volume of each one.

This is the part that is easy to say and hard to write. Every layer has to be worth listening to on its own and every combination of layers has to sound intentional. Each stem can be added and removed while the music is playing without anyone noticing a seam.

They are also phase locked. Every one of the six tracks shares the exact same timeline, so the layers stay in lockstep no matter which ones happen to be audible.

// Current score: loop point = 3:24.255 = 204.255s, with the reverb tail running
// past it to the file end. Every layer shares this timeline, so they all use the
// same numbers.

tracks=
{
    { track=music_game     loop_start=0.0 loop_end=204.255 }
    { track=music_stem_0   loop_start=0.0 loop_end=204.255 }
    { track=music_stem_1   loop_start=0.0 loop_end=204.255 }
    { track=music_stem_1_1 loop_start=0.0 loop_end=204.255 }
    { track=music_stem_2   loop_start=0.0 loop_end=204.255 }
    { track=music_stem_3   loop_start=0.0 loop_end=204.255 }
}

data/sounds/music_loops.ie


Here is my favourite thing in the entire audio system. Every track is authored in two parts: the loop body, and a tail.

Most looping game music has a problem: the reverb and decay from the final note has nowhere to go. If you cut the file at the loop point, you chop the ring-out and get a tiny hole in the sound every time round. If you let the reverb bleed into the start of the file it stacks on itself and slowly turns to mush in your ears.

So we do neither. At the loop point a fresh copy of all six tracks starts from the top, while the copies that were already playing keep going into their tails and ring out naturally over the new beginning. For a moment there are twelve tracks playing and the old score decays over the new one.

That only works because Megahammer authored the tail as a real region past the loop point rather than trimming the file to a clean loop. That was a small, technically-minded decision made by somebody who understood how the playback engine was going to use their file.


So when do the layers change?

The score moves through five states, driven by objective-tier progress toward the finale. A fresh run is calm and the BIG BOOM delivery is full intensity. It is tier-weighted so later goals move the needle harder than early ones.

Main:          M
Calm:          M, C
Active:        M, C, A, AE
Intense:       M, A, I
SuperIntense:  M, A, I, SI

source/game/lr_music.h

Going from Calm to Active adds two layers on top of what was already there. But going from Active to Intense drops two: the calm layer and the active extra both leave as the intense layer arrives.

Crucially the state rises and never falls during a run, because progress is permanent. The score ramps across the whole playthrough and does not decay.

However, this was not the first design of the music system. It was initially event based. Deliveries and stalled buildings bumped a meter that decayed over time. It sounded reactive and fun on paper and it was truly awful in practice. The score would rise and fall constantly and it was impossible to tune for early game to late game progression. I threw it all out and replaced it with a simple scoring system.

Every transition crossfades over three seconds so a state change is a shift in the mix rather than a switch being thrown.


What I keep coming back to with Megahammer is that none of the above is a music problem or a code problem. It is both, and it only works because the person writing the music understood the system it was going into, and the person writing the system understood what the music was trying to do.

I have had a lot of collaborations in my life that were "here is my part, good luck with yours." This one has never been that. Megahammer Studios understood the brief, and I warned Donovan that walking into my custom engine could be a bit of a nightmare. But he took it all in stride and came up with what I would best describe as goblin factory music.

Donovan is so good at what he does. Go bother him for more.


You can hear all of this for yourself: play the Gobs & Gears demo on Steam, and wishlist the full game while you are there. Sign up for dispatches from this Goblin. Next Dispatch Day is Monday.

GOBLINTEK is a two-person game studio. We own our shit.

← Previous The Demo Is Live