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
17 namespace stk {
18
19/***************************************************/
51/***************************************************/
52
53 const int DEFAULT_QUEUE_LIMIT = 200;
54
55 class 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
81 Messager();
82
84 ~Messager();
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
120 bool startStdInput();
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
RtMidi.h
RtMidiIn
A realtime MIDI input class.
Definition RtMidi.h:276
stk::Messager
STK input control message parser.
Definition Messager.h:56
stk::Messager::startStdInput
bool startStdInput()
Initiate the "realtime" retreival from stdin of control messages into the queue.
stk::Messager::setScoreFile
bool setScoreFile(const char *filename)
Specify a SKINI formatted scorefile from which messages should be read.
stk::Messager::startSocketInput
bool startSocketInput(int port=2001)
Start a socket server, accept connections, and read "realtime" control messages into the message queu...
stk::Messager::popMessage
void popMessage(Skini::Message &message)
Pop the next message from the queue and write it to the referenced message structure.
stk::Messager::startMidiInput
bool startMidiInput(int port=0)
Start MIDI input, with optional device and port identifiers.
stk::Messager::~Messager
~Messager()
Class destructor.
stk::Messager::Messager
Messager()
Default constructor.
stk::Messager::pushMessage
void pushMessage(Skini::Message &message)
Push the referenced message onto the message stack.
stk::Mutex
STK mutex class.
Definition Mutex.h:37
stk::Skini
STK SKINI parsing class.
Definition Skini.h:39
stk::Stk
STK base class.
Definition Stk.h:136
stk::TcpServer
STK TCP socket server class.
Definition TcpServer.h:34
stk::Thread
STK thread class.
Definition Thread.h:50
stk
The STK namespace.
Definition ADSR.h:6
stk::Skini::Message
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.