patzly / tack-android

A beautiful metronome for Android with a powerful Wear OS integration
https://patrickzedler.com/tack/
147 stars 6 forks source link

Edge case bug with tempo changes #38

Open flightmansam opened 1 week ago

flightmansam commented 1 week ago

I discovered a bit of a rare edge case. If (while playing) you move the tempo down to 1 bpm and then all the way back up to 120 bpm there will be no clicks until that 1bpm click timer has expired. I haven't looked how the interals work but I would imagine the tempo changes would feel more responsive if you reset the timer on the event of a tempo change. The solution right now is to stop the playback and re-enable it (presumably resetting any timers).

Awesome app by the way! Such dedication and perfectly implemented material you.

❤️‍🔥

patzly commented 3 days ago

Thanks for the issue and your compliments! The problem is a bit harder to solve than you might think, the incremental tempo change option is the real issue here. Incremental tempo changes can happen every time, counted in bars or in minutes or seconds. But no matter when an incremental tempo change happens, the musician doesn't want to have a mixture of the old tempo and the new tempo as the duration between the two beats at the time of change. But if we apply the new tempo at exactly the time it is selected which maybe is in the middle of two beats, the old (still running) beat timer would be stopped and the new timer would be started, resulting in an addition of the expired fraction of the old beat duration and the new beat duration, which would result in a beat duration unequal to both the new and the old tempo. So I think the current approach is the easier solution and requires you to not set a tempo of 1 bpm if you don't need it. But the current approach has another bug regarding that, which I wasn't able to solve yet. If you activate the timer option and set it to a few bars, and then start the metronome with 10 bpm, wait a few seconds and than switch to 120 bpm via bookmarks, the timer slider will directly move with the new tempo instead of moving to the beat duration of the old tempo until the next beat.