我正在用PyQt5制作一个数字钢琴软件,它的功能之一是能够自动弹奏音符。我已经在一个列表中注册了几个音符,并且正在尝试使用QSound来播放它们,但是当我这样做时,它们会同时播放。我如何才能在声音之间添加延迟?谢谢你的帮助
def playSheetMusic(self, Piano):
sheetmusic = ["A5", "G4", "C4", "C4", "C4"]
note1 = sheetmusic[0]
file1 = "pianokeys/" + note1 +".wav"
note2 = sheetmusic[1]
file2 = "pianokeys/" + note2 +".wav"
QSound.play(file1)
QSound.play(file2)
您只需使用
qWait()
函数添加延迟,如下所示:希望这有帮助:)
相关问题 更多 >
编程相关推荐