Guest User

Untitled

a guest
Dec 11th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. typedef unsigned int UINT32;
  5. typedef unsigned short UINT16;
  6. typedef unsigned char BYTE;
  7. typedef unsigned char UINT8;
  8.  
  9. UINT8 *Track_ptr[MAX_TRACKS];
  10. int main(void)
  11. {
  12. FILE *fp;
  13. BYTE *buf;
  14. int i;
  15. BYTE d,type;
  16. BYTE *track_p;
  17. UINT32 TrackTick;
  18. UINT32 size;
  19. UINT16 TrackNum; //Track 使用Track數量
  20. UINT16 TimeFormat;
  21.  
  22. //開啟檔案並讀入buf
  23. fp = fopen("C:\\bee.mid", "rb");
  24. fseek(fp, 0, SEEK_END);
  25. size = ftell(fp);
  26. fseek(fp, 0, SEEK_SET);
  27.  
  28. buf = (unsigned char *)malloc(sizeof(unsigned char));
  29.  
  30. fread(buf, 1, sizeof(unsigned char *), fp);
  31. fclose(fp);
  32. //檢查檔頭是否為MThd
  33. if( buf[0] != 0x4d&buf[1] != 0x54&buf[2] != 0x68&buf[3] != 0x64)
  34. {
  35. printf("This file is not Midi\n");
  36. }
  37. else
  38. {
  39. printf("This file is Midi\n");
  40. }
  41. free(buf);
  42. system("pause");
  43. return 0;
  44. }
Add Comment
Please, Sign In to add comment