简体   繁体   中英

Midi note length in midi file

Having a misunderstanding about note lengths in MIDI. I made a simple 2 whole note midi file in Ableton Live (whole file is 1 measure), then exported it and analyzed it with a python script ( mididump.py ).

midi.Pattern(format=0, resolution=96, tracks=\
[midi.Track(\
[midi.TrackNameEvent(tick=0, text='examplemidi\x00', data=[101, 120, 97, 109, 112, 108, 101, 109, 105, 100, 105, 0]),
midi.TimeSignatureEvent(tick=0, data=[4, 2, 36, 8]),
midi.TimeSignatureEvent(tick=0, data=[4, 2, 36, 8]),
midi.NoteOnEvent(tick=0, channel=0, data=[65, 127]),
midi.NoteOnEvent(tick=192, channel=0, data=[60, 100]),
midi.NoteOffEvent(tick=0, channel=0, data=[65, 64]),
midi.NoteOffEvent(tick=192, channel=0, data=[60, 64]),
midi.EndOfTrackEvent(tick=0, data=[])])])

The data parameter is [pitch,volume] for this analyzer. Those are confirmed correct. The part i dont understand is "tick". It looks like if the midi file is length 284, that the "Note On"s would make sense. Seeing as how the pitch=60 note starts half way thorugh. But the "Note Off"s are on the same "tick" as their "Note On"s, and also the End of track event is on tick 0. Im thinking I have a fundamental misunderstanding of how midi timing works, but i cant see how information regarding timing could be deduced from this data. Halp. Heres the midi in Hex for those that are interested:

4d54 6864 0000 0006 0000 0001 0060 4d54
726b 0000 0039 00ff 0301 0000 ff58 0404
0224 0800 ff58 0404 0224 0800 9040 6460
903c 6400 8040 4060 803c 4000 9040 6460
8040 4000 9043 6460 8043 4000 ff2f 00

Please and Thank You, Mingman

As @CL noted, MIDI ticks are relative to the previous event. There's a great StackOverflow answer that explains tick/absolute time conversion in a bit more depth .

If multiple events occur at the same time, then every event beyond the first one will have a tick value of 0. The first event will presumably have a value greater than 0, unless it occurs at the beginning of the arrangement.

MIDI文件使用增量时间,即,刻度值相对于轨道中的前一事件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM