youre right, this is not the right time for perceptionism I will go all in with the feeling!
for we to sync timing on beat we need a single source of truth script, a Conductor, he is responsible for the beats and related stuff, with a function to play the song he receives the bpm, start playing the song and tracking the song position, converts it into beats based on the bpm song_position / 60 / bpm, with that in hands we can check which beat we are in and call, wait to reach certain beat in a position on the song and etc, its easy to check if the input was pressed next to a full beat and create patterns based on the current beat after that