Accurate metronome with Python


The build-in time / timer libraries in Python fluctuate.

If you try to build a metronome at 60 BPM and imagine using the timer with a sleep time of 60 milliseconds, you will quickly find out that it will be triggered somewhere between 59.50 – 60.50 milliseconds.

Such a fluctuating metronome is not usable for a musician as a metronome.


Your code doesn’t access the hardware directly and goes through a lot of layers. Therefore, the moment of the actual trigger depends on many factors out of control.

So, is there no hope to build an accurate metronome with Python?


In my Guitar Training Remote Python project, I have solved this issue with a very simple but effective approach.

I have pre-recorded metronome clicks in various speeds, and saved them as .mp3 files within my project structure.

Whenever the user starts the metronome in a certain speed, I simply playback the corresponding .mp3 file.

Easy enough, eh?




, ,




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s