Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

classRtMidiIn.html 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <HTML>
  2. <HEAD>
  3. <TITLE>The RtMidi Tutorial</TITLE>
  4. <LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
  5. </HEAD>
  6. <BODY BGCOLOR="#FFFFFF">
  7. <CENTER>
  8. <a class="qindex" href="index.html">Tutorial</a> &nbsp; <a class="qindex" href="annotated.html">Class/Enum List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </CENTER>
  9. <HR>
  10. <!-- Generated by Doxygen 1.6.2 -->
  11. <div class="contents">
  12. <h1>RtMidiIn Class Reference</h1><!-- doxytag: class="RtMidiIn" --><!-- doxytag: inherits="RtMidi" -->
  13. <p>A realtime MIDI input class.
  14. <a href="#_details">More...</a></p>
  15. <p><code>#include &lt;<a class="el" href="RtMidi_8h_source.html">RtMidi.h</a>&gt;</code></p>
  16. <div class="dynheader">
  17. Inheritance diagram for RtMidiIn:</div>
  18. <div class="dynsection">
  19. <div class="center">
  20. <img src="classRtMidiIn.png" usemap="#RtMidiIn_map" alt=""/>
  21. <map id="RtMidiIn_map" name="RtMidiIn_map">
  22. <area href="classRtMidi.html" alt="RtMidi" shape="rect" coords="0,0,57,24"/>
  23. </map>
  24. </div>
  25. </div>
  26. <p><a href="classRtMidiIn-members.html">List of all members.</a></p>
  27. <table border="0" cellpadding="0" cellspacing="0">
  28. <tr><td colspan="2"><h2>Public Types</h2></td></tr>
  29. <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a297d2eb3c3420b437970a6fc59d89cbf"></a><!-- doxytag: member="RtMidiIn::RtMidiCallback" ref="a297d2eb3c3420b437970a6fc59d89cbf" args=")(double timeStamp, std::vector&lt; unsigned char &gt; *message, void *userData)" -->
  30. typedef void(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtMidiIn.html#a297d2eb3c3420b437970a6fc59d89cbf">RtMidiCallback</a> )(double timeStamp, std::vector&lt; unsigned char &gt; *message, void *userData)</td></tr>
  31. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">User callback function type definition. <br/></td></tr>
  32. <tr><td colspan="2"><h2>Public Member Functions</h2></td></tr>
  33. <tr><td class="memItemLeft" align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtMidiIn.html#aeeaeed8dae387dffc70e73e6e88b4d1a">RtMidiIn</a> (<a class="el" href="classRtMidi.html#aac66af04a85fe5c5f07c360574a19406">RtMidi::Api</a> api=UNSPECIFIED, const std::string clientName=std::string(&quot;RtMidi Input Client&quot;), unsigned int queueSizeLimit=100)</td></tr>
  34. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Default constructor that allows an optional api, client name and queue size. <a href="#aeeaeed8dae387dffc70e73e6e88b4d1a"></a><br/></td></tr>
  35. <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae79f4da8a1b2e7efecdd1047670b27dc"></a><!-- doxytag: member="RtMidiIn::~RtMidiIn" ref="ae79f4da8a1b2e7efecdd1047670b27dc" args="(void)" -->
  36. &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtMidiIn.html#ae79f4da8a1b2e7efecdd1047670b27dc">~RtMidiIn</a> (void) throw ()</td></tr>
  37. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">If a MIDI connection is still open, it will be closed by the destructor. <br/></td></tr>
  38. <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a6475a11eeb0c8bf22157c3887b100164"></a><!-- doxytag: member="RtMidiIn::getCurrentApi" ref="a6475a11eeb0c8bf22157c3887b100164" args="(void)" -->
  39. <a class="el" href="classRtMidi.html#aac66af04a85fe5c5f07c360574a19406">RtMidi::Api</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtMidiIn.html#a6475a11eeb0c8bf22157c3887b100164">getCurrentApi</a> (void) throw ()</td></tr>
  40. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns the MIDI API specifier for the current instance of <a class="el" href="classRtMidiIn.html" title="A realtime MIDI input class.">RtMidiIn</a>. <br/></td></tr>
  41. <tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtMidiIn.html#a39df8f81a22f729a9904707dde487d2c">openPort</a> (unsigned int portNumber=0, const std::string portName=std::string(&quot;RtMidi Input&quot;))</td></tr>
  42. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Open a MIDI input connection. <a href="#a39df8f81a22f729a9904707dde487d2c"></a><br/></td></tr>
  43. <tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtMidiIn.html#a245261b3f12ce727faed18fcfeef18c2">openVirtualPort</a> (const std::string portName=std::string(&quot;RtMidi Input&quot;))</td></tr>
  44. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create a virtual input port, with optional name, to allow software connections (OS X and ALSA only). <a href="#a245261b3f12ce727faed18fcfeef18c2"></a><br/></td></tr>
  45. <tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtMidiIn.html#a7590563461c7467608a4b3806406b32d">setCallback</a> (<a class="el" href="classRtMidiIn.html#a297d2eb3c3420b437970a6fc59d89cbf">RtMidiCallback</a> callback, void *userData=0)</td></tr>
  46. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set a callback function to be invoked for incoming MIDI messages. <a href="#a7590563461c7467608a4b3806406b32d"></a><br/></td></tr>
  47. <tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtMidiIn.html#ade23832a66c1ed56965c26325602543e">cancelCallback</a> ()</td></tr>
  48. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Cancel use of the current callback function (if one exists). <a href="#ade23832a66c1ed56965c26325602543e"></a><br/></td></tr>
  49. <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a55bacf0d228fd8e3be6a79d12fd1dc39"></a><!-- doxytag: member="RtMidiIn::closePort" ref="a55bacf0d228fd8e3be6a79d12fd1dc39" args="(void)" -->
  50. void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtMidiIn.html#a55bacf0d228fd8e3be6a79d12fd1dc39">closePort</a> (void)</td></tr>
  51. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Close an open MIDI connection (if one exists). <br/></td></tr>
  52. <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a62b1b38aa8e5f11cd66f03d59228f4e4"></a><!-- doxytag: member="RtMidiIn::getPortCount" ref="a62b1b38aa8e5f11cd66f03d59228f4e4" args="()" -->
  53. unsigned int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtMidiIn.html#a62b1b38aa8e5f11cd66f03d59228f4e4">getPortCount</a> ()</td></tr>
  54. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the number of available MIDI input ports. <br/></td></tr>
  55. <tr><td class="memItemLeft" align="right" valign="top">std::string&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtMidiIn.html#af2961fff09fa01a3d5bc0f0c5a042aaf">getPortName</a> (unsigned int portNumber=0)</td></tr>
  56. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return a string identifier for the specified MIDI input port number. <a href="#af2961fff09fa01a3d5bc0f0c5a042aaf"></a><br/></td></tr>
  57. <tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtMidiIn.html#af9507125aaa42276ccc01df576fc3533">ignoreTypes</a> (bool midiSysex=true, bool midiTime=true, bool midiSense=true)</td></tr>
  58. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Specify whether certain MIDI message types should be queued or ignored during input. <a href="#af9507125aaa42276ccc01df576fc3533"></a><br/></td></tr>
  59. <tr><td class="memItemLeft" align="right" valign="top">double&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtMidiIn.html#a1ba10ecd276b30a8579c7d60a9c890eb">getMessage</a> (std::vector&lt; unsigned char &gt; *message)</td></tr>
  60. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">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. <a href="#a1ba10ecd276b30a8579c7d60a9c890eb"></a><br/></td></tr>
  61. </table>
  62. <hr/><a name="_details"></a><h2>Detailed Description</h2>
  63. <p>A realtime MIDI input class. </p>
  64. <p>This class provides a common, platform-independent API for realtime MIDI input. It allows access to a single MIDI input port. Incoming MIDI messages are either saved to a queue for retrieval using the <a class="el" href="classRtMidiIn.html#a1ba10ecd276b30a8579c7d60a9c890eb" title="Fill the user-provided vector with the data bytes for the next available MIDI message...">getMessage()</a> function or immediately passed to a user-specified callback function. Create multiple instances of this class to connect to more than one MIDI device at the same time. With the OS-X and Linux ALSA MIDI APIs, it is also possible to open a virtual input port to which other MIDI software clients can connect.</p>
  65. <p>by Gary P. Scavone, 2003-2012. </p>
  66. <hr/><h2>Constructor &amp; Destructor Documentation</h2>
  67. <a class="anchor" id="aeeaeed8dae387dffc70e73e6e88b4d1a"></a><!-- doxytag: member="RtMidiIn::RtMidiIn" ref="aeeaeed8dae387dffc70e73e6e88b4d1a" args="(RtMidi::Api api=UNSPECIFIED, const std::string clientName=std::string(&quot;RtMidi Input Client&quot;), unsigned int queueSizeLimit=100)" -->
  68. <div class="memitem">
  69. <div class="memproto">
  70. <table class="memname">
  71. <tr>
  72. <td class="memname">RtMidiIn::RtMidiIn </td>
  73. <td>(</td>
  74. <td class="paramtype"><a class="el" href="classRtMidi.html#aac66af04a85fe5c5f07c360574a19406">RtMidi::Api</a>&nbsp;</td>
  75. <td class="paramname"> <em>api</em> = <code>UNSPECIFIED</code>, </td>
  76. </tr>
  77. <tr>
  78. <td class="paramkey"></td>
  79. <td></td>
  80. <td class="paramtype">const std::string&nbsp;</td>
  81. <td class="paramname"> <em>clientName</em> = <code>std::string(&quot;RtMidi&nbsp;Input&nbsp;Client&quot;)</code>, </td>
  82. </tr>
  83. <tr>
  84. <td class="paramkey"></td>
  85. <td></td>
  86. <td class="paramtype">unsigned int&nbsp;</td>
  87. <td class="paramname"> <em>queueSizeLimit</em> = <code>100</code></td><td>&nbsp;</td>
  88. </tr>
  89. <tr>
  90. <td></td>
  91. <td>)</td>
  92. <td></td><td></td><td></td>
  93. </tr>
  94. </table>
  95. </div>
  96. <div class="memdoc">
  97. <p>Default constructor that allows an optional api, client name and queue size. </p>
  98. <p>An exception will be thrown if a MIDI system initialization error occurs. The queue size defines the maximum number of messages that can be held in the MIDI queue (when not using a callback function). If the queue size limit is reached, incoming messages will be ignored.</p>
  99. <p>If no API argument is specified and multiple API support has been compiled, the default order of use is JACK, ALSA (Linux) and CORE, Jack (OS-X). </p>
  100. </div>
  101. </div>
  102. <hr/><h2>Member Function Documentation</h2>
  103. <a class="anchor" id="a39df8f81a22f729a9904707dde487d2c"></a><!-- doxytag: member="RtMidiIn::openPort" ref="a39df8f81a22f729a9904707dde487d2c" args="(unsigned int portNumber=0, const std::string portName=std::string(&quot;RtMidi Input&quot;))" -->
  104. <div class="memitem">
  105. <div class="memproto">
  106. <table class="memname">
  107. <tr>
  108. <td class="memname">void RtMidiIn::openPort </td>
  109. <td>(</td>
  110. <td class="paramtype">unsigned int&nbsp;</td>
  111. <td class="paramname"> <em>portNumber</em> = <code>0</code>, </td>
  112. </tr>
  113. <tr>
  114. <td class="paramkey"></td>
  115. <td></td>
  116. <td class="paramtype">const std::string&nbsp;</td>
  117. <td class="paramname"> <em>portName</em> = <code>std::string(&nbsp;&quot;RtMidi&nbsp;Input&quot;&nbsp;)</code></td><td>&nbsp;</td>
  118. </tr>
  119. <tr>
  120. <td></td>
  121. <td>)</td>
  122. <td></td><td></td><td><code> [inline, virtual]</code></td>
  123. </tr>
  124. </table>
  125. </div>
  126. <div class="memdoc">
  127. <p>Open a MIDI input connection. </p>
  128. <p>An optional port number greater than 0 can be specified. Otherwise, the default or first port found is opened. </p>
  129. <p>Implements <a class="el" href="classRtMidi.html#ad9e30a89638f93193cb40edebaa536f5">RtMidi</a>.</p>
  130. </div>
  131. </div>
  132. <a class="anchor" id="a245261b3f12ce727faed18fcfeef18c2"></a><!-- doxytag: member="RtMidiIn::openVirtualPort" ref="a245261b3f12ce727faed18fcfeef18c2" args="(const std::string portName=std::string(&quot;RtMidi Input&quot;))" -->
  133. <div class="memitem">
  134. <div class="memproto">
  135. <table class="memname">
  136. <tr>
  137. <td class="memname">void RtMidiIn::openVirtualPort </td>
  138. <td>(</td>
  139. <td class="paramtype">const std::string&nbsp;</td>
  140. <td class="paramname"> <em>portName</em> = <code>std::string(&nbsp;&quot;RtMidi&nbsp;Input&quot;&nbsp;)</code></td>
  141. <td>&nbsp;)&nbsp;</td>
  142. <td><code> [inline, virtual]</code></td>
  143. </tr>
  144. </table>
  145. </div>
  146. <div class="memdoc">
  147. <p>Create a virtual input port, with optional name, to allow software connections (OS X and ALSA only). </p>
  148. <p>This function creates a virtual MIDI input port to which other software applications can connect. This type of functionality is currently only supported by the Macintosh OS-X and Linux ALSA APIs (the function does nothing for the other APIs). </p>
  149. <p>Implements <a class="el" href="classRtMidi.html#a9200cde4f5337c0bc421d20bd4fcf654">RtMidi</a>.</p>
  150. </div>
  151. </div>
  152. <a class="anchor" id="a7590563461c7467608a4b3806406b32d"></a><!-- doxytag: member="RtMidiIn::setCallback" ref="a7590563461c7467608a4b3806406b32d" args="(RtMidiCallback callback, void *userData=0)" -->
  153. <div class="memitem">
  154. <div class="memproto">
  155. <table class="memname">
  156. <tr>
  157. <td class="memname">void RtMidiIn::setCallback </td>
  158. <td>(</td>
  159. <td class="paramtype"><a class="el" href="classRtMidiIn.html#a297d2eb3c3420b437970a6fc59d89cbf">RtMidiCallback</a>&nbsp;</td>
  160. <td class="paramname"> <em>callback</em>, </td>
  161. </tr>
  162. <tr>
  163. <td class="paramkey"></td>
  164. <td></td>
  165. <td class="paramtype">void *&nbsp;</td>
  166. <td class="paramname"> <em>userData</em> = <code>0</code></td><td>&nbsp;</td>
  167. </tr>
  168. <tr>
  169. <td></td>
  170. <td>)</td>
  171. <td></td><td></td><td><code> [inline]</code></td>
  172. </tr>
  173. </table>
  174. </div>
  175. <div class="memdoc">
  176. <p>Set a callback function to be invoked for incoming MIDI messages. </p>
  177. <p>The callback function will be called whenever an incoming MIDI message is received. While not absolutely necessary, it is best to set the callback function before opening a MIDI port to avoid leaving some messages in the queue. </p>
  178. </div>
  179. </div>
  180. <a class="anchor" id="ade23832a66c1ed56965c26325602543e"></a><!-- doxytag: member="RtMidiIn::cancelCallback" ref="ade23832a66c1ed56965c26325602543e" args="()" -->
  181. <div class="memitem">
  182. <div class="memproto">
  183. <table class="memname">
  184. <tr>
  185. <td class="memname">void RtMidiIn::cancelCallback </td>
  186. <td>(</td>
  187. <td class="paramtype">void&nbsp;</td>
  188. <td class="paramname"></td>
  189. <td>&nbsp;)&nbsp;</td>
  190. <td><code> [inline]</code></td>
  191. </tr>
  192. </table>
  193. </div>
  194. <div class="memdoc">
  195. <p>Cancel use of the current callback function (if one exists). </p>
  196. <p>Subsequent incoming MIDI messages will be written to the queue and can be retrieved with the <em>getMessage</em> function. </p>
  197. </div>
  198. </div>
  199. <a class="anchor" id="af2961fff09fa01a3d5bc0f0c5a042aaf"></a><!-- doxytag: member="RtMidiIn::getPortName" ref="af2961fff09fa01a3d5bc0f0c5a042aaf" args="(unsigned int portNumber=0)" -->
  200. <div class="memitem">
  201. <div class="memproto">
  202. <table class="memname">
  203. <tr>
  204. <td class="memname">std::string RtMidiIn::getPortName </td>
  205. <td>(</td>
  206. <td class="paramtype">unsigned int&nbsp;</td>
  207. <td class="paramname"> <em>portNumber</em> = <code>0</code></td>
  208. <td>&nbsp;)&nbsp;</td>
  209. <td><code> [inline, virtual]</code></td>
  210. </tr>
  211. </table>
  212. </div>
  213. <div class="memdoc">
  214. <p>Return a string identifier for the specified MIDI input port number. </p>
  215. <p>An empty string is returned if an invalid port specifier is provided. </p>
  216. <p>Implements <a class="el" href="classRtMidi.html#a799e2b9f4df39b298518f2b394db3391">RtMidi</a>.</p>
  217. </div>
  218. </div>
  219. <a class="anchor" id="af9507125aaa42276ccc01df576fc3533"></a><!-- doxytag: member="RtMidiIn::ignoreTypes" ref="af9507125aaa42276ccc01df576fc3533" args="(bool midiSysex=true, bool midiTime=true, bool midiSense=true)" -->
  220. <div class="memitem">
  221. <div class="memproto">
  222. <table class="memname">
  223. <tr>
  224. <td class="memname">void RtMidiIn::ignoreTypes </td>
  225. <td>(</td>
  226. <td class="paramtype">bool&nbsp;</td>
  227. <td class="paramname"> <em>midiSysex</em> = <code>true</code>, </td>
  228. </tr>
  229. <tr>
  230. <td class="paramkey"></td>
  231. <td></td>
  232. <td class="paramtype">bool&nbsp;</td>
  233. <td class="paramname"> <em>midiTime</em> = <code>true</code>, </td>
  234. </tr>
  235. <tr>
  236. <td class="paramkey"></td>
  237. <td></td>
  238. <td class="paramtype">bool&nbsp;</td>
  239. <td class="paramname"> <em>midiSense</em> = <code>true</code></td><td>&nbsp;</td>
  240. </tr>
  241. <tr>
  242. <td></td>
  243. <td>)</td>
  244. <td></td><td></td><td><code> [inline]</code></td>
  245. </tr>
  246. </table>
  247. </div>
  248. <div class="memdoc">
  249. <p>Specify whether certain MIDI message types should be queued or ignored during input. </p>
  250. <p>o By default, MIDI timing and active sensing messages are ignored during message input because of their relative high data rates. MIDI sysex messages are ignored by default as well. Variable values of "true" imply that the respective message type will be ignored. </p>
  251. </div>
  252. </div>
  253. <a class="anchor" id="a1ba10ecd276b30a8579c7d60a9c890eb"></a><!-- doxytag: member="RtMidiIn::getMessage" ref="a1ba10ecd276b30a8579c7d60a9c890eb" args="(std::vector&lt; unsigned char &gt; *message)" -->
  254. <div class="memitem">
  255. <div class="memproto">
  256. <table class="memname">
  257. <tr>
  258. <td class="memname">double RtMidiIn::getMessage </td>
  259. <td>(</td>
  260. <td class="paramtype">std::vector&lt; unsigned char &gt; *&nbsp;</td>
  261. <td class="paramname"> <em>message</em></td>
  262. <td>&nbsp;)&nbsp;</td>
  263. <td><code> [inline]</code></td>
  264. </tr>
  265. </table>
  266. </div>
  267. <div class="memdoc">
  268. <p>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. </p>
  269. <p>This function returns immediately whether a new message is available or not. A valid message is indicated by a non-zero vector size. An exception is thrown if an error occurs during message retrieval or an input connection was not previously established. </p>
  270. </div>
  271. </div>
  272. <hr/>The documentation for this class was generated from the following file:<ul>
  273. <li><a class="el" href="RtMidi_8h_source.html">RtMidi.h</a></li>
  274. </ul>
  275. </div>
  276. <HR>
  277. <table><tr><td><img src="../images/mcgill.gif" width=165></td>
  278. <td>&copy;2003-2012 Gary P. Scavone, McGill University. All Rights Reserved.<br>
  279. Maintained by Gary P. Scavone, gary at music.mcgill.ca</td></tr>
  280. </table>
  281. </BODY>
  282. </HTML>