from pygame.mixer import Sound, init
from time import sleep
init()
class metronome(object):
def bpm_to_interval(self,bpm):
return 60/bpm
def start(self, bpm):
sound = Sound("sound.mp3")
while True:
sound.play()
sleep(metronome().bpm_to_interval(bpm))
def stop(self):
break # SyntaxError: 'break' outside loop
m = metronome().start(60)
sleep(5)
m.stop()