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

784 lines
43 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_1InputSoundFile.html">InputSoundFile</a></li> </ul>
</div>
</div><!-- top -->
<div id="doc-content">
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classsf_1_1InputSoundFile-members.html">List of all members</a> </div>
<div class="headertitle"><div class="title">sf::InputSoundFile Class Reference<div class="ingroups"><a class="el" href="group__audio.html">Audio module</a></div></div></div>
</div><!--header-->
<div class="contents">
<p>Provide read access to sound files.
<a href="#details">More...</a></p>
<p><code>#include &lt;<a class="el" href="InputSoundFile_8hpp_source.html">SFML/Audio/InputSoundFile.hpp</a>&gt;</code></p>
<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:a656b5b198b7fc216915989b05b6ae51e" id="r_a656b5b198b7fc216915989b05b6ae51e"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a656b5b198b7fc216915989b05b6ae51e">InputSoundFile</a> ()=default</td></tr>
<tr class="memdesc:a656b5b198b7fc216915989b05b6ae51e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Default constructor. <br /></td></tr>
<tr class="separator:a656b5b198b7fc216915989b05b6ae51e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0729e8109a29eed7d844294ce254e137" id="r_a0729e8109a29eed7d844294ce254e137"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a0729e8109a29eed7d844294ce254e137">InputSoundFile</a> (const std::filesystem::path &amp;filename)</td></tr>
<tr class="memdesc:a0729e8109a29eed7d844294ce254e137"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct a sound file from the disk for reading. <br /></td></tr>
<tr class="separator:a0729e8109a29eed7d844294ce254e137"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3d893678827ac5b81012656978243707" id="r_a3d893678827ac5b81012656978243707"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a3d893678827ac5b81012656978243707">InputSoundFile</a> (const void *data, std::size_t sizeInBytes)</td></tr>
<tr class="memdesc:a3d893678827ac5b81012656978243707"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct a sound file in memory for reading. <br /></td></tr>
<tr class="separator:a3d893678827ac5b81012656978243707"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a95c3344624ab189e38f5b69333bf4076" id="r_a95c3344624ab189e38f5b69333bf4076"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a95c3344624ab189e38f5b69333bf4076">InputSoundFile</a> (<a class="el" href="classsf_1_1InputStream.html">InputStream</a> &amp;stream)</td></tr>
<tr class="memdesc:a95c3344624ab189e38f5b69333bf4076"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct a sound file from a custom stream for reading. <br /></td></tr>
<tr class="separator:a95c3344624ab189e38f5b69333bf4076"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4ca76fd9f563158d462bef20c6ed09cc" id="r_a4ca76fd9f563158d462bef20c6ed09cc"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a4ca76fd9f563158d462bef20c6ed09cc">openFromFile</a> (const std::filesystem::path &amp;filename)</td></tr>
<tr class="memdesc:a4ca76fd9f563158d462bef20c6ed09cc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Open a sound file from the disk for reading. <br /></td></tr>
<tr class="separator:a4ca76fd9f563158d462bef20c6ed09cc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4e034a8e9e69ca3c33a3f11180250400" id="r_a4e034a8e9e69ca3c33a3f11180250400"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a4e034a8e9e69ca3c33a3f11180250400">openFromMemory</a> (const void *data, std::size_t sizeInBytes)</td></tr>
<tr class="memdesc:a4e034a8e9e69ca3c33a3f11180250400"><td class="mdescLeft">&#160;</td><td class="mdescRight">Open a sound file in memory for reading. <br /></td></tr>
<tr class="separator:a4e034a8e9e69ca3c33a3f11180250400"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a32b76497aeb088a2b46dc6efd819b909" id="r_a32b76497aeb088a2b46dc6efd819b909"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a32b76497aeb088a2b46dc6efd819b909">openFromStream</a> (<a class="el" href="classsf_1_1InputStream.html">InputStream</a> &amp;stream)</td></tr>
<tr class="memdesc:a32b76497aeb088a2b46dc6efd819b909"><td class="mdescLeft">&#160;</td><td class="mdescRight">Open a sound file from a custom stream for reading. <br /></td></tr>
<tr class="separator:a32b76497aeb088a2b46dc6efd819b909"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5516ece930e7d1923ad19a8b3750e4f8" id="r_a5516ece930e7d1923ad19a8b3750e4f8"><td class="memItemLeft" align="right" valign="top">std::uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a5516ece930e7d1923ad19a8b3750e4f8">getSampleCount</a> () const</td></tr>
<tr class="memdesc:a5516ece930e7d1923ad19a8b3750e4f8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the total number of audio samples in the file. <br /></td></tr>
<tr class="separator:a5516ece930e7d1923ad19a8b3750e4f8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a54307c308ba05dea63aba54a29c804a4" id="r_a54307c308ba05dea63aba54a29c804a4"><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a54307c308ba05dea63aba54a29c804a4">getChannelCount</a> () const</td></tr>
<tr class="memdesc:a54307c308ba05dea63aba54a29c804a4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the number of channels used by the sound. <br /></td></tr>
<tr class="separator:a54307c308ba05dea63aba54a29c804a4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6b8177e40dd8020752f6d52f96b774c3" id="r_a6b8177e40dd8020752f6d52f96b774c3"><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a6b8177e40dd8020752f6d52f96b774c3">getSampleRate</a> () const</td></tr>
<tr class="memdesc:a6b8177e40dd8020752f6d52f96b774c3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the sample rate of the sound. <br /></td></tr>
<tr class="separator:a6b8177e40dd8020752f6d52f96b774c3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa1ec832743a0dfcc4f72caca77d8d5c5" id="r_aa1ec832743a0dfcc4f72caca77d8d5c5"><td class="memItemLeft" align="right" valign="top">const std::vector&lt; <a class="el" href="group__audio.html#ga9800c7f3d5e7a9c9310f707b2c995ff3">SoundChannel</a> &gt; &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aa1ec832743a0dfcc4f72caca77d8d5c5">getChannelMap</a> () const</td></tr>
<tr class="memdesc:aa1ec832743a0dfcc4f72caca77d8d5c5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the map of position in sample frame to sound channel. <br /></td></tr>
<tr class="separator:aa1ec832743a0dfcc4f72caca77d8d5c5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa081bd4d9732408d10b48227a360778e" id="r_aa081bd4d9732408d10b48227a360778e"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classsf_1_1Time.html">Time</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aa081bd4d9732408d10b48227a360778e">getDuration</a> () const</td></tr>
<tr class="memdesc:aa081bd4d9732408d10b48227a360778e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the total duration of the sound file. <br /></td></tr>
<tr class="separator:aa081bd4d9732408d10b48227a360778e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad1a2238acb734d8b1144ecd75cccc2e7" id="r_ad1a2238acb734d8b1144ecd75cccc2e7"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classsf_1_1Time.html">Time</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ad1a2238acb734d8b1144ecd75cccc2e7">getTimeOffset</a> () const</td></tr>
<tr class="memdesc:ad1a2238acb734d8b1144ecd75cccc2e7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the read offset of the file in time. <br /></td></tr>
<tr class="separator:ad1a2238acb734d8b1144ecd75cccc2e7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a861013e6105643881596dbaeffdb1ca2" id="r_a861013e6105643881596dbaeffdb1ca2"><td class="memItemLeft" align="right" valign="top">std::uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a861013e6105643881596dbaeffdb1ca2">getSampleOffset</a> () const</td></tr>
<tr class="memdesc:a861013e6105643881596dbaeffdb1ca2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the read offset of the file in samples. <br /></td></tr>
<tr class="separator:a861013e6105643881596dbaeffdb1ca2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afc98f7c941fbac7c2c0f697014b03b92" id="r_afc98f7c941fbac7c2c0f697014b03b92"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#afc98f7c941fbac7c2c0f697014b03b92">seek</a> (std::uint64_t sampleOffset)</td></tr>
<tr class="memdesc:afc98f7c941fbac7c2c0f697014b03b92"><td class="mdescLeft">&#160;</td><td class="mdescRight">Change the current read position to the given sample offset. <br /></td></tr>
<tr class="separator:afc98f7c941fbac7c2c0f697014b03b92"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8eee7af58ad75ddc61f93ad72e2d66c1" id="r_a8eee7af58ad75ddc61f93ad72e2d66c1"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a8eee7af58ad75ddc61f93ad72e2d66c1">seek</a> (<a class="el" href="classsf_1_1Time.html">Time</a> timeOffset)</td></tr>
<tr class="memdesc:a8eee7af58ad75ddc61f93ad72e2d66c1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Change the current read position to the given time offset. <br /></td></tr>
<tr class="separator:a8eee7af58ad75ddc61f93ad72e2d66c1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ace52e5a9baca072799366cb181a70280" id="r_ace52e5a9baca072799366cb181a70280"><td class="memItemLeft" align="right" valign="top">std::uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ace52e5a9baca072799366cb181a70280">read</a> (std::int16_t *samples, std::uint64_t maxCount)</td></tr>
<tr class="memdesc:ace52e5a9baca072799366cb181a70280"><td class="mdescLeft">&#160;</td><td class="mdescRight">Read audio samples from the open file. <br /></td></tr>
<tr class="separator:ace52e5a9baca072799366cb181a70280"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad28182aea9dc9f7d0dfc7f78691825b4" id="r_ad28182aea9dc9f7d0dfc7f78691825b4"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ad28182aea9dc9f7d0dfc7f78691825b4">close</a> ()</td></tr>
<tr class="memdesc:ad28182aea9dc9f7d0dfc7f78691825b4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Close the current file. <br /></td></tr>
<tr class="separator:ad28182aea9dc9f7d0dfc7f78691825b4"><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>Provide read access to sound files. </p>
<p>This class decodes audio samples from a sound file.</p>
<p>It is used internally by higher-level classes such as <code><a class="el" href="classsf_1_1SoundBuffer.html" title="Storage for audio samples defining a sound.">sf::SoundBuffer</a></code> and <code><a class="el" href="classsf_1_1Music.html" title="Streamed music played from an audio file.">sf::Music</a></code>, but can also be useful if you want to process or analyze audio files without playing them, or if you want to implement your own version of <code><a class="el" href="classsf_1_1Music.html" title="Streamed music played from an audio file.">sf::Music</a></code> with more specific features.</p>
<p>Usage example: </p><div class="fragment"><div class="line"><span class="comment">// Open a sound file</span></div>
<div class="line"><a class="code hl_class" href="classsf_1_1InputSoundFile.html">sf::InputSoundFile</a> file(<span class="stringliteral">&quot;music.ogg&quot;</span>);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Print the sound attributes</span></div>
<div class="line">std::cout &lt;&lt; <span class="stringliteral">&quot;duration: &quot;</span> &lt;&lt; file.getDuration().asSeconds() &lt;&lt; <span class="charliteral">&#39;\n&#39;</span></div>
<div class="line"> &lt;&lt; <span class="stringliteral">&quot;channels: &quot;</span> &lt;&lt; file.getChannelCount() &lt;&lt; <span class="charliteral">&#39;\n&#39;</span></div>
<div class="line"> &lt;&lt; <span class="stringliteral">&quot;sample rate: &quot;</span> &lt;&lt; file.getSampleRate() &lt;&lt; <span class="charliteral">&#39;\n&#39;</span></div>
<div class="line"> &lt;&lt; <span class="stringliteral">&quot;sample count: &quot;</span> &lt;&lt; file.getSampleCount() &lt;&lt; std::endl;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Read and process batches of samples until the end of file is reached</span></div>
<div class="line">std::array&lt;std::int16_t, 1024&gt; samples;</div>
<div class="line">std::uint64_t count;</div>
<div class="line"><span class="keywordflow">do</span></div>
<div class="line">{</div>
<div class="line"> count = file.read(samples.data(), samples.size());</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// process, analyze, play, convert, or whatever</span></div>
<div class="line"> <span class="comment">// you want to do with the samples...</span></div>
<div class="line">}</div>
<div class="line"><span class="keywordflow">while</span> (count &gt; 0);</div>
<div class="ttc" id="aclasssf_1_1InputSoundFile_html"><div class="ttname"><a href="classsf_1_1InputSoundFile.html">sf::InputSoundFile</a></div><div class="ttdoc">Provide read access to sound files.</div><div class="ttdef"><b>Definition</b> <a href="InputSoundFile_8hpp_source.html#l00051">InputSoundFile.hpp:52</a></div></div>
</div><!-- fragment --><dl class="section see"><dt>See also</dt><dd><code><a class="el" href="classsf_1_1SoundFileReader.html" title="Abstract base class for sound file decoding.">sf::SoundFileReader</a></code>, <code><a class="el" href="classsf_1_1OutputSoundFile.html" title="Provide write access to sound files.">sf::OutputSoundFile</a></code> </dd></dl>
<p class="definition">Definition at line <a class="el" href="InputSoundFile_8hpp_source.html#l00051">51</a> of file <a class="el" href="InputSoundFile_8hpp_source.html">InputSoundFile.hpp</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a656b5b198b7fc216915989b05b6ae51e" name="a656b5b198b7fc216915989b05b6ae51e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a656b5b198b7fc216915989b05b6ae51e">&#9670;&#160;</a></span>InputSoundFile() <span class="overload">[1/4]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">sf::InputSoundFile::InputSoundFile </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">default</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Default constructor. </p>
<p>Construct an input sound file that is not associated with a file to read. </p>
</div>
</div>
<a id="a0729e8109a29eed7d844294ce254e137" name="a0729e8109a29eed7d844294ce254e137"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0729e8109a29eed7d844294ce254e137">&#9670;&#160;</a></span>InputSoundFile() <span class="overload">[2/4]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">sf::InputSoundFile::InputSoundFile </td>
<td>(</td>
<td class="paramtype">const std::filesystem::path &amp;</td> <td class="paramname"><span class="paramname"><em>filename</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">explicit</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Construct a sound file from the disk for reading. </p>
<p>The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC, MP3. The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit.</p>
<p>Because of minimp3_ex limitation, for MP3 files with big (&gt;16kb) APEv2 tag, it may not be properly removed, tag data will be treated as MP3 data and there is a low chance of garbage decoded at the end of file. See also: <a href="https://github.com/lieff/minimp3">https://github.com/lieff/minimp3</a></p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">filename</td><td>Path of the sound file to load</td></tr>
</table>
</dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
<table class="exception">
<tr><td class="paramname"><a class="el" href="classsf_1_1Exception.html" title="Library-specific exception type.">sf::Exception</a></td><td>if opening the file was unsuccessful </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a id="a3d893678827ac5b81012656978243707" name="a3d893678827ac5b81012656978243707"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3d893678827ac5b81012656978243707">&#9670;&#160;</a></span>InputSoundFile() <span class="overload">[3/4]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">sf::InputSoundFile::InputSoundFile </td>
<td>(</td>
<td class="paramtype">const void *</td> <td class="paramname"><span class="paramname"><em>data</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">std::size_t</td> <td class="paramname"><span class="paramname"><em>sizeInBytes</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Construct a sound file in memory for reading. </p>
<p>The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">data</td><td>Pointer to the file data in memory </td></tr>
<tr><td class="paramname">sizeInBytes</td><td>Size of the data to load, in bytes</td></tr>
</table>
</dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
<table class="exception">
<tr><td class="paramname"><a class="el" href="classsf_1_1Exception.html" title="Library-specific exception type.">sf::Exception</a></td><td>if opening the file was unsuccessful </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a id="a95c3344624ab189e38f5b69333bf4076" name="a95c3344624ab189e38f5b69333bf4076"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a95c3344624ab189e38f5b69333bf4076">&#9670;&#160;</a></span>InputSoundFile() <span class="overload">[4/4]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">sf::InputSoundFile::InputSoundFile </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">explicit</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Construct a sound file from a custom stream for reading. </p>
<p>The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit.</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="exception"><dt>Exceptions</dt><dd>
<table class="exception">
<tr><td class="paramname"><a class="el" href="classsf_1_1Exception.html" title="Library-specific exception type.">sf::Exception</a></td><td>if opening the file was unsuccessful </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="ad28182aea9dc9f7d0dfc7f78691825b4" name="ad28182aea9dc9f7d0dfc7f78691825b4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad28182aea9dc9f7d0dfc7f78691825b4">&#9670;&#160;</a></span>close()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void sf::InputSoundFile::close </td>
<td>(</td>
<td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Close the current file. </p>
</div>
</div>
<a id="a54307c308ba05dea63aba54a29c804a4" name="a54307c308ba05dea63aba54a29c804a4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a54307c308ba05dea63aba54a29c804a4">&#9670;&#160;</a></span>getChannelCount()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">unsigned int sf::InputSoundFile::getChannelCount </td>
<td>(</td>
<td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">nodiscard</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Get the number of channels used by the sound. </p>
<dl class="section return"><dt>Returns</dt><dd>Number of channels (1 = mono, 2 = stereo) </dd></dl>
</div>
</div>
<a id="aa1ec832743a0dfcc4f72caca77d8d5c5" name="aa1ec832743a0dfcc4f72caca77d8d5c5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa1ec832743a0dfcc4f72caca77d8d5c5">&#9670;&#160;</a></span>getChannelMap()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">const std::vector&lt; <a class="el" href="group__audio.html#ga9800c7f3d5e7a9c9310f707b2c995ff3">SoundChannel</a> &gt; &amp; sf::InputSoundFile::getChannelMap </td>
<td>(</td>
<td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">nodiscard</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Get the map of position in sample frame to sound channel. </p>
<p>This is used to map a sample in the sample stream to a position during spatialization.</p>
<dl class="section return"><dt>Returns</dt><dd>Map of position in sample frame to sound channel</dd></dl>
<dl class="section see"><dt>See also</dt><dd><code><a class="el" href="#a6b8177e40dd8020752f6d52f96b774c3" title="Get the sample rate of the sound.">getSampleRate</a></code>, <code><a class="el" href="#a54307c308ba05dea63aba54a29c804a4" title="Get the number of channels used by the sound.">getChannelCount</a></code>, <code><a class="el" href="#aa081bd4d9732408d10b48227a360778e" title="Get the total duration of the sound file.">getDuration</a></code> </dd></dl>
</div>
</div>
<a id="aa081bd4d9732408d10b48227a360778e" name="aa081bd4d9732408d10b48227a360778e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa081bd4d9732408d10b48227a360778e">&#9670;&#160;</a></span>getDuration()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classsf_1_1Time.html">Time</a> sf::InputSoundFile::getDuration </td>
<td>(</td>
<td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">nodiscard</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Get the total duration of the sound file. </p>
<p>This function is provided for convenience, the duration is deduced from the other sound file attributes.</p>
<dl class="section return"><dt>Returns</dt><dd>Duration of the sound file </dd></dl>
</div>
</div>
<a id="a5516ece930e7d1923ad19a8b3750e4f8" name="a5516ece930e7d1923ad19a8b3750e4f8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5516ece930e7d1923ad19a8b3750e4f8">&#9670;&#160;</a></span>getSampleCount()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">std::uint64_t sf::InputSoundFile::getSampleCount </td>
<td>(</td>
<td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">nodiscard</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Get the total number of audio samples in the file. </p>
<dl class="section return"><dt>Returns</dt><dd>Number of samples </dd></dl>
</div>
</div>
<a id="a861013e6105643881596dbaeffdb1ca2" name="a861013e6105643881596dbaeffdb1ca2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a861013e6105643881596dbaeffdb1ca2">&#9670;&#160;</a></span>getSampleOffset()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">std::uint64_t sf::InputSoundFile::getSampleOffset </td>
<td>(</td>
<td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">nodiscard</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Get the read offset of the file in samples. </p>
<dl class="section return"><dt>Returns</dt><dd>Sample position </dd></dl>
</div>
</div>
<a id="a6b8177e40dd8020752f6d52f96b774c3" name="a6b8177e40dd8020752f6d52f96b774c3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6b8177e40dd8020752f6d52f96b774c3">&#9670;&#160;</a></span>getSampleRate()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">unsigned int sf::InputSoundFile::getSampleRate </td>
<td>(</td>
<td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">nodiscard</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Get the sample rate of the sound. </p>
<dl class="section return"><dt>Returns</dt><dd>Sample rate, in samples per second </dd></dl>
</div>
</div>
<a id="ad1a2238acb734d8b1144ecd75cccc2e7" name="ad1a2238acb734d8b1144ecd75cccc2e7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad1a2238acb734d8b1144ecd75cccc2e7">&#9670;&#160;</a></span>getTimeOffset()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classsf_1_1Time.html">Time</a> sf::InputSoundFile::getTimeOffset </td>
<td>(</td>
<td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">nodiscard</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Get the read offset of the file in time. </p>
<dl class="section return"><dt>Returns</dt><dd><a class="el" href="classsf_1_1Time.html" title="Represents a time value.">Time</a> position </dd></dl>
</div>
</div>
<a id="a4ca76fd9f563158d462bef20c6ed09cc" name="a4ca76fd9f563158d462bef20c6ed09cc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4ca76fd9f563158d462bef20c6ed09cc">&#9670;&#160;</a></span>openFromFile()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">bool sf::InputSoundFile::openFromFile </td>
<td>(</td>
<td class="paramtype">const std::filesystem::path &amp;</td> <td class="paramname"><span class="paramname"><em>filename</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">nodiscard</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Open a sound file from the disk for reading. </p>
<p>The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC, MP3. The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit.</p>
<p>Because of minimp3_ex limitation, for MP3 files with big (&gt;16kb) APEv2 tag, it may not be properly removed, tag data will be treated as MP3 data and there is a low chance of garbage decoded at the end of file. See also: <a href="https://github.com/lieff/minimp3">https://github.com/lieff/minimp3</a></p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">filename</td><td>Path of the sound file to load</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>true</code> if the file was successfully opened </dd></dl>
</div>
</div>
<a id="a4e034a8e9e69ca3c33a3f11180250400" name="a4e034a8e9e69ca3c33a3f11180250400"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4e034a8e9e69ca3c33a3f11180250400">&#9670;&#160;</a></span>openFromMemory()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">bool sf::InputSoundFile::openFromMemory </td>
<td>(</td>
<td class="paramtype">const void *</td> <td class="paramname"><span class="paramname"><em>data</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">std::size_t</td> <td class="paramname"><span class="paramname"><em>sizeInBytes</em></span>&#160;)</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">nodiscard</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Open a sound file in memory for reading. </p>
<p>The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">data</td><td>Pointer to the file data in memory </td></tr>
<tr><td class="paramname">sizeInBytes</td><td>Size of the data to load, in bytes</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>true</code> if the file was successfully opened </dd></dl>
</div>
</div>
<a id="a32b76497aeb088a2b46dc6efd819b909" name="a32b76497aeb088a2b46dc6efd819b909"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a32b76497aeb088a2b46dc6efd819b909">&#9670;&#160;</a></span>openFromStream()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">bool sf::InputSoundFile::openFromStream </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> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Open a sound file from a custom stream for reading. </p>
<p>The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit.</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><code>true</code> if the file was successfully opened </dd></dl>
</div>
</div>
<a id="ace52e5a9baca072799366cb181a70280" name="ace52e5a9baca072799366cb181a70280"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ace52e5a9baca072799366cb181a70280">&#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">std::uint64_t sf::InputSoundFile::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> </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="afc98f7c941fbac7c2c0f697014b03b92" name="afc98f7c941fbac7c2c0f697014b03b92"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afc98f7c941fbac7c2c0f697014b03b92">&#9670;&#160;</a></span>seek() <span class="overload">[1/2]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void sf::InputSoundFile::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>
</div><div class="memdoc">
<p>Change the current read position to the given sample offset. </p>
<p>This function takes a sample offset to provide maximum precision. If you need to jump to a given time, use the other overload.</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 jumps to the end of the sound 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>
<a id="a8eee7af58ad75ddc61f93ad72e2d66c1" name="a8eee7af58ad75ddc61f93ad72e2d66c1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8eee7af58ad75ddc61f93ad72e2d66c1">&#9670;&#160;</a></span>seek() <span class="overload">[2/2]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void sf::InputSoundFile::seek </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classsf_1_1Time.html">Time</a></td> <td class="paramname"><span class="paramname"><em>timeOffset</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Change the current read position to the given time offset. </p>
<p>Using a time offset is handy but imprecise. If you need an accurate result, consider using the overload which takes a sample offset.</p>
<p>If the given time exceeds to total duration, this function jumps to the end of the sound file.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">timeOffset</td><td><a class="el" href="classsf_1_1Time.html" title="Represents a time value.">Time</a> 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="InputSoundFile_8hpp_source.html">InputSoundFile.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>