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

120 lines
13 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>FileWvIn.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef STK_FILEWVIN_H</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define STK_FILEWVIN_H</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &quot;WvIn.h&quot;</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include &quot;FileRead.h&quot;</span>
<a name="l00006"></a>00006
<a name="l00007"></a>00007 <span class="keyword">namespace </span>stk {
<a name="l00008"></a>00008
<a name="l00009"></a>00009 <span class="comment">/***************************************************/</span>
<a name="l00040"></a>00040 <span class="comment">/***************************************************/</span>
<a name="l00041"></a>00041
<a name="l00042"></a><a class="code" href="classstk_1_1FileWvIn.html">00042</a> <span class="keyword">class </span><a class="code" href="classstk_1_1FileWvIn.html" title="STK audio file input class.">FileWvIn</a> : <span class="keyword">public</span> <a class="code" href="classstk_1_1WvIn.html" title="STK audio input abstract base class.">WvIn</a>
<a name="l00043"></a>00043 {
<a name="l00044"></a>00044 <span class="keyword">public</span>:
<a name="l00046"></a>00046 <a class="code" href="classstk_1_1FileWvIn.html#a0562e85c4cb0d1565d9697da966add94" title="Default constructor.">FileWvIn</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> chunkThreshold = 1000000, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> chunkSize = 1024 );
<a name="l00047"></a>00047
<a name="l00049"></a>00049
<a name="l00053"></a>00053 <a class="code" href="classstk_1_1FileWvIn.html#a0562e85c4cb0d1565d9697da966add94" title="Default constructor.">FileWvIn</a>( std::string fileName, <span class="keywordtype">bool</span> raw = <span class="keyword">false</span>, <span class="keywordtype">bool</span> doNormalize = <span class="keyword">true</span>,
<a name="l00054"></a>00054 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> chunkThreshold = 1000000, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> chunkSize = 1024 );
<a name="l00055"></a>00055
<a name="l00057"></a>00057 <a class="code" href="classstk_1_1FileWvIn.html#ad63f10df8795ce5cb6348b0bb1ad884e" title="Class destructor.">~FileWvIn</a>( <span class="keywordtype">void</span> );
<a name="l00058"></a>00058
<a name="l00060"></a>00060
<a name="l00069"></a>00069 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classstk_1_1FileWvIn.html#a7986664cd986cbacf4fb19e5c77deda1" title="Open the specified file and load its data.">openFile</a>( std::string fileName, <span class="keywordtype">bool</span> raw = <span class="keyword">false</span>, <span class="keywordtype">bool</span> doNormalize = <span class="keyword">true</span> );
<a name="l00070"></a>00070
<a name="l00072"></a>00072 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classstk_1_1FileWvIn.html#ae586a93b45a979881d9bd6fc1cb364cb" title="Close a file if one is open.">closeFile</a>( <span class="keywordtype">void</span> );
<a name="l00073"></a>00073
<a name="l00075"></a>00075 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classstk_1_1FileWvIn.html#ac7dfd47e46a083d434e63c9d1b8c3d28" title="Clear outputs and reset time (file) pointer to zero.">reset</a>( <span class="keywordtype">void</span> );
<a name="l00076"></a>00076
<a name="l00078"></a>00078
<a name="l00082"></a>00082 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classstk_1_1FileWvIn.html#aaecd1950fca3a5513e0efe4e86754b11" title="Normalize data to a maximum of +-1.0.">normalize</a>( <span class="keywordtype">void</span> );
<a name="l00083"></a>00083
<a name="l00085"></a>00085
<a name="l00089"></a>00089 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classstk_1_1FileWvIn.html#aaecd1950fca3a5513e0efe4e86754b11" title="Normalize data to a maximum of +-1.0.">normalize</a>( StkFloat peak );
<a name="l00090"></a>00090
<a name="l00092"></a><a class="code" href="classstk_1_1FileWvIn.html#aa8ef94c3ed01af0efc9e968f09207a26">00092</a> <span class="keyword">virtual</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classstk_1_1FileWvIn.html#aa8ef94c3ed01af0efc9e968f09207a26" title="Return the file size in sample frames.">getSize</a>( <span class="keywordtype">void</span> )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> data_.<a class="code" href="classstk_1_1StkFrames.html#a05b1ab6fa750a8221a7d65c30e0cdab9" title="Return the number of sample frames represented by the data.">frames</a>(); };
<a name="l00093"></a>00093
<a name="l00095"></a>00095
<a name="l00100"></a><a class="code" href="classstk_1_1FileWvIn.html#a867b7b7fdb60e5194e25d7a85a26ec0b">00100</a> <span class="keyword">virtual</span> StkFloat <a class="code" href="classstk_1_1FileWvIn.html#a867b7b7fdb60e5194e25d7a85a26ec0b" title="Return the input file sample rate in Hz (not the data read rate).">getFileRate</a>( <span class="keywordtype">void</span> )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> data_.<a class="code" href="classstk_1_1StkFrames.html#a4dbbcbdc8db39a803e0861976f7f3522" title="Return the sample rate associated with the StkFrames data.">dataRate</a>(); };
<a name="l00101"></a>00101
<a name="l00103"></a><a class="code" href="classstk_1_1FileWvIn.html#aa45344366bca49f71c7153ac5b296e91">00103</a> <span class="keywordtype">bool</span> <a class="code" href="classstk_1_1FileWvIn.html#aa45344366bca49f71c7153ac5b296e91" title="Query whether a file is open.">isOpen</a>( <span class="keywordtype">void</span> ) { <span class="keywordflow">return</span> file_.<a class="code" href="classstk_1_1FileRead.html#a3f30ed2a9f45493f0369aa2edbf38f70" title="Returns true if a file is currently open.">isOpen</a>(); };
<a name="l00104"></a>00104
<a name="l00106"></a><a class="code" href="classstk_1_1FileWvIn.html#aca9ad0c12af3323e7bbf877513b0d10b">00106</a> <span class="keywordtype">bool</span> <a class="code" href="classstk_1_1FileWvIn.html#aca9ad0c12af3323e7bbf877513b0d10b" title="Query whether reading is complete.">isFinished</a>( <span class="keywordtype">void</span> )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> finished_; };
<a name="l00107"></a>00107
<a name="l00109"></a>00109
<a name="l00112"></a>00112 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classstk_1_1FileWvIn.html#aacd97ad5f30f9cdc8201b4244aa69901" title="Set the data read rate in samples. The rate can be negative.">setRate</a>( StkFloat rate );
<a name="l00113"></a>00113
<a name="l00115"></a>00115
<a name="l00118"></a>00118 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classstk_1_1FileWvIn.html#ab2ccf7cc65c36a1ecfbb3b7d5707ea48" title="Increment the read pointer by time samples.">addTime</a>( StkFloat time );
<a name="l00119"></a>00119
<a name="l00121"></a>00121
<a name="l00127"></a><a class="code" href="classstk_1_1FileWvIn.html#a129c1e0b51497e6b09ad6aa37ad4d969">00127</a> <span class="keywordtype">void</span> <a class="code" href="classstk_1_1FileWvIn.html#a129c1e0b51497e6b09ad6aa37ad4d969" title="Turn linear interpolation on/off.">setInterpolate</a>( <span class="keywordtype">bool</span> doInterpolate ) { interpolate_ = doInterpolate; };
<a name="l00128"></a>00128
<a name="l00130"></a>00130
<a name="l00139"></a>00139 StkFloat <a class="code" href="classstk_1_1FileWvIn.html#ad17c12e8d51f90f59f0d0c9f6d626608" title="Return the specified channel value of the last computed frame.">lastOut</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channel = 0 );
<a name="l00140"></a>00140
<a name="l00142"></a>00142
<a name="l00151"></a>00151 <span class="keyword">virtual</span> StkFloat <a class="code" href="classstk_1_1FileWvIn.html#ada668a0bc0bf89e155ef341de00babc2" title="Compute a sample frame and return the specified channel value.">tick</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channel = 0 );
<a name="l00152"></a>00152
<a name="l00154"></a>00154
<a name="l00162"></a>00162 <span class="keyword">virtual</span> <a class="code" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a>&amp; <a class="code" href="classstk_1_1FileWvIn.html#ada668a0bc0bf89e155ef341de00babc2" title="Compute a sample frame and return the specified channel value.">tick</a>( <a class="code" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a>&amp; frames );
<a name="l00163"></a>00163
<a name="l00164"></a>00164 <span class="keyword">protected</span>:
<a name="l00165"></a>00165
<a name="l00166"></a>00166 <span class="keywordtype">void</span> sampleRateChanged( StkFloat newRate, StkFloat oldRate );
<a name="l00167"></a>00167
<a name="l00168"></a>00168 <a class="code" href="classstk_1_1FileRead.html" title="STK audio file input class.">FileRead</a> file_;
<a name="l00169"></a>00169 <span class="keywordtype">bool</span> finished_;
<a name="l00170"></a>00170 <span class="keywordtype">bool</span> interpolate_;
<a name="l00171"></a>00171 <span class="keywordtype">bool</span> normalizing_;
<a name="l00172"></a>00172 <span class="keywordtype">bool</span> chunking_;
<a name="l00173"></a>00173 StkFloat time_;
<a name="l00174"></a>00174 StkFloat rate_;
<a name="l00175"></a>00175 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> chunkThreshold_;
<a name="l00176"></a>00176 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> chunkSize_;
<a name="l00177"></a>00177 <span class="keywordtype">long</span> chunkPointer_;
<a name="l00178"></a>00178
<a name="l00179"></a>00179 };
<a name="l00180"></a>00180
<a name="l00181"></a><a class="code" href="classstk_1_1FileWvIn.html#ad17c12e8d51f90f59f0d0c9f6d626608">00181</a> <span class="keyword">inline</span> StkFloat <a class="code" href="classstk_1_1FileWvIn.html#ad17c12e8d51f90f59f0d0c9f6d626608" title="Return the specified channel value of the last computed frame.">FileWvIn :: lastOut</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channel )
<a name="l00182"></a>00182 {
<a name="l00183"></a>00183 <span class="preprocessor">#if defined(_STK_DEBUG_)</span>
<a name="l00184"></a>00184 <span class="preprocessor"></span> <span class="keywordflow">if</span> ( channel &gt;= data_.<a class="code" href="classstk_1_1StkFrames.html#aec7ef9c46675a24111aa6e2fda3ba870" title="Return the number of channels represented by the data.">channels</a>() ) {
<a name="l00185"></a>00185 oStream_ &lt;&lt; <span class="stringliteral">&quot;FileWvIn::lastOut(): channel argument and soundfile data are incompatible!&quot;</span>;
<a name="l00186"></a>00186 <a class="code" href="classstk_1_1Stk.html#a48ac73a0d8ca28445ba1a054e1f061ff" title="Static function for error reporting and handling using c-strings.">handleError</a>( StkError::FUNCTION_ARGUMENT );
<a name="l00187"></a>00187 }
<a name="l00188"></a>00188 <span class="preprocessor">#endif</span>
<a name="l00189"></a>00189 <span class="preprocessor"></span>
<a name="l00190"></a>00190 <span class="keywordflow">if</span> ( finished_ ) <span class="keywordflow">return</span> 0.0;
<a name="l00191"></a>00191 <span class="keywordflow">return</span> lastFrame_[channel];
<a name="l00192"></a>00192 }
<a name="l00193"></a>00193
<a name="l00194"></a>00194 } <span class="comment">// stk namespace</span>
<a name="l00195"></a>00195
<a name="l00196"></a>00196 <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>