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

248 lines
16 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_1FileRead.html">FileRead</a>
</div>
<div class="contents">
<h1>stk::FileRead Class Reference</h1><!-- doxytag: class="stk::FileRead" --><!-- doxytag: inherits="stk::Stk" -->STK audio file input class.
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="FileRead_8h-source.html">FileRead.h</a>&gt;</code>
<p>
<div class="dynheader">
Inheritance diagram for stk::FileRead:</div>
<div class="dynsection">
<p><center><img src="classstk_1_1FileRead.png" usemap="#stk::FileRead_map" border="0" alt=""></center>
<map name="stk::FileRead_map">
<area href="classstk_1_1Stk.html" alt="stk::Stk" shape="rect" coords="0,0,83,24">
</map>
</div>
<p>
<a href="classstk_1_1FileRead-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"><a class="anchor" name="9b8c55af1ca997dd3b808afcc54f3089"></a><!-- doxytag: member="stk::FileRead::FileRead" ref="9b8c55af1ca997dd3b808afcc54f3089" args="(void)" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1FileRead.html#9b8c55af1ca997dd3b808afcc54f3089">FileRead</a> (void)</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">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1FileRead.html#ef47f180e2d7ef77a118b993541b372d">FileRead</a> (std::string fileName, bool typeRaw=false, unsigned int nChannels=1, StkFormat format=<a class="el" href="classstk_1_1Stk.html#5a807971b7fc3c8985d97823be079a7b">STK_SINT16</a>, StkFloat rate=22050.0)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Overloaded constructor that opens a file during instantiation. <a href="#ef47f180e2d7ef77a118b993541b372d"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="24802c0e1846ea9f420f40293af4cde4"></a><!-- doxytag: member="stk::FileRead::~FileRead" ref="24802c0e1846ea9f420f40293af4cde4" args="(void)" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1FileRead.html#24802c0e1846ea9f420f40293af4cde4">~FileRead</a> (void)</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="classstk_1_1FileRead.html#cc11b53871e05af1b0342e2cc1fc3157">open</a> (std::string fileName, bool typeRaw=false, unsigned int nChannels=1, StkFormat format=<a class="el" href="classstk_1_1Stk.html#5a807971b7fc3c8985d97823be079a7b">STK_SINT16</a>, StkFloat rate=22050.0)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Open the specified file and determine its formatting. <a href="#cc11b53871e05af1b0342e2cc1fc3157"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="56d09169c0cca8623823579c7f80808a"></a><!-- doxytag: member="stk::FileRead::close" ref="56d09169c0cca8623823579c7f80808a" args="(void)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1FileRead.html#56d09169c0cca8623823579c7f80808a">close</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">If a file is open, close it. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="3f30ed2a9f45493f0369aa2edbf38f70"></a><!-- doxytag: member="stk::FileRead::isOpen" ref="3f30ed2a9f45493f0369aa2edbf38f70" args="(void)" -->
bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1FileRead.html#3f30ed2a9f45493f0369aa2edbf38f70">isOpen</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns <em>true</em> if a file is currently open. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="6a83d925dd5bd18c4299ea42cc0ea488"></a><!-- doxytag: member="stk::FileRead::fileSize" ref="6a83d925dd5bd18c4299ea42cc0ea488" args="(void) const " -->
unsigned long&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1FileRead.html#6a83d925dd5bd18c4299ea42cc0ea488">fileSize</a> (void) const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the file size in sample frames. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="4c0c35f1817a4984b325967f1e7bcd81"></a><!-- doxytag: member="stk::FileRead::channels" ref="4c0c35f1817a4984b325967f1e7bcd81" args="(void) const " -->
unsigned int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1FileRead.html#4c0c35f1817a4984b325967f1e7bcd81">channels</a> (void) const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the number of audio channels in the file. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">StkFloat&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1FileRead.html#7d6ba525b2f8ae693d953cb7f4b7c199">fileRate</a> (void) const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the file sample rate in Hz. <a href="#7d6ba525b2f8ae693d953cb7f4b7c199"></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_1FileRead.html#8eefe5d1479789c02ac2dfa76ba143f8">read</a> (<a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> &amp;buffer, unsigned long startFrame=0, bool doNormalize=true)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Read sample frames from the file into an <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> object. <a href="#8eefe5d1479789c02ac2dfa76ba143f8"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
STK audio file input class.
<p>
This class provides input support for various audio file formats. Multi-channel (&gt;2) soundfiles are supported. The file data is returned via an external <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> object passed to the <a class="el" href="classstk_1_1FileRead.html#8eefe5d1479789c02ac2dfa76ba143f8" title="Read sample frames from the file into an StkFrames object.">read()</a> function. This class does not store its own copy of the file data, rather the data is read directly from disk.<p>
<a class="el" href="classstk_1_1FileRead.html" title="STK audio file input class.">FileRead</a> currently supports uncompressed WAV, AIFF/AIFC, SND (AU), MAT-file (Matlab), and STK RAW file formats. Signed integer (8-, 16-, and 32-bit) and floating-point (32- and 64-bit) data types are supported. Compressed data types are not supported.<p>
STK RAW files have no header and are assumed to contain a monophonic stream of 16-bit signed integers in big-endian byte order at a sample rate of 22050 Hz. MAT-file data should be saved in an array with each data channel filling a matrix row. The sample rate for MAT-files is assumed to be 44100 Hz.<p>
by Perry R. Cook and Gary P. Scavone, 1995 - 2009. <hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="ef47f180e2d7ef77a118b993541b372d"></a><!-- doxytag: member="stk::FileRead::FileRead" ref="ef47f180e2d7ef77a118b993541b372d" args="(std::string fileName, bool typeRaw=false, unsigned int nChannels=1, StkFormat format=STK_SINT16, StkFloat rate=22050.0)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">stk::FileRead::FileRead </td>
<td>(</td>
<td class="paramtype">std::string&nbsp;</td>
<td class="paramname"> <em>fileName</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool&nbsp;</td>
<td class="paramname"> <em>typeRaw</em> = <code>false</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned int&nbsp;</td>
<td class="paramname"> <em>nChannels</em> = <code>1</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">StkFormat&nbsp;</td>
<td class="paramname"> <em>format</em> = <code><a class="el" href="classstk_1_1Stk.html#5a807971b7fc3c8985d97823be079a7b">STK_SINT16</a></code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">StkFloat&nbsp;</td>
<td class="paramname"> <em>rate</em> = <code>22050.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>
Overloaded constructor that opens a file during instantiation.
<p>
An <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> will be thrown if the file is not found or its format is unknown or unsupported. The optional arguments allow a headerless file type to be supported. If <code>typeRaw</code> is false (the default), the subsequent parameters are ignored.
</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="cc11b53871e05af1b0342e2cc1fc3157"></a><!-- doxytag: member="stk::FileRead::open" ref="cc11b53871e05af1b0342e2cc1fc3157" args="(std::string fileName, bool typeRaw=false, unsigned int nChannels=1, StkFormat format=STK_SINT16, StkFloat rate=22050.0)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void stk::FileRead::open </td>
<td>(</td>
<td class="paramtype">std::string&nbsp;</td>
<td class="paramname"> <em>fileName</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool&nbsp;</td>
<td class="paramname"> <em>typeRaw</em> = <code>false</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned int&nbsp;</td>
<td class="paramname"> <em>nChannels</em> = <code>1</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">StkFormat&nbsp;</td>
<td class="paramname"> <em>format</em> = <code><a class="el" href="classstk_1_1Stk.html#5a807971b7fc3c8985d97823be079a7b">STK_SINT16</a></code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">StkFloat&nbsp;</td>
<td class="paramname"> <em>rate</em> = <code>22050.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>
Open the specified file and determine its formatting.
<p>
An <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> will be thrown if the file is not found or its format is unknown or unsupported. The optional arguments allow a headerless file type to be supported. If <code>typeRaw</code> is false (the default), the subsequent parameters are ignored.
</div>
</div><p>
<a class="anchor" name="7d6ba525b2f8ae693d953cb7f4b7c199"></a><!-- doxytag: member="stk::FileRead::fileRate" ref="7d6ba525b2f8ae693d953cb7f4b7c199" args="(void) const " -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">StkFloat stk::FileRead::fileRate </td>
<td>(</td>
<td class="paramtype">void&nbsp;</td>
<td class="paramname"> </td>
<td>&nbsp;)&nbsp;</td>
<td> const<code> [inline]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Return the file sample rate in Hz.
<p>
WAV, SND, and AIF formatted files specify a sample rate in their headers. By definition, STK RAW files have a sample rate of 22050 Hz. MAT-files are assumed to have a rate of 44100 Hz.
</div>
</div><p>
<a class="anchor" name="8eefe5d1479789c02ac2dfa76ba143f8"></a><!-- doxytag: member="stk::FileRead::read" ref="8eefe5d1479789c02ac2dfa76ba143f8" args="(StkFrames &amp;buffer, unsigned long startFrame=0, bool doNormalize=true)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void stk::FileRead::read </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> &amp;&nbsp;</td>
<td class="paramname"> <em>buffer</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned long&nbsp;</td>
<td class="paramname"> <em>startFrame</em> = <code>0</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool&nbsp;</td>
<td class="paramname"> <em>doNormalize</em> = <code>true</code></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Read sample frames from the file into an <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> object.
<p>
The number of sample frames to read will be determined from the number of frames of the <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> argument. If this size is larger than the available data in the file (given the file size and starting frame index), the extra frames will be unaffected (the <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> object will not be resized). Optional parameters are provided to specify the starting sample frame within the file (default = 0) and whether to normalize the data with respect to fixed-point limits (default = true). An <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> will be thrown if a file error occurs or if the number of channels in the <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> argument is not equal to that in the file.
</div>
</div><p>
<hr>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="FileRead_8h-source.html">FileRead.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>