Add game music and SFX in PICO-8

By Dan Lambton-Howard. Posted

Use PICO-8’s built-in synthesizer to create space-age sound effects and get your pulse pounding by composing some bangin’ retro chiptunes

PICO-8 comes with a comprehensive and surprisingly versatile set of music and sound effect editors. Featuring eight synth instruments and seven built-in effects – including slides, vibrato, and arpeggiators – it is an accessible and easy way to make everything from retro bleeps aand bloops, up to entire chiptune symphonies.

We’ll walk you through each of the editors as we make some simple sound effects for our space shooter game. Then, we’ll put some loops together to explore the basics of writing a retro techno soundtrack. All together now!

An anatomy of sound

Let’s start with understanding how PICO‑8 handles audio. A PICO-8 cartridge can hold up to 64 sound effects (SFX). These SFX are used for everything from gameplay sounds, like the ‘boing’ you hear when jumping in a platformer, to backing tracks and incidental music.

Each SFX consists of 32 notes and each note contains information about its pitch (how high or low), its instrument (the overall timbre and aural quality), its volume (you guessed it), and effect (how that note is altered or modified). You can make a lot of noise with eight little bits!

The editors

Load up the space shooter game we’ve been building, and switch to the SFX editor. The first thing to know is that there are two modes. Pitch mode allows you to plot notes with the mouse and is best for creating sound effects, whilst tracker mode is more suited to music. Toggle between them with the top-left button.

Generally, they both show the same information, and both have the same speed, loop, and instrument selectors. The number at the top left is the index of the current SFX you are editing. Toggle to index 0 and let’s get started.

PICO-8's interface lets you draw out SFX by dragging a mouse

Pew pew pew!

We think our space shooter could do with an old-school laser sound, don’t you? To achieve this in pitch mode, draw a descending series of about eight notes (Figure 1). You can use any instrument you want, but we’ve alternated between square and pulse waves to give a little retro warble. We’ve also used noise for the last two notes, to create a sense of impact. Hit the SPACE bar at any point to play your SFX. We’ve chosen our SFX speed as 2 (1 is the quickest), but play around to see what works.

Figure 1: The same laser zap sound viewed in pitch mode and tracker mode

Impactful audio

To see how your laser sound works in game, add SFX(0) after the call to create_laser() around line 35. Reload your game to hear it in action. It really is that easy. Now, repeat this process to make an explosion sound.

For our example we’ve used around ten notes, starting with deep square wave, a surge of noise, then finishing on higher-pitched saw wave. This creates an initial impact noise and ends on a retro, dopamine-inducing chime. Visit the project’s GitHub repository (magpi.cc/fB0ksD) to hear it in action. Now, add your explosion SFX in code alongside wherever we create explosions.

Tracker mode

Now we’ve got some retro zaps and booms, let’s move onto the soundtrack. Toggle the editor to tracker mode. This mode is better for writing music as it is easier to see the relative spacing and timings of notes, as well as to adjust individual properties of each note. You will also be able to see the grey effect selector buttons in this view.

Notes might look like a baffling array of letters and numbers, but are actually quite simple. Each line shows the pitch (A–G#), octave (0–5), instrument (0–7), volume (0–9), and effect (0–7) of a note.

Kick and snare

To write notes in tracker mode, you need to actually play notes with your keyboard, just like a piano – see the layout in Figure 2 (overleaf). Have a little play around; you can hit SPACE to play your creation and if you set the loop controls to 0 and 32, it will play through all 32 notes before restarting. Once you’re comfortable, plot a simple drum beat. Use C1053 for a nice kick-drum sound, and C3655 for a punchy snare. We’ve gone for a pretty standard rock beat with a speed of 12.

Figure 2: This handy reference will soon have you playing PICO-8 like Beethoven

The full kit and caboodle

Next, you might want to make a few variations on this basic beat and save these as new SFX. To make things easier, you can copy and paste individual notes or whole sections. Use CTRL+A to select an entire SFX. To help, a high note with fade out (5) makes a great hi-hat, and mid notes with the drop effect (3) work for toms. Layer it up!

You can keep the SFX playing as you add notes and play around. Once you’ve made three or four variations, we’ll use the music editor to put them together into a composition.

Seeing patterns

The music editor is where the magic happens. It’s where individual SFX are layered and combined to make music. Switch to it now, and take a look. You’ll see a list of patterns at the top of the screen. Each pattern can contain up to four SFX, which are shown in the boxes below, and when it has finished playing, will move onto the next pattern. You can also use the controls on the top-right to set patterns to stop, or loop back to a previous pattern.

Tub thumping

Start adding your drum beat SFX to the leftmost slot of the first few patterns. You can see the index above the slot. Hit SPACE on the first pattern and you should hear your beat played, followed by the beat in the next pattern and so on.

Hit the SPACE bar to hear a perfect retro explosive boom

We’ve started with minimal drums for patterns 0–3, moved into fuller percussion for 4–7, and built our composition from there. Now, obviously, there is more to music than drums (though it’s a good place to start), so we’ll need to create some bass, rhythm, and melodies next. Cue the music!

Thank you for the music

You probably don’t need us to tell you that low notes work well for bass, and high and mid octaves work for melodies and harmonies. For now, concentrate on creating an SFX for each. You can start adding these (and looping them) in your music editor to see how they work together. Try playing around with volumes and effects to make notes more interesting and dynamic.

We’ve created a simple repetitive bassline to run through most of the composition, and a catchy melody for the dynamic peaks. Download the cartridge from the project’s GitHub repository to hear it.

Stops and starts

So now your masterpiece is composed, we need to get it into the game. Simply add music(0) to _init() and reload your game. Et voilà, your tune is now blasting out into space. For extra brownie points, you can add music(-1) to your code when game-over is triggered. This will stop the music from playing when the player is defeated. Or even better, why not compose a whole new game-over theme tune? Attempt to capture the sombre feeling of humanity’s last hope being snuffed out, in 8-bit.

Our composition playing on three of four available audio channels

Top tip

  • Use shortcuts

    The keyboard shortcuts for PICO-8 will really speed up your workflow. Check the manual for the full list.

Deep cuts

We’ve barely scratched the surface of what you can do with sound effects and music with PICO-8. But you should have a good enough grasp of the tools to start exploring the creative potential of this little virtual console.

If you want to go deeper, we highly recommend Chris ‘Gruber’ Donnelly’s series of video tutorials. To add to the possibilities, a recent PICO-8 update introduced SFX instruments, allowing makers to define and experiment with their own instruments on top of the basic eight. There's plenty to get your teeth stuck into. 

This article was written by Dan Lambton-Howard. An independent game designer based in Newcastle upon Tyne, Dan is lucky enough to make games for his PhD.

Note: this is part 4 of a tutorial series. To get the other parts, click here: PICO-8 for Raspberry Pi starter guide.

See also:

This article first appeared in The MagPi 86. Get a free Raspberry Pi with a 12-month subscription to the print edition of The MagPi magazine.

More articles from The MagPi magazine

Subscribe