Tap tempo app created in Godot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

26 lines
587 B

extends Control
var times = []
var i = 0
var bpm: float
onready var BPMNumber = $"BPMNumber"
func count():
times.append(OS.get_ticks_usec())
var avgDelta
#RESET STUFF THAT DIDN'T WORK
#var delta
#if (avgDelta && delta>(avgDelta*2)):
# i=0
# times.clear()
# bpm=0
#print(str(delta) + " " + str(avgDelta))
if (i>3):
avgDelta = ((times[i]-times[i-1]) + (times[i-1]-times[i-2]) + (times[i-2]-times[i-3]) + (times[i-3]-times[i-4]))/4
bpm = 60000000 / avgDelta
BPMNumber.text = str(bpm) + "BPM"
# delta = (times[i]-times[i-1])
i += 1
func _on_Tap_button_down():
count()