Home Information Classes Download Usage Mail List Requirements Links Tutorial
00001 /**********************************************************************/ 00036 /**********************************************************************/ 00037 00038 // RtMidi: Version 1.0.2, 21 September 2004 00039 00040 #ifndef RTMIDI_H 00041 #define RTMIDI_H 00042 00043 #include "RtError.h" 00044 #include <string> 00045 00046 class RtMidi 00047 { 00048 protected: 00049 00050 RtMidi(); 00051 00052 virtual ~RtMidi() {}; 00053 00054 // A basic error reporting function for internal use in the RtMidi 00055 // subclasses. The behavior of this function can be modified to 00056 // suit specific needs. 00057 void error( RtError::Type type ); 00058 00059 virtual void openPort( unsigned int portNumber = 0 ) = 0; 00060 00061 void *apiData_; 00062 bool connected_; 00063 std::string errorString_; 00064 }; 00065 00066 /**********************************************************************/ 00082 /**********************************************************************/ 00083 00084 #include <vector> 00085 #include <queue> 00086 00087 class RtMidiIn : public RtMidi 00088 { 00089 public: 00090 00092 typedef void (*RtMidiCallback)( double timeStamp, std::vector<unsigned char> *message, void *userData); 00093 00095 00098 RtMidiIn(); 00099 00101 ~RtMidiIn(); 00102 00104 00108 void openPort( unsigned int portNumber = 0 ); 00109 00111 00117 void openVirtualPort(); 00118 00120 00126 void setCallback( RtMidiCallback callback, void *userData = 0 ); 00127 00129 00133 void cancelCallback(); 00134 00136 void closePort( void ); 00137 00139 unsigned int getPortCount(); 00140 00142 00145 std::string getPortName( unsigned int portNumber = 0 ); 00146 00148 00152 void setQueueSizeLimit( unsigned int queueSize ); 00153 00155 00162 void ignoreTypes( bool midiSysex = true, bool midiTime = true, bool midiSense = true ); 00163 00165 00172 double getMessage( std::vector<unsigned char> *message ); 00173 00174 // A MIDI structure used internally by the class to store incoming 00175 // messages. Each message represents one and only one MIDI message. 00176 struct MidiMessage { 00177 std::vector<unsigned char> bytes; 00178 double timeStamp; 00179 00180 // Default constructor. 00181 MidiMessage() 00182 :bytes(3), timeStamp(0.0) {} 00183 }; 00184 00185 // The RtMidiInData structure is used to pass private class data to 00186 // the MIDI input handling function or thread. 00187 struct RtMidiInData { 00188 std::queue<MidiMessage> queue; 00189 unsigned int queueLimit; 00190 unsigned char ignoreFlags; 00191 bool doInput; 00192 bool firstMessage; 00193 void *apiData; 00194 bool usingCallback; 00195 void *userCallback; 00196 void *userData; 00197 00198 // Default constructor. 00199 RtMidiInData() 00200 : queueLimit(1024), ignoreFlags(7), doInput(false), firstMessage(true), 00201 apiData(0), usingCallback(false), userCallback(0), userData(0) {} 00202 }; 00203 00204 private: 00205 00206 void initialize( void ); 00207 RtMidiInData inputData_; 00208 00209 }; 00210 00211 /**********************************************************************/ 00223 /**********************************************************************/ 00224 00225 class RtMidiOut : public RtMidi 00226 { 00227 public: 00228 00230 00233 RtMidiOut(); 00234 00236 ~RtMidiOut(); 00237 00239 00245 void openPort( unsigned int portNumber = 0 ); 00246 00248 void closePort(); 00249 00251 00259 void openVirtualPort(); 00260 00262 unsigned int getPortCount(); 00263 00265 00268 std::string getPortName( unsigned int portNumber ); 00269 00271 00275 void sendMessage( std::vector<unsigned char> *message ); 00276 00277 private: 00278 00279 void initialize( void ); 00280 }; 00281 00282 #endif
The Synthesis ToolKit in C++ (STK) |
©1995-2004 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |