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 //! MIDI API specifier arguments.
56 enum Api
57 {
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);
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:
RtMidi()94 RtMidi(){};
~RtMidi()95 virtual ~RtMidi(){};
96 };
97
98 /**********************************************************************/
99 /*! \class RtMidiIn
100 \brief A realtime MIDI input class.
101
102 This class provides a common, platform-independent API for
103 realtime MIDI input. It allows access to a single MIDI input
104 port. Incoming MIDI messages are either saved to a queue for
105 retrieval using the getMessage() function or immediately passed to
106 a user-specified callback function. Create multiple instances of
107 this class to connect to more than one MIDI device at the same
108 time. With the OS-X and Linux ALSA MIDI APIs, it is also possible
109 to open a virtual input port to which other MIDI software clients
110 can connect.
111
112 by Gary P. Scavone, 2003-2012.
113 */
114 /**********************************************************************/
115
116 // **************************************************************** //
117 //
118 // RtMidiIn and RtMidiOut class declarations.
119 //
120 // RtMidiIn / RtMidiOut are "controllers" used to select an available
121 // MIDI input or output interface. They present common APIs for the
122 // user to call but all functionality is implemented by the classes
123 // MidiInApi, MidiOutApi and their subclasses. RtMidiIn and RtMidiOut
124 // each create an instance of a MidiInApi or MidiOutApi subclass based
125 // on the user's API choice. If no choice is made, they attempt to
126 // make a "logical" API selection.
127 //
128 // **************************************************************** //
129
130 class MidiInApi;
131 class MidiOutApi;
132
133 class RtMidiIn : public RtMidi
134 {
135 public:
136 //! User callback function type definition.
137 typedef void (*RtMidiCallback)(double timeStamp, std::vector<unsigned char> *message, void *userData);
138
139 //! Default constructor that allows an optional api, client name and queue size.
140 /*!
141 An assert will be fired if a MIDI system initialization
142 error occurs. The queue size defines the maximum number of
143 messages that can be held in the MIDI queue (when not using a
144 callback function). If the queue size limit is reached,
145 incoming messages will be ignored.
146
147 If no API argument is specified and multiple API support has been
148 compiled, the default order of use is JACK, ALSA (Linux) and CORE,
149 Jack (OS-X).
150 */
151 RtMidiIn(RtMidi::Api api = UNSPECIFIED,
152 const std::string clientName = std::string("RtMidi Input Client"),
153 unsigned int queueSizeLimit = 100);
154
155 //! If a MIDI connection is still open, it will be closed by the destructor.
156 ~RtMidiIn(void);
157
158 //! Returns the MIDI API specifier for the current instance of RtMidiIn.
159 RtMidi::Api getCurrentApi(void);
160
161 //! Open a MIDI input connection.
162 /*!
163 An optional port number greater than 0 can be specified.
164 Otherwise, the default or first port found is opened.
165 */
166 void openPort(unsigned int portNumber = 0, const std::string portName = std::string("RtMidi Input"));
167
168 //! Create a virtual input port, with optional name, to allow software connections (OS X and ALSA only).
169 /*!
170 This function creates a virtual MIDI input port to which other
171 software applications can connect. This type of functionality
172 is currently only supported by the Macintosh OS-X and Linux ALSA
173 APIs (the function does nothing for the other APIs).
174 */
175 void openVirtualPort(const std::string portName = std::string("RtMidi Input"));
176
177 //! Set a callback function to be invoked for incoming MIDI messages.
178 /*!
179 The callback function will be called whenever an incoming MIDI
180 message is received. While not absolutely necessary, it is best
181 to set the callback function before opening a MIDI port to avoid
182 leaving some messages in the queue.
183 */
184 void setCallback(RtMidiCallback callback, void *userData = 0);
185
186 //! Cancel use of the current callback function (if one exists).
187 /*!
188 Subsequent incoming MIDI messages will be written to the queue
189 and can be retrieved with the \e getMessage function.
190 */
191 void cancelCallback();
192
193 //! Close an open MIDI connection (if one exists).
194 void closePort(void);
195
196 //! Return the number of available MIDI input ports.
197 unsigned int getPortCount();
198
199 //! Return a string identifier for the specified MIDI input port number.
200 /*!
201 An empty string is returned if an invalid port specifier is provided.
202 */
203 std::string getPortName(unsigned int portNumber = 0);
204
205 //! Specify whether certain MIDI message types should be queued or ignored during input.
206 /*!
207 o By default, MIDI timing and active sensing messages are ignored
208 during message input because of their relative high data rates.
209 MIDI sysex messages are ignored by default as well. Variable
210 values of "true" imply that the respective message type will be
211 ignored.
212 */
213 void ignoreTypes(bool midiSysex = true, bool midiTime = true, bool midiSense = true);
214
215 //! 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.
216 /*!
217 This function returns immediately whether a new message is
218 available or not. A valid message is indicated by a non-zero
219 vector size. An assert is fired if an error occurs during
220 message retrieval or an input connection was not previously
221 established.
222 */
223 double getMessage(std::vector<unsigned char> *message);
224
225 protected:
226 void openMidiApi(RtMidi::Api api, const std::string clientName, unsigned int queueSizeLimit);
227 MidiInApi *rtapi_;
228 };
229
230 /**********************************************************************/
231 /*! \class RtMidiOut
232 \brief A realtime MIDI output class.
233
234 This class provides a common, platform-independent API for MIDI
235 output. It allows one to probe available MIDI output ports, to
236 connect to one such port, and to send MIDI bytes immediately over
237 the connection. Create multiple instances of this class to
238 connect to more than one MIDI device at the same time. With the
239 OS-X and Linux ALSA MIDI APIs, it is also possible to open a
240 virtual port to which other MIDI software clients can connect.
241
242 by Gary P. Scavone, 2003-2012.
243 */
244 /**********************************************************************/
245
246 class RtMidiOut : public RtMidi
247 {
248 public:
249 //! Default constructor that allows an optional client name.
250 /*!
251 An exception will be thrown if a MIDI system initialization error occurs.
252
253 If no API argument is specified and multiple API support has been
254 compiled, the default order of use is JACK, ALSA (Linux) and CORE,
255 Jack (OS-X).
256 */
257 RtMidiOut(RtMidi::Api api = UNSPECIFIED,
258 const std::string clientName = std::string("RtMidi Output Client"));
259
260 //! The destructor closes any open MIDI connections.
261 ~RtMidiOut(void);
262
263 //! Returns the MIDI API specifier for the current instance of RtMidiOut.
264 RtMidi::Api getCurrentApi(void);
265
266 //! Open a MIDI output connection.
267 /*!
268 An optional port number greater than 0 can be specified.
269 Otherwise, the default or first port found is opened. An
270 exception is thrown if an error occurs while attempting to make
271 the port connection.
272 */
273 void openPort(unsigned int portNumber = 0, const std::string portName = std::string("RtMidi Output"));
274
275 //! Close an open MIDI connection (if one exists).
276 void closePort(void);
277
278 //! Create a virtual output port, with optional name, to allow software connections (OS X and ALSA only).
279 /*!
280 This function creates a virtual MIDI output port to which other
281 software applications can connect. This type of functionality
282 is currently only supported by the Macintosh OS-X and Linux ALSA
283 APIs (the function does nothing with the other APIs). An
284 exception is thrown if an error occurs while attempting to create
285 the virtual port.
286 */
287 void openVirtualPort(const std::string portName = std::string("RtMidi Output"));
288
289 //! Return the number of available MIDI output ports.
290 unsigned int getPortCount(void);
291
292 //! Return a string identifier for the specified MIDI port type and number.
293 /*!
294 An empty string is returned if an invalid port specifier is provided.
295 */
296 std::string getPortName(unsigned int portNumber = 0);
297
298 //! Immediately send a single message out an open MIDI output port.
299 /*!
300 An exception is thrown if an error occurs during output or an
301 output connection was not previously established.
302 */
303 void sendMessage(std::vector<unsigned char> *message);
304
305 protected:
306 void openMidiApi(RtMidi::Api api, const std::string clientName);
307 MidiOutApi *rtapi_;
308 };
309
310 // **************************************************************** //
311 //
312 // MidiInApi / MidiOutApi class declarations.
313 //
314 // Subclasses of MidiInApi and MidiOutApi contain all API- and
315 // OS-specific code necessary to fully implement the RtMidi API.
316 //
317 // Note that MidiInApi and MidiOutApi are abstract base classes and
318 // cannot be explicitly instantiated. RtMidiIn and RtMidiOut will
319 // create instances of a MidiInApi or MidiOutApi subclass.
320 //
321 // **************************************************************** //
322
323 class MidiInApi
324 {
325 public:
326 MidiInApi(unsigned int queueSizeLimit);
327 virtual ~MidiInApi(void);
328 virtual RtMidi::Api getCurrentApi(void) = 0;
329 virtual void openPort(unsigned int portNumber, const std::string portName) = 0;
330 virtual void openVirtualPort(const std::string portName) = 0;
331 virtual void closePort(void) = 0;
332 void setCallback(RtMidiIn::RtMidiCallback callback, void *userData);
333 void cancelCallback(void);
334 virtual unsigned int getPortCount(void) = 0;
335 virtual std::string getPortName(unsigned int portNumber) = 0;
336 virtual void ignoreTypes(bool midiSysex, bool midiTime, bool midiSense);
337 double getMessage(std::vector<unsigned char> *message);
338
339 // A MIDI structure used internally by the class to store incoming
340 // messages. Each message represents one and only one MIDI message.
341 struct MidiMessage
342 {
343 std::vector<unsigned char> bytes;
344 double timeStamp;
345
346 // Default constructor.
MidiMessageMidiMessage347 MidiMessage()
348 : bytes(0), timeStamp(0.0) {}
349 };
350
351 struct MidiQueue
352 {
353 unsigned int front;
354 unsigned int back;
355 unsigned int size;
356 unsigned int ringSize;
357 MidiMessage *ring;
358
359 // Default constructor.
MidiQueueMidiQueue360 MidiQueue()
361 : front(0), back(0), size(0), ringSize(0) {}
362 };
363
364 // The RtMidiInData structure is used to pass private class data to
365 // the MIDI input handling function or thread.
366 struct RtMidiInData
367 {
368 MidiQueue queue;
369 MidiMessage message;
370 unsigned char ignoreFlags;
371 bool doInput;
372 bool firstMessage;
373 void *apiData;
374 bool usingCallback;
375 void *userCallback;
376 void *userData;
377 bool continueSysex;
378
379 // Default constructor.
RtMidiInDataRtMidiInData380 RtMidiInData()
381 : ignoreFlags(7), doInput(false), firstMessage(true), apiData(0), usingCallback(false), userCallback(0), userData(0), continueSysex(false) {}
382 };
383
384 protected:
385 virtual void initialize(const std::string &clientName) = 0;
386 RtMidiInData inputData_;
387
388 void *apiData_;
389 bool connected_;
390 std::string errorString_;
391 };
392
393 class MidiOutApi
394 {
395 public:
396 MidiOutApi(void);
397 virtual ~MidiOutApi(void);
398 virtual RtMidi::Api getCurrentApi(void) = 0;
399 virtual void openPort(unsigned int portNumber, const std::string portName) = 0;
400 virtual void openVirtualPort(const std::string portName) = 0;
401 virtual void closePort(void) = 0;
402 virtual unsigned int getPortCount(void) = 0;
403 virtual std::string getPortName(unsigned int portNumber) = 0;
404 virtual void sendMessage(std::vector<unsigned char> *message) = 0;
405
406 protected:
407 virtual void initialize(const std::string &clientName) = 0;
408
409 void *apiData_;
410 bool connected_;
411 std::string errorString_;
412 };
413
414 // **************************************************************** //
415 //
416 // Inline RtMidiIn and RtMidiOut definitions.
417 //
418 // **************************************************************** //
419
getCurrentApi(void)420 inline RtMidi::Api RtMidiIn ::getCurrentApi(void) { return rtapi_->getCurrentApi(); }
openPort(unsigned int portNumber,const std::string portName)421 inline void RtMidiIn ::openPort(unsigned int portNumber, const std::string portName) { return rtapi_->openPort(portNumber, portName); }
openVirtualPort(const std::string portName)422 inline void RtMidiIn ::openVirtualPort(const std::string portName) { return rtapi_->openVirtualPort(portName); }
closePort(void)423 inline void RtMidiIn ::closePort(void) { return rtapi_->closePort(); }
setCallback(RtMidiCallback callback,void * userData)424 inline void RtMidiIn ::setCallback(RtMidiCallback callback, void *userData) { return rtapi_->setCallback(callback, userData); }
cancelCallback(void)425 inline void RtMidiIn ::cancelCallback(void) { return rtapi_->cancelCallback(); }
getPortCount(void)426 inline unsigned int RtMidiIn ::getPortCount(void) { return rtapi_->getPortCount(); }
getPortName(unsigned int portNumber)427 inline std::string RtMidiIn ::getPortName(unsigned int portNumber) { return rtapi_->getPortName(portNumber); }
ignoreTypes(bool midiSysex,bool midiTime,bool midiSense)428 inline void RtMidiIn ::ignoreTypes(bool midiSysex, bool midiTime, bool midiSense) { return rtapi_->ignoreTypes(midiSysex, midiTime, midiSense); }
getMessage(std::vector<unsigned char> * message)429 inline double RtMidiIn ::getMessage(std::vector<unsigned char> *message) { return rtapi_->getMessage(message); }
430
getCurrentApi(void)431 inline RtMidi::Api RtMidiOut ::getCurrentApi(void) { return rtapi_->getCurrentApi(); }
openPort(unsigned int portNumber,const std::string portName)432 inline void RtMidiOut ::openPort(unsigned int portNumber, const std::string portName) { return rtapi_->openPort(portNumber, portName); }
openVirtualPort(const std::string portName)433 inline void RtMidiOut ::openVirtualPort(const std::string portName) { return rtapi_->openVirtualPort(portName); }
closePort(void)434 inline void RtMidiOut ::closePort(void) { return rtapi_->closePort(); }
getPortCount(void)435 inline unsigned int RtMidiOut ::getPortCount(void) { return rtapi_->getPortCount(); }
getPortName(unsigned int portNumber)436 inline std::string RtMidiOut ::getPortName(unsigned int portNumber) { return rtapi_->getPortName(portNumber); }
sendMessage(std::vector<unsigned char> * message)437 inline void RtMidiOut ::sendMessage(std::vector<unsigned char> *message) { return rtapi_->sendMessage(message); }
438
439 // **************************************************************** //
440 //
441 // MidiInApi and MidiOutApi subclass prototypes.
442 //
443 // **************************************************************** //
444
445 #if !defined(__LINUX_ALSA__) && !defined(__UNIX_JACK__) && !defined(__MACOSX_CORE__) && !defined(__WINDOWS_MM__) && !defined(__WINDOWS_KS__)
446 #define __RTMIDI_DUMMY__
447 #endif
448
449 #if defined(__MACOSX_CORE__)
450
451 class MidiInCore : public MidiInApi
452 {
453 public:
454 MidiInCore(const std::string clientName, unsigned int queueSizeLimit);
455 ~MidiInCore(void);
getCurrentApi(void)456 RtMidi::Api getCurrentApi(void) { return RtMidi::MACOSX_CORE; };
457 void openPort(unsigned int portNumber, const std::string portName);
458 void openVirtualPort(const std::string portName);
459 void closePort(void);
460 unsigned int getPortCount(void);
461 std::string getPortName(unsigned int portNumber);
462
463 protected:
464 void initialize(const std::string &clientName);
465 };
466
467 class MidiOutCore : public MidiOutApi
468 {
469 public:
470 MidiOutCore(const std::string clientName);
471 ~MidiOutCore(void);
getCurrentApi(void)472 RtMidi::Api getCurrentApi(void) { return RtMidi::MACOSX_CORE; };
473 void openPort(unsigned int portNumber, const std::string portName);
474 void openVirtualPort(const std::string portName);
475 void closePort(void);
476 unsigned int getPortCount(void);
477 std::string getPortName(unsigned int portNumber);
478 void sendMessage(std::vector<unsigned char> *message);
479
480 protected:
481 void initialize(const std::string &clientName);
482 };
483
484 #endif
485
486 #if defined(__UNIX_JACK__)
487
488 class MidiInJack : public MidiInApi
489 {
490 public:
491 MidiInJack(const std::string clientName, unsigned int queueSizeLimit);
492 ~MidiInJack(void);
getCurrentApi(void)493 RtMidi::Api getCurrentApi(void) { return RtMidi::UNIX_JACK; };
494 void openPort(unsigned int portNumber, const std::string portName);
495 void openVirtualPort(const std::string portName);
496 void closePort(void);
497 unsigned int getPortCount(void);
498 std::string getPortName(unsigned int portNumber);
499
500 protected:
501 void initialize(const std::string &clientName);
502 };
503
504 class MidiOutJack : public MidiOutApi
505 {
506 public:
507 MidiOutJack(const std::string clientName);
508 ~MidiOutJack(void);
getCurrentApi(void)509 RtMidi::Api getCurrentApi(void) { return RtMidi::UNIX_JACK; };
510 void openPort(unsigned int portNumber, const std::string portName);
511 void openVirtualPort(const std::string portName);
512 void closePort(void);
513 unsigned int getPortCount(void);
514 std::string getPortName(unsigned int portNumber);
515 void sendMessage(std::vector<unsigned char> *message);
516
517 protected:
518 void initialize(const std::string &clientName);
519 };
520
521 #endif
522
523 #if defined(__LINUX_ALSA__)
524
525 class MidiInAlsa : public MidiInApi
526 {
527 public:
528 MidiInAlsa(const std::string clientName, unsigned int queueSizeLimit);
529 ~MidiInAlsa(void);
getCurrentApi(void)530 RtMidi::Api getCurrentApi(void) { return RtMidi::LINUX_ALSA; };
531 void openPort(unsigned int portNumber, const std::string portName);
532 void openVirtualPort(const std::string portName);
533 void closePort(void);
534 unsigned int getPortCount(void);
535 std::string getPortName(unsigned int portNumber);
536
537 protected:
538 void initialize(const std::string &clientName);
539 };
540
541 class MidiOutAlsa : public MidiOutApi
542 {
543 public:
544 MidiOutAlsa(const std::string clientName);
545 ~MidiOutAlsa(void);
getCurrentApi(void)546 RtMidi::Api getCurrentApi(void) { return RtMidi::LINUX_ALSA; };
547 void openPort(unsigned int portNumber, const std::string portName);
548 void openVirtualPort(const std::string portName);
549 void closePort(void);
550 unsigned int getPortCount(void);
551 std::string getPortName(unsigned int portNumber);
552 void sendMessage(std::vector<unsigned char> *message);
553
554 protected:
555 void initialize(const std::string &clientName);
556 };
557
558 #endif
559
560 #if defined(__WINDOWS_MM__)
561
562 class MidiInWinMM : public MidiInApi
563 {
564 public:
565 MidiInWinMM(const std::string clientName, unsigned int queueSizeLimit);
566 ~MidiInWinMM(void);
getCurrentApi(void)567 RtMidi::Api getCurrentApi(void) { return RtMidi::WINDOWS_MM; };
568 void openPort(unsigned int portNumber, const std::string portName);
569 void openVirtualPort(const std::string portName);
570 void closePort(void);
571 unsigned int getPortCount(void);
572 std::string getPortName(unsigned int portNumber);
573
574 protected:
575 void initialize(const std::string &clientName);
576 };
577
578 class MidiOutWinMM : public MidiOutApi
579 {
580 public:
581 MidiOutWinMM(const std::string clientName);
582 ~MidiOutWinMM(void);
getCurrentApi(void)583 RtMidi::Api getCurrentApi(void) { return RtMidi::WINDOWS_MM; };
584 void openPort(unsigned int portNumber, const std::string portName);
585 void openVirtualPort(const std::string portName);
586 void closePort(void);
587 unsigned int getPortCount(void);
588 std::string getPortName(unsigned int portNumber);
589 void sendMessage(std::vector<unsigned char> *message);
590
591 protected:
592 void initialize(const std::string &clientName);
593 };
594
595 #endif
596
597 #if defined(__WINDOWS_KS__)
598
599 class MidiInWinKS : public MidiInApi
600 {
601 public:
602 MidiInWinKS(const std::string clientName, unsigned int queueSizeLimit);
603 ~MidiInWinKS(void);
getCurrentApi(void)604 RtMidi::Api getCurrentApi(void) { return RtMidi::WINDOWS_KS; };
605 void openPort(unsigned int portNumber, const std::string portName);
606 void openVirtualPort(const std::string portName);
607 void closePort(void);
608 unsigned int getPortCount(void);
609 std::string getPortName(unsigned int portNumber);
610
611 protected:
612 void initialize(const std::string &clientName);
613 };
614
615 class MidiOutWinKS : public MidiOutApi
616 {
617 public:
618 MidiOutWinKS(const std::string clientName);
619 ~MidiOutWinKS(void);
getCurrentApi(void)620 RtMidi::Api getCurrentApi(void) { return RtMidi::WINDOWS_KS; };
621 void openPort(unsigned int portNumber, const std::string portName);
622 void openVirtualPort(const std::string portName);
623 void closePort(void);
624 unsigned int getPortCount(void);
625 std::string getPortName(unsigned int portNumber);
626 void sendMessage(std::vector<unsigned char> *message);
627
628 protected:
629 void initialize(const std::string &clientName);
630 };
631
632 #endif
633
634 #if defined(__RTMIDI_DUMMY__)
635
636 class MidiInDummy : public MidiInApi
637 {
638 public:
MidiInDummy(const std::string clientName,unsigned int queueSizeLimit)639 MidiInDummy(const std::string clientName, unsigned int queueSizeLimit) : MidiInApi(queueSizeLimit)
640 {
641 errorString_ = "MidiInDummy: This class provides no functionality.";
642 RtMidi::error(RtError::WARNING, errorString_);
643 };
getCurrentApi(void)644 RtMidi::Api getCurrentApi(void) { return RtMidi::RTMIDI_DUMMY; };
openPort(unsigned int portNumber,const std::string portName)645 void openPort(unsigned int portNumber, const std::string portName){};
openVirtualPort(const std::string portName)646 void openVirtualPort(const std::string portName){};
closePort(void)647 void closePort(void){};
getPortCount(void)648 unsigned int getPortCount(void) { return 0; };
getPortName(unsigned int portNumber)649 std::string getPortName(unsigned int portNumber) { return ""; };
650
651 protected:
initialize(const std::string & clientName)652 void initialize(const std::string &clientName){};
653 };
654
655 class MidiOutDummy : public MidiOutApi
656 {
657 public:
MidiOutDummy(const std::string clientName)658 MidiOutDummy(const std::string clientName)
659 {
660 errorString_ = "MidiOutDummy: This class provides no functionality.";
661 RtMidi::error(RtError::WARNING, errorString_);
662 };
getCurrentApi(void)663 RtMidi::Api getCurrentApi(void) { return RtMidi::RTMIDI_DUMMY; };
openPort(unsigned int portNumber,const std::string portName)664 void openPort(unsigned int portNumber, const std::string portName){};
openVirtualPort(const std::string portName)665 void openVirtualPort(const std::string portName){};
closePort(void)666 void closePort(void){};
getPortCount(void)667 unsigned int getPortCount(void) { return 0; };
getPortName(unsigned int portNumber)668 std::string getPortName(unsigned int portNumber) { return ""; };
sendMessage(std::vector<unsigned char> * message)669 void sendMessage(std::vector<unsigned char> *message){};
670
671 protected:
initialize(const std::string & clientName)672 void initialize(const std::string &clientName){};
673 };
674
675 #endif
676
677 #endif