Skip to main content
Music CreationMusic TheoryVideo Game Music

Megalovania Music Theory: 5 Composition Lessons

By October 12, 2026No Comments8 min read

Megalovania offers five useful composition lessons:

  1. Combine a repeating motif with descending bass notes.
  2. Contrast short and long sounds.
  3. Reuse a riff as a countermelody.
  4. Make drum fills count.
  5. Change the melody between sections.

Those are the features I explore in Toby Fox’s track from the Undertale soundtrack.

The little figure in Megalovania’s opening riff keeps coming back. The lower notes keep stepping down. Listen to one, then the other, and you can hear two different things happening inside the same line: something insists on repeating itself while something else gives it a direction.

The opening riff

Follow the opening note pairs: D, C, B natural, then B-flat. Each pair begins another return of the riff.

Single-staff notation of the opening four bars, with the opening D, C, B natural and B-flat note pairs identified.
Notation
Piano-roll view of the opening four bars, showing the descending opening note pairs and recurring upper figure.
Piano roll. A-sharp and G-sharp are enharmonic equivalents of B-flat and A-flat: the same pitches, spelled differently.

Download MIDI · Download score (PDF)

Hear the riff in the video.

Score excerpts: Toby Fox, piano arrangement by Cantavanda. Arrows, outlines and analytical labels added for this lesson.

The riff is strong enough to become the thing we recognize, but its usefulness keeps changing. Later, it can sit underneath another melody and help hold the music together while our attention follows something new. Toby Fox gets more than one opening’s worth of music out of his opening idea.

There’s a useful composing question in that: once you have a riff you like, how much can it do?

The movement is inside the repetition

A riff is a repeating pattern that becomes a featured part of a piece. Inside this riff, there’s a smaller recognizable idea: a motif. The motif is the notes between that descending bass line…and also includes the bassline note itself. The motif and the descent work together so closely that we hear the changing bass notes as part of the melody’s identity.

The complete motif

The complete motif includes the low notes at its beginning. The smaller outline identifies those notes within the larger phrase.

Single-staff notation of the complete first-bar motif, including its two opening low D notes.
Notation
Piano-roll view of the complete first-bar motif, including the two opening low D notes.
Piano roll

Download MIDI · Download score (PDF)

In my Megalovania breakdown, I pull those parts apart. The motif sounds cool by itself. Put the descending notes back in, and it has a different kind of movement. The figure can keep returning because its surroundings are already changing from within the riff.

With and without the low notes

Listen to the upper figure first, then include the outlined low notes. Separating the parts for this demonstration does not change which notes belong to the full motif.

A. Upper figure only

The low-note attacks are omitted for this comparison; the upper figure keeps its place in the bar.

Single-staff notation of the upper figure alone, with rests where the opening low-note attacks were omitted.
Notation
Piano-roll view of the upper figure alone, with gaps at the omitted low-note attacks.
Piano roll

Download MIDI · Download score (PDF)

B. Complete riff

The low notes return in their original places.

Single-staff notation of the same two bars with the opening low-note attacks restored.
Notation
Piano-roll view of the complete two-bar riff with the low notes restored.
Piano roll

Download MIDI · Download score (PDF)

Hear the comparison.

I also try putting different chords underneath it. Those are possible harmonizations, ways of hearing what else the riff could support. They aren’t a transcription of the full chords in the recording. Keeping the figure recognizable while changing its harmonic setting makes its flexibility easier to hear.

One possible harmonization

Single-staff notation of the riff with added chord voicings for D minor, C major, G over B and B-flat.
Notation
Piano-roll view of the riff and the added chord voicings for the alternative harmonization.
Piano roll. A-sharp and G-sharp are enharmonic equivalents of B-flat and A-flat: the same pitches, spelled differently.

Download MIDI · Download score (PDF)

Hear the harmonizations.

Even before adding chords, though, there’s another kind of movement to pay attention to: the lengths of the notes. The short sounds in Megalovania make the long ones matter. A run of short notes establishes a behavior, then one note stays. After all that activity, a held sound can have a surprising amount of presence. The short notes return, and we feel the difference again.

I think that contrast does a lot of the melodic work here. It’s easy to become fascinated by which pitch comes next and barely notice how much character comes from letting the current one last. In the video, one of my live melody examples is approximate, so use the recording for the exact line. What I’m drawing attention to is the relationship between short and long.

You can test that relationship with a phrase of your own. Keep its pitches and change the length of a few notes. Let one linger where the others move quickly, then try the opposite. Does a note become a destination? Does the phrase suddenly seem impatient to continue? You haven’t changed the pitch sequence, but you may have changed quite a bit of what the melody says.

Same pitches, different lengths

A. Even lengths

Single-staff notation of a two-bar teaching phrase with eight quarter notes.
Notation
Piano-roll view of the teaching phrase with eight evenly spaced notes.
Piano roll

Download MIDI · Download score (PDF)

B. Short and long

Single-staff notation of the same pitch sequence with contrasting short and long note values.
Notation
Piano-roll view of the same pitch sequence with varied spacing and longer held notes.
Piano roll

Download MIDI · Download score (PDF)

The riff gets a second job

