mirror of
https://github.com/thestk/stk
synced 2026-01-11 20:11:52 +00:00
118 lines
13 KiB
HTML
118 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"> <img src="ccrma.gif"> <img src="mcgill.gif"><P>
|
|
<a class="qindex" href="index.html">Home</a> <a class="qindex" href="information.html">Information</a> <a class="qindex" href="classes.html">Classes</a> <a class="qindex" href="download.html">Download</a> <a class="qindex" href="usage.html">Usage</a> <a class="qindex" href="maillist.html">Mail List</a> <a class="qindex" href="system.html">Requirements</a> <a class="qindex" href="links.html">Links</a> <a class="qindex" href="faq.html">FAQ</a> <a class="qindex" href="tutorial.html">Tutorial</a></CENTER>
|
|
<HR>
|
|
<!-- Generated by Doxygen 1.5.8 -->
|
|
<div class="navpath"><a class="el" href="dir_c28bfe24b93fcab464ea84f988cb34ef.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 "WvIn.h"</span>
|
|
<a name="l00005"></a>00005 <span class="preprocessor">#include "FileRead.h"</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#0562e85c4cb0d1565d9697da966add94" 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#0562e85c4cb0d1565d9697da966add94" 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#d63f10df8795ce5cb6348b0bb1ad884e" 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#7986664cd986cbacf4fb19e5c77deda1" 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#e586a93b45a979881d9bd6fc1cb364cb" 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#c7dfd47e46a083d434e63c9d1b8c3d28" 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#aecd1950fca3a5513e0efe4e86754b11" 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#aecd1950fca3a5513e0efe4e86754b11" 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#a8ef94c3ed01af0efc9e968f09207a26">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#a8ef94c3ed01af0efc9e968f09207a26" 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#05b1ab6fa750a8221a7d65c30e0cdab9" 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#867b7b7fdb60e5194e25d7a85a26ec0b">00100</a> <span class="keyword">virtual</span> StkFloat <a class="code" href="classstk_1_1FileWvIn.html#867b7b7fdb60e5194e25d7a85a26ec0b" 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#4dbbcbdc8db39a803e0861976f7f3522" 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#ca9ad0c12af3323e7bbf877513b0d10b">00103</a> <span class="keywordtype">bool</span> <a class="code" href="classstk_1_1FileWvIn.html#ca9ad0c12af3323e7bbf877513b0d10b" 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="l00104"></a>00104
|
|
<a name="l00106"></a>00106
|
|
<a name="l00109"></a>00109 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classstk_1_1FileWvIn.html#acd97ad5f30f9cdc8201b4244aa69901" title="Set the data read rate in samples. The rate can be negative.">setRate</a>( StkFloat rate );
|
|
<a name="l00110"></a>00110
|
|
<a name="l00112"></a>00112
|
|
<a name="l00115"></a>00115 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classstk_1_1FileWvIn.html#b2ccf7cc65c36a1ecfbb3b7d5707ea48" title="Increment the read pointer by time samples.">addTime</a>( StkFloat time );
|
|
<a name="l00116"></a>00116
|
|
<a name="l00118"></a>00118
|
|
<a name="l00124"></a><a class="code" href="classstk_1_1FileWvIn.html#129c1e0b51497e6b09ad6aa37ad4d969">00124</a> <span class="keywordtype">void</span> <a class="code" href="classstk_1_1FileWvIn.html#129c1e0b51497e6b09ad6aa37ad4d969" title="Turn linear interpolation on/off.">setInterpolate</a>( <span class="keywordtype">bool</span> doInterpolate ) { interpolate_ = doInterpolate; };
|
|
<a name="l00125"></a>00125
|
|
<a name="l00127"></a>00127
|
|
<a name="l00136"></a>00136 StkFloat <a class="code" href="classstk_1_1FileWvIn.html#d17c12e8d51f90f59f0d0c9f6d626608" 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="l00137"></a>00137
|
|
<a name="l00139"></a>00139
|
|
<a name="l00148"></a>00148 <span class="keyword">virtual</span> StkFloat <a class="code" href="classstk_1_1FileWvIn.html#da668a0bc0bf89e155ef341de00babc2" 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="l00149"></a>00149
|
|
<a name="l00151"></a>00151
|
|
<a name="l00159"></a>00159 <span class="keyword">virtual</span> <a class="code" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a>& <a class="code" href="classstk_1_1FileWvIn.html#da668a0bc0bf89e155ef341de00babc2" 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>& frames );
|
|
<a name="l00160"></a>00160
|
|
<a name="l00161"></a>00161 <span class="keyword">protected</span>:
|
|
<a name="l00162"></a>00162
|
|
<a name="l00163"></a>00163 <span class="keywordtype">void</span> sampleRateChanged( StkFloat newRate, StkFloat oldRate );
|
|
<a name="l00164"></a>00164
|
|
<a name="l00165"></a>00165 <a class="code" href="classstk_1_1FileRead.html" title="STK audio file input class.">FileRead</a> file_;
|
|
<a name="l00166"></a>00166 <span class="keywordtype">bool</span> finished_;
|
|
<a name="l00167"></a>00167 <span class="keywordtype">bool</span> interpolate_;
|
|
<a name="l00168"></a>00168 <span class="keywordtype">bool</span> normalizing_;
|
|
<a name="l00169"></a>00169 <span class="keywordtype">bool</span> chunking_;
|
|
<a name="l00170"></a>00170 StkFloat time_;
|
|
<a name="l00171"></a>00171 StkFloat rate_;
|
|
<a name="l00172"></a>00172 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> chunkThreshold_;
|
|
<a name="l00173"></a>00173 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> chunkSize_;
|
|
<a name="l00174"></a>00174 <span class="keywordtype">long</span> chunkPointer_;
|
|
<a name="l00175"></a>00175
|
|
<a name="l00176"></a>00176 };
|
|
<a name="l00177"></a>00177
|
|
<a name="l00178"></a><a class="code" href="classstk_1_1FileWvIn.html#d17c12e8d51f90f59f0d0c9f6d626608">00178</a> <span class="keyword">inline</span> StkFloat <a class="code" href="classstk_1_1FileWvIn.html#d17c12e8d51f90f59f0d0c9f6d626608" 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="l00179"></a>00179 {
|
|
<a name="l00180"></a>00180 <span class="preprocessor">#if defined(_STK_DEBUG_)</span>
|
|
<a name="l00181"></a>00181 <span class="preprocessor"></span> <span class="keywordflow">if</span> ( channel >= data_.<a class="code" href="classstk_1_1StkFrames.html#ec7ef9c46675a24111aa6e2fda3ba870" title="Return the number of channels represented by the data.">channels</a>() ) {
|
|
<a name="l00182"></a>00182 errorString_ << <span class="stringliteral">"FileWvIn::lastOut(): channel argument and soundfile data are incompatible!"</span>;
|
|
<a name="l00183"></a>00183 <a class="code" href="classstk_1_1Stk.html#48ac73a0d8ca28445ba1a054e1f061ff" title="Static function for error reporting and handling using c-strings.">handleError</a>( StkError::FUNCTION_ARGUMENT );
|
|
<a name="l00184"></a>00184 }
|
|
<a name="l00185"></a>00185 <span class="preprocessor">#endif</span>
|
|
<a name="l00186"></a>00186 <span class="preprocessor"></span>
|
|
<a name="l00187"></a>00187 <span class="keywordflow">if</span> ( finished_ ) <span class="keywordflow">return</span> 0.0;
|
|
<a name="l00188"></a>00188 <span class="keywordflow">return</span> lastFrame_[channel];
|
|
<a name="l00189"></a>00189 }
|
|
<a name="l00190"></a>00190
|
|
<a name="l00191"></a>00191 } <span class="comment">// stk namespace</span>
|
|
<a name="l00192"></a>00192
|
|
<a name="l00193"></a>00193 <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>©1995-2009 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
|
|
</table>
|
|
|
|
</BODY>
|
|
</HTML>
|