以每秒帧数确定 MIDI 文件的时间划分
Determining time division of a MIDI file in Frames per second
昨天我问了一个关于 的问题,但现在我遇到的问题是以每秒帧数显示的拍号。例如,我有一个带有 header 4d54 6864 0000 0006 0001 0008 0180
的 MIDI 文件,它的时间签名以每秒帧数为单位。按照上面链接的答案中的说明,我尝试分离字节以找到 SMPTE 格式和每秒帧数,但到目前为止我没有运气。如果这个 MIDI 文件确实是韵律计时(例如,每四分音符的滴答声),那么将不胜感激如何以每秒帧数解析时间码的示例。
您示例中的 0x0180
是每个四分音符的节拍数。 (未设置高位表示此格式,与 SMPTE 相反)。
要将其转化为绝对时间,您需要寻找 Set Tempo (0x51) 元事件。
那些通常(总是?)在第一个 MTrk 块中,看起来像这样:
0xff 0x51 0x03 0x11 0x22 0x33
...表示每个四分音符 0x112233
微秒的速度。
给定来自 MThd 的每四分之一音符节拍数和来自 MTrk 的每四分之一音符微秒数,您可以计算节拍的绝对时间。请注意,如果出现另一个 Set Tempo 事件,这应该会改变。
规范中关于 SMPTE 时序的说明:
If bit 15 of is a one, delta-times in a file correspond to subdivisions of a second, in
a way consistent with SMPTE and MIDI time code. Bits 14 thru 8 contain one of the four
values -24, -25, -29, or -30, corresponding to the four standard SMPTE and MIDI time code
formats (-29 corresponds to 30 drop frame), and represents the number of frames per second.
These negative numbers are stored in two's complement form. The second byte (stored
positive) is the resolution within a frame: typical values may be 4 (MIDI time code resolution),
8, 10, 80 (bit resolution), or 100. This system allows exact specification of time-code-based
tracks, but also allows millisecond-based tracks by specifying 25 frames/sec and a resolution of
40 units per frame. If the events in a file are stored with bit resolution of thirty-frame time
code, the division word would be E250 hex.
...基本上,高字节是每秒帧数,低字节是每帧滴答数。
昨天我问了一个关于 4d54 6864 0000 0006 0001 0008 0180
的 MIDI 文件,它的时间签名以每秒帧数为单位。按照上面链接的答案中的说明,我尝试分离字节以找到 SMPTE 格式和每秒帧数,但到目前为止我没有运气。如果这个 MIDI 文件确实是韵律计时(例如,每四分音符的滴答声),那么将不胜感激如何以每秒帧数解析时间码的示例。
您示例中的 0x0180
是每个四分音符的节拍数。 (未设置高位表示此格式,与 SMPTE 相反)。
要将其转化为绝对时间,您需要寻找 Set Tempo (0x51) 元事件。
那些通常(总是?)在第一个 MTrk 块中,看起来像这样:
0xff 0x51 0x03 0x11 0x22 0x33
...表示每个四分音符 0x112233
微秒的速度。
给定来自 MThd 的每四分之一音符节拍数和来自 MTrk 的每四分之一音符微秒数,您可以计算节拍的绝对时间。请注意,如果出现另一个 Set Tempo 事件,这应该会改变。
规范中关于 SMPTE 时序的说明:
If bit 15 of is a one, delta-times in a file correspond to subdivisions of a second, in a way consistent with SMPTE and MIDI time code. Bits 14 thru 8 contain one of the four values -24, -25, -29, or -30, corresponding to the four standard SMPTE and MIDI time code formats (-29 corresponds to 30 drop frame), and represents the number of frames per second. These negative numbers are stored in two's complement form. The second byte (stored positive) is the resolution within a frame: typical values may be 4 (MIDI time code resolution), 8, 10, 80 (bit resolution), or 100. This system allows exact specification of time-code-based tracks, but also allows millisecond-based tracks by specifying 25 frames/sec and a resolution of 40 units per frame. If the events in a file are stored with bit resolution of thirty-frame time code, the division word would be E250 hex.
...基本上,高字节是每秒帧数,低字节是每帧滴答数。