2010年10月9日 星期六

MIDI Format (未完成)

MIDI = <header_chunk> + <track_chunk> (+ <track_chunk> ...)

Header Chunk

header_chunk = "MThd" + <chunk_size> + <format_type> + <number_of_tracks> + <time_division>
          
             = 0x 4D 54 68 64 00 00 00 06 ff ff nn nn dd dd

"MThd" = 0x 4D 54 68 64

<chunk_size> = 0x 00 00 00 06

    length of the header chunk (always 6 bytes long--the size of the next three fields which are considered the header chunk).

<format_type> = 0x ff ff

    0 = single track file format

    1 = multiple track file format

    2 = multiple song file format

<number_of_tracks>
= 0x nn nn

    number of track chunks

<time_division> = 0x dd dd

    unit of time for delta timing. If the value is positive, then it represents the units per beat. For example, +96 would mean 96 ticks per beat. If the value is negative, delta times are in SMPTE compatible units.

          +---+-----------------------------------------+
          | 0 |         ticks per quarter-note          |
          ==============================================|
          | 1 | negative SMPTE format | ticks per frame |
          +---+-----------------------+-----------------+
          |15 |14                   8 |7              0 |


dd dd     is the number of delta-time ticks per quarter note. (More about this
later)


Track Chunks
4D 54 72 6B ss ss ss ss

"MTrk" = 0x 4D 54 72 6B

<chunk_size> = ss ss ss ss

沒有留言:

張貼留言