簡體   English   中英

使用 mido 庫的絕對 MIDI 刻度值

[英]Absolute MIDI tick value using mido library

我正在使用Mido 庫來讀取 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)的刻度表示的。

如何使用絕對時間參考(以滴答聲)重新排序筆記?

我想有一個我的筆記的絕對時間線,但我不知道如何從我擁有的數據中“提取”它。

是否還有其他庫已經實現了這個 function? 我看到了這個庫: Python-midi ,但不幸的是它僅適用於 Python 2。

增量時間與相應的音符開事件無關,而是與同一軌道中的前一個事件相關。

只需按順序將所有增量時間相加即可。

不幸的是,絕對 midi 刻度值尚未作為功能實現...... https://github.com/mido/mido/issues/185

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM