0

我正在研究一个经过训练以生成 midis 的神经网络,但是我在将 midi 文件转换为原始数据时遇到了问题。我正在使用 mido 将每个单独的音符转换为大小为 2 的数组,因此转换后的歌曲将看起来像这样:

[[40, 0.0023809520833333333],
 [47, 0],
 [47, 0.2142856875],
 [47, 0.5400941145833332],
 [40, 0.18867916666666665],
...

大多数笔记没有单独的时间。相反,它由诸如 set_tempo 或 set_signature 之类的元消息或诸如 'control_change' 之类的消息确定,如下所示:

    <meta message time_signature numerator=4 denominator=4 clocks_per_click=24 notated_32nd_notes_per_beat=8 time=0>
    <meta message set_tempo tempo=1153846 time=0.5660375  
    note_on channel=0 note=57 velocity=0 time=0  
    note_on channel=0 note=47 velocity=0 time=0  
    note_on channel=0 note=48 velocity=29 time=0  
    note_on channel=0 note=40 velocity=25 time=0  
    control_change channel=0 control=64 value=0 time=0.026442304166666666  
    control_change channel=0 control=64 value=127 time=0.19230766666666665  
    note_on channel=0 note=40 velocity=0 time=0.35817302916666666  
    note_on channel=0 note=48 velocity=0 time=0  
    note_on channel=0 note=57 velocity=25 time=0  
    note_on channel=0 note=45 velocity=20 time=0   

不幸的是,我不完全理解这些元消息如何影响单个笔记,所以我不确定如何正确地将数据转换为我的网络的简单 numpy 数组。

谁能告诉我如何使用 mido 计算单个音符的时间?或者也许有一个更好的库来完成这个特定的任务?

4

0 回答 0