我正在玩 python mido 库,我正在尝试获取笔记数据,但我不明白。
我的代码:
# open midi file
midi = str(MidiFile('./midi/piano/WA_Mozart_Marche_Turque_Turkish_March_fingered.mid', clip=True))
# copy content of midi file to text file for easier work
midiTextFile = open("midi.txt", "w")
midiTextFile.write(midi)
输出的一些示例部分
Message('note_on', channel=0, note=80, velocity=96, time=1),
Message('note_on', channel=0, note=80, velocity=0, time=119),
Message('note_on', channel=0, note=64, velocity=96, time=1),
Message('note_on', channel=0, note=64, velocity=0, time=119),
Message('note_on', channel=0, note=76, velocity=96, time=1),
Message('note_on', channel=0, note=76, velocity=0, time=119),
MetaMessage('time_signature', numerator=1, denominator=4, clocks_per_click=24, notated_32nd_notes_per_beat=8, time=1),
Message('note_on', channel=0, note=69, velocity=96, time=0),
Message('note_on', channel=0, note=81, velocity=96, time=0),
MetaMessage('set_tempo', tempo=500000, time=479),
Message('note_on', channel=0, note=69, velocity=0, time=0),
Message('note_on', channel=0, note=81, velocity=0, time=0),
MetaMessage('key_signature', key='A', time=1),
Message('note_on', channel=0, note=69, velocity=96, time=0),
Message('note_on', channel=0, note=69, velocity=0, time=119),
Message('note_on', channel=0, note=81, velocity=96, time=1),
Message('note_on', channel=0, note=81, velocity=0, time=119),
Message('note_on', channel=0, note=71, velocity=96, time=1),
Message('note_on', channel=0, note=71, velocity=0, time=119),
Message('note_on', channel=0, note=83, velocity=96, time=1),
Message('note_on', channel=0, note=83, velocity=0, time=119),
MetaMessage('time_signature', numerator=2, denominator=4, clocks_per_click=24, notated_32nd_notes_per_beat=8, time=1),
Message('note_on', channel=0, note=73, velocity=96, time=0),
Message('note_on', channel=0, note=73, velocity=0, time=119),
Message('note_on', channel=0, note=85, velocity=96, time=1),
Message('note_on', channel=0, note=85, velocity=0, time=119),
Message('note_on', channel=0, note=69, velocity=96, time=241),
Message('note_on', channel=0, note=69, velocity=0, time=119),
Message('note_on', channel=0, note=81, velocity=96, time=1),
Message('note_on', channel=0, note=81, velocity=0, time=119),
Message('note_on', channel=0, note=71, velocity=96, time=1),
现在我不确定几件事。这部分意味着音符 64 开始于 1 毫秒并结束于 119 毫秒?如果是的话,有没有比这更好的方法来开始和结束笔记?
Message('note_on', channel=0, note=64, velocity=96, time=1),
Message('note_on', channel=0, note=64, velocity=0, time=119),
我不明白的另一件事是midi编辑器中的歌曲有3分钟,而在这个midi文本文件中没有时间值更大time=500
谢谢你的帮助。