Creating the Shepard Tone audio illusion with JavaScript

The Shepard Tone is an audio illusion that creates the impression of an endlessly rising or falling tone.

Back in 2009 I rendered an example of it using Lilypond, which was pretty hacky.

Having recently played with the Web Audio API for my Winamp2-js project I realized it would be easy to create this effect using Javascript.

You can hear for yourself, just turn up the volume:


Check out the ~40 lines of code on JSFiddle or GitHub