1
/******************************************/
4
by Gary P. Scavone, 2000
6
This object will accept control messages
7
from a variety of sources, such as a MIDI
8
port, scorefile, socket connection, or
9
pipe. MIDI messages are retrieved with
10
the RtMidi class. All other input sources
11
(scorefile, socket, or pipe) are assumed
12
to provide SKINI formatted messages.
14
For each call of getNextMessage(), the
15
active input devices are queried to see
16
if a new control message is available.
17
Only one message per call is returned, so
18
a subsequent call begins querying the
19
next available device "after" the previously
22
This class is primarily for use in STK
25
One of my original goals in creating this class
26
was to simplify the message acquisition process
27
by removing all threads. If the windoze
28
select() function behaved just like the unix one,
29
that would have been possible. Since it does not
30
(it can't be used to poll STDIN), I am using a
31
thread to acquire messages from STDIN, which are
32
then sent via a socket connection to the message
33
socket server. Perhaps in the future, I will be
34
able to simplify things.
36
/******************************************/
38
#if !defined(__Controller_h)
39
#define __Controller_h
44
#if defined(__STK_REALTIME_)
48
#if (defined(__OS_IRIX_) || defined(__OS_Linux_))
49
#include <sys/types.h>
52
#include <sys/socket.h>
53
#include <arpa/inet.h>
59
void *stdinHandler(void *);
61
#elif defined(__OS_Win_)
65
void stdinHandler(void *);
69
#endif // __STK_REALTIME
71
#define STK_MIDI 0x0001
72
#define STK_PIPE 0x0002
73
#define STK_SOCKET 0x0004
74
#define STK_SCOREFILE 0x0008
76
#define MESSAGE_LENGTH 128
77
#define MAX_MESSAGES 25
78
#define STK_SOCKET_PORT 2001
80
class Controller : public Object
89
char message[MAX_MESSAGES][MESSAGE_LENGTH];
94
#if defined(__STK_REALTIME_)
100
int parseSocketData(int fd);
101
#if (defined(__OS_IRIX_) || defined(__OS_Linux_))
102
pthread_t stdin_thread;
103
#elif defined(__OS_Win_)
104
unsigned long stdin_thread;
106
#endif // __STK_REALTIME
109
Controller(int inputMask);
111
void setDefaultTicks(long nSamples);
112
int getNextMessage();
116
MY_FLOAT getChannel();
119
#endif // defined(__Controller_h)