client-side beat slicer in javascript