Files
stk/doc/html/MidiFileIn_8h_source.html
2013-09-29 23:49:37 +02:00

101 lines
9.1 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="navpath"><a class="el" href="dir_f14fd23bc74c76f288031ad23b3f3505.html">include</a>
</div>
<div class="contents">
<h1>MidiFileIn.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef STK_MIDIFILEIN_H</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define STK_MIDIFILEIN_H</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &quot;Stk.h&quot;</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00006"></a>00006 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00007"></a>00007 <span class="preprocessor">#include &lt;fstream&gt;</span>
<a name="l00008"></a>00008 <span class="preprocessor">#include &lt;sstream&gt;</span>
<a name="l00009"></a>00009
<a name="l00010"></a>00010 <span class="keyword">namespace </span>stk {
<a name="l00011"></a>00011
<a name="l00012"></a>00012 <span class="comment">/**********************************************************************/</span>
<a name="l00027"></a>00027 <span class="comment">/**********************************************************************/</span>
<a name="l00028"></a>00028
<a name="l00029"></a><a class="code" href="classstk_1_1MidiFileIn.html">00029</a> <span class="keyword">class </span><a class="code" href="classstk_1_1MidiFileIn.html" title="A standard MIDI file reading/parsing class.">MidiFileIn</a> : <span class="keyword">public</span> <a class="code" href="classstk_1_1Stk.html" title="STK base class.">Stk</a>
<a name="l00030"></a>00030 {
<a name="l00031"></a>00031 <span class="keyword">public</span>:
<a name="l00033"></a>00033
<a name="l00037"></a>00037 <a class="code" href="classstk_1_1MidiFileIn.html#ad273dc7c13d4c4a4ced893af93d9176e" title="Default constructor.">MidiFileIn</a>( std::string fileName );
<a name="l00038"></a>00038
<a name="l00040"></a>00040 <a class="code" href="classstk_1_1MidiFileIn.html#a857246dbaf234cc9d68709afea6d0141" title="Class destructor.">~MidiFileIn</a>();
<a name="l00041"></a>00041
<a name="l00043"></a><a class="code" href="classstk_1_1MidiFileIn.html#ac93b16c4de0ed3d98d31a2edb92bc105">00043</a> <span class="keywordtype">int</span> <a class="code" href="classstk_1_1MidiFileIn.html#ac93b16c4de0ed3d98d31a2edb92bc105" title="Return the MIDI file format (0, 1, or 2).">getFileFormat</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> format_; };
<a name="l00044"></a>00044
<a name="l00046"></a><a class="code" href="classstk_1_1MidiFileIn.html#a7db7e6b2f6c1aedfbb78045106d36b17">00046</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classstk_1_1MidiFileIn.html#a7db7e6b2f6c1aedfbb78045106d36b17" title="Return the number of tracks in the MIDI file.">getNumberOfTracks</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> nTracks_; };
<a name="l00047"></a>00047
<a name="l00049"></a>00049
<a name="l00054"></a><a class="code" href="classstk_1_1MidiFileIn.html#a43bc34a26e72f3311b855139a1408f78">00054</a> <span class="keywordtype">int</span> <a class="code" href="classstk_1_1MidiFileIn.html#a43bc34a26e72f3311b855139a1408f78" title="Return the MIDI file division value from the file header.">getDivision</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> division_; };
<a name="l00055"></a>00055
<a name="l00057"></a>00057
<a name="l00061"></a>00061 <span class="keywordtype">void</span> <a class="code" href="classstk_1_1MidiFileIn.html#a3bd547e3ee5bb8ad780274d7a09f12ff" title="Move the specified track event reader to the beginning of its track.">rewindTrack</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> track = 0 );
<a name="l00062"></a>00062
<a name="l00064"></a>00064
<a name="l00071"></a>00071 <span class="keywordtype">double</span> <a class="code" href="classstk_1_1MidiFileIn.html#a92508a5847e45a05a3ff05de3e5d3efe" title="Get the current value, in seconds, of delta-time ticks for the specified track.">getTickSeconds</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> track = 0 );
<a name="l00072"></a>00072
<a name="l00074"></a>00074
<a name="l00086"></a>00086 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classstk_1_1MidiFileIn.html#a117dd19afbc42d6c769d959588f9176b" title="Fill the user-provided vector with the next event in the specified track and return...">getNextEvent</a>( std::vector&lt;unsigned char&gt; *event, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> track = 0 );
<a name="l00087"></a>00087
<a name="l00089"></a>00089
<a name="l00099"></a>00099 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classstk_1_1MidiFileIn.html#ab10ea0e225484fa2d31796f505d4e582" title="Fill the user-provided vector with the next MIDI channel event in the specified track...">getNextMidiEvent</a>( std::vector&lt;unsigned char&gt; *midiEvent, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> track = 0 );
<a name="l00100"></a>00100
<a name="l00101"></a>00101 <span class="keyword">protected</span>:
<a name="l00102"></a>00102
<a name="l00103"></a>00103 <span class="comment">// This protected class function is used for reading variable-length</span>
<a name="l00104"></a>00104 <span class="comment">// MIDI file values. It is assumed that this function is called with</span>
<a name="l00105"></a>00105 <span class="comment">// the file read pointer positioned at the start of a</span>
<a name="l00106"></a>00106 <span class="comment">// variable-length value. The function returns true if the value is</span>
<a name="l00107"></a>00107 <span class="comment">// successfully parsed. Otherwise, it returns false.</span>
<a name="l00108"></a>00108 <span class="keywordtype">bool</span> readVariableLength( <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *value );
<a name="l00109"></a>00109
<a name="l00110"></a>00110 std::ifstream file_;
<a name="l00111"></a>00111 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nTracks_;
<a name="l00112"></a>00112 <span class="keywordtype">int</span> format_;
<a name="l00113"></a>00113 <span class="keywordtype">int</span> division_;
<a name="l00114"></a>00114 <span class="keywordtype">bool</span> usingTimeCode_;
<a name="l00115"></a>00115 std::vector&lt;double&gt; tickSeconds_;
<a name="l00116"></a>00116 std::vector&lt;long&gt; trackPointers_;
<a name="l00117"></a>00117 std::vector&lt;long&gt; trackOffsets_;
<a name="l00118"></a>00118 std::vector&lt;long&gt; trackLengths_;
<a name="l00119"></a>00119 std::vector&lt;char&gt; trackStatus_;
<a name="l00120"></a>00120
<a name="l00121"></a>00121 <span class="comment">// This structure and the following variables are used to save and</span>
<a name="l00122"></a>00122 <span class="comment">// keep track of a format 1 tempo map (and the initial tickSeconds</span>
<a name="l00123"></a>00123 <span class="comment">// parameter for formats 0 and 2).</span>
<a name="l00124"></a>00124 <span class="keyword">struct </span>TempoChange {
<a name="l00125"></a>00125 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> count;
<a name="l00126"></a>00126 <span class="keywordtype">double</span> tickSeconds;
<a name="l00127"></a>00127 };
<a name="l00128"></a>00128 std::vector&lt;TempoChange&gt; tempoEvents_;
<a name="l00129"></a>00129 std::vector&lt;unsigned long&gt; trackCounters_;
<a name="l00130"></a>00130 std::vector&lt;unsigned int&gt; trackTempoIndex_;
<a name="l00131"></a>00131 };
<a name="l00132"></a>00132
<a name="l00133"></a>00133 } <span class="comment">// stk namespace</span>
<a name="l00134"></a>00134
<a name="l00135"></a>00135 <span class="preprocessor">#endif</span>
</pre></div></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-2011 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
</table>
</BODY>
</HTML>