首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用mido库的MIDI绝对滴答值

使用mido库的MIDI绝对滴答值
EN

Stack Overflow用户
提问于 2020-04-13 21:06:53
回答 2查看 479关注 0票数 1

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

我的MIDI文件如下:https://www.dropbox.com/s/t80kg9l2k525g0h/file.mid?dl=0

这只是我用基本笔记创建的一个虚拟MIDI文件。

我用Mido库打开了它,并打印了它的内容:

代码语言:javascript
复制
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)

这是我得到的:

代码语言:javascript
复制
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。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-04-13 21:29:40

增量时间不是相对于相应的音符事件,而是相对于同一轨道中的前一个事件。

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

票数 3
EN

Stack Overflow用户

发布于 2020-04-16 06:19:09

不幸的是,midi滴答值的绝对值还没有实现为特性...https://github.com/mido/mido/issues/185

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61188563

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档