我正在使用Mido library在python中读取一个简单的MIDI文件。
我的MIDI文件如下:https://www.dropbox.com/s/t80kg9l2k525g0h/file.mid?dl=0
这只是我用基本笔记创建的一个虚拟MIDI文件。
我用Mido库打开了它,并打印了它的内容:
from mido import MidiFile
mid = MidiFile('file.mid')
for i, track in enumerate(mid.tracks):
print('Track {}: {}'.format(i, track.name))
for msg in track:
print(msg)这是我得到的:
Track 0:
<meta message track_name name='\x00' time=0>
<meta message time_signature numerator=4 denominator=4 clocks_per_click=36 notated_32nd_notes_per_beat=8 time=0>
<meta message time_signature numerator=4 denominator=4 clocks_per_click=36 notated_32nd_notes_per_beat=8 time=0>
note_on channel=0 note=60 velocity=100 time=0
note_on channel=0 note=64 velocity=100 time=0
note_off channel=0 note=60 velocity=64 time=384
note_on channel=0 note=62 velocity=100 time=0
note_on channel=0 note=67 velocity=100 time=0
note_off channel=0 note=62 velocity=64 time=384
note_off channel=0 note=64 velocity=64 time=0
note_on channel=0 note=64 velocity=100 time=0
note_off channel=0 note=67 velocity=64 time=0
note_off channel=0 note=64 velocity=64 time=384
note_on channel=0 note=67 velocity=100 time=0
note_on channel=0 note=66 velocity=100 time=384
note_off channel=0 note=67 velocity=64 time=0
note_off channel=0 note=66 velocity=64 time=384
note_on channel=0 note=67 velocity=100 time=0
note_off channel=0 note=67 velocity=64 time=384
note_on channel=0 note=69 velocity=100 time=0
note_off channel=0 note=69 velocity=64 time=384
note_on channel=0 note=71 velocity=100 time=0
note_on channel=0 note=60 velocity=100 time=384
note_off channel=0 note=71 velocity=64 time=0
note_off channel=0 note=60 velocity=64 time=384
note_on channel=0 note=62 velocity=100 time=0
note_off channel=0 note=62 velocity=64 time=384
note_on channel=0 note=64 velocity=100 time=0
note_off channel=0 note=64 velocity=64 time=375
note_on channel=0 note=67 velocity=100 time=9
note_on channel=0 note=66 velocity=100 time=384
note_off channel=0 note=67 velocity=64 time=0
note_off channel=0 note=66 velocity=64 time=384
note_on channel=0 note=67 velocity=100 time=0
note_off channel=0 note=67 velocity=64 time=384
note_on channel=0 note=69 velocity=100 time=0
note_off channel=0 note=69 velocity=64 time=384
note_on channel=0 note=71 velocity=100 time=0
note_off channel=0 note=71 velocity=64 time=384
<meta message end_of_track time=0>在做一些实验时,我有点理解了时间是以刻度表示的,相对于前一个事件(note_on - note_off)。
如何使用绝对时间参考重新排序注释(以刻度为单位)?
我希望我的笔记有一个绝对的时间表,但我不知道如何从我拥有的数据中“提取”它。
还有没有其他库已经实现了这个函数?我看到了这个库:Python-midi,但不幸的是它只适用于Python2。
发布于 2020-04-13 21:29:40
增量时间不是相对于相应的音符事件,而是相对于同一轨道中的前一个事件。
只需按顺序将所有增量时间相加。
发布于 2020-04-16 06:19:09
不幸的是,midi滴答值的绝对值还没有实现为特性...https://github.com/mido/mido/issues/185
https://stackoverflow.com/questions/61188563
复制相似问题