本文整理汇总了Python中track.Track.addNote方法的典型用法代码示例。如果您正苦于以下问题:Python Track.addNote方法的具体用法?Python Track.addNote怎么用?Python Track.addNote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类track.Track
的用法示例。
在下文中一共展示了Track.addNote方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from track import Track [as 别名]
# 或者: from track.Track import addNote [as 别名]
progression = composer.chordGen()
#print("progression:")
#for chord in progression:
# print(str(chord))
# render a melody
melody = composer.createMelody(progression)
# store music in a Song
song = Song()
chordTrack = Track(75)
pos = 0
for chord in progression:
for note in chord.notes:
chordTrack.addNote(pos, note)
pos += 4
chordTrack.setVelocity(0x50)
song.addTrack(chordTrack)
melodyTrack = Track(57)
for pos, note in melody.items():
melodyTrack.addNote(pos, note)
melodyTrack.setVelocity(0x70)
song.addTrack(melodyTrack)
# write the song to midi
out_file = 'out.mid'
song.writeToMidi(out_file)