Then comes one of my favorite uses of the material: the main riff turns up as a countermelody beneath other melodies. The idea that introduced the piece is still there, but something else has our attention.

That is economical writing. The new melody brings a change, while the familiar riff supplies a connection to what came before. We get to recognize something and discover something at the same time.

A countermelody is a second melody playing alongside the primary one. The relationship matters: if both lines demand the foreground all the time, following either can become difficult. The supporting line needs enough presence to contribute and enough restraint to let us hear what it supports. On another listen, follow the part underneath the main melody. An old idea may be doing more work than you realized.

The changing foreground in Megalovania gives that familiar material different company. The melody sections use different starting notes, groups of pitches, rhythmic ideas, and contours. Contour is the shape the melody traces as it rises and falls. A new contour can make a new section feel as though it has its own character, even while something recognizable continues below it.

Try that with a riff you already have. Give it a different melody to accompany. Listen to both parts together, then lower or simplify the supporting part if it keeps pulling attention away. This is the beginning of deciding who does what in the music, a question I take further in Orchestration for Beginners.

A riff gets different company

A. Riff alone

Single-staff notation of an original two-bar recurring riff.
Notation
Piano-roll view of the two-bar riff alone.
Piano roll

Download MIDI · Download score (PDF)

B. Riff with melody 1

Single-staff notation showing the recurring riff and the first upper melody as separate voices.
Notation
Piano-roll view of the recurring lower riff beneath the first upper melody.
Piano roll

Download MIDI · Download score (PDF)

C. Riff with melody 2

Single-staff notation showing the unchanged riff beneath a second melody with a different starting note and contour.
Notation
Piano-roll view of the unchanged lower riff and the second upper melody.
Piano roll

Download MIDI · Download score (PDF)

Make the interruption count

The drums play their part in this balance between recognition and change. In the breakdown, I use kick-snare-kick-snare across four beats to establish a clear reference pattern. That’s one way of making the expectation easy to hear; four-beat music has plenty of other possibilities.

Once we know the pattern, we can feel it being interrupted. Megalovania’s drum fills break the expected kick-and-snare behavior to create movement and keep the energy going. One fill I point out comes near the end of a melody section, just before the music heads into its final section. The timing of the interruption gives it a job beyond adding more drum hits.

A fill gets to be surprising because the groove has been dependable.

For your own transition, repeat a groove and change its ending as the next section approaches. Then remove the fill and listen through the join again. The comparison will tell you whether the change is helping the music arrive somewhere, or whether you simply enjoy that particular burst of drums. Either is worth knowing before adding another one.

A fill changes the arrival

A. Steady groove

Single-staff drum notation showing three bars of the same kick, snare and closed hi-hat groove.
Notation
Piano-roll view of the steady three-bar kick, snare and hi-hat groove.
Drum MIDI: C2 = kick, D2 = snare, F♯2 = closed hi-hat.

Download MIDI · Download score (PDF)

B. With a fill

Single-staff drum notation with a snare fill in the last two beats of bar 2 and the original groove restored in bar 3.
Notation
Piano-roll view showing the extra snare attacks in bar 2 and the unchanged groove in bar 3.
Drum MIDI: C2 = kick, D2 = snare, F♯2 = closed hi-hat.

Download MIDI · Download score (PDF)

Megalovania keeps finding uses for what we already recognize. The motif returns against descending notes. Short sounds make a long one stand out. The riff becomes support for a new melody, and an established drum pattern gives a fill something to interrupt. The piece keeps its identity through all of it.

That’s a lot to ask of a stubborn little idea. This one keeps finding a reason to come back.

For the broader path from a musical idea to a finished piece, start with my video game music composition guide.

Frequently asked questions

What makes Megalovania’s opening riff effective?

The repeating motif and descending bass notes work together inside the riff. In the breakdown, I separate them, then put them back together. The motif stays recognizable while the descending notes give it movement.

Why do the lengths of the notes matter?

Short sounds make the longer ones stand out. I hear that contrast as a big part of the melody’s character. Listen for where a note holds on after a run of shorter sounds, then notice what happens when the short notes return.

How does Megalovania reuse its main riff?

The riff returns underneath other melodies as a countermelody. It becomes a supporting line while another melody takes the foreground. The familiar idea still contributes, but its job has changed.

What do the drum fills contribute?

They interrupt an established pattern to add movement and keep the energy going. One fill I discuss leads from a melody section into the final section. Listen to the groove before the fill; that gives the interruption its context.

About the Author

Dan Spencer is a video game music composer with credits on Yes, My Warlord (Steam) and Minimalist Rally 2D (itch.io). Both original soundtracks stream on Spotify as Music Mentor Dan. He is the author of 12 music education books with six #1 Amazon bestsellers, including The Best Music Theory Book for Beginners series (Amazon author store).

Dan is the founder of Best Music Coach and creator of the 4M Video Game Music Composition Protocol, the curriculum taught inside the Gamer Music Creator Guild. He runs four YouTube channels:

Connect with Dan on LinkedIn or at musicmentordan.com.

See what other composers have achieved →

Gamer Music Creator Guild Results

Guild members who have released music
25
Total Guild member releases
114
Average days to first release
67.2
Guild soundtracks in progress
4

The average covers members who have reached a first release. See the releases and stories.