[4] | 1 | /*******************************************************************************
|
---|
| 2 | * FILE NAME: IRTMidi.hpp *
|
---|
| 3 | * *
|
---|
| 4 | * DESCRIPTION: *
|
---|
| 5 | * Class implementation of the class: *
|
---|
| 6 | * IRTMidi- Real Time Midi Base Class *
|
---|
| 7 | * *
|
---|
| 8 | * Copyright Joel Troster *
|
---|
| 9 | *
|
---|
| 10 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
| 11 | *
|
---|
| 12 | *******************************************************************************/
|
---|
| 13 | #ifndef _IRMIDI_
|
---|
| 14 | #define _IRMIDI_
|
---|
| 15 |
|
---|
| 16 | #ifdef _OS2WIN_H
|
---|
| 17 | #include <winos2def.h>
|
---|
| 18 | #endif
|
---|
| 19 |
|
---|
| 20 | #include <mididll.h>
|
---|
| 21 |
|
---|
| 22 | #define MAX_INSTANCES 32
|
---|
| 23 |
|
---|
| 24 | class IMidiInstance {
|
---|
| 25 | public:
|
---|
| 26 | IMidiInstance();
|
---|
| 27 |
|
---|
| 28 | virtual ~IMidiInstance();
|
---|
| 29 |
|
---|
| 30 | void setInstanceInfo( MIDIINSTANCEINFO * theInstanceInfo );
|
---|
| 31 | MINSTANCE instance() const;
|
---|
| 32 | unsigned long classNum() const;
|
---|
| 33 | char * name();
|
---|
| 34 | unsigned long numLinks() const;
|
---|
| 35 | unsigned long attributes() const;
|
---|
| 36 | BOOL isSend() const;
|
---|
| 37 | IMidiInstance& enableSend(BOOL enable = TRUE);
|
---|
| 38 | BOOL isReceive() const;
|
---|
| 39 | IMidiInstance& enableReceive(BOOL enable = TRUE);
|
---|
| 40 | BOOL canReceive() const;
|
---|
| 41 | BOOL canSend() const;
|
---|
| 42 | IMidiInstance& removeLink(IMidiInstance* toInstance);
|
---|
| 43 | IMidiInstance& addLink(IMidiInstance* toInstance);
|
---|
| 44 |
|
---|
| 45 | unsigned long getMessage( ULONG * pTime, ULONG * pMsg );
|
---|
| 46 | void sendMessage( UCHAR b1, UCHAR b2, UCHAR b3, UCHAR b4 ) const;
|
---|
| 47 | void sendMessage( ULONG theMsg ) const;
|
---|
| 48 | void sendSysexMessage( UCHAR* theMsg, ULONG msgLen ) const;
|
---|
| 49 |
|
---|
| 50 | MIDIINSTANCEINFO iInfo;
|
---|
| 51 |
|
---|
| 52 | }; // IMidiInstance
|
---|
| 53 |
|
---|
| 54 | class IAppMidiInstance : public IMidiInstance
|
---|
| 55 | {
|
---|
| 56 | public:
|
---|
| 57 | IAppMidiInstance( unsigned long attrs );
|
---|
| 58 |
|
---|
| 59 | virtual ~IAppMidiInstance();
|
---|
| 60 | private:
|
---|
| 61 | static unsigned long appNum;
|
---|
| 62 | }; // IAppMidiInstance
|
---|
| 63 |
|
---|
| 64 | // *****************************************************************************
|
---|
| 65 | // Class declaration for IRTMidi
|
---|
| 66 | // *****************************************************************************
|
---|
| 67 | class IRTMidi {
|
---|
| 68 | public:
|
---|
| 69 | //----------------------------------------------------------------------------
|
---|
| 70 | // Constructors / destructors
|
---|
| 71 | //----------------------------------------------------------------------------
|
---|
| 72 | IRTMidi();
|
---|
| 73 |
|
---|
| 74 | virtual ~IRTMidi();
|
---|
| 75 |
|
---|
| 76 | public:
|
---|
[5269] | 77 | void startTimer();
|
---|
| 78 | void stopTimer();
|
---|
[4] | 79 | MINSTANCE addInstance(IMidiInstance* theInstance, ULONG classNum, char * );
|
---|
| 80 | void delInstance(IMidiInstance* theInstance);
|
---|
| 81 | void resetLastRC();
|
---|
| 82 | unsigned long lastRC() const
|
---|
| 83 | { return iLastRC; }
|
---|
| 84 | void setLastRC(unsigned long theRC);
|
---|
| 85 | unsigned long applicationClass() const
|
---|
| 86 | { return iApplicationClass; };
|
---|
| 87 | unsigned long hardwareClass() const
|
---|
| 88 | { return iHardwareClass; };
|
---|
[21916] | 89 | const char * RCExplanation() const;
|
---|
[4] | 90 | static IRTMidi* instance();
|
---|
| 91 | static void shutdown();
|
---|
| 92 |
|
---|
| 93 | unsigned int numInInstances() const
|
---|
| 94 | { return iNumInInstances; };
|
---|
| 95 | IMidiInstance* inInstance( unsigned int i ) const
|
---|
| 96 | { return iInInstances[i]; };
|
---|
| 97 | unsigned int numOutInstances() const
|
---|
| 98 | { return iNumOutInstances; };
|
---|
| 99 | IMidiInstance* outInstance( unsigned int i ) const
|
---|
| 100 | { return iOutInstances[i]; };
|
---|
| 101 | unsigned long currentTime() const
|
---|
| 102 | { return *iCurrentTime; };
|
---|
| 103 |
|
---|
| 104 | // Methods for calls to RTMIDI functions
|
---|
[21916] | 105 | ULONG (*APIENTRY pfnMidiCreateInstance) ( ULONG, MINSTANCE*, PCSZ, ULONG );
|
---|
[5269] | 106 | ULONG (*APIENTRY pfnMidiDeleteInstance) ( MINSTANCE, ULONG );
|
---|
| 107 | ULONG (*APIENTRY pfnMidiEnableInstance) ( MINSTANCE, ULONG );
|
---|
| 108 | ULONG (*APIENTRY pfnMidiDisableInstance) ( MINSTANCE, ULONG );
|
---|
| 109 | ULONG (*APIENTRY pfnMidiAddLink) ( MINSTANCE, MINSTANCE, ULONG, ULONG );
|
---|
| 110 | ULONG (*APIENTRY pfnMidiRemoveLink) ( MINSTANCE, MINSTANCE, ULONG, ULONG );
|
---|
| 111 | ULONG (*APIENTRY pfnMidiQueryClassList) ( ULONG, PMIDICLASSINFO, ULONG );
|
---|
| 112 | ULONG (*APIENTRY pfnMidiQueryInstanceList) ( ULONG, PMIDIINSTANCEINFO, ULONG );
|
---|
| 113 | ULONG (*APIENTRY pfnMidiQueryNumClasses) ( PULONG, ULONG );
|
---|
| 114 | ULONG (*APIENTRY pfnMidiQueryNumInstances) ( PULONG, ULONG );
|
---|
| 115 | ULONG (*APIENTRY pfnMidiSendMessages) ( PMESSAGE, ULONG, ULONG );
|
---|
| 116 | ULONG (*APIENTRY pfnMidiSendSysexMessage) ( PMESSAGE, ULONG, ULONG );
|
---|
| 117 | ULONG (*APIENTRY pfnMidiRetrieveMessages) ( MINSTANCE, PVOID, PULONG, ULONG );
|
---|
| 118 | ULONG (*APIENTRY pfnMidiSetup) ( PMIDISETUP, ULONG );
|
---|
| 119 | ULONG (*APIENTRY pfnMidiTimer) ( ULONG, ULONG );
|
---|
[4] | 120 |
|
---|
[21916] | 121 | ULONG MidiCreateInstance ( ULONG, MINSTANCE*, PCSZ, ULONG );
|
---|
[5269] | 122 | ULONG MidiDeleteInstance ( MINSTANCE, ULONG );
|
---|
| 123 | ULONG MidiEnableInstance ( MINSTANCE, ULONG );
|
---|
| 124 | ULONG MidiDisableInstance ( MINSTANCE, ULONG );
|
---|
| 125 | ULONG MidiAddLink ( MINSTANCE, MINSTANCE, ULONG, ULONG );
|
---|
| 126 | ULONG MidiRemoveLink ( MINSTANCE, MINSTANCE, ULONG, ULONG );
|
---|
| 127 | ULONG MidiQueryClassList ( ULONG, PMIDICLASSINFO, ULONG );
|
---|
| 128 | ULONG MidiQueryInstanceList ( ULONG, PMIDIINSTANCEINFO, ULONG );
|
---|
| 129 | ULONG MidiQueryNumClasses ( PULONG, ULONG );
|
---|
| 130 | ULONG MidiQueryNumInstances ( PULONG, ULONG );
|
---|
| 131 | ULONG MidiSendMessages ( PMESSAGE, ULONG, ULONG );
|
---|
| 132 | ULONG MidiSendSysexMessage ( PMESSAGE, ULONG, ULONG );
|
---|
| 133 | ULONG MidiRetrieveMessages ( MINSTANCE, PVOID, PULONG, ULONG );
|
---|
| 134 | ULONG MidiSetup ( PMIDISETUP, ULONG );
|
---|
| 135 | ULONG MidiTimer ( ULONG, ULONG );
|
---|
| 136 |
|
---|
[4] | 137 | private:
|
---|
| 138 | unsigned long getRTMidiProcs();
|
---|
| 139 | unsigned long getClasses();
|
---|
| 140 | unsigned long getInstances();
|
---|
| 141 | void delInstances();
|
---|
| 142 | unsigned long findFreeInstance() const;
|
---|
| 143 |
|
---|
| 144 | unsigned long iLastRC;
|
---|
| 145 |
|
---|
| 146 | IMidiInstance* iInstances[MAX_INSTANCES+1];
|
---|
| 147 | unsigned int iNumInInstances;
|
---|
| 148 | IMidiInstance* iInInstances[MAX_INSTANCES+1];
|
---|
| 149 | unsigned int iNumOutInstances;
|
---|
| 150 | IMidiInstance* iOutInstances[MAX_INSTANCES+1];
|
---|
| 151 | unsigned long iApplicationClass;
|
---|
| 152 | unsigned long iHardwareClass;
|
---|
| 153 | static IRTMidi* iTheIRTMidiSingleton;
|
---|
| 154 | MIDISETUP iSetup;
|
---|
| 155 | unsigned long maxRTSysexLen;
|
---|
| 156 | unsigned long * iCurrentTime;
|
---|
| 157 | HMODULE iRTMidiModule;
|
---|
| 158 | };
|
---|
| 159 |
|
---|
| 160 | #define IRTMIDI IRTMidi::instance()
|
---|
| 161 |
|
---|
| 162 | extern "C"
|
---|
| 163 | {
|
---|
| 164 | void IRTMidiShutdown();
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | #endif
|
---|
| 168 |
|
---|