00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef XMIDIFILE_H_INCLUDED
00020 #define XMIDIFILE_H_INCLUDED
00021
00022 class IDataSource;
00023 class OIDataSource;
00024 struct XMidiEvent;
00025 class XMidiEventList;
00026
00027
00028 #define XMIDIFILE_CONVERT_NOCONVERSION 0
00029 #define XMIDIFILE_CONVERT_MT32_TO_GM 1
00030 #define XMIDIFILE_CONVERT_MT32_TO_GS 2
00031 #define XMIDIFILE_CONVERT_MT32_TO_GS127 3
00032 #define XMIDIFILE_CONVERT_GM_TO_MT32 4
00033
00034 #define XMIDIFILE_CONVERT_GS127_TO_GS 5
00035 #define XMIDIFILE_HINT_U7VOICE_MT_FILE 6
00036 #define XMIDIFILE_HINT_XMIDI_MT_FILE 7
00037 #define XMIDIFILE_HINT_SYX_FILE 8
00038 #define XMIDIFILE_HINT_SYSEX_IN_MID 9
00039
00040 class XMidiFile
00041 {
00042 protected:
00043 uint16 num_tracks;
00044
00045 private:
00046 XMidiEventList **events;
00047
00048 XMidiEvent *list;
00049 XMidiEvent *branches;
00050 XMidiEvent *current;
00051 XMidiEvent *notes_on;
00052
00053 const static char mt32asgm[128];
00054 const static char mt32asgs[256];
00055 const static char gmasmt32[128];
00056 bool bank127[16];
00057 int convert_type;
00058
00059 bool do_reverb;
00060 bool do_chorus;
00061 int chorus_value;
00062 int reverb_value;
00063
00064
00065
00066
00067 public:
00068 XMidiFile(IDataSource *source, int pconvert);
00069 ~XMidiFile();
00070
00071 int number_of_tracks() { return num_tracks; }
00072
00073
00074 XMidiEventList *GetEventList (uint32 track);
00075
00076
00077
00078
00079 private:
00080 XMidiFile();
00081
00082 struct first_state {
00083 XMidiEvent *patch[16];
00084 XMidiEvent *bank[16];
00085 XMidiEvent *pan[16];
00086 XMidiEvent *vol[16];
00087 };
00088
00089
00090 void CreateNewEvent (int time);
00091
00092
00093 int GetVLQ (IDataSource *source, uint32 &quant);
00094 int GetVLQ2 (IDataSource *source, uint32 &quant);
00095
00096 void AdjustTimings(uint32 ppqn);
00097 void ApplyFirstState(first_state &fs, int chan_mask);
00098
00099 int ConvertNote (const int time, const unsigned char status, IDataSource *source, const int size);
00100 int ConvertEvent (const int time, const unsigned char status, IDataSource *source, const int size, first_state& fs);
00101 int ConvertSystemMessage (const int time, const unsigned char status, IDataSource *source);
00102 int CreateMT32SystemMessage(const int time, uint32 address_base, uint16 address_offset, uint32 len, const void *data = 0, IDataSource *source=0);
00103
00104 int ConvertFiletoList (IDataSource *source, const bool is_xmi, first_state& fs);
00105
00106 int ExtractTracksFromXmi (IDataSource *source);
00107 int ExtractTracksFromMid (IDataSource *source, const uint32 ppqn, const int num_tracks, const bool type1);
00108
00109 int ExtractTracks (IDataSource *source);
00110
00111 int ExtractTracksFromU7V (IDataSource *source);
00112 int ExtractTracksFromXMIDIMT (IDataSource *source);
00113 void InsertDisplayEvents();
00114 };
00115
00116 #endif //XMIDIFILE_H_INCLUDED