mfmidi.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #define NOTEOFF 0x80
  2. #define NOTEON 0x90
  3. #define PRESSURE 0xa0
  4. #define CONTROLLER 0xb0
  5. #define PITCHBEND 0xe0
  6. #define PROGRAM 0xc0
  7. #define CHANPRESSURE 0xd0
  8. /* These are the strings used in keynote to identify Standard MIDI File */
  9. /* meta text messages. */
  10. #define METATEXT "Text Event"
  11. #define METACOPYRIGHT "Copyright Notice"
  12. #define METASEQUENCE "Sequence/Track Name"
  13. #define METAINSTRUMENT "Instrument Name"
  14. #define METALYRIC "Lyric"
  15. #define METAMARKER "Marker"
  16. #define METACUE "Cue Point"
  17. #define METAUNRECOGNIZED "Unrecognized"
  18. class Midifile_reader {
  19. public:
  20. void midifile();
  21. int Mf_nomerge; /* 1 => continue'ed system exclusives are */
  22. /* not collapsed. */
  23. long Mf_currtime; /* current time in delta-time units */
  24. int Mf_skipinit; /* 1 if initial garbage should be skipped */
  25. Midifile_reader();
  26. // call finalize() when done or you may leak memory.
  27. void finalize(); /* clean up before deletion */
  28. // Note: rather than finalize, we should have ~Midifile_reader(),
  29. // but at least VC++ complains that there is no Mf_free(), even
  30. // though Mf_free is declared as virtual and this is an abstract
  31. // class. I don't understand this, so finalize() is a workaround. -RBD
  32. protected:
  33. int midifile_error;
  34. virtual void *Mf_malloc(size_t size) = 0; /* malloc() */
  35. virtual void Mf_free(void *obj, size_t size) = 0; /* free() */
  36. /* Methods to be called while processing the MIDI file. */
  37. virtual void Mf_starttrack() = 0;
  38. virtual void Mf_endtrack() = 0;
  39. virtual int Mf_getc() = 0;
  40. virtual void Mf_chanprefix(int) = 0;
  41. virtual void Mf_portprefix(int) = 0;
  42. virtual void Mf_eot() = 0;
  43. virtual void Mf_error(char *) = 0;
  44. virtual void Mf_header(int,int,int) = 0;
  45. virtual void Mf_on(int,int,int) = 0;
  46. virtual void Mf_off(int,int,int) = 0;
  47. virtual void Mf_pressure(int,int,int) = 0;
  48. virtual void Mf_controller(int,int,int) = 0;
  49. virtual void Mf_pitchbend(int,int,int) = 0;
  50. virtual void Mf_program(int,int) = 0;
  51. virtual void Mf_chanpressure(int,int) = 0;
  52. virtual void Mf_sysex(int,unsigned char*) = 0;
  53. virtual void Mf_arbitrary(int,unsigned char*) = 0;
  54. virtual void Mf_metamisc(int,int,unsigned char*) = 0;
  55. virtual void Mf_seqnum(int) = 0;
  56. virtual void Mf_smpte(int,int,int,int,int) = 0;
  57. virtual void Mf_timesig(int,int,int,int) = 0;
  58. virtual void Mf_tempo(int) = 0;
  59. virtual void Mf_keysig(int,int) = 0;
  60. virtual void Mf_sqspecific(int,unsigned char*) = 0;
  61. virtual void Mf_text(int,int,unsigned char*) = 0;
  62. private:
  63. long Mf_toberead;
  64. long readvarinum();
  65. long read32bit();
  66. int read16bit();
  67. void msgenlarge();
  68. unsigned char *msg();
  69. int readheader();
  70. void readtrack();
  71. void sysex();
  72. void msginit();
  73. int egetc();
  74. int msgleng();
  75. int readmt(const char*,int);
  76. long to32bit(int,int,int,int);
  77. int to16bit(int,int);
  78. void mferror(char *);
  79. void mferror(const char *);
  80. void badbyte(int);
  81. void metaevent(int);
  82. void msgadd(int);
  83. void chanmessage(int,int,int);
  84. unsigned char *Msgbuff;
  85. long Msgsize;
  86. long Msgindex;
  87. };