开发者

Midi timestamp in seconds

开发者 https://www.devze.com 2023-03-28 16:43 出处:网络
What is the formula for timestamp in second? The tick is actually a timestamp From Midi DumpSequence: tick 0: Set Tempo: 88.0 bpm

What is the formula for timestamp in second? The tick is actually a timestamp

From Midi DumpSequence:

tick 0: Set Tempo: 88.0 bpm
tick 0: Time Signature: 4/4,

MIDI clocks per metronome tick: 24,
1/32 per 24 MIDI clocks: 8

tick 0: Sequence/Track Name:         
tick 0: Sysex message: F0 7E 7F 09 01 F7
tick 480: Sysex message: F0 43 10 4C 00 00 7E 00 F7
tick 600: Sysex message: F0 43 10 4C 02 01 40 03 00 F7
tick 602: Sysex message: F0 43 10 4C 02 01 5A 01 F7
tick 604: ch01
tick 606: ch01
tick 608: ch01
tick 613: ch01
tick 615: ch01
tick 617: ch01
tick 619: ch01
tick 621: ch01
tick 623: ch01
tick 625: ch02
tick 627: ch02
tick 629: ch02
tick 634: ch02
tick 636: ch02
tick 638: ch02
tick 640: ch02
tick 642: ch02
tick 644: ch02
tick 1920: Time Signature: 4/4, MIDI clocks per metronome tick: 24, 1/32 per 24开发者_运维技巧 MIDI clocks: 8
tick 1920: ch01+B2
tick 2784: ch01-B2
tick 2880: ch01+G2
tick 3744: ch01-G2
tick 3840: ch01+A2
tick 4704: ch01-A2
tick 4800: ch01+D2


To calculate metric time of a MIDI event you need to know two values:

  • number of ticks per qurter note (beat)
  • microseconds per beat

The first value is contained in the time division parameter of the header chunk (MThd) of a MIDI file. Your dump doesn't contain this information.

The second value can be retrieved from a Set Tempo event. Your dump starts with this event, but I should to notice that tempo is presented in a MIDI file as microseconds per beat rather than beats per minute (BPM). In some cases BPM can be inaccurate since it is calculated as 60,000,000 / microseconds_per_beat.

Using these two values we can calculate duration of one tick:

tick_duration = microseconds_per_beat / ticks_per_beat

or if you have tempo as BPM

tick_duration = 60,000,000 / (beats_per_minute * ticks_per_beat)

Thus, for any arbitrary timestamp its metric representation can be calculated by the formula:

microseconds = ticks * tick_duration


There are 88 beats per minute, and 24 MIDI clock ticks per beat.

That's 88 * 24 / 60 = 35.2 MIDI clocks per second.

So the timestamp in seconds is just the MIDI clock ticks divided by 35.2.


I found this is the correct formula. The other post showing the wrong method.

BPM x PPQ = # (ticks/min)
(ticks/min) * 1/60000 = # ticks/millisecond

timestamp / 0.704 = # ms

From source: http://harmoniccycle.com/harmonicweb/music-25-MIDI-BPM-PPQ.htm

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号