source: trunk/src/winmm/irtmidi.hpp@ 1036

Last change on this file since 1036 was 46, checked in by sandervl, 26 years ago

* empty log message *

File size: 5.5 KB
Line 
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
24class IMidiInstance {
25public:
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
54class IAppMidiInstance : public IMidiInstance
55{
56public:
57 IAppMidiInstance( unsigned long attrs );
58
59 virtual ~IAppMidiInstance();
60private:
61 static unsigned long appNum;
62}; // IAppMidiInstance
63
64// *****************************************************************************
65// Class declaration for IRTMidi
66// *****************************************************************************
67class IRTMidi {
68public:
69 //----------------------------------------------------------------------------
70 // Constructors / destructors
71 //----------------------------------------------------------------------------
72 IRTMidi();
73
74 virtual ~IRTMidi();
75
76public:
77 void startTimer() const;
78 void stopTimer() const;
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; };
89 char * RCExplanation() const;
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
105 ULONG (*APIENTRY MidiCreateInstance) ( ULONG, MINSTANCE*, PSZ, ULONG );
106 ULONG (*APIENTRY MidiDeleteInstance) ( MINSTANCE, ULONG );
107 ULONG (*APIENTRY MidiEnableInstance) ( MINSTANCE, ULONG );
108 ULONG (*APIENTRY MidiDisableInstance) ( MINSTANCE, ULONG );
109 ULONG (*APIENTRY MidiAddLink) ( MINSTANCE, MINSTANCE, ULONG, ULONG );
110 ULONG (*APIENTRY MidiRemoveLink) ( MINSTANCE, MINSTANCE, ULONG, ULONG );
111 ULONG (*APIENTRY MidiQueryClassList) ( ULONG, PMIDICLASSINFO, ULONG );
112 ULONG (*APIENTRY MidiQueryInstanceList) ( ULONG, PMIDIINSTANCEINFO, ULONG );
113 ULONG (*APIENTRY MidiQueryNumClasses) ( PULONG, ULONG );
114 ULONG (*APIENTRY MidiQueryNumInstances) ( PULONG, ULONG );
115 ULONG (*APIENTRY MidiSendMessages) ( PMESSAGE, ULONG, ULONG );
116 ULONG (*APIENTRY MidiSendSysexMessage) ( PMESSAGE, ULONG, ULONG );
117 ULONG (*APIENTRY MidiRetrieveMessages) ( MINSTANCE, PVOID, PULONG, ULONG );
118 ULONG (*APIENTRY MidiSetup) ( PMIDISETUP, ULONG );
119 ULONG (*APIENTRY MidiTimer) ( ULONG, ULONG );
120
121private:
122 unsigned long getRTMidiProcs();
123 unsigned long getClasses();
124 unsigned long getInstances();
125 void delInstances();
126 unsigned long findFreeInstance() const;
127
128 unsigned long iLastRC;
129
130 IMidiInstance* iInstances[MAX_INSTANCES+1];
131 unsigned int iNumInInstances;
132 IMidiInstance* iInInstances[MAX_INSTANCES+1];
133 unsigned int iNumOutInstances;
134 IMidiInstance* iOutInstances[MAX_INSTANCES+1];
135 unsigned long iApplicationClass;
136 unsigned long iHardwareClass;
137 static IRTMidi* iTheIRTMidiSingleton;
138 MIDISETUP iSetup;
139 unsigned long maxRTSysexLen;
140 unsigned long * iCurrentTime;
141 HMODULE iRTMidiModule;
142};
143
144#define IRTMIDI IRTMidi::instance()
145
146extern "C"
147{
148 void IRTMidiShutdown();
149}
150
151#endif
152
Note: See TracBrowser for help on using the repository browser.