亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? standard midi file format.txt

?? c51經典子程序代碼全集
?? TXT
字號:
用【 小 | 中 | 大 】字體瀏覽 
其他:standard midi file format [傲氣雄鷹] [40次] 01-10-23 下午 07:36:39
standard midi file format

dustin caldwell

the standard midi file format is a very strange beast. when viewed as a
whole, it can be quite overwhelming. of course, no matter how you look at it,
describing a piece of music in enough detail to be able to reproduce it
accurately is no small task. so, while complicated, the structure of the midi
file format is fairly intuitive when understood. 
i must insert a disclaimer here that i am by no means an expert with
midi nor midi files. i recently obtained a gravis ultrasound board for my pc,
and upon hearing a few midi files (.mid) thought, "gee, i'd like to be able to
make my own .mid files." well, many aggravating hours later, i discovered that
this was no trivial task. but, i couldn't let a stupid file format stop me.
(besides, i once told my wife that computers aren't really that hard to use,
and i'd hate to be a hypocrite) so if any errors are found in this
information, please let me know and i will fix it. also, this document's scope
does not extend to every type of midi command and every possible file
configuration. it is a basic guide that should enable the reader (with a
moderate investment in time) to generate a quality midi file.

1. overview

a midi (.mid) file contains basically 2 things, header chunks and track
chunks. section 2 explains the header chunks, and section 3 explains the track
chunks. a midi file contains one header chunk describing the file format,
etc., and any number of track chunks. a track may be thought of in the same
way as a track on a multi-track tape deck. you may assign one track to each
voice, each staff, each instrument or whatever you want. 

2. header chunk

the header chunk appears at the beginning of the file, and describes the
file in three ways. the header chunk always looks like:

4d 54 68 64 00 00 00 06 ff ff nn nn dd dd

the ascii equivalent of the first 4 bytes is mthd. after mthd comes the 4-byte
size of the header. this will always be 00 00 00 06, because the actual header
information will always be 6 bytes. 

ff ff is the file format. there are 3 formats:

0 - single-track 
1 - multiple tracks, synchronous
2 - multiple tracks, asynchronous

single track is fairly self-explanatory - one track only. synchronous multiple
tracks means that the tracks will all be vertically synchronous, or in other
words, they all start at the same time, and so can represent different parts
in one song. asynchronous multiple tracks do not necessarily start at the same
time, and can be completely asynchronous. 

nn nn is the number of tracks in the midi file.

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


3. track chunks

the remainder of the file after the header chunk consists of track chunks.
each track has one header and may contain as many midi commands as you like.
the header for a track is very similar to the one for the file:

4d 54 72 6b xx xx xx xx

as with the header, the first 4 bytes has an ascii equivalent. this one is
mtrk. the 4 bytes after mtrk give the length of the track (not including the
track header) in bytes. 
following the header are midi events. these events are identical to the
actual data sent and received by midi ports on a synth with one addition. a
midi event is preceded by a delta-time. a delta time is the number of ticks
after which the midi event is to be executed. the number of ticks per quarter
note was defined previously in the file header chunk. this delta-time is a
variable-length encoded value. this format, while confusing, allows large
numbers to use as many bytes as they need, without requiring small numbers to
waste bytes by filling with zeros. the number is converted into 7-bit bytes,
and the most-significant bit of each byte is 1 except for the last byte of the
number, which has a msb of 0. this allows the number to be read one byte at a
time, and when you see a msb of 0, you know that it was the last (least
significant) byte of the number. according to the midi spec, the entire delta-
time should be at most 4 bytes long. 
following the delta-time is a midi event. each midi event (except a
running midi event) has a command byte which will always have a msb of 1 (the
value will be >= 128). a list of most of these commands is in appendix a. each
command has different parameters and lengths, but the data that follows the
command will have a msb of 0 (less than 128). the exception to this is a meta-
event, which may contain data with a msb of 1. however, meta-events require a
length parameter which alleviates confusion. 
one subtlety which can cause confusion is running mode. this is where
the actual midi command is omitted, and the last midi command issued is
assumed. this means that the midi event will consist of a delta-time and the
parameters that would go to the command if it were included. 

4. conclusion

if this explanation has only served to confuse the issue more, the
appendices contain examples which may help clarify the issue. also, 2
utilities and a graphic file should have been included with this document: 

dec.exe - this utility converts a binary file (like .mid) to a tab-delimited
text file containing the decimal equivalents of each byte.

rec.exe - this utility converts a tab-delimited text file of decimal values
into a binary file in which each byte corresponds to one of the decimal
values.

midinote.ps - this is the postscript form of a page showing note numbers with
a keyboard and with the standard grand staff.
appendix a

1. midi event commands

each command byte has 2 parts. the left nybble (4 bits) contains the actual
command, and the right nybble contains the midi channel number on which the
command will be executed. there are 16 midi channels, and 8 midi commands (the
command nybble must have a msb of 1).
in the following table, x indicates the midi channel number. note that all
data bytes will be <128 (msb set to 0).

hex binary data description
8x 1000xxxx nn vv note off (key is released)
nn=note number
vv=velocity

9x 1001xxxx nn vv note on (key is pressed)
nn=note number
vv=velocity

ax 1010xxxx nn vv key after-touch
nn=note number
vv=velocity

bx 1011xxxx cc vv control change
cc=controller number
vv=new value

cx 1100xxxx pp program (patch) change
pp=new program number

dx 1101xxxx cc channel after-touch
cc=channel number

ex 1110xxxx bb tt pitch wheel change (2000h is normal or no
change)
bb=bottom (least sig) 7 bits of value
tt=top (most sig) 7 bits of value
the following table lists meta-events which have no midi channel number. they
are of the format:

ff xx nn dd

all meta-events start with ff followed by the command (xx), the length, or
number of bytes that will contain data (nn), and the actual data (dd).

hex binary data description
00 00000000 nn ssss sets the track's sequence number.
nn=02 (length of 2-byte sequence number)
ssss=sequence number

01 00000001 nn tt .. text event- any text you want.
nn=length in bytes of text
tt=text characters

02 00000010 nn tt .. same as text event, but used for
copyright info.
nn tt=same as text event

03 00000011 nn tt .. sequence or track name
nn tt=same as text event

04 00000100 nn tt .. track instrument name
nn tt=same as text event

05 00000101 nn tt .. lyric
nn tt=same as text event

06 00000110 nn tt .. marker
nn tt=same as text event

07 00000111 nn tt .. cue point
nn tt=same as text event

2f 00101111 00 this event must come at the end of each
track

51 01010001 03 tttttt set tempo
tttttt=microseconds/quarter note

58 01011000 04 nn dd ccbb time signature
nn=numerator of time sig.
dd=denominator of time sig. 2=quarter
3=eighth, etc.
cc=number of ticks in metronome click
bb=number of 32nd notes to the quarter
note

59 01011001 02 sf mi key signature
sf=sharps/flats (-7=7 flats, 0=key of c,
7=7 sharps)
mi=major/minor (0=major, 1=minor)

7f 01111111 xx dd .. sequencer specific information
xx=number of bytes to be sent
dd=data 
the following table lists system messages which control the entire system.
these have no midi channel number. (these will generally only apply to
controlling a midi keyboard, etc.)

hex binary data description
f8 11111000 timing clock used when synchronization is
required.

fa 11111010 start current sequence

fb 11111011 continue a stopped sequence where left
off

fc 11111100 stop a sequence


the following table lists the numbers corresponding to notes for use in note 
on and note off commands.


octave|| note numbers
# ||
|| c | c# | d | d# | e | f | f# | g | g# | a | a# | b
-----------------------------------------------------------------------------
0 || 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11
1 || 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23
2 || 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35
3 || 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47
4 || 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59
5 || 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71
6 || 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83
7 || 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95
8 || 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107
9 || 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119
10 || 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 |


bibliography

"midi systems and control" francis rumsey 1990 focal press

"midi and sound book for the atari st" bernd enders and wolfgang klemme
1989 m&t publishing, inc.

midi file specs and general midi specs were also obtained by sending e-mail
to listserv@auvm.american.edu with the phrase get midispec package
in the message.


------------------------------- dec.cpp ------------------------------------

/* file dec.cpp

by dustin caldwell (dustin@gse.utah.edu)

*/


#include <dos.h>
#include <stdio.h>
#include <stdlib.h>

void helpdoc();

main()
{
file *fp;

unsigned char ch, c;

if((fp=fopen(_argv[1], "rb"))==null) /* open file to read */
{
printf("cannot open file %s\n",_argv[1]);
helpdoc();
exit(-1);
}

c=0;
ch=fgetc(fp);

while(!feof(fp)) /* loop for whole file */
{
printf("%u\t", ch); /* print every byte's decimal equiv. */
c++;
if(c>8) /* print 8 numbers to a line */
{
c=0;
printf("\n");
}

ch=fgetc(fp);
}

fclose(fp); /* close up */
}

void helpdoc() /* print help message */
{
printf("\n binary file decoder\n\n");

printf("\n syntax: dec binary_file_name\n\n");

printf("by dustin caldwell (dustin@gse.utah.edu)\n\n");
printf("this is a filter program that reads a binary file\n");
printf("and prints the decimal equivalent of each byte\n");
printf("tab-separated. this is mostly useful when piped \n");
printf("into another file to be edited manually. eg:\n\n");
printf("c:\>dec sonata3.mid > son3.txt\n\n");
printf("this will create a file called son3.txt which can\n");
printf("be edited with any ascii editor. \n\n");
printf("(rec.exe may also be useful, as it reencodes the \n");
printf("ascii text file).\n\n");
printf("have fun!!\n");
}

---------------------------- rec.cpp ----------------------------------

/* file rec.cpp
by dustin caldwell (dustin@gse.utah.edu)
*/

#include <dos.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

void helpdoc();

main()
{
file *rfp, *wfp;

unsigned char ch, c;
char s[20];

if((rfp=fopen(_argv[1], "r"))==null) /* open the read file */
{
printf("cannot open file %s \n",_argv[1]);
helpdoc();
exit(-1);
}

if((wfp=fopen(_argv[2], "wb"))==null) /* open the write file */
{
printf("cannot open file %s \n",_argv[1]);
helpdoc();
exit(-1);
}

c=0;

ch=fgetc(rfp);

while(!feof(rfp)) /* loop for whole file */
{

if(isalnum(ch)) /* only 'see' valid ascii chars */
{
c=0;
while(isdigit(ch)) /* only use decimal digits (0-9) */
{
s[c]=ch; /* build a string containing the number */
c++;
ch=fgetc(rfp);
}
s[c]=null; /* must have null terminator */

fputc(atoi(s), wfp);/* write the binary equivalent to file */

}

ch=fgetc(rfp); /* loop until next number starts */


}

fclose(rfp); /* close up */
fclose(wfp);
}


void helpdoc() /* print help message */
{
printf("\n text file encoder\n\n");

printf("\n syntax: rec text_file_name binary_file_name\n\n");

printf("by dustin caldwell (dustin@gse.utah.edu)\n\n");
printf("this is a program that reads an ascii tab-\n");
printf("delimited file and builds a binary file where\n");
printf("each byte of the binary file is one of the decimal\n");
printf("digits in the text file.\n");
printf(" eg:\n\n");
printf("c:\>rec son3.txt son3.mid\n\n");
printf("(this will create a file called son3.mid which is\n");
printf("a valid binary file)\n\n");
printf("(dec.exe may also be useful, as it decodes binary files)\n\n");
printf("have fun!!\n");
} 


哈哈!兄弟,真是感謝啊! [阿風] [4次] 01-10-23 下午 09:23:43 

能不能用單片機播放 midi? [龍嘯九天] [10次] 01-10-23 下午 09:31:07 

我不知道,這個例程是PC機上的。 [傲氣雄鷹] [3次] 01-10-23 下午 09:39:43 
 

 
點擊這里回復這篇貼子>>
_____________________________________________________________________________
Copyright?,C51BBS論壇 2000-2002 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一级片在线观看| 日韩高清不卡一区二区| 欧美一区二区三区在线观看视频| 国产精品12区| 水蜜桃久久夜色精品一区的特点| 国产精品污www在线观看| 欧美一区日韩一区| 色婷婷亚洲综合| 大白屁股一区二区视频| 蜜桃在线一区二区三区| 综合av第一页| 久久久电影一区二区三区| 欧美日韩国产精品自在自线| 成人福利电影精品一区二区在线观看| 免费在线观看视频一区| 亚洲影视资源网| 中文字幕一区二区三区蜜月| 久久久久久久免费视频了| 欧美精品日韩精品| 在线观看91精品国产入口| 成人福利视频在线| 国产91丝袜在线播放0| 精品一区二区免费| 蜜乳av一区二区三区| 亚洲国产wwwccc36天堂| 亚洲精品v日韩精品| 中文字幕中文字幕在线一区 | 久久久精品人体av艺术| 91.xcao| 欧美日韩在线播放三区| 色综合久久88色综合天天| 99久久伊人精品| 播五月开心婷婷综合| 风流少妇一区二区| 国产成人亚洲精品狼色在线 | 国产白丝网站精品污在线入口| 美女被吸乳得到大胸91| 裸体健美xxxx欧美裸体表演| 三级成人在线视频| 美国十次综合导航| 麻豆高清免费国产一区| 毛片av一区二区| 国产曰批免费观看久久久| 国产一区二区在线免费观看| 国产尤物一区二区| 国产成人精品亚洲日本在线桃色| 国产成人综合亚洲91猫咪| 成人一区在线观看| 91免费视频大全| 欧美丝袜自拍制服另类| 欧美日韩国产成人在线免费| 在线综合亚洲欧美在线视频 | 亚洲欧美色图小说| 亚洲一区二区三区爽爽爽爽爽| 亚洲一二三专区| 日本不卡免费在线视频| 国产乱码精品一区二区三区忘忧草| 国产一区二区三区久久悠悠色av | 丁香婷婷深情五月亚洲| 97精品久久久久中文字幕| 在线亚洲精品福利网址导航| 欧美日韩亚洲丝袜制服| 精品黑人一区二区三区久久| 久久久国产精华| 亚洲激情av在线| 日本欧美肥老太交大片| 国产一区二区三区在线观看免费视频 | 91免费版pro下载短视频| 欧美亚洲自拍偷拍| 精品福利一区二区三区| 国产精品高潮呻吟| 午夜伦理一区二区| 国产成人综合在线| 精品污污网站免费看| 亚洲精品在线观看视频| 亚洲男女毛片无遮挡| 视频在线在亚洲| 成人黄色在线视频| 欧美久久久影院| 国产欧美一区视频| 日韩主播视频在线| 国产成人精品免费网站| 欧美美女网站色| 国产精品视频线看| 麻豆精品一二三| 91麻豆精品在线观看| 欧美tickling网站挠脚心| 成人免费一区二区三区在线观看| 午夜电影久久久| 成人黄色国产精品网站大全在线免费观看 | 欧美日韩专区在线| 欧美激情中文字幕一区二区| 亚洲最大成人综合| 国产精品456露脸| 在线播放中文字幕一区| √…a在线天堂一区| 久久99精品久久久久久动态图 | 亚洲一区免费观看| 国内精品视频666| 欧美日韩国产一级片| 国产精品二三区| 国产精品亚洲一区二区三区妖精| 欧美无人高清视频在线观看| 国产女主播一区| 麻豆精品一区二区| 欧美狂野另类xxxxoooo| 亚洲色图另类专区| 国产成人精品影院| 欧美电影精品一区二区| 亚洲成av人影院| 91久久精品午夜一区二区| 欧美激情在线观看视频免费| 轻轻草成人在线| 5858s免费视频成人| 一区二区三区四区视频精品免费 | 国产成人8x视频一区二区| 日韩三级高清在线| 午夜精品福利一区二区蜜股av | 日韩欧美一区中文| 日韩激情av在线| 欧美色图在线观看| 一区二区三区精品| 91社区在线播放| 亚洲色图视频免费播放| 99久久精品国产毛片| 国产精品福利av| 99久久精品免费精品国产| 国产精品久久福利| 成人v精品蜜桃久久一区| 国产精品青草综合久久久久99| 国产精品一级片| 久久免费的精品国产v∧| 国产在线播精品第三| 久久日韩精品一区二区五区| 精品亚洲国产成人av制服丝袜 | 欧美军同video69gay| 午夜免费久久看| 欧美一区二区在线视频| 日韩电影在线免费看| 日韩欧美成人激情| 国内精品免费**视频| 精品国产网站在线观看| 国产综合一区二区| 欧美经典三级视频一区二区三区| 国产精品一区三区| 国产精品毛片高清在线完整版| 成人激情小说乱人伦| 亚洲人成网站在线| 欧美精品在欧美一区二区少妇| 婷婷夜色潮精品综合在线| 欧美一级淫片007| 国产精品一区二区男女羞羞无遮挡| 中文字幕精品一区二区精品绿巨人| 国产91高潮流白浆在线麻豆| 18成人在线视频| 欧美日韩精品三区| 麻豆免费精品视频| 中文字幕在线一区二区三区| 色综合网站在线| 视频一区视频二区中文字幕| www久久精品| 成年人国产精品| 亚洲成人1区2区| 久久亚洲综合色| 色又黄又爽网站www久久| 视频在线观看国产精品| 久久精品一区二区三区不卡| 91女神在线视频| 麻豆91在线看| 成人欧美一区二区三区在线播放| 欧美日韩视频不卡| 国产一区不卡在线| 亚洲另类色综合网站| 日韩一区二区三区精品视频| 国产91精品在线观看| 亚洲一区免费观看| 国产视频911| 欧美色图激情小说| 国产成人aaaa| 欧美aaa在线| ●精品国产综合乱码久久久久| 日韩一区二区在线看| 成人av免费观看| 奇米888四色在线精品| 《视频一区视频二区| 欧美电影免费观看高清完整版在线 | 26uuu成人网一区二区三区| av网站一区二区三区| 六月丁香婷婷久久| 亚洲人成影院在线观看| 精品三级av在线| 色狠狠色噜噜噜综合网| 国产综合色产在线精品| 亚洲国产精品影院| 欧美国产日韩在线观看| 91精品国产免费久久综合| 91欧美一区二区| 懂色中文一区二区在线播放| 青青草视频一区| 亚洲综合在线视频|