rtmidi 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.yardopts +7 -0
- data/DEV_NOTES.md +13 -0
- data/LICENSE.txt +46 -0
- data/README.md +82 -0
- data/Rakefile +10 -0
- data/examples/list_ports.rb +15 -0
- data/examples/monitor_input.rb +31 -0
- data/examples/play_notes.rb +28 -0
- data/ext/Rakefile +57 -0
- data/ext/rtmidi-2.0.1/RtError.h +60 -0
- data/ext/rtmidi-2.0.1/RtMidi.cpp +3747 -0
- data/ext/rtmidi-2.0.1/RtMidi.h +675 -0
- data/ext/rtmidi-2.0.1/RtMidi.o +0 -0
- data/ext/rtmidi-2.0.1/include/ks.h +3577 -0
- data/ext/rtmidi-2.0.1/include/ksmedia.h +4824 -0
- data/ext/ruby-rtmidi.cpp +108 -0
- data/ext/ruby-rtmidi.h +44 -0
- data/ext/ruby-rtmidi.o +0 -0
- data/ext/ruby-rtmidi.so +0 -0
- data/lib/rtmidi.rb +4 -0
- data/lib/rtmidi/in.rb +76 -0
- data/lib/rtmidi/interface.rb +67 -0
- data/lib/rtmidi/out.rb +59 -0
- metadata +85 -0
@@ -0,0 +1,675 @@
|
|
1
|
+
/**********************************************************************/
|
2
|
+
/*! \class RtMidi
|
3
|
+
\brief An abstract base class for realtime MIDI input/output.
|
4
|
+
|
5
|
+
This class implements some common functionality for the realtime
|
6
|
+
MIDI input/output subclasses RtMidiIn and RtMidiOut.
|
7
|
+
|
8
|
+
RtMidi WWW site: http://music.mcgill.ca/~gary/rtmidi/
|
9
|
+
|
10
|
+
RtMidi: realtime MIDI i/o C++ classes
|
11
|
+
Copyright (c) 2003-2012 Gary P. Scavone
|
12
|
+
|
13
|
+
Permission is hereby granted, free of charge, to any person
|
14
|
+
obtaining a copy of this software and associated documentation files
|
15
|
+
(the "Software"), to deal in the Software without restriction,
|
16
|
+
including without limitation the rights to use, copy, modify, merge,
|
17
|
+
publish, distribute, sublicense, and/or sell copies of the Software,
|
18
|
+
and to permit persons to whom the Software is furnished to do so,
|
19
|
+
subject to the following conditions:
|
20
|
+
|
21
|
+
The above copyright notice and this permission notice shall be
|
22
|
+
included in all copies or substantial portions of the Software.
|
23
|
+
|
24
|
+
Any person wishing to distribute modifications to the Software is
|
25
|
+
asked to send the modifications to the original developer so that
|
26
|
+
they can be incorporated into the canonical version. This is,
|
27
|
+
however, not a binding provision of this license.
|
28
|
+
|
29
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
30
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
31
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
32
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
33
|
+
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
34
|
+
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
35
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
36
|
+
*/
|
37
|
+
/**********************************************************************/
|
38
|
+
|
39
|
+
/*!
|
40
|
+
\file RtMidi.h
|
41
|
+
*/
|
42
|
+
|
43
|
+
// RtMidi: Version 2.0.1
|
44
|
+
|
45
|
+
#ifndef RTMIDI_H
|
46
|
+
#define RTMIDI_H
|
47
|
+
|
48
|
+
#include "RtError.h"
|
49
|
+
#include <string>
|
50
|
+
#include <vector>
|
51
|
+
|
52
|
+
class RtMidi
|
53
|
+
{
|
54
|
+
public:
|
55
|
+
|
56
|
+
//! MIDI API specifier arguments.
|
57
|
+
enum Api {
|
58
|
+
UNSPECIFIED, /*!< Search for a working compiled API. */
|
59
|
+
MACOSX_CORE, /*!< Macintosh OS-X Core Midi API. */
|
60
|
+
LINUX_ALSA, /*!< The Advanced Linux Sound Architecture API. */
|
61
|
+
UNIX_JACK, /*!< The Jack Low-Latency MIDI Server API. */
|
62
|
+
WINDOWS_MM, /*!< The Microsoft Multimedia MIDI API. */
|
63
|
+
WINDOWS_KS, /*!< The Microsoft Kernel Streaming MIDI API. */
|
64
|
+
RTMIDI_DUMMY /*!< A compilable but non-functional API. */
|
65
|
+
};
|
66
|
+
|
67
|
+
//! A static function to determine the available compiled MIDI APIs.
|
68
|
+
/*!
|
69
|
+
The values returned in the std::vector can be compared against
|
70
|
+
the enumerated list values. Note that there can be more than one
|
71
|
+
API compiled for certain operating systems.
|
72
|
+
*/
|
73
|
+
static void getCompiledApi( std::vector<RtMidi::Api> &apis ) throw();
|
74
|
+
|
75
|
+
//! Pure virtual openPort() function.
|
76
|
+
virtual void openPort( unsigned int portNumber = 0, const std::string portName = std::string( "RtMidi" ) ) = 0;
|
77
|
+
|
78
|
+
//! Pure virtual openVirtualPort() function.
|
79
|
+
virtual void openVirtualPort( const std::string portName = std::string( "RtMidi" ) ) = 0;
|
80
|
+
|
81
|
+
//! Pure virtual getPortCount() function.
|
82
|
+
virtual unsigned int getPortCount() = 0;
|
83
|
+
|
84
|
+
//! Pure virtual getPortName() function.
|
85
|
+
virtual std::string getPortName( unsigned int portNumber = 0 ) = 0;
|
86
|
+
|
87
|
+
//! Pure virtual closePort() function.
|
88
|
+
virtual void closePort( void ) = 0;
|
89
|
+
|
90
|
+
//! A basic error reporting function for RtMidi classes.
|
91
|
+
static void error( RtError::Type type, std::string errorString );
|
92
|
+
|
93
|
+
protected:
|
94
|
+
|
95
|
+
RtMidi() {};
|
96
|
+
virtual ~RtMidi() {};
|
97
|
+
};
|
98
|
+
|
99
|
+
/**********************************************************************/
|
100
|
+
/*! \class RtMidiIn
|
101
|
+
\brief A realtime MIDI input class.
|
102
|
+
|
103
|
+
This class provides a common, platform-independent API for
|
104
|
+
realtime MIDI input. It allows access to a single MIDI input
|
105
|
+
port. Incoming MIDI messages are either saved to a queue for
|
106
|
+
retrieval using the getMessage() function or immediately passed to
|
107
|
+
a user-specified callback function. Create multiple instances of
|
108
|
+
this class to connect to more than one MIDI device at the same
|
109
|
+
time. With the OS-X and Linux ALSA MIDI APIs, it is also possible
|
110
|
+
to open a virtual input port to which other MIDI software clients
|
111
|
+
can connect.
|
112
|
+
|
113
|
+
by Gary P. Scavone, 2003-2012.
|
114
|
+
*/
|
115
|
+
/**********************************************************************/
|
116
|
+
|
117
|
+
// **************************************************************** //
|
118
|
+
//
|
119
|
+
// RtMidiIn and RtMidiOut class declarations.
|
120
|
+
//
|
121
|
+
// RtMidiIn / RtMidiOut are "controllers" used to select an available
|
122
|
+
// MIDI input or output interface. They present common APIs for the
|
123
|
+
// user to call but all functionality is implemented by the classes
|
124
|
+
// MidiInApi, MidiOutApi and their subclasses. RtMidiIn and RtMidiOut
|
125
|
+
// each create an instance of a MidiInApi or MidiOutApi subclass based
|
126
|
+
// on the user's API choice. If no choice is made, they attempt to
|
127
|
+
// make a "logical" API selection.
|
128
|
+
//
|
129
|
+
// **************************************************************** //
|
130
|
+
|
131
|
+
class MidiInApi;
|
132
|
+
class MidiOutApi;
|
133
|
+
|
134
|
+
class RtMidiIn : public RtMidi
|
135
|
+
{
|
136
|
+
public:
|
137
|
+
|
138
|
+
//! User callback function type definition.
|
139
|
+
typedef void (*RtMidiCallback)( double timeStamp, std::vector<unsigned char> *message, void *userData);
|
140
|
+
|
141
|
+
//! Default constructor that allows an optional api, client name and queue size.
|
142
|
+
/*!
|
143
|
+
An exception will be thrown if a MIDI system initialization
|
144
|
+
error occurs. The queue size defines the maximum number of
|
145
|
+
messages that can be held in the MIDI queue (when not using a
|
146
|
+
callback function). If the queue size limit is reached,
|
147
|
+
incoming messages will be ignored.
|
148
|
+
|
149
|
+
If no API argument is specified and multiple API support has been
|
150
|
+
compiled, the default order of use is JACK, ALSA (Linux) and CORE,
|
151
|
+
Jack (OS-X).
|
152
|
+
*/
|
153
|
+
RtMidiIn( RtMidi::Api api=UNSPECIFIED,
|
154
|
+
const std::string clientName = std::string( "RtMidi Input Client"),
|
155
|
+
unsigned int queueSizeLimit = 100 );
|
156
|
+
|
157
|
+
//! If a MIDI connection is still open, it will be closed by the destructor.
|
158
|
+
~RtMidiIn ( void ) throw();
|
159
|
+
|
160
|
+
//! Returns the MIDI API specifier for the current instance of RtMidiIn.
|
161
|
+
RtMidi::Api getCurrentApi( void ) throw();
|
162
|
+
|
163
|
+
//! Open a MIDI input connection.
|
164
|
+
/*!
|
165
|
+
An optional port number greater than 0 can be specified.
|
166
|
+
Otherwise, the default or first port found is opened.
|
167
|
+
*/
|
168
|
+
void openPort( unsigned int portNumber = 0, const std::string portName = std::string( "RtMidi Input" ) );
|
169
|
+
|
170
|
+
//! Create a virtual input port, with optional name, to allow software connections (OS X and ALSA only).
|
171
|
+
/*!
|
172
|
+
This function creates a virtual MIDI input port to which other
|
173
|
+
software applications can connect. This type of functionality
|
174
|
+
is currently only supported by the Macintosh OS-X and Linux ALSA
|
175
|
+
APIs (the function does nothing for the other APIs).
|
176
|
+
*/
|
177
|
+
void openVirtualPort( const std::string portName = std::string( "RtMidi Input" ) );
|
178
|
+
|
179
|
+
//! Set a callback function to be invoked for incoming MIDI messages.
|
180
|
+
/*!
|
181
|
+
The callback function will be called whenever an incoming MIDI
|
182
|
+
message is received. While not absolutely necessary, it is best
|
183
|
+
to set the callback function before opening a MIDI port to avoid
|
184
|
+
leaving some messages in the queue.
|
185
|
+
*/
|
186
|
+
void setCallback( RtMidiCallback callback, void *userData = 0 );
|
187
|
+
|
188
|
+
//! Cancel use of the current callback function (if one exists).
|
189
|
+
/*!
|
190
|
+
Subsequent incoming MIDI messages will be written to the queue
|
191
|
+
and can be retrieved with the \e getMessage function.
|
192
|
+
*/
|
193
|
+
void cancelCallback();
|
194
|
+
|
195
|
+
//! Close an open MIDI connection (if one exists).
|
196
|
+
void closePort( void );
|
197
|
+
|
198
|
+
//! Return the number of available MIDI input ports.
|
199
|
+
unsigned int getPortCount();
|
200
|
+
|
201
|
+
//! Return a string identifier for the specified MIDI input port number.
|
202
|
+
/*!
|
203
|
+
An empty string is returned if an invalid port specifier is provided.
|
204
|
+
*/
|
205
|
+
std::string getPortName( unsigned int portNumber = 0 );
|
206
|
+
|
207
|
+
//! Specify whether certain MIDI message types should be queued or ignored during input.
|
208
|
+
/*!
|
209
|
+
o By default, MIDI timing and active sensing messages are ignored
|
210
|
+
during message input because of their relative high data rates.
|
211
|
+
MIDI sysex messages are ignored by default as well. Variable
|
212
|
+
values of "true" imply that the respective message type will be
|
213
|
+
ignored.
|
214
|
+
*/
|
215
|
+
void ignoreTypes( bool midiSysex = true, bool midiTime = true, bool midiSense = true );
|
216
|
+
|
217
|
+
//! Fill the user-provided vector with the data bytes for the next available MIDI message in the input queue and return the event delta-time in seconds.
|
218
|
+
/*!
|
219
|
+
This function returns immediately whether a new message is
|
220
|
+
available or not. A valid message is indicated by a non-zero
|
221
|
+
vector size. An exception is thrown if an error occurs during
|
222
|
+
message retrieval or an input connection was not previously
|
223
|
+
established.
|
224
|
+
*/
|
225
|
+
double getMessage( std::vector<unsigned char> *message );
|
226
|
+
|
227
|
+
protected:
|
228
|
+
void openMidiApi( RtMidi::Api api, const std::string clientName, unsigned int queueSizeLimit );
|
229
|
+
MidiInApi *rtapi_;
|
230
|
+
|
231
|
+
};
|
232
|
+
|
233
|
+
/**********************************************************************/
|
234
|
+
/*! \class RtMidiOut
|
235
|
+
\brief A realtime MIDI output class.
|
236
|
+
|
237
|
+
This class provides a common, platform-independent API for MIDI
|
238
|
+
output. It allows one to probe available MIDI output ports, to
|
239
|
+
connect to one such port, and to send MIDI bytes immediately over
|
240
|
+
the connection. Create multiple instances of this class to
|
241
|
+
connect to more than one MIDI device at the same time. With the
|
242
|
+
OS-X and Linux ALSA MIDI APIs, it is also possible to open a
|
243
|
+
virtual port to which other MIDI software clients can connect.
|
244
|
+
|
245
|
+
by Gary P. Scavone, 2003-2012.
|
246
|
+
*/
|
247
|
+
/**********************************************************************/
|
248
|
+
|
249
|
+
class RtMidiOut : public RtMidi
|
250
|
+
{
|
251
|
+
public:
|
252
|
+
|
253
|
+
//! Default constructor that allows an optional client name.
|
254
|
+
/*!
|
255
|
+
An exception will be thrown if a MIDI system initialization error occurs.
|
256
|
+
|
257
|
+
If no API argument is specified and multiple API support has been
|
258
|
+
compiled, the default order of use is JACK, ALSA (Linux) and CORE,
|
259
|
+
Jack (OS-X).
|
260
|
+
*/
|
261
|
+
RtMidiOut( RtMidi::Api api=UNSPECIFIED,
|
262
|
+
const std::string clientName = std::string( "RtMidi Output Client") );
|
263
|
+
|
264
|
+
//! The destructor closes any open MIDI connections.
|
265
|
+
~RtMidiOut( void ) throw();
|
266
|
+
|
267
|
+
//! Returns the MIDI API specifier for the current instance of RtMidiOut.
|
268
|
+
RtMidi::Api getCurrentApi( void ) throw();
|
269
|
+
|
270
|
+
//! Open a MIDI output connection.
|
271
|
+
/*!
|
272
|
+
An optional port number greater than 0 can be specified.
|
273
|
+
Otherwise, the default or first port found is opened. An
|
274
|
+
exception is thrown if an error occurs while attempting to make
|
275
|
+
the port connection.
|
276
|
+
*/
|
277
|
+
void openPort( unsigned int portNumber = 0, const std::string portName = std::string( "RtMidi Output" ) );
|
278
|
+
|
279
|
+
//! Close an open MIDI connection (if one exists).
|
280
|
+
void closePort( void );
|
281
|
+
|
282
|
+
//! Create a virtual output port, with optional name, to allow software connections (OS X and ALSA only).
|
283
|
+
/*!
|
284
|
+
This function creates a virtual MIDI output port to which other
|
285
|
+
software applications can connect. This type of functionality
|
286
|
+
is currently only supported by the Macintosh OS-X and Linux ALSA
|
287
|
+
APIs (the function does nothing with the other APIs). An
|
288
|
+
exception is thrown if an error occurs while attempting to create
|
289
|
+
the virtual port.
|
290
|
+
*/
|
291
|
+
void openVirtualPort( const std::string portName = std::string( "RtMidi Output" ) );
|
292
|
+
|
293
|
+
//! Return the number of available MIDI output ports.
|
294
|
+
unsigned int getPortCount( void );
|
295
|
+
|
296
|
+
//! Return a string identifier for the specified MIDI port type and number.
|
297
|
+
/*!
|
298
|
+
An empty string is returned if an invalid port specifier is provided.
|
299
|
+
*/
|
300
|
+
std::string getPortName( unsigned int portNumber = 0 );
|
301
|
+
|
302
|
+
//! Immediately send a single message out an open MIDI output port.
|
303
|
+
/*!
|
304
|
+
An exception is thrown if an error occurs during output or an
|
305
|
+
output connection was not previously established.
|
306
|
+
*/
|
307
|
+
void sendMessage( std::vector<unsigned char> *message );
|
308
|
+
|
309
|
+
protected:
|
310
|
+
void openMidiApi( RtMidi::Api api, const std::string clientName );
|
311
|
+
MidiOutApi *rtapi_;
|
312
|
+
};
|
313
|
+
|
314
|
+
|
315
|
+
// **************************************************************** //
|
316
|
+
//
|
317
|
+
// MidiInApi / MidiOutApi class declarations.
|
318
|
+
//
|
319
|
+
// Subclasses of MidiInApi and MidiOutApi contain all API- and
|
320
|
+
// OS-specific code necessary to fully implement the RtMidi API.
|
321
|
+
//
|
322
|
+
// Note that MidiInApi and MidiOutApi are abstract base classes and
|
323
|
+
// cannot be explicitly instantiated. RtMidiIn and RtMidiOut will
|
324
|
+
// create instances of a MidiInApi or MidiOutApi subclass.
|
325
|
+
//
|
326
|
+
// **************************************************************** //
|
327
|
+
|
328
|
+
class MidiInApi
|
329
|
+
{
|
330
|
+
public:
|
331
|
+
|
332
|
+
MidiInApi( unsigned int queueSizeLimit );
|
333
|
+
virtual ~MidiInApi( void );
|
334
|
+
virtual RtMidi::Api getCurrentApi( void ) = 0;
|
335
|
+
virtual void openPort( unsigned int portNumber, const std::string portName ) = 0;
|
336
|
+
virtual void openVirtualPort( const std::string portName ) = 0;
|
337
|
+
virtual void closePort( void ) = 0;
|
338
|
+
void setCallback( RtMidiIn::RtMidiCallback callback, void *userData );
|
339
|
+
void cancelCallback( void );
|
340
|
+
virtual unsigned int getPortCount( void ) = 0;
|
341
|
+
virtual std::string getPortName( unsigned int portNumber ) = 0;
|
342
|
+
virtual void ignoreTypes( bool midiSysex, bool midiTime, bool midiSense );
|
343
|
+
double getMessage( std::vector<unsigned char> *message );
|
344
|
+
|
345
|
+
// A MIDI structure used internally by the class to store incoming
|
346
|
+
// messages. Each message represents one and only one MIDI message.
|
347
|
+
struct MidiMessage {
|
348
|
+
std::vector<unsigned char> bytes;
|
349
|
+
double timeStamp;
|
350
|
+
|
351
|
+
// Default constructor.
|
352
|
+
MidiMessage()
|
353
|
+
:bytes(0), timeStamp(0.0) {}
|
354
|
+
};
|
355
|
+
|
356
|
+
struct MidiQueue {
|
357
|
+
unsigned int front;
|
358
|
+
unsigned int back;
|
359
|
+
unsigned int size;
|
360
|
+
unsigned int ringSize;
|
361
|
+
MidiMessage *ring;
|
362
|
+
|
363
|
+
// Default constructor.
|
364
|
+
MidiQueue()
|
365
|
+
:front(0), back(0), size(0), ringSize(0) {}
|
366
|
+
};
|
367
|
+
|
368
|
+
// The RtMidiInData structure is used to pass private class data to
|
369
|
+
// the MIDI input handling function or thread.
|
370
|
+
struct RtMidiInData {
|
371
|
+
MidiQueue queue;
|
372
|
+
MidiMessage message;
|
373
|
+
unsigned char ignoreFlags;
|
374
|
+
bool doInput;
|
375
|
+
bool firstMessage;
|
376
|
+
void *apiData;
|
377
|
+
bool usingCallback;
|
378
|
+
void *userCallback;
|
379
|
+
void *userData;
|
380
|
+
bool continueSysex;
|
381
|
+
|
382
|
+
// Default constructor.
|
383
|
+
RtMidiInData()
|
384
|
+
: ignoreFlags(7), doInput(false), firstMessage(true),
|
385
|
+
apiData(0), usingCallback(false), userCallback(0), userData(0),
|
386
|
+
continueSysex(false) {}
|
387
|
+
};
|
388
|
+
|
389
|
+
protected:
|
390
|
+
virtual void initialize( const std::string& clientName ) = 0;
|
391
|
+
RtMidiInData inputData_;
|
392
|
+
|
393
|
+
void *apiData_;
|
394
|
+
bool connected_;
|
395
|
+
std::string errorString_;
|
396
|
+
};
|
397
|
+
|
398
|
+
class MidiOutApi
|
399
|
+
{
|
400
|
+
public:
|
401
|
+
|
402
|
+
MidiOutApi( void );
|
403
|
+
virtual ~MidiOutApi( void );
|
404
|
+
virtual RtMidi::Api getCurrentApi( void ) = 0;
|
405
|
+
virtual void openPort( unsigned int portNumber, const std::string portName ) = 0;
|
406
|
+
virtual void openVirtualPort( const std::string portName ) = 0;
|
407
|
+
virtual void closePort( void ) = 0;
|
408
|
+
virtual unsigned int getPortCount( void ) = 0;
|
409
|
+
virtual std::string getPortName( unsigned int portNumber ) = 0;
|
410
|
+
virtual void sendMessage( std::vector<unsigned char> *message ) = 0;
|
411
|
+
|
412
|
+
protected:
|
413
|
+
virtual void initialize( const std::string& clientName ) = 0;
|
414
|
+
|
415
|
+
void *apiData_;
|
416
|
+
bool connected_;
|
417
|
+
std::string errorString_;
|
418
|
+
};
|
419
|
+
|
420
|
+
// **************************************************************** //
|
421
|
+
//
|
422
|
+
// Inline RtMidiIn and RtMidiOut definitions.
|
423
|
+
//
|
424
|
+
// **************************************************************** //
|
425
|
+
|
426
|
+
inline RtMidi::Api RtMidiIn :: getCurrentApi( void ) throw() { return rtapi_->getCurrentApi(); }
|
427
|
+
inline void RtMidiIn :: openPort( unsigned int portNumber, const std::string portName ) { return rtapi_->openPort( portNumber, portName ); }
|
428
|
+
inline void RtMidiIn :: openVirtualPort( const std::string portName ) { return rtapi_->openVirtualPort( portName ); }
|
429
|
+
inline void RtMidiIn :: closePort( void ) { return rtapi_->closePort(); }
|
430
|
+
inline void RtMidiIn :: setCallback( RtMidiCallback callback, void *userData ) { return rtapi_->setCallback( callback, userData ); }
|
431
|
+
inline void RtMidiIn :: cancelCallback( void ) { return rtapi_->cancelCallback(); }
|
432
|
+
inline unsigned int RtMidiIn :: getPortCount( void ) { return rtapi_->getPortCount(); }
|
433
|
+
inline std::string RtMidiIn :: getPortName( unsigned int portNumber ) { return rtapi_->getPortName( portNumber ); }
|
434
|
+
inline void RtMidiIn :: ignoreTypes( bool midiSysex, bool midiTime, bool midiSense ) { return rtapi_->ignoreTypes( midiSysex, midiTime, midiSense ); }
|
435
|
+
inline double RtMidiIn :: getMessage( std::vector<unsigned char> *message ) { return rtapi_->getMessage( message ); }
|
436
|
+
|
437
|
+
inline RtMidi::Api RtMidiOut :: getCurrentApi( void ) throw() { return rtapi_->getCurrentApi(); }
|
438
|
+
inline void RtMidiOut :: openPort( unsigned int portNumber, const std::string portName ) { return rtapi_->openPort( portNumber, portName ); }
|
439
|
+
inline void RtMidiOut :: openVirtualPort( const std::string portName ) { return rtapi_->openVirtualPort( portName ); }
|
440
|
+
inline void RtMidiOut :: closePort( void ) { return rtapi_->closePort(); }
|
441
|
+
inline unsigned int RtMidiOut :: getPortCount( void ) { return rtapi_->getPortCount(); }
|
442
|
+
inline std::string RtMidiOut :: getPortName( unsigned int portNumber ) { return rtapi_->getPortName( portNumber ); }
|
443
|
+
inline void RtMidiOut :: sendMessage( std::vector<unsigned char> *message ) { return rtapi_->sendMessage( message ); }
|
444
|
+
|
445
|
+
// **************************************************************** //
|
446
|
+
//
|
447
|
+
// MidiInApi and MidiOutApi subclass prototypes.
|
448
|
+
//
|
449
|
+
// **************************************************************** //
|
450
|
+
|
451
|
+
#if !defined(__LINUX_ALSA__) && !defined(__UNIX_JACK__) && !defined(__MACOSX_CORE__) && !defined(__WINDOWS_MM__) && !defined(__WINDOWS_KS__)
|
452
|
+
#define __RTMIDI_DUMMY__
|
453
|
+
#endif
|
454
|
+
|
455
|
+
#if defined(__MACOSX_CORE__)
|
456
|
+
|
457
|
+
class MidiInCore: public MidiInApi
|
458
|
+
{
|
459
|
+
public:
|
460
|
+
MidiInCore( const std::string clientName, unsigned int queueSizeLimit );
|
461
|
+
~MidiInCore( void );
|
462
|
+
RtMidi::Api getCurrentApi( void ) { return RtMidi::MACOSX_CORE; };
|
463
|
+
void openPort( unsigned int portNumber, const std::string portName );
|
464
|
+
void openVirtualPort( const std::string portName );
|
465
|
+
void closePort( void );
|
466
|
+
unsigned int getPortCount( void );
|
467
|
+
std::string getPortName( unsigned int portNumber );
|
468
|
+
|
469
|
+
protected:
|
470
|
+
void initialize( const std::string& clientName );
|
471
|
+
};
|
472
|
+
|
473
|
+
class MidiOutCore: public MidiOutApi
|
474
|
+
{
|
475
|
+
public:
|
476
|
+
MidiOutCore( const std::string clientName );
|
477
|
+
~MidiOutCore( void );
|
478
|
+
RtMidi::Api getCurrentApi( void ) { return RtMidi::MACOSX_CORE; };
|
479
|
+
void openPort( unsigned int portNumber, const std::string portName );
|
480
|
+
void openVirtualPort( const std::string portName );
|
481
|
+
void closePort( void );
|
482
|
+
unsigned int getPortCount( void );
|
483
|
+
std::string getPortName( unsigned int portNumber );
|
484
|
+
void sendMessage( std::vector<unsigned char> *message );
|
485
|
+
|
486
|
+
protected:
|
487
|
+
void initialize( const std::string& clientName );
|
488
|
+
};
|
489
|
+
|
490
|
+
#endif
|
491
|
+
|
492
|
+
#if defined(__UNIX_JACK__)
|
493
|
+
|
494
|
+
class MidiInJack: public MidiInApi
|
495
|
+
{
|
496
|
+
public:
|
497
|
+
MidiInJack( const std::string clientName, unsigned int queueSizeLimit );
|
498
|
+
~MidiInJack( void );
|
499
|
+
RtMidi::Api getCurrentApi( void ) { return RtMidi::UNIX_JACK; };
|
500
|
+
void openPort( unsigned int portNumber, const std::string portName );
|
501
|
+
void openVirtualPort( const std::string portName );
|
502
|
+
void closePort( void );
|
503
|
+
unsigned int getPortCount( void );
|
504
|
+
std::string getPortName( unsigned int portNumber );
|
505
|
+
|
506
|
+
protected:
|
507
|
+
void initialize( const std::string& clientName );
|
508
|
+
};
|
509
|
+
|
510
|
+
class MidiOutJack: public MidiOutApi
|
511
|
+
{
|
512
|
+
public:
|
513
|
+
MidiOutJack( const std::string clientName );
|
514
|
+
~MidiOutJack( void );
|
515
|
+
RtMidi::Api getCurrentApi( void ) { return RtMidi::UNIX_JACK; };
|
516
|
+
void openPort( unsigned int portNumber, const std::string portName );
|
517
|
+
void openVirtualPort( const std::string portName );
|
518
|
+
void closePort( void );
|
519
|
+
unsigned int getPortCount( void );
|
520
|
+
std::string getPortName( unsigned int portNumber );
|
521
|
+
void sendMessage( std::vector<unsigned char> *message );
|
522
|
+
|
523
|
+
protected:
|
524
|
+
void initialize( const std::string& clientName );
|
525
|
+
};
|
526
|
+
|
527
|
+
#endif
|
528
|
+
|
529
|
+
#if defined(__LINUX_ALSA__)
|
530
|
+
|
531
|
+
class MidiInAlsa: public MidiInApi
|
532
|
+
{
|
533
|
+
public:
|
534
|
+
MidiInAlsa( const std::string clientName, unsigned int queueSizeLimit );
|
535
|
+
~MidiInAlsa( void );
|
536
|
+
RtMidi::Api getCurrentApi( void ) { return RtMidi::LINUX_ALSA; };
|
537
|
+
void openPort( unsigned int portNumber, const std::string portName );
|
538
|
+
void openVirtualPort( const std::string portName );
|
539
|
+
void closePort( void );
|
540
|
+
unsigned int getPortCount( void );
|
541
|
+
std::string getPortName( unsigned int portNumber );
|
542
|
+
|
543
|
+
protected:
|
544
|
+
void initialize( const std::string& clientName );
|
545
|
+
};
|
546
|
+
|
547
|
+
class MidiOutAlsa: public MidiOutApi
|
548
|
+
{
|
549
|
+
public:
|
550
|
+
MidiOutAlsa( const std::string clientName );
|
551
|
+
~MidiOutAlsa( void );
|
552
|
+
RtMidi::Api getCurrentApi( void ) { return RtMidi::LINUX_ALSA; };
|
553
|
+
void openPort( unsigned int portNumber, const std::string portName );
|
554
|
+
void openVirtualPort( const std::string portName );
|
555
|
+
void closePort( void );
|
556
|
+
unsigned int getPortCount( void );
|
557
|
+
std::string getPortName( unsigned int portNumber );
|
558
|
+
void sendMessage( std::vector<unsigned char> *message );
|
559
|
+
|
560
|
+
protected:
|
561
|
+
void initialize( const std::string& clientName );
|
562
|
+
};
|
563
|
+
|
564
|
+
#endif
|
565
|
+
|
566
|
+
#if defined(__WINDOWS_MM__)
|
567
|
+
|
568
|
+
class MidiInWinMM: public MidiInApi
|
569
|
+
{
|
570
|
+
public:
|
571
|
+
MidiInWinMM( const std::string clientName, unsigned int queueSizeLimit );
|
572
|
+
~MidiInWinMM( void );
|
573
|
+
RtMidi::Api getCurrentApi( void ) { return RtMidi::WINDOWS_MM; };
|
574
|
+
void openPort( unsigned int portNumber, const std::string portName );
|
575
|
+
void openVirtualPort( const std::string portName );
|
576
|
+
void closePort( void );
|
577
|
+
unsigned int getPortCount( void );
|
578
|
+
std::string getPortName( unsigned int portNumber );
|
579
|
+
|
580
|
+
protected:
|
581
|
+
void initialize( const std::string& clientName );
|
582
|
+
};
|
583
|
+
|
584
|
+
class MidiOutWinMM: public MidiOutApi
|
585
|
+
{
|
586
|
+
public:
|
587
|
+
MidiOutWinMM( const std::string clientName );
|
588
|
+
~MidiOutWinMM( void );
|
589
|
+
RtMidi::Api getCurrentApi( void ) { return RtMidi::WINDOWS_MM; };
|
590
|
+
void openPort( unsigned int portNumber, const std::string portName );
|
591
|
+
void openVirtualPort( const std::string portName );
|
592
|
+
void closePort( void );
|
593
|
+
unsigned int getPortCount( void );
|
594
|
+
std::string getPortName( unsigned int portNumber );
|
595
|
+
void sendMessage( std::vector<unsigned char> *message );
|
596
|
+
|
597
|
+
protected:
|
598
|
+
void initialize( const std::string& clientName );
|
599
|
+
};
|
600
|
+
|
601
|
+
#endif
|
602
|
+
|
603
|
+
#if defined(__WINDOWS_KS__)
|
604
|
+
|
605
|
+
class MidiInWinKS: public MidiInApi
|
606
|
+
{
|
607
|
+
public:
|
608
|
+
MidiInWinKS( const std::string clientName, unsigned int queueSizeLimit );
|
609
|
+
~MidiInWinKS( void );
|
610
|
+
RtMidi::Api getCurrentApi( void ) { return RtMidi::WINDOWS_KS; };
|
611
|
+
void openPort( unsigned int portNumber, const std::string portName );
|
612
|
+
void openVirtualPort( const std::string portName );
|
613
|
+
void closePort( void );
|
614
|
+
unsigned int getPortCount( void );
|
615
|
+
std::string getPortName( unsigned int portNumber );
|
616
|
+
|
617
|
+
protected:
|
618
|
+
void initialize( const std::string& clientName );
|
619
|
+
};
|
620
|
+
|
621
|
+
class MidiOutWinKS: public MidiOutApi
|
622
|
+
{
|
623
|
+
public:
|
624
|
+
MidiOutWinKS( const std::string clientName );
|
625
|
+
~MidiOutWinKS( void );
|
626
|
+
RtMidi::Api getCurrentApi( void ) { return RtMidi::WINDOWS_KS; };
|
627
|
+
void openPort( unsigned int portNumber, const std::string portName );
|
628
|
+
void openVirtualPort( const std::string portName );
|
629
|
+
void closePort( void );
|
630
|
+
unsigned int getPortCount( void );
|
631
|
+
std::string getPortName( unsigned int portNumber );
|
632
|
+
void sendMessage( std::vector<unsigned char> *message );
|
633
|
+
|
634
|
+
protected:
|
635
|
+
void initialize( const std::string& clientName );
|
636
|
+
};
|
637
|
+
|
638
|
+
#endif
|
639
|
+
|
640
|
+
#if defined(__RTMIDI_DUMMY__)
|
641
|
+
|
642
|
+
class MidiInDummy: public MidiInApi
|
643
|
+
{
|
644
|
+
public:
|
645
|
+
MidiInDummy( const std::string clientName, unsigned int queueSizeLimit ) : MidiInApi( queueSizeLimit ) { errorString_ = "MidiInDummy: This class provides no functionality."; RtMidi::error( RtError::WARNING, errorString_ ); };
|
646
|
+
RtMidi::Api getCurrentApi( void ) { return RtMidi::RTMIDI_DUMMY; };
|
647
|
+
void openPort( unsigned int portNumber, const std::string portName ) {};
|
648
|
+
void openVirtualPort( const std::string portName ) {};
|
649
|
+
void closePort( void ) {};
|
650
|
+
unsigned int getPortCount( void ) { return 0; };
|
651
|
+
std::string getPortName( unsigned int portNumber ) { return ""; };
|
652
|
+
|
653
|
+
protected:
|
654
|
+
void initialize( const std::string& clientName ) {};
|
655
|
+
};
|
656
|
+
|
657
|
+
class MidiOutDummy: public MidiOutApi
|
658
|
+
{
|
659
|
+
public:
|
660
|
+
MidiOutDummy( const std::string clientName ) { errorString_ = "MidiOutDummy: This class provides no functionality."; RtMidi::error( RtError::WARNING, errorString_ ); };
|
661
|
+
RtMidi::Api getCurrentApi( void ) { return RtMidi::RTMIDI_DUMMY; };
|
662
|
+
void openPort( unsigned int portNumber, const std::string portName ) {};
|
663
|
+
void openVirtualPort( const std::string portName ) {};
|
664
|
+
void closePort( void ) {};
|
665
|
+
unsigned int getPortCount( void ) { return 0; };
|
666
|
+
std::string getPortName( unsigned int portNumber ) { return ""; };
|
667
|
+
void sendMessage( std::vector<unsigned char> *message ) {};
|
668
|
+
|
669
|
+
protected:
|
670
|
+
void initialize( const std::string& clientName ) {};
|
671
|
+
};
|
672
|
+
|
673
|
+
#endif
|
674
|
+
|
675
|
+
#endif
|