Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


Messager.h
1#ifndef STK_MESSAGER_H
2#define STK_MESSAGER_H
3
4#include "Stk.h"
5#include "Skini.h"
6#include <queue>
7
8#if defined(__STK_REALTIME__)
9
10#include "Mutex.h"
11#include "Thread.h"
12#include "TcpServer.h"
13#include "RtMidi.h"
14
15#endif // __STK_REALTIME__
16
17namespace stk {
18
19/***************************************************/
51/***************************************************/
52
53const int DEFAULT_QUEUE_LIMIT = 200;
54
55class Messager : public Stk
56{
57 public:
58
59 // This structure is used to share data among the various realtime
60 // messager threads. It must be public.
61 struct MessagerData {
62 Skini skini;
63 std::queue<Skini::Message> queue;
64 unsigned int queueLimit;
65 int sources;
66
67#if defined(__STK_REALTIME__)
68 Mutex mutex;
69 RtMidiIn *midi;
70 TcpServer *socket;
71 std::vector<int> fd;
72 fd_set mask;
73#endif
74
75 // Default constructor.
76 MessagerData()
77 :queueLimit(0), sources(0) {}
78 };
79
82
85
87
93 void popMessage( Skini::Message& message );
94
96 void pushMessage( Skini::Message& message );
97
99
107 bool setScoreFile( const char* filename );
108
109#if defined(__STK_REALTIME__)
111
121
123
134 bool startSocketInput( int port=2001 );
135
137
149 bool startMidiInput( int port=0 );
150
151#endif
152
153 protected:
154
155 MessagerData data_;
156
157#if defined(__STK_REALTIME__)
158 Thread stdinThread_;
159 Thread socketThread_;
160#endif
161
162};
163
164} // stk namespace
165
166#endif
A realtime MIDI input class.
Definition RtMidi.h:276
STK input control message parser.
Definition Messager.h:56
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:37
STK SKINI parsing class.
Definition Skini.h:39
STK base class.
Definition Stk.h:136
STK TCP socket server class.
Definition TcpServer.h:34
STK thread class.
Definition Thread.h:50
The STK namespace.
Definition ADSR.h:6
A message structure to store and pass parsed SKINI messages.
Definition Skini.h:43

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