Files
stk/doc/html/classRtMidiIn.html
2013-09-29 23:48:48 +02:00

310 lines
19 KiB
HTML

<HTML>
<HEAD>
<TITLE>The Synthesis ToolKit in C++ (STK)</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<img src="princeton.gif"> &nbsp; <img src="ccrma.gif"> &nbsp; <img src="mcgill.gif"><P>
<a class="qindex" href="index.html">Home</a> &nbsp; <a class="qindex" href="information.html">Information</a> &nbsp; <a class="qindex" href="classes.html">Classes</a> &nbsp; <a class="qindex" href="download.html">Download</a> &nbsp; <a class="qindex" href="usage.html">Usage</a> &nbsp; <a class="qindex" href="maillist.html">Mail List</a> &nbsp; <a class="qindex" href="system.html">Requirements</a> &nbsp; <a class="qindex" href="links.html">Links</a> &nbsp; <a class="qindex" href="faq.html">FAQ</a> &nbsp; <a class="qindex" href="tutorial.html">Tutorial</a></CENTER>
<HR>
<!-- Generated by Doxygen 1.6.2 -->
<div class="contents">
<h1>RtMidiIn Class Reference</h1><!-- doxytag: class="RtMidiIn" --><!-- doxytag: inherits="RtMidi" -->
<p>A realtime MIDI input class.
<a href="#_details">More...</a></p>
<p><code>#include &lt;<a class="el" href="RtMidi_8h_source.html">RtMidi.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for RtMidiIn:</div>
<div class="dynsection">
<div class="center">
<img src="classRtMidiIn.png" usemap="#RtMidiIn_map" alt=""/>
<map id="RtMidiIn_map" name="RtMidiIn_map">
<area href="classRtMidi.html" alt="RtMidi" shape="rect" coords="0,0,57,24"/>
</map>
</div>
</div>
<p><a href="classRtMidiIn-members.html">List of all members.</a></p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Public Types</h2></td></tr>
<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)" -->
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>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">User callback function type definition. <br/></td></tr>
<tr><td colspan="2"><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtMidiIn.html#a31abb996e5fdc4a8f9dc5a50848e2ee5">RtMidiIn</a> (const std::string clientName=std::string(&quot;RtMidi Input Client&quot;))</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Default constructor that allows an optional client name. <a href="#a31abb996e5fdc4a8f9dc5a50848e2ee5"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="af865d88c154b6fdadc640da5dc278d40"></a><!-- doxytag: member="RtMidiIn::~RtMidiIn" ref="af865d88c154b6fdadc640da5dc278d40" args="()" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtMidiIn.html#af865d88c154b6fdadc640da5dc278d40">~RtMidiIn</a> ()</td></tr>
<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>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtMidiIn.html#a7e853661b1056083e07318d67c51f6fd">openPort</a> (unsigned int portNumber=0, const std::string Portname=std::string(&quot;RtMidi Input&quot;))</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Open a MIDI input connection. <a href="#a7e853661b1056083e07318d67c51f6fd"></a><br/></td></tr>
<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>
<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>
<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>
<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>
<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>
<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>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a55bacf0d228fd8e3be6a79d12fd1dc39"></a><!-- doxytag: member="RtMidiIn::closePort" ref="a55bacf0d228fd8e3be6a79d12fd1dc39" args="(void)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtMidiIn.html#a55bacf0d228fd8e3be6a79d12fd1dc39">closePort</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Close an open MIDI connection (if one exists). <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a62b1b38aa8e5f11cd66f03d59228f4e4"></a><!-- doxytag: member="RtMidiIn::getPortCount" ref="a62b1b38aa8e5f11cd66f03d59228f4e4" args="()" -->
unsigned int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtMidiIn.html#a62b1b38aa8e5f11cd66f03d59228f4e4">getPortCount</a> ()</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the number of available MIDI input ports. <br/></td></tr>
<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>
<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>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtMidiIn.html#a2e15868916737039e0a34d47bffdf188">setQueueSizeLimit</a> (unsigned int queueSize)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set the maximum number of MIDI messages to be saved in the queue. <a href="#a2e15868916737039e0a34d47bffdf188"></a><br/></td></tr>
<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>
<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>
<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>
<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>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>A realtime MIDI input class. </p>
<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>
<p>by Gary P. Scavone, 2003-2008. </p>
<hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a31abb996e5fdc4a8f9dc5a50848e2ee5"></a><!-- doxytag: member="RtMidiIn::RtMidiIn" ref="a31abb996e5fdc4a8f9dc5a50848e2ee5" args="(const std::string clientName=std::string(&quot;RtMidi Input Client&quot;))" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">RtMidiIn::RtMidiIn </td>
<td>(</td>
<td class="paramtype">const std::string&nbsp;</td>
<td class="paramname"> <em>clientName</em> = <code>std::string(&quot;RtMidi&nbsp;Input&nbsp;Client&quot;)</code></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Default constructor that allows an optional client name. </p>
<p>An exception will be thrown if a MIDI system initialization error occurs. </p>
</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a7e853661b1056083e07318d67c51f6fd"></a><!-- doxytag: member="RtMidiIn::openPort" ref="a7e853661b1056083e07318d67c51f6fd" args="(unsigned int portNumber=0, const std::string Portname=std::string(&quot;RtMidi Input&quot;))" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void RtMidiIn::openPort </td>
<td>(</td>
<td class="paramtype">unsigned int&nbsp;</td>
<td class="paramname"> <em>portNumber</em> = <code>0</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::string&nbsp;</td>
<td class="paramname"> <em>Portname</em> = <code>std::string(&quot;RtMidi&nbsp;Input&quot;)</code></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td><code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Open a MIDI input connection. </p>
<p>An optional port number greater than 0 can be specified. Otherwise, the default or first port found is opened. </p>
<p>Implements <a class="el" href="classRtMidi.html#ad9e30a89638f93193cb40edebaa536f5">RtMidi</a>.</p>
</div>
</div>
<a class="anchor" id="a245261b3f12ce727faed18fcfeef18c2"></a><!-- doxytag: member="RtMidiIn::openVirtualPort" ref="a245261b3f12ce727faed18fcfeef18c2" args="(const std::string portName=std::string(&quot;RtMidi Input&quot;))" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void RtMidiIn::openVirtualPort </td>
<td>(</td>
<td class="paramtype">const std::string&nbsp;</td>
<td class="paramname"> <em>portName</em> = <code>std::string(&quot;RtMidi&nbsp;Input&quot;)</code></td>
<td>&nbsp;)&nbsp;</td>
<td><code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Create a virtual input port, with optional name, to allow software connections (OS X and ALSA only). </p>
<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>
<p>Implements <a class="el" href="classRtMidi.html#a9200cde4f5337c0bc421d20bd4fcf654">RtMidi</a>.</p>
</div>
</div>
<a class="anchor" id="a7590563461c7467608a4b3806406b32d"></a><!-- doxytag: member="RtMidiIn::setCallback" ref="a7590563461c7467608a4b3806406b32d" args="(RtMidiCallback callback, void *userData=0)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void RtMidiIn::setCallback </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classRtMidiIn.html#a297d2eb3c3420b437970a6fc59d89cbf">RtMidiCallback</a>&nbsp;</td>
<td class="paramname"> <em>callback</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>userData</em> = <code>0</code></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Set a callback function to be invoked for incoming MIDI messages. </p>
<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>
</div>
</div>
<a class="anchor" id="ade23832a66c1ed56965c26325602543e"></a><!-- doxytag: member="RtMidiIn::cancelCallback" ref="ade23832a66c1ed56965c26325602543e" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void RtMidiIn::cancelCallback </td>
<td>(</td>
<td class="paramname"></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Cancel use of the current callback function (if one exists). </p>
<p>Subsequent incoming MIDI messages will be written to the queue and can be retrieved with the <em>getMessage</em> function. </p>
</div>
</div>
<a class="anchor" id="af2961fff09fa01a3d5bc0f0c5a042aaf"></a><!-- doxytag: member="RtMidiIn::getPortName" ref="af2961fff09fa01a3d5bc0f0c5a042aaf" args="(unsigned int portNumber=0)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">std::string RtMidiIn::getPortName </td>
<td>(</td>
<td class="paramtype">unsigned int&nbsp;</td>
<td class="paramname"> <em>portNumber</em> = <code>0</code></td>
<td>&nbsp;)&nbsp;</td>
<td><code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Return a string identifier for the specified MIDI input port number. </p>
<p>An exception is thrown if an invalid port specifier is provided. </p>
<p>Implements <a class="el" href="classRtMidi.html#a799e2b9f4df39b298518f2b394db3391">RtMidi</a>.</p>
</div>
</div>
<a class="anchor" id="a2e15868916737039e0a34d47bffdf188"></a><!-- doxytag: member="RtMidiIn::setQueueSizeLimit" ref="a2e15868916737039e0a34d47bffdf188" args="(unsigned int queueSize)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void RtMidiIn::setQueueSizeLimit </td>
<td>(</td>
<td class="paramtype">unsigned int&nbsp;</td>
<td class="paramname"> <em>queueSize</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Set the maximum number of MIDI messages to be saved in the queue. </p>
<p>If the queue size limit is reached, incoming messages will be ignored. The default limit is 1024. </p>
</div>
</div>
<a class="anchor" id="af9507125aaa42276ccc01df576fc3533"></a><!-- doxytag: member="RtMidiIn::ignoreTypes" ref="af9507125aaa42276ccc01df576fc3533" args="(bool midiSysex=true, bool midiTime=true, bool midiSense=true)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void RtMidiIn::ignoreTypes </td>
<td>(</td>
<td class="paramtype">bool&nbsp;</td>
<td class="paramname"> <em>midiSysex</em> = <code>true</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool&nbsp;</td>
<td class="paramname"> <em>midiTime</em> = <code>true</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool&nbsp;</td>
<td class="paramname"> <em>midiSense</em> = <code>true</code></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Specify whether certain MIDI message types should be queued or ignored during input. </p>
<p>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>
</div>
</div>
<a class="anchor" id="a1ba10ecd276b30a8579c7d60a9c890eb"></a><!-- doxytag: member="RtMidiIn::getMessage" ref="a1ba10ecd276b30a8579c7d60a9c890eb" args="(std::vector&lt; unsigned char &gt; *message)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">double RtMidiIn::getMessage </td>
<td>(</td>
<td class="paramtype">std::vector&lt; unsigned char &gt; *&nbsp;</td>
<td class="paramname"> <em>message</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<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>
<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>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="RtMidi_8h_source.html">RtMidi.h</a></li>
</ul>
</div>
<HR>
<table>
<tr><td><A HREF="http://ccrma.stanford.edu/software/stk/"><I>The Synthesis ToolKit in C++ (STK)</I></A></td></tr>
<tr><td>&copy;1995-2010 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
</table>
</BODY>
</HTML>