XMidiFile.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2003  The Pentagram Team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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 // Conversion types for Midi files
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         // Midi Volume Curve Modification
00065         //static GammaTable<unsigned char>      VolumeCurve;
00066 
00067 public:
00068         XMidiFile(IDataSource *source, int pconvert);
00069         ~XMidiFile();
00070 
00071         int number_of_tracks() { return num_tracks; }
00072 
00073         // External Event list functions
00074         XMidiEventList *GetEventList (uint32 track);
00075 
00076         // Not yet implimented
00077         // int apply_patch (int track, DataSource *source);
00078 
00079 private:
00080         XMidiFile(); // No default constructor
00081     
00082     struct first_state {                        // Status,      Data[0]
00083                 XMidiEvent              *patch[16];     // 0xC
00084                 XMidiEvent              *bank[16];      // 0xB,         0
00085                 XMidiEvent              *pan[16];       // 0xB,         7
00086                 XMidiEvent              *vol[16];       // 0xB,         10
00087         };
00088 
00089         // List manipulation
00090         void CreateNewEvent (int time);
00091 
00092         // Variable length quantity
00093         int GetVLQ (IDataSource *source, uint32 &quant);
00094         int GetVLQ2 (IDataSource *source, uint32 &quant);
00095 
00096         void AdjustTimings(uint32 ppqn);        // This is used by Midi's ONLY!
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

Generated on Fri Jul 27 22:27:55 2007 for pentagram by  doxygen 1.4.7