[英]How to make MIDI file from notes with Flute instrument in Python (music21 library)
[英]How do I createa midi file with mutiple tracks of different instrument? with python and music21
所以我有下面的代码
m3 = stream.Measure()
m4 = stream.Measure()
m5 = stream.Measure()
m3.append(instrument.Guitar())
m4.append(instrument.Tuba())
m5.append(instrument.Harp())
#----adding notes to track------#
newNote = note.Note('F')
newNote.duration.type = 'quarter'
m3.append(newNote)
newNote = note.Note('A')
newNote.duration.type = 'eighth'
m4.append(newNote)
newNote = note.Note('G')
newNote.duration.type = 'quarter'
m5.append(newNote)
#-----adding tracks to song------------#
song = stream.Score()
song.insert(0,m3)
song.insert(0,m4)
song.insert(0,m5)
song.write('midi', 'blah.mid')
我想创建一首包含 3 条不同轨道且每条都演奏不同乐器的歌曲。 上面的代码类型将所有内容组合成 1 个音轨并覆盖前 2 个乐器。 有没有办法我可以做到这一点?
好的,我想通了。 我需要将 m3 = stream.Measure() 更改为 m3 = stream.Part() 和 m3.append(instrument.Guitar()) 到 m3.insert(instrument.Guitar())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.