Programming challenge: Shepard tone in Sonic Pi


A Shepard tone, is an auditory illusion in which a sound seem to get higher and higher pitched forever – or lower and lower pitch. This is done by looping a cleverly crafted part of the music over itself.

In this challenge, you will create a Shepard tone using the Sonic Pi program. You can install Sonic Pi directly from the official website.


For example, listen to the music of these two videos. Don’t worry about the images, just focus on the audio.

To try to understand how this works, you can listen to the audio track of this video. The transitions between the different parts of the illusions are audible. There is also a breakdown of the frequency as an image, but it will only help you if you know how to read those.

Finally, there is this example on a piano. The notes are discrete (instead of having continuously rising frequencies), but the principle is the same.

You can get more explanations about the Shepard tone on wikipedia. The page also list some uses of Shepard tones in movies and video games.


Using the Sonic Pi programming language, create a Shepard tone. You can choose whether you want an ascending or descending tone, discrete notes or continuous frequencies, what kind of sound to use, etc.

Post your solution below to show off or ask for feedback!


A simple implementation is available on Github. It works by repeatedly creating threads that play strands of upwards going notes. The repository also includes mp3 files recorded from Sonic Pi directly.