Both sides previous revisionPrevious revisionNext revision | Previous revision |
midi_file_format [2011/11/19 23:49] – [Meta-Events] javapimp | midi_file_format [2023/08/18 18:15] (current) – external edit 127.0.0.1 |
---|
The next field is a 16-bit value specifying the number of tracks in the file (''nn nn'' above). For single-track this value is 1. For multiple track files this can be up to 65535. | The next field is a 16-bit value specifying the number of tracks in the file (''nn nn'' above). For single-track this value is 1. For multiple track files this can be up to 65535. |
| |
The last field is a 16-bit value specifying the number of delta-time ticks per quarter note (''dd dd'' above) or frames per second. If the most significant bit is 0 the remaining bits specify the delta-time ticks per beat. If the most significant bit is 1 the remaining bits spacify the delta-time in frames per second. For ticks per beat, common values range from 48 to 960. | The last field is a 16-bit value specifying the number of delta-time ticks per quarter note (''dd dd'' above) or frames per second. If the most significant bit is 0 the remaining bits specify the delta-time ticks per beat. If the most significant bit is 1 the remaining bits specify the delta-time in frames per second. For ticks per beat, common values range from 48 to 960. |
| |
Frames per second is defined by breaking the remaining 15 bits into two values. The top 7 bits define a value for the number of SMPTE frames and can be 24, 25, 29 (for 29.97 fps) or 30. The remaining 8 bits define how many ticks there are per frame. | Frames per second is defined by breaking the remaining 15 bits into two values. The top 7 bits define a value for the number of SMPTE frames and can be 24, 25, 29 (for 29.97 fps) or 30. The remaining 8 bits define how many ticks there are per frame. |
| ''21'' | ''00100001'' | ''01 pp'' | Has been used, though unofficially, for a MIDI port or cable number. (deprecated) | | | ''21'' | ''00100001'' | ''01 pp'' | Has been used, though unofficially, for a MIDI port or cable number. (deprecated) | |
| ''2F'' | ''00101111'' | ''00'' | End of Track. This event must come at the end of each track. | | | ''2F'' | ''00101111'' | ''00'' | End of Track. This event must come at the end of each track. | |
| ''51'' | ''01010001'' | ''03 tttttt'' | Set tempo\\ \\ ''tttttt'' = microseconds/quarter note. (microseconds/beat)\\ \\ MICROSECONDS_PER_MINUTE = 60000000\\ \\ BPM = MICROSECONDS_PER_MINUTE / MPQN\\ MPQN = MICROSECONDS_PER_MINUTE / BPM\\ \\ TODO: How does this relate to delta-time ticks per quarter note specified in the header chunk? | | | ''51'' | ''01010001'' | ''03 tttttt'' | Set tempo\\ \\ ''tttttt'' = microseconds/quarter note. (microseconds/beat)\\ \\ MICROSECONDS_PER_MINUTE = 60000000\\ \\ BPM = MICROSECONDS_PER_MINUTE / MPQN\\ MPQN = MICROSECONDS_PER_MINUTE / BPM\\ \\ If no tempo is specified, the default is 120 beats-per-minute. (500,000 microseconds/beat)\\ \\ TODO: How does this relate to delta-time ticks per quarter note specified in the header chunk? | |
| ''54'' | ''01010100'' | ''05 hh mm ss ff sf'' | SMPTE offset. SMPTE starting point from the beginning of the track. ''hh'' = hours (0-23), ''mm'' = minutes (0-59), ''ss'' = seconds (0-59), ''ff'' = frames (0-30) and ''sf'' = sub-frames (0-99) (always 100 sub-frames per frame, no matter what sub-division is specified in the MIDI header chunk).\\ \\ The byte used to specify the hour offset also specifies the frame rate in the following format: ''0rrhhhhh'' where ''rr'' is two bits for the frame rate where 00 = 24 fps, 01 = 25 fps, 10 = 30 fps (drop frame), 11 = 30 fps and ''hhhhh'' is 5 bits for the hour (0-23). The hour byte's top bit is always 0. The frame byte's possible range depends on the encoded frame rate in the hour byte. A 25 fps frame rate means that a maximum value of 24 may be set for the frame byte. | | | ''54'' | ''01010100'' | ''05 hh mm ss ff sf'' | SMPTE offset. SMPTE starting point from the beginning of the track. ''hh'' = hours (0-23), ''mm'' = minutes (0-59), ''ss'' = seconds (0-59), ''ff'' = frames (0-30) and ''sf'' = sub-frames (0-99) (always 100 sub-frames per frame, no matter what sub-division is specified in the MIDI header chunk).\\ \\ The byte used to specify the hour offset also specifies the frame rate in the following format: ''0rrhhhhh'' where ''rr'' is two bits for the frame rate where 00 = 24 fps, 01 = 25 fps, 10 = 30 fps (drop frame), 11 = 30 fps and ''hhhhh'' is 5 bits for the hour (0-23). The hour byte's top bit is always 0. The frame byte's possible range depends on the encoded frame rate in the hour byte. A 25 fps frame rate means that a maximum value of 24 may be set for the frame byte. | |
| ''58'' | ''01011000'' | ''04 nn dd cc bb'' | Time Signature\\ \\ ''nn'' = numerator of time sig. \\ ''dd'' = denominator of time sig. 2 = quarter 3 = eighth, etc.\\ ''cc'' = number of MIDI clocks in metronome click. (MIDI clocks per beat) \\ ''bb'' = number of 32nd notes to the quarter note\\ \\ MIDI clock bytes are used to synchronize playback of multiple MIDI devices. The MIDI clock ticks 24 times per quarter note. For example, 6/8 time with a metronome click every 3 eighth notes and 24 clocks per quarter note, the ''cc'' value would be set to 36 MIDI clocks per beat. | | | ''58'' | ''01011000'' | ''04 nn dd cc bb'' | Time Signature\\ \\ ''nn'' = numerator of time sig. \\ ''dd'' = denominator of time sig. 2 = quarter 3 = eighth, etc.\\ ''cc'' = number of MIDI clocks in metronome click. (MIDI clocks per beat) \\ ''bb'' = number of 32nd notes to the quarter note\\ \\ MIDI clock bytes are used to synchronize playback of multiple MIDI devices. The MIDI clock ticks 24 times per quarter note. For example, 6/8 time with a metronome click every 3 eighth notes and 24 clocks per quarter note, the ''cc'' value would be set to 36 MIDI clocks per beat. | |