0
ここに私がやっていることがあります。私はあなたが曲が終了した後にボタンを押す必要がある反応時間のゲームです。関数を終了するには?
def play(melody, tempo, pause, pace=0.800):
start = time.time()
for i in range(0, len(melody)): # Play song
noteDuration = pace/tempo[i]
buzz(melody[i], noteDuration) # Change the frequency along the song
note
pauseBetweenNotes = noteDuration * pause
time.sleep(pauseBetweenNotes)
if time.time() >= start + rng:
print("Click!!!")
return
だから私の問題は、私は時間が到達していたときに、曲を停止するために使用し、この部分は、それがとても遅いの機能を終了しますということです。
if time.time() >= start + rng:
print("Click!!!")
return
私の質問です:私はそれを最適化するにはどうすればよいです万一それを速くするか?