How do i rotate a 2d sprite in sync with bpm?

I’m making a rhythm game and i have a sprite that i need to rotate in sync with the song’s bpm. Every beat should be a 90 degree rotation. I made this bit of code and i just plug in the bpm of whatever song im using. The song im testing with right now is 181 bpm.

Sprite.rotation += (deg_to_rad(90) * (delta * (bpm/60)))

It’s close to accurate but its slightly too slow and only syncs up midway through the song then isn’t synced anymore after a few seconds. i don’t know how to make it any more accurate than it already is.

I also noticed that the rotation is never at 0, 90, 180, 270, or 360 degrees, because when i set it to print something every 90 degrees i get no output.

if I were to do it somehow within the _process method, I would worry about performance. As an alternative, I would look into plugins that could help out like GitHub - ynot01/Godot-BeatKeeper: A plugin for Godot that adds a node that emits signals at beat intervals, meant for rhythm games

This plugin looks like exactly what i need, thank you so much