RtMidi.h
gehe zur Dokumentation dieser Datei
00001 /**********************************************************************/
00036 /**********************************************************************/
00037 
00038 // RtMidi: Version 1.0.3, 22 November 2004
00039 
00040 #ifndef RTMIDI_H
00041 #define RTMIDI_H
00042 
00043 #include <iostream>
00044 #include "RtError.h"
00045 //using namespace std;
00046 
00047 #include <string>
00048 #include <queue>
00049 #include <deque>
00050 
00051 class RtMidi
00052 {
00053 
00054 public:
00055 
00057         virtual void openPort( unsigned int portNumber = 0 ) = 0;
00058 
00060         virtual void openVirtualPort() = 0;
00061 
00063         virtual unsigned int getPortCount() = 0;
00064 
00066 #ifdef __WXMSW__
00067         virtual wxString getPortName(unsigned int portNumber = 0 ) = 0;
00068 #else
00069         virtual std::string getPortName( unsigned int portNumber = 0 ) = 0;
00070 #endif
00071 
00073         virtual void closePort( void ) = 0;
00074 
00075 protected:
00076 
00077         RtMidi();
00078         virtual ~RtMidi()
00079         {};
00080 
00081         // A basic error reporting function for internal use in the RtMidi
00082         // subclasses.  The behavior of this function can be modified to
00083         // suit specific needs.
00084         void error( RtError::Type type );
00085 
00086         void *apiData_;
00087         bool connected_;
00088         std::string errorString_;
00089 };
00090 
00091 /**********************************************************************/
00107 /**********************************************************************/
00108 
00109 #include <vector>
00110 #include <queue>
00111 
00112 class RtMidiIn : public RtMidi
00113 {
00114 
00115 public:
00116 
00118         typedef void (*RtMidiCallback)( double timeStamp, std::vector<unsigned char> *message, void *userData);
00119 
00121 
00124         RtMidiIn();
00125 
00127         ~RtMidiIn();
00128 
00130 
00134         void openPort( unsigned int portNumber = 0 );
00135 
00137 
00143         void openVirtualPort();
00144 
00146 
00152         void setCallback( RtMidiCallback callback, void *userData = 0 );
00153 
00155 
00159         void cancelCallback();
00160 
00162         void closePort( void );
00163 
00165         unsigned int getPortCount();
00166 
00168 
00171 #ifdef __WXMSW__
00172         wxString getPortName( unsigned int portNumber = 0 );
00173 #else
00174         std::string getPortName( unsigned int portNumber = 0 );
00175 #endif
00176 
00178 
00182         void setQueueSizeLimit( unsigned int queueSize );
00183 
00185 
00192         void ignoreTypes( bool midiSysex = true, bool midiTime = true, bool midiSense = true );
00193 
00195 
00202         double getMessage( std::vector<unsigned char> *message );
00203 
00204         // A MIDI structure used internally by the class to store incoming
00205         // messages.  Each message represents one and only one MIDI message.
00206 
00207         struct MidiMessage
00208         {
00209                 std::vector<unsigned char> bytes;
00210                 double timeStamp;
00211 
00212                 // Default constructor.
00213                 MidiMessage()
00214                                 :bytes(3), timeStamp(0.0)
00215                 {}
00216 
00217         };
00218 
00219         // The RtMidiInData structure is used to pass private class data to
00220         // the MIDI input handling function or thread.
00221 
00222         struct RtMidiInData
00223         {
00224                 std::queue<MidiMessage, std::deque<MidiMessage> > queue;
00225                 unsigned int queueLimit;
00226                 unsigned char ignoreFlags;
00227                 bool doInput;
00228                 bool firstMessage;
00229                 void *apiData;
00230                 bool usingCallback;
00231                 void *userCallback;
00232                 void *userData;
00233 
00234                 // Default constructor.
00235                 RtMidiInData()
00236                                 : queueLimit(1024), ignoreFlags(7), doInput(false), firstMessage(true),
00237                                 apiData(0), usingCallback(false), userCallback(0), userData(0)
00238                 {}
00239 
00240         };
00241 
00242 private:
00243 
00244         void initialize( void );
00245         RtMidiInData inputData_;
00246 
00247 };
00248 
00249 /**********************************************************************/
00261 /**********************************************************************/
00262 
00263 class RtMidiOut : public RtMidi
00264 {
00265 
00266 public:
00267 
00269 
00272         RtMidiOut();
00273 
00275         ~RtMidiOut();
00276 
00278 
00284         void openPort( unsigned int portNumber = 0 );
00285 
00287         void closePort();
00288 
00290 
00298         void openVirtualPort();
00299 
00301         unsigned int getPortCount();
00302 
00304 
00307 #ifdef __WXMSW__
00308         wxString getPortName( unsigned int portNumber );
00309 #else
00310         std::string getPortName( unsigned int portNumber );
00311 #endif
00312 
00314 
00318         void sendMessage( std::vector<unsigned char> *message );
00319 
00320 private:
00321 
00322         void initialize( void );
00323 };
00324 
00325 #endif

Erzeugt am Sun Aug 21 2011 10:51:57 für Mutabor von doxygen 1.7.4