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