2d-platformer/vendor/SFML/doc/html/classsf_1_1SoundFileReader....

335 lines
21 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SFML - Simple and Fast Multimedia Library</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="doxygen.css" title="default" media="screen,print" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link rel="stylesheet" type="text/css" href="search/search.css" />
<link rel="stylesheet" type="text/css" href="searchOverrides.css" />
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function() { init_search(); });
/* @license-end */
</script>
</head>
<body>
<div id="banner-container">
<div id="banner">
<span id="sfml">SFML 3.0.0</span>
</div>
</div>
<div id="content">
<div>
<!-- Generated by Doxygen 1.12.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="topics.html"><span>Topics</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<span id="MSearchSelect" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()">&#160;</span>
<input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class&#160;List</span></a></li>
<li><a href="classes.html"><span>Class&#160;Index</span></a></li>
<li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class&#160;Members</span></a></li>
</ul>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){ initResizable(false); });
/* @license-end */
</script>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="namespacesf.html">sf</a></li><li class="navelem"><a class="el" href="classsf_1_1SoundFileReader.html">SoundFileReader</a></li> </ul>
</div>
</div><!-- top -->
<div id="doc-content">
<div class="header">
<div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classsf_1_1SoundFileReader-members.html">List of all members</a> </div>
<div class="headertitle"><div class="title">sf::SoundFileReader Class Reference<span class="mlabels"><span class="mlabel">abstract</span></span><div class="ingroups"><a class="el" href="group__audio.html">Audio module</a></div></div></div>
</div><!--header-->
<div class="contents">
<p>Abstract base class for sound file decoding.
<a href="#details">More...</a></p>
<p><code>#include &lt;<a class="el" href="SoundFileReader_8hpp_source.html">SFML/Audio/SoundFileReader.hpp</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structsf_1_1SoundFileReader_1_1Info.html">Info</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Structure holding the audio properties of a sound file. <a href="structsf_1_1SoundFileReader_1_1Info.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a970f3fcf831511a9bbbf1547d4f97a8e" id="r_a970f3fcf831511a9bbbf1547d4f97a8e"><td class="memItemLeft" align="right" valign="top">virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a970f3fcf831511a9bbbf1547d4f97a8e">~SoundFileReader</a> ()=default</td></tr>
<tr class="memdesc:a970f3fcf831511a9bbbf1547d4f97a8e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Virtual destructor. <br /></td></tr>
<tr class="separator:a970f3fcf831511a9bbbf1547d4f97a8e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6b2fdac6bac532ad92567877f70c8ef0" id="r_a6b2fdac6bac532ad92567877f70c8ef0"><td class="memItemLeft" align="right" valign="top">virtual std::optional&lt; <a class="el" href="structsf_1_1SoundFileReader_1_1Info.html">Info</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a6b2fdac6bac532ad92567877f70c8ef0">open</a> (<a class="el" href="classsf_1_1InputStream.html">InputStream</a> &amp;stream)=0</td></tr>
<tr class="memdesc:a6b2fdac6bac532ad92567877f70c8ef0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Open a sound file for reading. <br /></td></tr>
<tr class="separator:a6b2fdac6bac532ad92567877f70c8ef0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aeca1cdc8b1f7ccb131d71802c4c22d26" id="r_aeca1cdc8b1f7ccb131d71802c4c22d26"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aeca1cdc8b1f7ccb131d71802c4c22d26">seek</a> (std::uint64_t sampleOffset)=0</td></tr>
<tr class="memdesc:aeca1cdc8b1f7ccb131d71802c4c22d26"><td class="mdescLeft">&#160;</td><td class="mdescRight">Change the current read position to the given sample offset. <br /></td></tr>
<tr class="separator:aeca1cdc8b1f7ccb131d71802c4c22d26"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af69875a2a6352c25ad58e2d5d1884f31" id="r_af69875a2a6352c25ad58e2d5d1884f31"><td class="memItemLeft" align="right" valign="top">virtual std::uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#af69875a2a6352c25ad58e2d5d1884f31">read</a> (std::int16_t *samples, std::uint64_t maxCount)=0</td></tr>
<tr class="memdesc:af69875a2a6352c25ad58e2d5d1884f31"><td class="mdescLeft">&#160;</td><td class="mdescRight">Read audio samples from the open file. <br /></td></tr>
<tr class="separator:af69875a2a6352c25ad58e2d5d1884f31"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Abstract base class for sound file decoding. </p>
<p>This class allows users to read audio file formats not natively supported by SFML, and thus extend the set of supported readable audio formats.</p>
<p>A valid sound file reader must override the open, seek and write functions, as well as providing a static check function; the latter is used by SFML to find a suitable writer for a given input file.</p>
<p>To register a new reader, use the <code><a class="el" href="classsf_1_1SoundFileFactory.html#aeee396bfdbb6ac24c57e5c73c30ec105" title="Register a new reader.">sf::SoundFileFactory::registerReader</a></code> template function.</p>
<p>Usage example: </p><div class="fragment"><div class="line"><span class="keyword">class </span>MySoundFileReader : <span class="keyword">public</span> <a class="code hl_class" href="classsf_1_1SoundFileReader.html">sf::SoundFileReader</a></div>
<div class="line">{</div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line"> </div>
<div class="line"> [[nodiscard]] <span class="keyword">static</span> <span class="keywordtype">bool</span> check(<a class="code hl_class" href="classsf_1_1InputStream.html">sf::InputStream</a>&amp; stream)</div>
<div class="line"> {</div>
<div class="line"> <span class="comment">// typically, read the first few header bytes and check fields that identify the format</span></div>
<div class="line"> <span class="comment">// return true if the reader can handle the format</span></div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"> [[nodiscard]] std::optional&lt;sf::SoundFileReader::Info&gt; <a class="code hl_function" href="#a6b2fdac6bac532ad92567877f70c8ef0">open</a>(<a class="code hl_class" href="classsf_1_1InputStream.html">sf::InputStream</a>&amp; stream)<span class="keyword"> override</span></div>
<div class="line"><span class="keyword"> </span>{</div>
<div class="line"> <span class="comment">// read the sound file header and fill the sound attributes</span></div>
<div class="line"> <span class="comment">// (channel count, sample count and sample rate)</span></div>
<div class="line"> <span class="comment">// return true on success</span></div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"> <span class="keywordtype">void</span> <a class="code hl_function" href="#aeca1cdc8b1f7ccb131d71802c4c22d26">seek</a>(std::uint64_t sampleOffset)<span class="keyword"> override</span></div>
<div class="line"><span class="keyword"> </span>{</div>
<div class="line"> <span class="comment">// advance to the sampleOffset-th sample from the beginning of the</span></div>
<div class="line"> sound</div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"> std::uint64_t <a class="code hl_function" href="#af69875a2a6352c25ad58e2d5d1884f31">read</a>(std::int16_t* samples, std::uint64_t maxCount)<span class="keyword"> override</span></div>
<div class="line"><span class="keyword"> </span>{</div>
<div class="line"> <span class="comment">// read up to &#39;maxCount&#39; samples into the &#39;samples&#39; array,</span></div>
<div class="line"> <span class="comment">// convert them (for example from normalized float) if they are not stored</span></div>
<div class="line"> <span class="comment">// as 16-bits signed integers in the file</span></div>
<div class="line"> <span class="comment">// return the actual number of samples read</span></div>
<div class="line"> }</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><a class="code hl_function" href="classsf_1_1SoundFileFactory.html#aeee396bfdbb6ac24c57e5c73c30ec105">sf::SoundFileFactory::registerReader&lt;MySoundFileReader&gt;</a>();</div>
<div class="ttc" id="aclasssf_1_1InputStream_html"><div class="ttname"><a href="classsf_1_1InputStream.html">sf::InputStream</a></div><div class="ttdoc">Abstract class for custom file input streams.</div><div class="ttdef"><b>Definition</b> <a href="InputStream_8hpp_source.html#l00045">InputStream.hpp:46</a></div></div>
<div class="ttc" id="aclasssf_1_1SoundFileFactory_html_aeee396bfdbb6ac24c57e5c73c30ec105"><div class="ttname"><a href="classsf_1_1SoundFileFactory.html#aeee396bfdbb6ac24c57e5c73c30ec105">sf::SoundFileFactory::registerReader</a></div><div class="ttdeci">static void registerReader()</div><div class="ttdoc">Register a new reader.</div></div>
<div class="ttc" id="aclasssf_1_1SoundFileReader_html"><div class="ttname"><a href="classsf_1_1SoundFileReader.html">sf::SoundFileReader</a></div><div class="ttdoc">Abstract base class for sound file decoding.</div><div class="ttdef"><b>Definition</b> <a href="SoundFileReader_8hpp_source.html#l00048">SoundFileReader.hpp:49</a></div></div>
<div class="ttc" id="aclasssf_1_1SoundFileReader_html_a6b2fdac6bac532ad92567877f70c8ef0"><div class="ttname"><a href="#a6b2fdac6bac532ad92567877f70c8ef0">sf::SoundFileReader::open</a></div><div class="ttdeci">virtual std::optional&lt; Info &gt; open(InputStream &amp;stream)=0</div><div class="ttdoc">Open a sound file for reading.</div></div>
<div class="ttc" id="aclasssf_1_1SoundFileReader_html_aeca1cdc8b1f7ccb131d71802c4c22d26"><div class="ttname"><a href="#aeca1cdc8b1f7ccb131d71802c4c22d26">sf::SoundFileReader::seek</a></div><div class="ttdeci">virtual void seek(std::uint64_t sampleOffset)=0</div><div class="ttdoc">Change the current read position to the given sample offset.</div></div>
<div class="ttc" id="aclasssf_1_1SoundFileReader_html_af69875a2a6352c25ad58e2d5d1884f31"><div class="ttname"><a href="#af69875a2a6352c25ad58e2d5d1884f31">sf::SoundFileReader::read</a></div><div class="ttdeci">virtual std::uint64_t read(std::int16_t *samples, std::uint64_t maxCount)=0</div><div class="ttdoc">Read audio samples from the open file.</div></div>
</div><!-- fragment --><dl class="section see"><dt>See also</dt><dd><code><a class="el" href="classsf_1_1InputSoundFile.html" title="Provide read access to sound files.">sf::InputSoundFile</a></code>, <code><a class="el" href="classsf_1_1SoundFileFactory.html" title="Manages and instantiates sound file readers and writers.">sf::SoundFileFactory</a></code>, <code><a class="el" href="classsf_1_1SoundFileWriter.html" title="Abstract base class for sound file encoding.">sf::SoundFileWriter</a></code> </dd></dl>
<p class="definition">Definition at line <a class="el" href="SoundFileReader_8hpp_source.html#l00048">48</a> of file <a class="el" href="SoundFileReader_8hpp_source.html">SoundFileReader.hpp</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a970f3fcf831511a9bbbf1547d4f97a8e" name="a970f3fcf831511a9bbbf1547d4f97a8e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a970f3fcf831511a9bbbf1547d4f97a8e">&#9670;&#160;</a></span>~SoundFileReader()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual sf::SoundFileReader::~SoundFileReader </td>
<td>(</td>
<td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span><span class="mlabel">default</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Virtual destructor. </p>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a6b2fdac6bac532ad92567877f70c8ef0" name="a6b2fdac6bac532ad92567877f70c8ef0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6b2fdac6bac532ad92567877f70c8ef0">&#9670;&#160;</a></span>open()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual std::optional&lt; <a class="el" href="structsf_1_1SoundFileReader_1_1Info.html">Info</a> &gt; sf::SoundFileReader::open </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classsf_1_1InputStream.html">InputStream</a> &amp;</td> <td class="paramname"><span class="paramname"><em>stream</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">nodiscard</span><span class="mlabel">pure virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Open a sound file for reading. </p>
<p>The provided stream reference is valid as long as the <code><a class="el" href="classsf_1_1SoundFileReader.html" title="Abstract base class for sound file decoding.">SoundFileReader</a></code> is alive, so it is safe to use/store it during the whole lifetime of the reader.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">stream</td><td>Source stream to read from</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Properties of the loaded sound if the file was successfully opened </dd></dl>
</div>
</div>
<a id="af69875a2a6352c25ad58e2d5d1884f31" name="af69875a2a6352c25ad58e2d5d1884f31"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af69875a2a6352c25ad58e2d5d1884f31">&#9670;&#160;</a></span>read()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual std::uint64_t sf::SoundFileReader::read </td>
<td>(</td>
<td class="paramtype">std::int16_t *</td> <td class="paramname"><span class="paramname"><em>samples</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">std::uint64_t</td> <td class="paramname"><span class="paramname"><em>maxCount</em></span>&#160;)</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">nodiscard</span><span class="mlabel">pure virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Read audio samples from the open file. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">samples</td><td>Pointer to the sample array to fill </td></tr>
<tr><td class="paramname">maxCount</td><td>Maximum number of samples to read</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Number of samples actually read (may be less than <em>maxCount</em>) </dd></dl>
</div>
</div>
<a id="aeca1cdc8b1f7ccb131d71802c4c22d26" name="aeca1cdc8b1f7ccb131d71802c4c22d26"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aeca1cdc8b1f7ccb131d71802c4c22d26">&#9670;&#160;</a></span>seek()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual void sf::SoundFileReader::seek </td>
<td>(</td>
<td class="paramtype">std::uint64_t</td> <td class="paramname"><span class="paramname"><em>sampleOffset</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">pure virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Change the current read position to the given sample offset. </p>
<p>The sample offset takes the channels into account. If you have a time offset instead, you can easily find the corresponding sample offset with the following formula: <code>timeInSeconds * sampleRate * channelCount</code> If the given offset exceeds to total number of samples, this function must jump to the end of the file.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">sampleOffset</td><td>Index of the sample to jump to, relative to the beginning </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="SoundFileReader_8hpp_source.html">SoundFileReader.hpp</a></li>
</ul>
</div><!-- contents -->
</div>
<div id="footer-container">
<div id="footer">
SFML is licensed under the terms and conditions of the <a href="https://www.sfml-dev.org/license.php">zlib/png license</a>.<br />
Copyright &copy; Laurent Gomila &nbsp;::&nbsp;
Documentation generated by <a href="http://www.doxygen.org/" title="doxygen website">doxygen</a> &nbsp;::&nbsp;
</div>
</div>
</body>
</html>