Syncing Music to Moving Widget

Hi everyone. I am creating a rhythm-based game and I need to sync a moving widget to the speed of the bpm of the music. The widget is a simple slider that bounces from the left side of the screen to the right and back, ala a metronome.

Here’s my problem, the widget is updated every frame depending on the game’s current fps, though the music seems to play without any regard of fps. So the two are often out of sync.

I’ve gotten the speed of the widget down precisely (thousandth percentile or something) to match the widget, but the next time I started my project up, it was out of sync once again.

I’ve also tried locking the fps of the project to match the bpm of the music but that just gave very erroneous results.

What would be the best way to get the two synced? Would the best way be to lock the speed variable of the widget to the fps and then divide by the bpm or something similar?

I appreciate any help!