我正在尝试同时播放歌曲 1 和歌曲 2(被注释掉的歌曲),但我不知道如何使用 myro 或 winsound 或其他任何方式来做到这一点。有人建议使用线程,但我也不知道该怎么做,因为我只是一个非常初级的程序员。有人可以帮我解决这个问题和/或详细解释如何做到这一点吗?这是我到目前为止所拥有的:
import winsound
from myro import *
def main():
HftM1 = makeSong("Db4 3/8; C4 3/8; Bb3 1/4; Bb3 3/8; Ab3 3/8; Gb3 3/8; Ab3 1/16; C4 3/8; Bb3 3/8; Ab3 1/8; Eb3 1/16; F3 1/16; Ab3 3/8; G3 3/8; F3 3/8; C4 1/16; Db4 3/8; C4 3/8; Bb3 1/8; F3 1/16; Gb3 1/16; Bb3 3/8; Ab3 3/8; Gb3 3/8; C4 3/8; Bb3 3/8; Ab3 1/8; Eb3 1/16; F3 1/16; Ab3 3/8; G3 3/8; F3 3/8")
saveSong(HftM1, "HymnfortheMissing1.txt", append=1)
HftM2 = makeSong("Bb2 1/8; F3 1/8; Bb3 1/4; Bb2 1/8; F3 3/8; Gb2 1/8; Db3 1/8; Gb3 1/4; Gb2 1/8; Db3 3/8; Ab2 1/8; Eb3 1/8; Ab3 1/4; Ab2 1/8; Eb3 3/8; F2 1/8; C3 1/8; F3 1/4; F2 1/8; C3 3/8; Bb2 1/8; F3 1/8; Bb3 1/4; Bb2 1/8; F3 3/8; Gb2 1/8; Db3 1/8; Gb3 1/4; Gb2 1/8; Db3 3/8; Ab2 1/8; Eb3 1/8; Ab3 1/4; Ab2 1/8; Eb3 3/8; F2 1/8; C3 1/8; F3 1/4; F2 1/8; C3 3/8")
saveSong(HftM2, "HymnfortheMissing2.txt", append=1)
song1 = readSong("HymnfortheMissing1.txt")
#song2 = readSong("HymnfortheMissing2.txt") #This part of the song is supposed to be played at the same time as the first part, but I don't know how to do that so...
play = []
for n in range(len(song1)):
play = song1[n]
note = play[0]
duration = play[1]
winsound.Beep(int(note), int(duration*2000))
main()