Files
stk/doc/html/classstk_1_1MidiFileIn.html
2013-09-29 23:44:33 +02:00

232 lines
15 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.5.8 -->
<div class="navpath"><a class="el" href="namespacestk.html">stk</a>::<a class="el" href="classstk_1_1MidiFileIn.html">MidiFileIn</a>
</div>
<div class="contents">
<h1>stk::MidiFileIn Class Reference</h1><!-- doxytag: class="stk::MidiFileIn" --><!-- doxytag: inherits="stk::Stk" -->A standard MIDI file reading/parsing class.
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="MidiFileIn_8h-source.html">MidiFileIn.h</a>&gt;</code>
<p>
<div class="dynheader">
Inheritance diagram for stk::MidiFileIn:</div>
<div class="dynsection">
<p><center><img src="classstk_1_1MidiFileIn.png" usemap="#stk::MidiFileIn_map" border="0" alt=""></center>
<map name="stk::MidiFileIn_map">
<area href="classstk_1_1Stk.html" alt="stk::Stk" shape="rect" coords="0,0,88,24">
</map>
</div>
<p>
<a href="classstk_1_1MidiFileIn-members.html">List of all members.</a><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">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1MidiFileIn.html#d273dc7c13d4c4a4ced893af93d9176e">MidiFileIn</a> (std::string fileName)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Default constructor. <a href="#d273dc7c13d4c4a4ced893af93d9176e"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="857246dbaf234cc9d68709afea6d0141"></a><!-- doxytag: member="stk::MidiFileIn::~MidiFileIn" ref="857246dbaf234cc9d68709afea6d0141" args="()" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1MidiFileIn.html#857246dbaf234cc9d68709afea6d0141">~MidiFileIn</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"><a class="anchor" name="c93b16c4de0ed3d98d31a2edb92bc105"></a><!-- doxytag: member="stk::MidiFileIn::getFileFormat" ref="c93b16c4de0ed3d98d31a2edb92bc105" args="() const " -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1MidiFileIn.html#c93b16c4de0ed3d98d31a2edb92bc105">getFileFormat</a> () const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the MIDI file format (0, 1, or 2). <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="7db7e6b2f6c1aedfbb78045106d36b17"></a><!-- doxytag: member="stk::MidiFileIn::getNumberOfTracks" ref="7db7e6b2f6c1aedfbb78045106d36b17" args="() const " -->
unsigned int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1MidiFileIn.html#7db7e6b2f6c1aedfbb78045106d36b17">getNumberOfTracks</a> () const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the number of tracks in the MIDI file. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1MidiFileIn.html#43bc34a26e72f3311b855139a1408f78">getDivision</a> () const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the MIDI file division value from the file header. <a href="#43bc34a26e72f3311b855139a1408f78"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1MidiFileIn.html#3bd547e3ee5bb8ad780274d7a09f12ff">rewindTrack</a> (unsigned int track=0)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Move the specified track event reader to the beginning of its track. <a href="#3bd547e3ee5bb8ad780274d7a09f12ff"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">double&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1MidiFileIn.html#92508a5847e45a05a3ff05de3e5d3efe">getTickSeconds</a> (unsigned int track=0)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get the current value, in seconds, of delta-time ticks for the specified track. <a href="#92508a5847e45a05a3ff05de3e5d3efe"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">unsigned long&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1MidiFileIn.html#117dd19afbc42d6c769d959588f9176b">getNextEvent</a> (std::vector&lt; unsigned char &gt; *event, unsigned int track=0)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Fill the user-provided vector with the next event in the specified track and return the event delta-time in ticks. <a href="#117dd19afbc42d6c769d959588f9176b"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">unsigned long&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1MidiFileIn.html#b10ea0e225484fa2d31796f505d4e582">getNextMidiEvent</a> (std::vector&lt; unsigned char &gt; *midiEvent, unsigned int track=0)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Fill the user-provided vector with the next MIDI channel event in the specified track and return the event delta time in ticks. <a href="#b10ea0e225484fa2d31796f505d4e582"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
A standard MIDI file reading/parsing class.
<p>
This class can be used to read events from a standard MIDI file. Event bytes are copied to a C++ vector and must be subsequently interpreted by the user. The function <a class="el" href="classstk_1_1MidiFileIn.html#b10ea0e225484fa2d31796f505d4e582" title="Fill the user-provided vector with the next MIDI channel event in the specified track...">getNextMidiEvent()</a> skips meta and sysex events, returning only MIDI channel messages. Event delta-times are returned in the form of "ticks" and a function is provided to determine the current "seconds per tick". Tempo changes are internally tracked by the class and reflected in the values returned by the function <a class="el" href="classstk_1_1MidiFileIn.html#92508a5847e45a05a3ff05de3e5d3efe" title="Get the current value, in seconds, of delta-time ticks for the specified track.">getTickSeconds()</a>.<p>
by Gary P. Scavone, 2003 - 2009. <hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="d273dc7c13d4c4a4ced893af93d9176e"></a><!-- doxytag: member="stk::MidiFileIn::MidiFileIn" ref="d273dc7c13d4c4a4ced893af93d9176e" args="(std::string fileName)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">stk::MidiFileIn::MidiFileIn </td>
<td>(</td>
<td class="paramtype">std::string&nbsp;</td>
<td class="paramname"> <em>fileName</em> </td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Default constructor.
<p>
If an error occurs while opening or parsing the file header, an <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> exception will be thrown.
</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="43bc34a26e72f3311b855139a1408f78"></a><!-- doxytag: member="stk::MidiFileIn::getDivision" ref="43bc34a26e72f3311b855139a1408f78" args="() const " -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int stk::MidiFileIn::getDivision </td>
<td>(</td>
<td class="paramname"> </td>
<td>&nbsp;)&nbsp;</td>
<td> const</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Return the MIDI file division value from the file header.
<p>
Note that this value must be "parsed" in accordance with the MIDI File Specification. In particular, if the MSB is set, the file uses time-code representations for delta-time values.
</div>
</div><p>
<a class="anchor" name="3bd547e3ee5bb8ad780274d7a09f12ff"></a><!-- doxytag: member="stk::MidiFileIn::rewindTrack" ref="3bd547e3ee5bb8ad780274d7a09f12ff" args="(unsigned int track=0)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void stk::MidiFileIn::rewindTrack </td>
<td>(</td>
<td class="paramtype">unsigned int&nbsp;</td>
<td class="paramname"> <em>track</em> = <code>0</code> </td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Move the specified track event reader to the beginning of its track.
<p>
The relevant track tempo value is reset as well. If an invalid track number is specified, an <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> exception will be thrown.
</div>
</div><p>
<a class="anchor" name="92508a5847e45a05a3ff05de3e5d3efe"></a><!-- doxytag: member="stk::MidiFileIn::getTickSeconds" ref="92508a5847e45a05a3ff05de3e5d3efe" args="(unsigned int track=0)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">double stk::MidiFileIn::getTickSeconds </td>
<td>(</td>
<td class="paramtype">unsigned int&nbsp;</td>
<td class="paramname"> <em>track</em> = <code>0</code> </td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Get the current value, in seconds, of delta-time ticks for the specified track.
<p>
This value can change as events are read (via "Set Tempo" Meta-Events). Therefore, one should call this function after every call to <a class="el" href="classstk_1_1MidiFileIn.html#117dd19afbc42d6c769d959588f9176b" title="Fill the user-provided vector with the next event in the specified track and return...">getNextEvent()</a> or <a class="el" href="classstk_1_1MidiFileIn.html#b10ea0e225484fa2d31796f505d4e582" title="Fill the user-provided vector with the next MIDI channel event in the specified track...">getNextMidiEvent()</a>. If an invalid track number is specified, an <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> exception will be thrown.
</div>
</div><p>
<a class="anchor" name="117dd19afbc42d6c769d959588f9176b"></a><!-- doxytag: member="stk::MidiFileIn::getNextEvent" ref="117dd19afbc42d6c769d959588f9176b" args="(std::vector&lt; unsigned char &gt; *event, unsigned int track=0)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">unsigned long stk::MidiFileIn::getNextEvent </td>
<td>(</td>
<td class="paramtype">std::vector&lt; unsigned char &gt; *&nbsp;</td>
<td class="paramname"> <em>event</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned int&nbsp;</td>
<td class="paramname"> <em>track</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>
Fill the user-provided vector with the next event in the specified track and return the event delta-time in ticks.
<p>
MIDI File events consist of a delta time and a sequence of event bytes. This function returns the delta-time value and writes the subsequent event bytes directly to the event vector. The user must parse the event bytes in accordance with the MIDI File Specification. All returned MIDI channel events are complete ... a status byte is provided even when running status is used in the file. If the track has reached its end, no bytes will be written and the event vector size will be zero. If an invalid track number is specified or an error occurs while reading the file, an <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> exception will be thrown.
</div>
</div><p>
<a class="anchor" name="b10ea0e225484fa2d31796f505d4e582"></a><!-- doxytag: member="stk::MidiFileIn::getNextMidiEvent" ref="b10ea0e225484fa2d31796f505d4e582" args="(std::vector&lt; unsigned char &gt; *midiEvent, unsigned int track=0)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">unsigned long stk::MidiFileIn::getNextMidiEvent </td>
<td>(</td>
<td class="paramtype">std::vector&lt; unsigned char &gt; *&nbsp;</td>
<td class="paramname"> <em>midiEvent</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned int&nbsp;</td>
<td class="paramname"> <em>track</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>
Fill the user-provided vector with the next MIDI channel event in the specified track and return the event delta time in ticks.
<p>
All returned MIDI events are complete ... a status byte is provided even when running status is used in the file. Meta and sysex events in the track are skipped though "Set Tempo" events are properly parsed for use by the <a class="el" href="classstk_1_1MidiFileIn.html#92508a5847e45a05a3ff05de3e5d3efe" title="Get the current value, in seconds, of delta-time ticks for the specified track.">getTickSeconds()</a> function. If the track has reached its end, no bytes will be written and the event vector size will be zero. If an invalid track number is specified or an error occurs while reading the file, an <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> exception will be thrown.
</div>
</div><p>
<hr>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="MidiFileIn_8h-source.html">MidiFileIn.h</a></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-2009 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
</table>
</BODY>
</HTML>