Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- typedef unsigned int UINT32;
- typedef unsigned short UINT16;
- typedef unsigned char BYTE;
- typedef unsigned char UINT8;
- UINT8 *Track_ptr[MAX_TRACKS];
- int main(int argc, char *argv[])
- {
- FILE *fp;
- BYTE *buf;
- int i;
- int a;
- BYTE d,type;
- BYTE *track_p;
- UINT32 TrackTick;
- UINT32 size;
- UINT16 TrackNum; //Track 使用Track數量
- UINT16 TimeFormat;
- //開啟檔案並讀入buf
- fp = fopen("C:\\456.mid", "rb");
- fseek(fp, 0, SEEK_END);
- size = ftell(fp);
- fseek(fp, 0, SEEK_SET);
- buf = (unsigned char *)malloc(size);
- fread(buf,1 , size, fp);
- fclose(fp);
- //檢查檔頭是否為MThd
- if( buf[0] != 0x4d&buf[1] != 0x54&buf[2] != 0x68&buf[3] != 0x64)
- {
- printf("this File is not Midi\n");
- }
- //判斷format
- if( buf[9] == 0x00)
- {
- printf("File Format is 0\n");
- TrackNum=buf[11];
- printf(" TrackNumber is %d\n",buf[11]);
- }
- if( buf[9] == 0x01)
- {
- printf("File Format is 1\n");
- TrackNum=buf[11];
- printf("TrackNumber is %d\n",buf[11]);
- }
- if( buf[9] == 0x02)
- {
- printf("File Format is 2\n");
- TrackNum=buf[11];
- printf("TrackNumber is %d\n",buf[11]);
- }
- for(i=0;i<100;i++)
- {
- printf("%4d",buf[i]);
- }
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment