Tutorial Class/Enum List File List Compound Members

# RtMidi.h

    00001 /**********************************************************************/
    00036 /**********************************************************************/
    00037
    00038 // RtMidi: Version 1.0.11
    00039
    00040 #ifndef RTMIDI_H
    00041 #define RTMIDI_H
    00042
    00043 #include "RtError.h"
    00044 #include <string>
    00045
    00046 class RtMidi
    00047 {
    00048  public:
    00049
    00051   virtual void openPort( unsigned int portNumber = 0, const std::string portName = std::string( "RtMidi" ) ) = 0;
    00052
    00054   virtual void openVirtualPort( const std::string portName = std::string( "RtMidi" ) ) = 0;
    00055
    00057   virtual unsigned int getPortCount() = 0;
    00058
    00060   virtual std::string getPortName( unsigned int portNumber = 0 ) = 0;
    00061
    00063   virtual void closePort( void ) = 0;
    00064
    00065  protected:
    00066
    00067   RtMidi();
    00068   virtual ~RtMidi() {};
    00069
    00070   // A basic error reporting function for internal use in the RtMidi
    00071   // subclasses.  The behavior of this function can be modified to
    00072   // suit specific needs.
    00073   void error( RtError::Type type );
    00074
    00075   void *apiData_;
    00076   bool connected_;
    00077   std::string errorString_;
    00078 };
    00079
    00080 /**********************************************************************/
    00096 /**********************************************************************/
    00097
    00098 #include <vector>
    00099 #include <queue>
    00100
    00101 class RtMidiIn : public RtMidi
    00102 {
    00103  public:
    00104
    00106   typedef void (*RtMidiCallback)( double timeStamp, std::vector<unsigned char> *message, void *userData);
    00107
    00109
    00112   RtMidiIn( const std::string clientName = std::string( "RtMidi Input Client") );
    00113
    00115   ~RtMidiIn();
    00116
    00118
    00122   void openPort( unsigned int portNumber = 0, const std::string Portname = std::string( "RtMidi Input" ) );
    00123
    00125
    00131   void openVirtualPort( const std::string portName = std::string( "RtMidi Input" ) );
    00132
    00134
    00140   void setCallback( RtMidiCallback callback, void *userData = 0 );
    00141
    00143
    00147   void cancelCallback();
    00148
    00150   void closePort( void );
    00151
    00153   unsigned int getPortCount();
    00154
    00156
    00159   std::string getPortName( unsigned int portNumber = 0 );
    00160
    00162
    00166   void setQueueSizeLimit( unsigned int queueSize );
    00167
    00169
    00176   void ignoreTypes( bool midiSysex = true, bool midiTime = true, bool midiSense = true );
    00177
    00179
    00186   double getMessage( std::vector<unsigned char> *message );
    00187
    00188   // A MIDI structure used internally by the class to store incoming
    00189   // messages.  Each message represents one and only one MIDI message.
    00190   struct MidiMessage {
    00191     std::vector<unsigned char> bytes;
    00192     double timeStamp;
    00193
    00194     // Default constructor.
    00195     MidiMessage()
    00196       :bytes(3), timeStamp(0.0) {}
    00197   };
    00198
    00199   // The RtMidiInData structure is used to pass private class data to
    00200   // the MIDI input handling function or thread.
    00201   struct RtMidiInData {
    00202     std::queue<MidiMessage> queue;
    00203     MidiMessage message;
    00204     unsigned int queueLimit;
    00205     unsigned char ignoreFlags;
    00206     bool doInput;
    00207     bool firstMessage;
    00208     void *apiData;
    00209     bool usingCallback;
    00210     void *userCallback;
    00211     void *userData;
    00212     bool continueSysex;
    00213
    00214     // Default constructor.
    00215     RtMidiInData()
    00216       : queueLimit(1024), ignoreFlags(7), doInput(false), firstMessage(true),
    00217         apiData(0), usingCallback(false), userCallback(0), userData(0),
    00218         continueSysex(false) {}
    00219   };
    00220
    00221  private:
    00222
    00223   void initialize( const std::string& clientName );
    00224   RtMidiInData inputData_;
    00225
    00226 };
    00227
    00228 /**********************************************************************/
    00240 /**********************************************************************/
    00241
    00242 class RtMidiOut : public RtMidi
    00243 {
    00244  public:
    00245
    00247
    00250   RtMidiOut( const std::string clientName = std::string( "RtMidi Output Client" ) );
    00251
    00253   ~RtMidiOut();
    00254
    00256
    00262   void openPort( unsigned int portNumber = 0, const std::string portName = std::string( "RtMidi Output" ) );
    00263
    00265   void closePort();
    00266
    00268
    00276   void openVirtualPort( const std::string portName = std::string( "RtMidi Output" ) );
    00277
    00279   unsigned int getPortCount();
    00280
    00282
    00285   std::string getPortName( unsigned int portNumber = 0 );
    00286
    00288
    00292   void sendMessage( std::vector<unsigned char> *message );
    00293
    00294  private:
    00295
    00296   void initialize( const std::string& clientName );
    00297 };
    00298
    00299 #endif

| ©2003-2009 Gary P. Scavone, McGill University. All Rights Reserved. Maintained by Gary P. Scavone, gary at music.mcgill.ca