Home Information Classes Download Usage Mail List Requirements Links Tutorial

# Messager.h

    00001 /***************************************************/
    00034 /***************************************************/
    00035
    00036 #if !defined(__MESSAGER_H)
    00037 #define __MESSSAGER_H
    00038
    00039 #include "Stk.h"
    00040 #include "SKINI.h"
    00041
    00042 #define MESSAGE_LENGTH  128
    00043 #define MAX_MESSAGES 25
    00044 #define STK_MIDI        0x0001
    00045 #define STK_PIPE        0x0002
    00046 #define STK_SOCKET      0x0004
    00047
    00048 #if defined(__STK_REALTIME__)
    00049
    00050 #include "Thread.h"
    00051 #include "Socket.h"
    00052 #include "RtMidi.h"
    00053
    00054 extern "C" THREAD_RETURN THREAD_TYPE stdinHandler(void * ptr);
    00055
    00056 #if (defined(__OS_IRIX__) || defined(__OS_LINUX__) || defined(__OS_MACOSX__))
    00057   #include <sys/types.h>
    00058   #include <sys/time.h>
    00059 #endif
    00060
    00061 #endif // __STK_REALTIME__
    00062
    00063 class Messager : public Stk
    00064 {
    00065  public:
    00067
    00075   Messager(int inputMask = 0, int port = 2001);
    00076
    00078   ~Messager();
    00079
    00081
    00087   long nextMessage(void);
    00088
    00090   void setRtDelta(long nSamples);
    00091
    00093   long getDelta(void) const;
    00094
    00096   long getType() const;
    00097
    00099   MY_FLOAT getByteTwo() const;
    00100
    00102   MY_FLOAT getByteThree() const;
    00103
    00105   long getChannel() const;
    00106
    00107  protected:
    00108
    00109   SKINI *skini;
    00110   long type;
    00111   long channel;
    00112   MY_FLOAT byte2;
    00113   MY_FLOAT byte3;
    00114   int sources;
    00115   long delta;
    00116   long rtDelta;
    00117   char message[MAX_MESSAGES][MESSAGE_LENGTH];
    00118   unsigned int messageIndex;
    00119   int nMessages;
    00120
    00121 #if defined(__STK_REALTIME__)
    00122
    00123   // Check MIDI source for new messages.
    00124   bool midiMessage(void);
    00125
    00126   // Check socket sources for new messages.
    00127   bool socketMessage(void);
    00128
    00129   // Receive and parse socket data.
    00130   bool readSocket(int fd);
    00131
    00132   RtMidi *midi;
    00133   Thread *thread;
    00134   Socket *soket;
    00135
    00136   unsigned int nSockets;
    00137   fd_set mask;
    00138   int maxfd;
    00139   int pipefd;
    00140   int fd[16];
    00141   char error[256];
    00142
    00143 #endif // __STK_REALTIME__
    00144
    00145 };
    00146
    00147 #endif // defined(__MESSAGER_H)

The Synthesis ToolKit in C++ (STK)
©1995-2004 Perry R. Cook and Gary P. Scavone. All Rights Reserved.