Files
stk/doc/html/classMessager.html
2013-09-29 23:41:50 +02:00

220 lines
14 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.4.4 -->
<h1>Messager Class Reference</h1><!-- doxytag: class="Messager" --><!-- doxytag: inherits="Stk" --><code>#include &lt;<a class="el" href="Messager_8h-source.html">Messager.h</a>&gt;</code>
<p>
<p>Inheritance diagram for Messager:
<p><center><img src="classMessager.png" usemap="#Messager_map" border="0" alt=""></center>
<map name="Messager_map">
<area href="classStk.html" alt="Stk" shape="rect" coords="0,0,68,24">
</map>
<a href="classMessager-members.html">List of all members.</a><hr><a name="_details"></a><h2>Detailed Description</h2>
STK input control message parser.
<p>
This class reads and parses control messages from a variety of sources, such as a scorefile, MIDI port, socket connection, or stdin. MIDI messages are retrieved using the <a class="el" href="classRtMidi.html">RtMidi</a> class. All other input sources (scorefile, socket, or stdin) are assumed to provide SKINI formatted messages. This class can be compiled with generic, non-realtime support, in which case only scorefile reading is possible.<p>
The various <em>realtime</em> message acquisition mechanisms (from MIDI, socket, or stdin) take place asynchronously, filling the message queue. A call to <a class="el" href="classMessager.html#a2">popMessage()</a> will pop the next available control message from the queue and return it via the referenced Message structure. When a <em>non-realtime</em> scorefile is set, it is not possible to start reading realtime input messages (from MIDI, socket, or stdin). Likewise, it is not possible to read from a scorefile when a realtime input mechanism is running.<p>
When MIDI input is started, input is also automatically read from stdin. This allows for program termination via the terminal window. An __SK_Exit_ message is pushed onto the stack whenever an "exit" or "Exit" message is received from stdin or when all socket connections close and no stdin thread is running.<p>
This class is primarily for use in STK example programs but it is generic enough to work in many other contexts.<p>
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
<p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a0"></a><!-- doxytag: member="Messager::Messager" ref="a0" args="()" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMessager.html#a0">Messager</a> ()</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Default constructor. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a1"></a><!-- doxytag: member="Messager::~Messager" ref="a1" args="()" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMessager.html#a1">~Messager</a> ()</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Class destructor. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMessager.html#a2">popMessage</a> (<a class="el" href="structSkini_1_1Message.html">Skini::Message</a> &amp;message)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Pop the next message from the queue and write it to the referenced message structure. <a href="#a2"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a3"></a><!-- doxytag: member="Messager::pushMessage" ref="a3" args="(Skini::Message &amp;message)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMessager.html#a3">pushMessage</a> (<a class="el" href="structSkini_1_1Message.html">Skini::Message</a> &amp;message)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Push the referenced message onto the message stack. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMessager.html#a4">setScoreFile</a> (const char *filename)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Specify a SKINI formatted scorefile from which messages should be read. <a href="#a4"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMessager.html#a5">startStdInput</a> ()</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Initiate the "realtime" retreival from stdin of control messages into the queue. <a href="#a5"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMessager.html#a6">startSocketInput</a> (int port=2001)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Start a socket server, accept connections, and read "realtime" control messages into the message queue. <a href="#a6"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMessager.html#a7">startMidiInput</a> (int port=0)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Start MIDI input, with optional device and port identifiers. <a href="#a7"></a><br></td></tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="a2"></a><!-- doxytag: member="Messager::popMessage" ref="a2" args="(Skini::Message &amp;message)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">void Messager::popMessage </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top"><a class="el" href="structSkini_1_1Message.html">Skini::Message</a> &amp;&nbsp;</td>
<td class="mdname1" valign="top" nowrap> <em>message</em> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Pop the next message from the queue and write it to the referenced message structure.
<p>
Invalid messages (or an empty queue) are indicated by type values of zero, in which case all other message structure values are undefined. The user MUST verify the returned message type is valid before reading other message values. </td>
</tr>
</table>
<a class="anchor" name="a4"></a><!-- doxytag: member="Messager::setScoreFile" ref="a4" args="(const char *filename)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">bool Messager::setScoreFile </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">const char *&nbsp;</td>
<td class="mdname1" valign="top" nowrap> <em>filename</em> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Specify a SKINI formatted scorefile from which messages should be read.
<p>
A return value of <code>true</code> indicates the call was successful. A return value of <code>false</code> can occur if the file is not found, cannot be opened, another file is currently still open, or if a realtime input mechanism is running. Scorefile input is considered to be a non-realtime control mechanism that cannot run concurrently with realtime input. </td>
</tr>
</table>
<a class="anchor" name="a5"></a><!-- doxytag: member="Messager::startStdInput" ref="a5" args="()" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">bool Messager::startStdInput </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Initiate the "realtime" retreival from stdin of control messages into the queue.
<p>
This function initiates a thread for asynchronous retrieval of SKINI formatted messages from stdin. A return value of <code>true</code> indicates the call was successful. A return value of <code>false</code> can occur if a scorefile is being read, a stdin thread is already running, or a thread error occurs during startup. Stdin input is considered to be a realtime control mechanism that cannot run concurrently with non-realtime scorefile input. </td>
</tr>
</table>
<a class="anchor" name="a6"></a><!-- doxytag: member="Messager::startSocketInput" ref="a6" args="(int port=2001)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">bool Messager::startSocketInput </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">int&nbsp;</td>
<td class="mdname1" valign="top" nowrap> <em>port</em> = <code>2001</code> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Start a socket server, accept connections, and read "realtime" control messages into the message queue.
<p>
This function creates a socket server on the optional port (default = 2001) and starts a thread for asynchronous retrieval of SKINI formatted messages from socket connections. A return value of <code>true</code> indicates the call was successful. A return value of <code>false</code> can occur if a scorefile is being read, a socket thread is already running, or an error occurs during the socket server or thread initialization stages. <a class="el" href="classSocket.html">Socket</a> input is considered to be a realtime control mechanism that cannot run concurrently with non-realtime scorefile input. </td>
</tr>
</table>
<a class="anchor" name="a7"></a><!-- doxytag: member="Messager::startMidiInput" ref="a7" args="(int port=0)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">bool Messager::startMidiInput </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">int&nbsp;</td>
<td class="mdname1" valign="top" nowrap> <em>port</em> = <code>0</code> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Start MIDI input, with optional device and port identifiers.
<p>
This function creates an <a class="el" href="classRtMidiIn.html">RtMidiIn</a> instance for MIDI input. The <a class="el" href="classRtMidiIn.html">RtMidiIn</a> class invokes a local callback function to read incoming messages into the queue. If <code>port</code> = -1, <a class="el" href="classRtMidiIn.html">RtMidiIn</a> will open a virtual port to which other software applications can connect (OS X and Linux only). A return value of <code>true</code> indicates the call was successful. A return value of <code>false</code> can occur if a scorefile is being read, MIDI input is already running, or an error occurs during <a class="el" href="classRtMidiIn.html">RtMidiIn</a> construction. Midi input is considered to be a realtime control mechanism that cannot run concurrently with non-realtime scorefile input. </td>
</tr>
</table>
<hr>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="Messager_8h-source.html">Messager.h</a></ul>
<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-2007 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
</table>
</BODY>
</HTML>