Home
Information
Classes
Download
Usage
Mail List
Requirements
Links
FAQ
Tutorial
include
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__)
110
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
The Synthesis ToolKit in C++ (STK)
©1995--2014 Perry R. Cook and Gary P. Scavone. All Rights Reserved.