1
0

midifile.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef NULLSOFT_IN_MIDI_MIDIFILE_H
  2. #define NULLSOFT_IN_MIDI_MIDIFILE_H
  3. #include <dsound.h>
  4. #ifndef MF_NO_DMCRAP
  5. #define MF_USE_DMCRAP
  6. #endif
  7. #ifdef MF_USE_DMCRAP
  8. #include <dmusici.h>
  9. #include <dmusicf.h>
  10. #endif
  11. typedef struct
  12. {
  13. UINT fmt,ntrax,tix;
  14. UINT channels;
  15. const char* e_type;
  16. string copyright;
  17. string * traxnames;
  18. } MIDIINFO;
  19. #define FLAG_INCOMPLETE 1
  20. typedef struct tagINSDESC
  21. {
  22. tagINSDESC * next;
  23. UINT bank_hi,bank_lo,patch,count,note_max,note_min,channels,user;
  24. BOOL drum;
  25. } INSTRUMENT_DESC;
  26. class MIDI_file
  27. {
  28. public:
  29. string path;
  30. string title;
  31. int flags;
  32. int format;
  33. int len,tix;
  34. int size;
  35. const BYTE* data;
  36. #ifdef MF_USE_DMCRAP
  37. IDirectMusicSegment *pSeg;
  38. IDirectMusicCollection *pDLS;
  39. BYTE* pDLSdata;
  40. int DLSsize;
  41. #endif
  42. MIDIINFO info;
  43. int loopstart,loopend;
  44. int loopstart_t;
  45. void * rmi_data;//extra RMI crap
  46. int rmi_size;
  47. void * bmp_data;//RMI-style bitmap data w/o BITMAPFILEHEADER
  48. int bmp_size;
  49. int kar_track;
  50. CTempoMap * tmap;
  51. CSysexMap * smap;
  52. void GetTitle(char *buf, int maxlen);
  53. inline int GetLength(void) {return len;}
  54. static MIDI_file* Create(const char* fn,const void * data, size_t size);
  55. void Free() {if (--refcount==0) delete this;}
  56. MIDI_file * AddRef() {refcount++;return this;}
  57. static int HeaderTest(const void * data,int total_size);//test first 256 bytes of file
  58. private:
  59. int refcount;
  60. MIDI_file(const char * fn);
  61. int Load(const void * data,int size);
  62. ~MIDI_file();
  63. };
  64. #define CLEAN_DM 1
  65. #define CLEAN_1TRACK 2
  66. #define CLEAN_NOSYSEX 4
  67. #define CLEAN_NOTEMPO 8
  68. #define CLEAN_DLS 16
  69. int DoCleanUp(MIDI_file*,DWORD,void** out_data,int * out_size);
  70. INSTRUMENT_DESC* GetInstruments(MIDI_file*,BOOL do_lsb);
  71. #ifdef MF_USE_DMCRAP
  72. IDirectMusicSegment * LoadSegment(MIDI_file*);
  73. void LoadDLS(MIDI_file* mf);
  74. #endif
  75. #endif