I figured out how to write a shepard tone in Pico-8.
If you don’t know what a shepard tone is, it’s an aural illusion that gives the impression that a tone is infinitely rising (or descending). Here’s an example, with a good visual of how it works.
Basically, you have multiple pitches, all an octave apart. The highest pitch gradually fades out as the lowest pitch gradually fades in.
I originally wanted to do a video tutorial explaining this but, despite what it looks like, it’s actually very complex, and the video wouldn’t be as short and concise as I’d like.
So instead, I’ve attached the cart and have written about some of the important details below:
Using the Instrument Editor
When you use the slide effect (#1) on the first row on an SFX, the note ALWAYS slides from C2. This makes connecting multiple SFX problematic. Row 1 won’t slide from row 32 from the previous SFX, it will slide from C2. This means your gradually rising pitch will have a sudden hiccup on the next music pattern.
My solution to this was to use the instrument editor. I created an instrument that is gradually sliding up the chromatic scale (starting on C#2). So now you can call that instrument on any row (including row 1), on any note, and it will gradually ascend without any hiccups.

Setting the SPD
When using the instrument editor, it’s possible to have an instrument being played at a different SPD than the SFX in which it’s being called. To make things easier, BOTH are SPD=255. This helps keep track of what frequencies are being played on any given row.
Connecting Pitches Over Multiple Patterns
Now we have another problem: The chromatic scale has twelve notes. But an SFX in Pico-8 has 32 rows. Starting on C#2, The 32nd note of the chromatic scale is G#4.

This means when connecting multiple SFX together, the next SFX needs to start on the note A4 (actually G#, because we’re starting on C, not C#)

Setting Volume Curves
Now that we know the pitches should all line up, the last detail is figuring out the volume curves.
My solution was to incorporate the curves directly into the instrument editor. There are three instruments with their own volume curve:
However, these volume curves are interrupted at the beginning of the next music pattern, so four more instruments are needed:
In the above picture, instrument 3 fades in over 4-rows, and instrument 4 fades out over 4-rows. Those fades are made complete using effects 4 & 5 in the actual SFX.
--
Whew! Hopefully that was clear.
It’s possible there are other ways to do it, so if you think of another way, please play around with it and let me know! I'm going to post some examples of the shepard tone descending in pitch and at different SPDs.
It’d also be cool to have some animation accompanying this, like a fractal zoom. Any volunteers?