Bonjour à tous,
Suites aux ports de TapTempo en Rust, Ada, JS, et PERL
Voilà ma version en python ;-)
#!/usr/bin/python
# -*- coding: utf-8 -*
import sys,termios,tty,datetime
def getKey():
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
try:
tty.setraw(fd)
ch = sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
return ch
print "tapTempo : press any key (q for quit)"
t=[]
while getKey()!="q":
t.append( datetime.datetime.now() )
ll=[ (j-i).microseconds for i, j in zip(t[:-1], t[1:]) ][-5:]
print "BPM:",60000000*len(ll)/sum(ll) if ll else None