Python 使用mido库的绝对MIDI刻度值

Python 使用mido库的绝对MIDI刻度值,python,midi,mido,Python,Midi,Mido,我正在使用读取python中的一个简单MIDI文件 我的MIDI文件如下所示: 这只是我用基本音符创建的一个虚拟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(m

我正在使用读取python中的一个简单MIDI文件

我的MIDI文件如下所示:

这只是我用基本音符创建的一个虚拟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>
轨道0:
通道上的注释=0注释=60速度=100时间=0
通道上的注释=0注释=64速度=100时间=0
注\u关闭通道=0注=60速度=64时间=384
通道上的注释=0注释=62速度=100时间=0
通道上的注释=0注释=67速度=100时间=0
注\u关闭通道=0注=62速度=64时间=384
注\u关闭通道=0注=64速度=64时间=0
通道上的注释=0注释=64速度=100时间=0
注\u关闭通道=0注=67速度=64时间=0
注\u关闭通道=0注=64速度=64时间=384
通道上的注释=0注释=67速度=100时间=0
通道上的注释=0注释=66速度=100时间=384
注\u关闭通道=0注=67速度=64时间=0
注\u关闭通道=0注=66速度=64时间=384
通道上的注释=0注释=67速度=100时间=0
注\u关闭通道=0注=67速度=64时间=384
通道上的注释=0注释=69速度=100时间=0
注\u关闭通道=0注=69速度=64时间=384
通道上的注释=0注释=71速度=100时间=0
通道上的注释=0注释=60速度=100时间=384
注\u关闭通道=0注=71速度=64时间=0
注\u关闭通道=0注=60速度=64时间=384
通道上的注释=0注释=62速度=100时间=0
注\u关闭通道=0注=62速度=64时间=384
通道上的注释=0注释=64速度=100时间=0
注\u关闭通道=0注=64速度=64时间=375
通道上的注释=0注释=67速度=100时间=9
通道上的注释=0注释=66速度=100时间=384
注\u关闭通道=0注=67速度=64时间=0
注\u关闭通道=0注=66速度=64时间=384
通道上的注释=0注释=67速度=100时间=0
注\u关闭通道=0注=67速度=64时间=384
通道上的注释=0注释=69速度=100时间=0
注\u关闭通道=0注=69速度=64时间=384
通道上的注释=0注释=71速度=100时间=0
注\u关闭通道=0注=71速度=64时间=384
在做一些实验时,我有点理解时间是以相对于前一个事件(note_on-note_off)的滴答数表示的

如何使用绝对时间参考(以记号为单位)重新排序笔记

我希望我的笔记有一个绝对的时间表,但我不知道如何从我的数据中“提取”出来


是否有其他库已经实现此功能?我看到了这个库:,但不幸的是它只适用于Python2

增量时间不是相对于事件的相应注释,而是相对于同一轨道中的前一事件


只需按顺序将所有增量时间相加。

增量时间不是相对于事件的相应注释,而是相对于同一曲目中的上一个事件


只需按顺序将所有增量时间相加。

不幸的是,绝对midi刻度值尚未作为功能实现。。。

不幸的是,绝对midi刻度值尚未作为功能实现。。。

我能问一下“追踪”是什么意思吗?我也在库的文档代码中读过,但我不知道它是什么represents@MattiaSurricchio在使用该库之前,您需要先阅读标准MIDI文件规范。MIDI文件包含包含事件的曲目块。事件的绝对时间是所有以前事件的增量时间之和。@Maxim您有到这些资源的有用链接吗?我尝试了几个来源,但我发现它们相当含糊不清,难以理解。我真的很感激你能帮我个忙我能问你“追踪”是什么意思吗?我也在库的文档代码中读到了它,但我不知道它是什么represents@MattiaSurricchio在使用该库之前,您需要先阅读标准MIDI文件规范。MIDI文件包含包含事件的曲目块。事件的绝对时间是所有以前事件的增量时间之和。@Maxim您有到这些资源的有用链接吗?我尝试了几个来源,但我发现它们相当含糊不清,难以理解。我真的很感激任何帮助