mid1.htm ( File view )

  • By 2010-07-31
  • View(s):8
  • Download(s):0
  • Point(s): 1

<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>standard midi file formatdustin caldwellthe standard midi file format is a very 
strange beast</title>
<meta name="generator" content="microsoft frontpage 3.0">

<body background="../jpg/di1.JPG">

<p align="center"><font size="6" color="#0000ff">standard midi file format</font></p>
<div align="center"><center>

<table border="0" width="88%">
    <td width="100%">dustin caldwell<br>
    the standard midi file format is a very strange beast. when viewed as a<br>
    whole, it can be quite overwhelming. of course, no matter how you look at it,<br>
    describing a piece of music in enough detail to be able to reproduce it<br>
    accurately is no small task. so, while complicated, the structure of the midi<br>
    file format is fairly intuitive when understood. <br>
    i must insert a disclaimer here that i am by no means an expert with<br>
    midi nor midi files. i recently obtained a gravis ultrasound board for my pc,<br>
    and upon hearing a few midi files (.mid) thought, &quot;gee, i'd like to be able to<br>
    make my own .mid files.&quot; well, many aggravating hours later, i discovered that<br>
    this was no trivial task. but, i couldn't let a stupid file format stop me.<br>
    (besides, i once told my wife that computers aren't really that hard to use,<br>
    and i'd hate to be a hypocrite) so if any errors are found in this<br>
    information, please let me know and i will fix it. also, this document's scope<br>
    does not extend to every type of midi command and every possible file<br>
    configuration. it is a basic guide that should enable the reader (with a<br>
    moderate investment in time) to generate a quality midi file.<br>
    1. overview<br>
    a midi (.mid) file contains basically 2 things, header chunks and track<br>
    chunks. section 2 explains the header chunks, and section 3 explains the track<br>
    chunks. a midi file contains one header chunk describing the file format,<br>
    etc., and any number of track chunks. a track may be thought of in the same<br>
    way as a track on a multi-track tape deck. you may assign one track to each<br>
    voice, each staff, each instrument or whatever you want. <br>
    2. header chunk<br>
    the header chunk appears at the beginning of the file, and describes the<br>
    file in three ways. the header chunk always looks like:<br>
    4d 54 68 64 00 00 00 06 ff ff nn nn dd dd<br>
    the ascii equivalent of the first 4 bytes is mthd. after mthd comes the 4-byte<br>
    size of the header. this will always be 00 00 00 06, because the actual header<br>
    information will always be 6 bytes. <br>
    ff ff is the file format. there are 3 formats:<br>
    0 - single-track <br>
    1 - multiple tracks, synchronous<br>
    2 - multiple tracks, asynchronous<br>
    single track is fairly self-explanatory - one track only. synchronous multiple<br>
    tracks means that the tracks will all be vertically synchronous, or in other<br>
    words, they all start at the same time, and so can represent different parts<br>
    in one song. asynchronous multiple tracks do not necessarily start at the same<br>
    time, and can be completely asynchronous. <br>
    nn nn is the number of tracks in the midi file.<br>
    dd dd is the number of delta-time ticks per quarter note. (more about this<br>
    3. track chunks<br>
    the remainder of the file after the header chunk consists of track chunks.<br>
    each track has one header and may contain as many midi commands as you like.<br>
    the header for a track is very similar to the one for the file:<br>
    4d 54 72 6b xx xx xx xx<br>
    as with the header, the first 4 bytes has an ascii equivalent. this one is<br>
    mtrk. the 4 bytes after mtrk give the length of the track (not including the<br>
    track header) in bytes. <br>
    following the header are midi events. these events are identical to the<br>
    actual data sent and received by midi ports on a synth with one addition. a<br>
    midi event is preceded by a delta-time. a delta time is the number of ticks<br>
    after which the midi event is to be executed. the number of ticks per quarter<br>
    note was defined previously in the file header chunk. this delta-time is a<br>
    variable-length encoded value. this format, while confusing, allows large<br>
    numbers to use as many bytes as they need, without requiring small numbers to<br>
    waste bytes by filling with zeros. the number is converted into 7-bit bytes,<br>
    and the most-significant bit of each byte is 1 except for the last byte of the<br>
    number, which has a msb of 0. this allows the number to be read one byte at a<br>
    time, and when you see a msb of 0, you know that it was the last (least<br>
    significant) byte of the number. according to the midi spec, the entire delta-<br>
    time should be at most 4 bytes long. <br>
    following the delta-time is a midi event. each midi event (except a<br>
    running midi event) has a command byte which will always have a msb of 1 (the<br>
    value will be &gt;= 128). a list of most of these commands is in appendix a. each<br>
    command has different parameters and lengths, but the data that follows the<br>
    command will have a msb of 0 (less than 128). the exception to this is a meta-<br>
    event, which may contain data with a msb of 1. however, meta-events require a<br>
    length parameter which alleviates confusion. <br>
    one subtlety which can cause confusion is running mode. this is where<br>
    the actual midi command is omitted, and the last midi command issued is<br>
    assumed. this means that the midi event will consist of a delta-time and the<br>
    parameters that would go to the command if it were included. <br>
    4. conclusion<br>
    if this explanation has only served to confuse the issue more, the<br>
    appendices contain examples which may help clarify the issue. also, 2<br>
    utilities and a graphic file should have been included with this document: <br>
    dec.exe - this utility converts a binary file (like .mid) to a tab-delimited<br>
    text file containing the decimal equivalents of each byte.<br>
    rec.exe - this utility converts a tab-delimited text file of decimal values<br>
    into a binary file in which each byte corresponds to one of the decimal<br>
    midinote.ps - this is the postscript form of a page showing note numbers with<br>
    a keyboard and with the standard grand staff.<br>
    &#12; appendix a<br>
    1. midi event commands<br>
    each command byte has 2 parts. the left nybble (4 bits) contains the actual<br>
    command, and the right nybble contains the midi channel number on which the<br>
    command will be executed. there are 16 midi channels, and 8 midi commands (the<br>
    command nybble must have a msb of 1).<br>
    in the following table, x indicates the midi channel number. note that all<br>
    data bytes will be &lt;128 (msb set to 0).<br>
    hex binary data description<br>
    8x 1000xxxx nn vv note off (key is released)<br>
    nn=note number<br>
    9x 1001xxxx nn vv note on (key is pressed)<br>
    nn=note number<br>
    ax 1010xxxx nn vv key after-touch<br>
    nn=note number<br>
    bx 1011xxxx cc vv control change<br>
    cc=controller number<br>
    vv=new value<br>
    cx 1100xxxx pp program (patch) change<br>
    pp=new program number<br>
    dx 1101xxxx cc channel after-touch<br>
    cc=channel number<br>
    ex 1110xxxx bb tt pitch wheel change (2000h is normal or no<br>
    bb=bottom (least sig) 7 bits of value<br>
    tt=top (most sig) 7 bits of value<br>
    &#12;the following table lists meta-events which have no midi channel number. they<br>
    are of the format:<br>
    ff xx nn dd<br>
    all meta-events start with ff followed by the command (xx), the length, or<br>
    number of bytes that will contain data (nn), and the actual data (dd).<br>
    hex binary data description<br>
    00 00000000 nn ssss sets the track's sequence number.<br>
    nn=02 (length of 2-byte sequence number)<br>
    ssss=sequence number<br>
    01 00000001 nn tt .. text event- any text you want.<br>
    nn=length in bytes of text<br>
    tt=text characters<br>
    02 00000010 nn tt .. same as text event, but used for<br>
    copyright info.<br>
    nn tt=same as text event<br>
    03 00000011 nn tt .. sequence or track name<br>
    nn tt=same as text event<br>
    04 00000100 nn tt .. track instrument name<br>
    nn tt=same as text event<br>
    05 00000101 nn tt .. lyric<br>
    nn tt=same as text event<br>
    06 00000110 nn tt .. marker<br>
    nn tt=same as text event<br>
    07 00000111 nn tt .. cue point<br>
    nn tt=same as text event<br>
    2f 00101111 00 this event must come at the end of each<br>
    51 01010001 03 tttttt set tempo<br>
    tttttt=microseconds/quarter note<br>
    58 01011000 04 nn dd ccbb time signature<br>
    nn=numerator of time sig.<br>
    dd=denominator of time sig. 2=quarter<br>
    3=eighth, etc.<br>
    cc=number of ticks in metronome click<br>
    bb=number of 32nd notes to the quarter<br>
    59 01011001 02 sf mi key signature<br>
    sf=sharps/flats (-7=7 flats, 0=key of c,<br>
    7=7 sharps)<br>
    mi=major/minor (0=major, 1=minor)<br>
    7f 01111111 xx dd .. sequencer specific information<br>
    xx=number of bytes to be sent<br>
    the f
(Not finished, please download and read the complete file)
Expand> <Close

Want complete source code? Download it here

Point(s): 1

0 lines left, continue to read

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
index.htm66.63 kB24-03-99|22:05
binary0.00 B27-01-04|20:12
arc.htm4.53 kB18-03-99|04:12
ARJ.htm8.27 kB18-03-99|04:12
cab.zip43.49 kB11-12-98|03:08
lzh.htm2.08 kB18-03-99|04:12
tar.htm12.38 kB18-03-99|04:12
comm0.00 B27-01-04|20:12
clarion.zip32.79 kB11-12-98|03:09
dbase.htm5.56 kB18-03-99|04:12
dbf.htm2.99 kB18-03-99|04:12
ntx.htm11.44 kB18-03-99|04:12
paradox.rtf61.50 kB29-01-99|17:09
wks.zip22.04 kB11-12-98|03:09
xls.txt44.32 kB29-01-99|17:30
data0.00 B27-01-04|20:12
ai30.pdf260.00 kB29-03-98|22:54
bmp.htm46.13 kB18-03-99|04:12
Bmp.html37.97 kB18-03-99|04:12
BW.htm2.71 kB18-03-99|04:12
col.htm2.02 kB18-03-99|04:12
draft-bo.rtf240.19 kB14-03-99|00:24
dwg_ff.htm11.31 kB18-03-99|04:12
dxf.htm86.74 kB18-03-99|04:12
dxf12.htm140.73 kB18-03-99|04:12
dxf13.zip143.43 kB11-12-98|02:44
dxf14htm.zip160.37 kB11-12-98|02:48
DXF_R14.HLP201.27 kB24-06-98|19:27
emf.hlp73.22 kB17-10-95|23:53
gif87.htm29.98 kB18-03-99|04:12
Gif89a.doc83.47 kB29-10-90|08:27
grap.htm14.76 kB18-03-99|04:12
Ico.zip114.21 kB27-01-99|19:13
jpg.pdf93.35 kB29-03-98|22:59
jpg.rtf15.97 kB23-01-99|01:36
lzw.htm6.44 kB18-03-99|04:12
lzwexp.htm17.13 kB18-03-99|04:12
PCD.htm5.46 kB18-03-99|04:12
pcx.htm26.13 kB18-03-99|04:12
pic.htm4.49 kB18-03-99|04:12
PSD.pdf368.64 kB18-04-97|19:01
ps_plug.pdf377.16 kB29-03-98|22:59
rle.pdf31.59 kB29-03-98|23:06
tga.htm45.46 kB18-03-99|04:12
tga2.zip54.38 kB10-12-98|19:48
tif.pdf365.72 kB29-03-98|23:07
YUV.htm3.96 kB18-03-99|04:12
graphics0.00 B27-01-04|20:12
agentref.zip11.06 kB11-12-98|03:18
bbs.htm12.85 kB18-03-99|04:12
bluewave.htm43.85 kB18-03-99|04:12
idx.htm3.68 kB18-03-99|04:12
url.htm1.61 kB18-03-99|04:12
uuencode.htm11.10 kB18-03-99|04:12
Vrml.rtf70.88 kB28-01-99|14:10
VRML2.hlp181.23 kB21-02-98|20:57
internet0.00 B27-01-04|20:12
jpg0.00 B27-01-04|20:12
escode.rtf49.26 kB08-02-99|21:53
Intel.rtf130.99 kB08-02-99|21:50
joystick.rtf14.53 kB08-02-99|21:57
keyboard.rtf14.81 kB08-02-99|21:59
mouse.rtf15.75 kB08-02-99|22:00
pcl5.zip92.62 kB13-12-98|04:33
speaker.rtf16.96 kB08-02-99|22:04
VGA.htm29.31 kB18-03-99|04:12
other0.00 B27-01-04|20:12
cd.htm26.36 kB18-03-99|04:12
cda.htm2.98 kB18-03-99|04:12
mid1.htm16.87 kB18-03-99|04:12
midi2.htm12.08 kB18-03-99|04:12
midi3.htm10.51 kB18-03-99|04:12
MIND1-2.htm7.09 kB18-03-99|04:12
MPEG.zip573.61 kB11-12-98|04:02
mpeg1.zip65.24 kB11-12-98|03:45
Wav.rtf30.08 kB25-01-99|00:30
wave.htm104.17 kB18-03-99|04:12
sound0.00 B27-01-04|20:12
adobe_EPSF1_2.pdf12.64 kB29-03-98|22:51
adobe_EPSF2_0.pdf42.59 kB29-03-98|22:51
adobe_EPSF3_0.pdf127.45 kB29-03-98|22:54
afont.htm9.14 kB18-03-99|04:12
font.htm17.99 kB18-03-99|04:12
rtf.rtf158.74 kB25-01-99|01:41
rtf.zip147.10 kB11-12-98|03:32
word60.rtf463.82 kB25-01-99|03:24
word8.htm532.04 kB18-03-99|04:12
Wordpf.htm3.29 kB18-03-99|04:12
wordst.htm51.88 kB18-03-99|04:12
wri.htm21.84 kB18-03-99|04:12
text0.00 B27-01-04|20:13
ani.htm3.05 kB18-03-99|04:12
Bmp.html33.82 kB18-03-99|04:12
cab.zip43.49 kB11-12-98|03:08
cal.htm5.64 kB18-03-99|04:12
clp.htm2.33 kB18-03-99|04:12
crd.htm4.59 kB18-03-99|04:12
find.htm4.38 kB18-03-99|04:12
grp.htm8.54 kB18-03-99|04:12
Hlp.htm57.27 kB18-03-99|04:12
Hpj.doc71.12 kB14-01-93|06:22
Ico.zip114.21 kB27-01-99|19:13
icons.htm28.52 kB18-03-99|04:12
inf.htm2.74 kB18-03-99|04:12
Lnk.htm5.24 kB18-03-99|04:12
LONG.htm3.15 kB18-03-99|04:12
reg.htm11.13 kB18-03-99|04:12
res32.htm16.18 kB18-03-99|04:12
rle.pdf31.59 kB29-03-98|23:06
rtfwr.htm8.10 kB18-03-99|04:12
scr.htm1.69 kB18-03-99|04:12
ttfspec1.zip752.40 kB28-01-99|12:00
ttfspec2.zip501.01 kB27-01-99|20:51
Wav.rtf30.08 kB25-01-99|00:30
wave.htm101.51 kB18-03-99|04:12
wavec.htm205.63 kB18-03-99|04:12
WinReg.htm22.02 kB18-03-99|04:12
wmf.htm11.82 kB18-03-99|04:12
wri.htm21.84 kB18-03-99|04:12
windows0.00 B27-01-04|20:13
FORMAT0.00 B27-01-04|20:12
文件格式大全0.00 B27-01-04|20:12

mid1.htm (4.88 MB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point


Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com


CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D