FMOplMidiDriver.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 FMOPLMIDIDRIVER_H_INCLUDED
00020 #define FMOPLMIDIDRIVER_H_INCLUDED
00021 
00022 #ifdef USE_FMOPL_MIDI
00023 
00024 #include "LowLevelMidiDriver.h"
00025 #include "fmopl.h"
00026 
00027 class IDataSource;
00028 
00029 class FMOplMidiDriver : public LowLevelMidiDriver
00030 {
00031         const static MidiDriverDesc     desc;
00032         static MidiDriver *createInstance() {
00033                 return new FMOplMidiDriver();
00034         }
00035 
00036 public:
00037         const static MidiDriverDesc* getDesc() { return &desc; }
00038         FMOplMidiDriver();
00039 
00040 protected:
00041         // LowLevelMidiDriver implementation
00042         virtual int                     open();
00043         virtual void            close();
00044         virtual void            send(uint32 b);
00045         virtual void            lowLevelProduceSamples(sint16 *samples, uint32 num_samples);
00046 
00047         // MidiDriver overloads
00048         virtual bool            isSampleProducer() { return true; }
00049         virtual bool            isFMSynth() { return true; }
00050         virtual void            loadTimbreLibrary(IDataSource*, TimbreLibraryType type);
00051 
00052 private:
00053 
00054         static const unsigned char midi_fm_instruments_table[128][11];
00055         static const int my_midi_fm_vol_table[128];
00056         static int lucas_fm_vol_table[128];
00057         static const unsigned char adlib_opadd[9];
00058         static const int fnums[12];
00059         static const double bend_fine[256];
00060         static const double bend_coarse[128];
00061 
00062         struct midi_channel {
00063                 int inum;
00064                 unsigned char ins[12];
00065                 bool xmidi;
00066                 int     xmidi_bank;
00067                 int vol;
00068                 int expression;
00069                 int nshift;
00070                 int on;
00071                 int pitchbend;
00072                 int pan;
00073         };
00074         struct xmidibank {
00075                 unsigned char   insbank[128][12];
00076         };
00077 
00078         enum {
00079                 ADLIB_MELODIC = 0,
00080                 ADLIB_RYTHM = 1
00081         };
00082 
00083         void midi_write_adlib(unsigned int reg, unsigned char val);
00084         void midi_fm_instrument(int voice, unsigned char *inst);
00085         int  midi_calc_volume(int chan, int vel);
00086         void midi_update_volume(int chan);
00087         void midi_fm_volume(int voice, int volume);
00088         void midi_fm_playnote(int voice, int note, int volume, int pitchbend);
00089         void midi_fm_endnote(int voice);
00090         unsigned char adlib_data[256];
00091 
00092 
00093         int chp[9][4];
00094         unsigned char   myinsbank[128][12];
00095         xmidibank               *xmidibanks[128];
00096         void                    loadXMIDITimbres(IDataSource *ds);
00097         void                    loadU7VoiceTimbres(IDataSource *ds);
00098 
00099         FMOpl_Pentagram::FM_OPL *opl;
00100         midi_channel ch[16];
00101 };
00102 
00103 #endif //USE_FMOPL_MIDI
00104 
00105 #endif //FMOPLDRV_H

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