Nine Songs in PICO-8

I’ve written an album, “9 Songs for PICO-8” with the intention that other people can use the songs in their PICO-8 games. They’re in a bunch of different styles, but nothing far from what you’ve heard before. That being said, it’s not as easy as just taking an audio file and dropping it into your own project. Let’s have a look at how to take a song from one cart and put it in another!

The first thing we need to do is open up the cart in an external code editor. I like to use Sublime Text, and set to View the Syntax as “Lua” – this way everything becomes nicely colour coded. You could also just use Notepad or TextEdit if you wanted. In the file, you’ll see a few sections denoted with double underscores before and after the title (e.g. __lua__). We’re interested in the __sfx__ and __music__ sections, but let’s get into a little bit of the theory before we start moving things around.

Figure 1

Music in PICO-8 is made up of sound effects. The music player can play up to four sound effects at once, making your song. On a cart with no sounds, the __sfx__ section is followed by a ton of zeroes. If you’re looking at a cart which already has sound effects and music in it, you’ll see what looks like a bunch of gibberish. Each of these lines is one of sixty-four “sound effects,” (numbered from 0 to 63). The numbers and letters are the code which tells the audio system what notes to play, in what order, using what articulation, and how fast.

Underneath the __music__ section is much easier to understand. Again, it’s 64 lines of information for the audio system, but because all the heavy lifting is taken care of by the sound effects themselves, this section is almost readable. The first two digits tell the tracker if the music is supposed to loop from that point, continue or stop, then the 8 digits following are hexadecimal for which sound effects will be triggered.

Figure 2

The easiest way to share music between carts is to open them both up in the external editor, and copy and paste the entire __sfx__ and __music__ sections onto the second cart. Then, when you open it in PICO-8, you’ll see all the music and sounds from one cart on the other. This is great for collaborative work, but be careful because if two people are working on sounds separately, you certainly risk overwriting someone’s work.

That brings us to the more precise and careful way of doing this: copying specific lines. This is easy with the sound effects themselves, you just count from the first line after __sfx__ (starting at 0, see diagram below). That number will correspond to the name of the sound effect when it was in PICO-8. You can pick and choose which sounds to copy over. Be careful to paste them on the same line they came from! Repeat this process for the relevant __music__ lines as well, and you’re all set.

Figure 3

If you want to take it a step further, you can paste the sound effects to whatever line you want. This is good if you want to consolidate, or if you want to move a song from a high tracker number to a lower one. Remember how the music steps just point to sound effects? Well, if you copy over the relevant sound effects to whatever line you want (and you’re like me and can’t easily write out hexadecimal), it’s not hard to just open the file in PICO-8 and point the tracker to the relevant sounds after the fact.

If you’d like more help with this process, or use some of my music in your PICO-8 game, message me on twitter: @RobbyDuguay.