Files
stk/doc/html/classFileRead.html
2013-09-29 23:42:39 +02:00

269 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.4.4 -->
<h1>FileRead Class Reference</h1><!-- doxytag: class="FileRead" --><!-- doxytag: inherits="Stk" --><code>#include &lt;<a class="el" href="FileRead_8h-source.html">FileRead.h</a>&gt;</code>
<p>
<p>Inheritance diagram for FileRead:
<p><center><img src="classFileRead.png" usemap="#FileRead_map" border="0" alt=""></center>
<map name="FileRead_map">
<area href="classStk.html" alt="Stk" shape="rect" coords="0,0,62,24">
</map>
<a href="classFileRead-members.html">List of all members.</a><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="classStkFrames.html">StkFrames</a> object passed to the <a class="el" href="classFileRead.html#a9">read()</a> function. This class does not store its own copy of the file data, rather the data is read directly from disk.<p>
FileRead 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 - 2007.
<p>
<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="a0"></a><!-- doxytag: member="FileRead::FileRead" ref="a0" args="()" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classFileRead.html#a0">FileRead</a> ()</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="classFileRead.html#a1">FileRead</a> (std::string fileName, bool typeRaw=false, unsigned int nChannels=1, StkFormat format=<a class="el" href="classStk.html#s1">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="#a1"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a2"></a><!-- doxytag: member="FileRead::~FileRead" ref="a2" args="()" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classFileRead.html#a2">~FileRead</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">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classFileRead.html#a3">open</a> (std::string fileName, bool typeRaw=false, unsigned int nChannels=1, StkFormat format=<a class="el" href="classStk.html#s1">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="#a3"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a4"></a><!-- doxytag: member="FileRead::close" ref="a4" args="(void)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classFileRead.html#a4">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="a5"></a><!-- doxytag: member="FileRead::isOpen" ref="a5" args="(void)" -->
bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classFileRead.html#a5">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="a6"></a><!-- doxytag: member="FileRead::fileSize" ref="a6" args="(void) const " -->
unsigned long&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classFileRead.html#a6">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="a7"></a><!-- doxytag: member="FileRead::channels" ref="a7" args="(void) const " -->
unsigned int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classFileRead.html#a7">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="classFileRead.html#a8">fileRate</a> (void) const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the file sample rate in Hz. <a href="#a8"></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="classFileRead.html#a9">read</a> (<a class="el" href="classStkFrames.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="classStkFrames.html">StkFrames</a> object. <a href="#a9"></a><br></td></tr>
</table>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="a1"></a><!-- doxytag: member="FileRead::FileRead" ref="a1" args="(std::string fileName, bool typeRaw=false, unsigned int nChannels=1, StkFormat format=STK_SINT16, StkFloat rate=22050.0)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">FileRead::FileRead </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">std::string&nbsp;</td>
<td class="mdname" nowrap> <em>fileName</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>bool&nbsp;</td>
<td class="mdname" nowrap> <em>typeRaw</em> = <code>false</code>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>unsigned int&nbsp;</td>
<td class="mdname" nowrap> <em>nChannels</em> = <code>1</code>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>StkFormat&nbsp;</td>
<td class="mdname" nowrap> <em>format</em> = <code><a class="el" href="classStk.html#s1">STK_SINT16</a></code>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>StkFloat&nbsp;</td>
<td class="mdname" nowrap> <em>rate</em> = <code>22050.0</code></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Overloaded constructor that opens a file during instantiation.
<p>
An <a class="el" href="classStkError.html">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. </td>
</tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="a3"></a><!-- doxytag: member="FileRead::open" ref="a3" args="(std::string fileName, bool typeRaw=false, unsigned int nChannels=1, StkFormat format=STK_SINT16, StkFloat rate=22050.0)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">void FileRead::open </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">std::string&nbsp;</td>
<td class="mdname" nowrap> <em>fileName</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>bool&nbsp;</td>
<td class="mdname" nowrap> <em>typeRaw</em> = <code>false</code>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>unsigned int&nbsp;</td>
<td class="mdname" nowrap> <em>nChannels</em> = <code>1</code>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>StkFormat&nbsp;</td>
<td class="mdname" nowrap> <em>format</em> = <code><a class="el" href="classStk.html#s1">STK_SINT16</a></code>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>StkFloat&nbsp;</td>
<td class="mdname" nowrap> <em>rate</em> = <code>22050.0</code></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Open the specified file and determine its formatting.
<p>
An <a class="el" href="classStkError.html">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. </td>
</tr>
</table>
<a class="anchor" name="a8"></a><!-- doxytag: member="FileRead::fileRate" ref="a8" args="(void) const " --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">StkFloat FileRead::fileRate </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">void&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap> const<code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<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. </td>
</tr>
</table>
<a class="anchor" name="a9"></a><!-- doxytag: member="FileRead::read" ref="a9" args="(StkFrames &amp;buffer, unsigned long startFrame=0, bool doNormalize=true)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">void FileRead::read </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top"><a class="el" href="classStkFrames.html">StkFrames</a> &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>buffer</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>unsigned long&nbsp;</td>
<td class="mdname" nowrap> <em>startFrame</em> = <code>0</code>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>bool&nbsp;</td>
<td class="mdname" nowrap> <em>doNormalize</em> = <code>true</code></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Read sample frames from the file into an <a class="el" href="classStkFrames.html">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="classStkFrames.html">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="classStkFrames.html">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="classStkError.html">StkError</a> will be thrown if a file error occurs or if the number of channels in the <a class="el" href="classStkFrames.html">StkFrames</a> argument is not equal to that in the file. </td>
</tr>
</table>
<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>
<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-2007 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
</table>
</BODY>
</HTML>