Arduino STK 4.6.2
Messager.h
1#ifndef STK_MESSAGER_H
2#define STK_MESSAGER_H
3
4#include "Stk.h"
5// deactivate this functionality if no fstreams are supported by the environment
6#ifndef __NO_FSTREAM__
7#include "Skini.h"
8#include <queue>
9
10#if defined(__STK_REALTIME__)
11
12#include "Mutex.h"
13#include "Thread.h"
14#include "TcpServer.h"
15#include "RtMidi.h"
16
17#endif // __STK_REALTIME__
18
19namespace stk {
20
21/***************************************************/
53/***************************************************/
54
55const int DEFAULT_QUEUE_LIMIT = 200;
56
57class Messager : public Stk
58{
59 public:
60
61 // This structure is used to share data among the various realtime
62 // messager threads. It must be public.
63 struct MessagerData {
64 Skini skini;
65 std::queue<Skini::Message> queue;
66 unsigned int queueLimit;
67 int sources;
68
69#if defined(__STK_REALTIME__)
70 Mutex mutex;
71 RtMidiIn *midi;
72 TcpServer *socket;
73 std::vector<int> fd;
74 fd_set mask;
75#endif
76
77 // Default constructor.
78 MessagerData()
79 :queueLimit(0), sources(0) {}
80 };
81
84
87
89
95 void popMessage( Skini::Message& message );
96
98 void pushMessage( Skini::Message& message );
99
101
109 bool setScoreFile( const char* filename );
110
111#if defined(__STK_REALTIME__)
113
123
125
136 bool startSocketInput( int port=2001 );
137
139
151 bool startMidiInput( int port=0 );
152
153#endif
154
155 protected:
156
157 MessagerData data_;
158
159#if defined(__STK_REALTIME__)
160 Thread stdinThread_;
161 Thread socketThread_;
162#endif
163
164};
165
166} // stk namespace
167
168#endif
169
170#endif //__NO_FSTREAM__
bool startStdInput()
Initiate the "realtime" retreival from stdin of control messages into the queue.
bool setScoreFile(const char *filename)
Specify a SKINI formatted scorefile from which messages should be read.
bool startSocketInput(int port=2001)
Start a socket server, accept connections, and read "realtime" control messages into the message queu...
void popMessage(Skini::Message &message)
Pop the next message from the queue and write it to the referenced message structure.
bool startMidiInput(int port=0)
Start MIDI input, with optional device and port identifiers.
~Messager()
Class destructor.
Messager()
Default constructor.
void pushMessage(Skini::Message &message)
Push the referenced message onto the message stack.
STK mutex class.
Definition Mutex.h:49
Stk(void)
Default constructor.
STK thread class.
Definition Thread.h:63
The STK namespace.
Definition ADSR.h:8