这就是我正在做的。我是一个反应时游戏,你必须在歌曲结束后按下按钮
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
我的问题是:我怎样才能优化它或使它更快
没关系,我知道了!。 原来我撕下的音乐密码有时间。在里面睡觉。所以,我错了。哈哈
相关问题 更多 >
编程相关推荐