Move metronome code to a new js file