Words set
the clock and the shape.
One loop needs timed sounds and a matching visible step. A scheduler is code that arranges when notes will play. The audio clock measures playback time; the highlight should follow it rather than the browser’s irregular screen redraws.
Each step is an eighth note.
BPM counts quarter-note beats per minute. Two eighth notes fit each beat, so one step lasts 30/BPM seconds. At 120 BPM that is 0.25 seconds; the eight-step loop lasts two seconds.
Schedule ahead using the audio clock
Send each note and its future play time to the audio system slightly before it is due. Move the visible highlight when that time arrives. This connects what you hear to the column you see.
four arrays of eight booleans
An array is a list; a boolean is true or false. Four lists of eight on/off values store the four note rows. A validator checks every value and row length before restoring a saved pattern.