MidiDriver.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2003-2005  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 MIDIDRIVER_H_INCLUDED
00020 #define MIDIDRIVER_H_INCLUDED
00021 
00022 class XMidiEventList;
00023 class IDataSource;
00024 
00026 class   MidiDriver
00027 {
00028 protected:
00029         bool                                    initialized;
00030         MidiDriver() : initialized(false) { }
00031 
00032 public:
00034         struct MidiDriverDesc {
00035                 MidiDriverDesc(const char * const n, MidiDriver * (*c)()) :
00036                         name(n), createInstance(c) { }
00037                 const char * const name;                        
00038                 MidiDriver * (*createInstance)();       
00039         };
00040 
00041         enum TimbreLibraryType {
00042                 TIMBRE_LIBRARY_U7VOICE_AD       = 0,    // U7Voice for Adlib
00043                 TIMBRE_LIBRARY_U7VOICE_MT       = 1,    // U7Voice for MT32
00044                 TIMBRE_LIBRARY_XMIDI_AD         = 2,    // XMIDI.AD
00045                 TIMBRE_LIBRARY_XMIDI_MT         = 3,    // XMIDI.MT
00046                 TIMBRE_LIBRARY_SYX_FILE         = 4,    // .SYX
00047                 TIMBRE_LIBRARY_XMIDI_FILE       = 5,    // Timbre is Sysex Data in MID/RMI/XMI file
00048                 TIMBRE_LIBRARY_FMOPL_SETGM      = 6             // Special to set FMOPL into GM mode
00049         };
00050 
00055         virtual int                     initMidiDriver(uint32 sample_rate, bool stereo) = 0;
00056 
00058         virtual void            destroyMidiDriver() = 0;
00059 
00060         bool                            isInitialized() { return initialized; }
00061 
00064         virtual int                     maxSequences() = 0;
00065 
00068         virtual void            setGlobalVolume(int vol) = 0;
00069 
00076         virtual void            startSequence(int seq_num, XMidiEventList *list, bool repeat, int vol, int branch = -1) = 0;
00077 
00080         virtual void            finishSequence(int seq_num) = 0;
00081 
00084         virtual void            pauseSequence(int seq_num) = 0;
00085 
00088         virtual void            unpauseSequence(int seq_num) = 0;
00089 
00093         virtual void            setSequenceVolume(int seq_num, int vol) = 0;
00094 
00098         virtual void            setSequenceSpeed(int seq_num, int speed) = 0;
00099 
00103         virtual bool            isSequencePlaying(int seq_num) = 0;
00104 
00107         virtual uint32          getSequenceCallbackData(int seq_num) { return 0; }
00108 
00110         virtual bool            isSampleProducer() { return false; }
00111 
00115         virtual void            produceSamples(sint16 *samples, uint32 bytes) { }
00116 
00118         virtual bool            isFMSynth() { return false; }
00119 
00121         virtual bool            isMT32() { return false; }
00122 
00124         virtual bool            noTimbreSupport() { return false; }
00125 
00127         virtual void            loadTimbreLibrary(IDataSource*, TimbreLibraryType type) { };
00128 
00130         virtual ~MidiDriver() { };
00131 
00132         //
00133         // Statics to Initialize Midi Drivers and to get info
00134         //
00135         
00137         static int                      getDriverCount();
00138 
00141         static std::string      getDriverName(uint32 index);
00142 
00146         static MidiDriver       *createInstance(std::string driverName,uint32 sample_rate,bool stereo);
00147 
00148 protected:
00150         std::string getConfigSetting(std::string name, std::string defaultval);
00151 };
00152 
00153 #endif //MIDIDRIVER_H_INCLUDED

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