JS port of Pete Kellock's "Rhythm Engine"