我试图在同一时间打松1和song2(注释掉的),但我不知道怎么说使用myro或广州市运生或不管它是什么做的。 有人使用线程的建议,但我不知道该怎么做决定,因为我只是一个很婴儿初学编程的。 会有人请帮助我这个东西出来和/或详细解释如何做到这一点? 这是我到目前为止有:
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()