2d-platformer/vendor/SFML-3.0.0/doc/html/classsf_1_1SoundBuffer.html

930 lines
61 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_1SoundBuffer.html">SoundBuffer</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="#friends">Friends</a> &#124;
<a href="classsf_1_1SoundBuffer-members.html">List of all members</a> </div>
<div class="headertitle"><div class="title">sf::SoundBuffer Class Reference<div class="ingroups"><a class="el" href="group__audio.html">Audio module</a></div></div></div>
</div><!--header-->
<div class="contents">
<p>Storage for audio samples defining a sound.
<a href="#details">More...</a></p>
<p><code>#include &lt;<a class="el" href="SoundBuffer_8hpp_source.html">SFML/Audio/SoundBuffer.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:a7e322e6d110d54650e729c41112c4666" id="r_a7e322e6d110d54650e729c41112c4666"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a7e322e6d110d54650e729c41112c4666">SoundBuffer</a> ()=default</td></tr>
<tr class="memdesc:a7e322e6d110d54650e729c41112c4666"><td class="mdescLeft">&#160;</td><td class="mdescRight">Default constructor. <br /></td></tr>
<tr class="separator:a7e322e6d110d54650e729c41112c4666"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aaf000fc741ff27015907e8588263f4a6" id="r_aaf000fc741ff27015907e8588263f4a6"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aaf000fc741ff27015907e8588263f4a6">SoundBuffer</a> (const <a class="el" href="classsf_1_1SoundBuffer.html">SoundBuffer</a> &amp;copy)</td></tr>
<tr class="memdesc:aaf000fc741ff27015907e8588263f4a6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy constructor. <br /></td></tr>
<tr class="separator:aaf000fc741ff27015907e8588263f4a6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1b2344bb0444fd4ce864369a95df00c2" id="r_a1b2344bb0444fd4ce864369a95df00c2"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a1b2344bb0444fd4ce864369a95df00c2">SoundBuffer</a> (const std::filesystem::path &amp;filename)</td></tr>
<tr class="memdesc:a1b2344bb0444fd4ce864369a95df00c2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct the sound buffer from a file. <br /></td></tr>
<tr class="separator:a1b2344bb0444fd4ce864369a95df00c2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af34d1a5bb6db60aead02493090600891" id="r_af34d1a5bb6db60aead02493090600891"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#af34d1a5bb6db60aead02493090600891">SoundBuffer</a> (const void *data, std::size_t sizeInBytes)</td></tr>
<tr class="memdesc:af34d1a5bb6db60aead02493090600891"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct the sound buffer from a file in memory. <br /></td></tr>
<tr class="separator:af34d1a5bb6db60aead02493090600891"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aee16d82812f9c803a55159bb44df891c" id="r_aee16d82812f9c803a55159bb44df891c"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aee16d82812f9c803a55159bb44df891c">SoundBuffer</a> (<a class="el" href="classsf_1_1InputStream.html">InputStream</a> &amp;stream)</td></tr>
<tr class="memdesc:aee16d82812f9c803a55159bb44df891c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct the sound buffer from a custom stream. <br /></td></tr>
<tr class="separator:aee16d82812f9c803a55159bb44df891c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4a1a60c07dac5f12d189f2b628fb607a" id="r_a4a1a60c07dac5f12d189f2b628fb607a"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a4a1a60c07dac5f12d189f2b628fb607a">SoundBuffer</a> (const std::int16_t *samples, std::uint64_t sampleCount, unsigned int channelCount, unsigned int sampleRate, const std::vector&lt; <a class="el" href="group__audio.html#ga9800c7f3d5e7a9c9310f707b2c995ff3">SoundChannel</a> &gt; &amp;channelMap)</td></tr>
<tr class="memdesc:a4a1a60c07dac5f12d189f2b628fb607a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct the sound buffer from an array of audio samples. <br /></td></tr>
<tr class="separator:a4a1a60c07dac5f12d189f2b628fb607a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aea240161724ffba74a0d6a9e277d3cd5" id="r_aea240161724ffba74a0d6a9e277d3cd5"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aea240161724ffba74a0d6a9e277d3cd5">~SoundBuffer</a> ()</td></tr>
<tr class="memdesc:aea240161724ffba74a0d6a9e277d3cd5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destructor. <br /></td></tr>
<tr class="separator:aea240161724ffba74a0d6a9e277d3cd5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a54a9a27b31c1a787fd0ae65936f6a09d" id="r_a54a9a27b31c1a787fd0ae65936f6a09d"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a54a9a27b31c1a787fd0ae65936f6a09d">loadFromFile</a> (const std::filesystem::path &amp;filename)</td></tr>
<tr class="memdesc:a54a9a27b31c1a787fd0ae65936f6a09d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Load the sound buffer from a file. <br /></td></tr>
<tr class="separator:a54a9a27b31c1a787fd0ae65936f6a09d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af8cfa5599739a7edae69c5cba273d33f" id="r_af8cfa5599739a7edae69c5cba273d33f"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#af8cfa5599739a7edae69c5cba273d33f">loadFromMemory</a> (const void *data, std::size_t sizeInBytes)</td></tr>
<tr class="memdesc:af8cfa5599739a7edae69c5cba273d33f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Load the sound buffer from a file in memory. <br /></td></tr>
<tr class="separator:af8cfa5599739a7edae69c5cba273d33f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad292156b1e01f6dabd4c0c277d5e079e" id="r_ad292156b1e01f6dabd4c0c277d5e079e"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ad292156b1e01f6dabd4c0c277d5e079e">loadFromStream</a> (<a class="el" href="classsf_1_1InputStream.html">InputStream</a> &amp;stream)</td></tr>
<tr class="memdesc:ad292156b1e01f6dabd4c0c277d5e079e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Load the sound buffer from a custom stream. <br /></td></tr>
<tr class="separator:ad292156b1e01f6dabd4c0c277d5e079e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8189b2f4dc98bfaeefa49cd2c5a0fc33" id="r_a8189b2f4dc98bfaeefa49cd2c5a0fc33"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a8189b2f4dc98bfaeefa49cd2c5a0fc33">loadFromSamples</a> (const std::int16_t *samples, std::uint64_t sampleCount, unsigned int channelCount, unsigned int sampleRate, const std::vector&lt; <a class="el" href="group__audio.html#ga9800c7f3d5e7a9c9310f707b2c995ff3">SoundChannel</a> &gt; &amp;channelMap)</td></tr>
<tr class="memdesc:a8189b2f4dc98bfaeefa49cd2c5a0fc33"><td class="mdescLeft">&#160;</td><td class="mdescRight">Load the sound buffer from an array of audio samples. <br /></td></tr>
<tr class="separator:a8189b2f4dc98bfaeefa49cd2c5a0fc33"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab6a37b1508233b505db66a0e47304ae8" id="r_ab6a37b1508233b505db66a0e47304ae8"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ab6a37b1508233b505db66a0e47304ae8">saveToFile</a> (const std::filesystem::path &amp;filename) const</td></tr>
<tr class="memdesc:ab6a37b1508233b505db66a0e47304ae8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Save the sound buffer to an audio file. <br /></td></tr>
<tr class="separator:ab6a37b1508233b505db66a0e47304ae8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5ae1d0f4170add05ed9a8345f4745674" id="r_a5ae1d0f4170add05ed9a8345f4745674"><td class="memItemLeft" align="right" valign="top">const std::int16_t *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a5ae1d0f4170add05ed9a8345f4745674">getSamples</a> () const</td></tr>
<tr class="memdesc:a5ae1d0f4170add05ed9a8345f4745674"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the array of audio samples stored in the buffer. <br /></td></tr>
<tr class="separator:a5ae1d0f4170add05ed9a8345f4745674"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7dc9181bddf117b596e15cb5ffbf7c97" id="r_a7dc9181bddf117b596e15cb5ffbf7c97"><td class="memItemLeft" align="right" valign="top">std::uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a7dc9181bddf117b596e15cb5ffbf7c97">getSampleCount</a> () const</td></tr>
<tr class="memdesc:a7dc9181bddf117b596e15cb5ffbf7c97"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the number of samples stored in the buffer. <br /></td></tr>
<tr class="separator:a7dc9181bddf117b596e15cb5ffbf7c97"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2c2cf0078ce0549246ecc4a1646212b4" id="r_a2c2cf0078ce0549246ecc4a1646212b4"><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a2c2cf0078ce0549246ecc4a1646212b4">getSampleRate</a> () const</td></tr>
<tr class="memdesc:a2c2cf0078ce0549246ecc4a1646212b4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the sample rate of the sound. <br /></td></tr>
<tr class="separator:a2c2cf0078ce0549246ecc4a1646212b4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a127707b831d875ed790eef1aa2b9fcc3" id="r_a127707b831d875ed790eef1aa2b9fcc3"><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a127707b831d875ed790eef1aa2b9fcc3">getChannelCount</a> () const</td></tr>
<tr class="memdesc:a127707b831d875ed790eef1aa2b9fcc3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the number of channels used by the sound. <br /></td></tr>
<tr class="separator:a127707b831d875ed790eef1aa2b9fcc3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a604d63466e4b89f9495147a215d4415c" id="r_a604d63466e4b89f9495147a215d4415c"><td class="memItemLeft" align="right" valign="top">std::vector&lt; <a class="el" href="group__audio.html#ga9800c7f3d5e7a9c9310f707b2c995ff3">SoundChannel</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a604d63466e4b89f9495147a215d4415c">getChannelMap</a> () const</td></tr>
<tr class="memdesc:a604d63466e4b89f9495147a215d4415c"><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:a604d63466e4b89f9495147a215d4415c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a280a581d9b360fd16121714c51fc8261" id="r_a280a581d9b360fd16121714c51fc8261"><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="#a280a581d9b360fd16121714c51fc8261">getDuration</a> () const</td></tr>
<tr class="memdesc:a280a581d9b360fd16121714c51fc8261"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the total duration of the sound. <br /></td></tr>
<tr class="separator:a280a581d9b360fd16121714c51fc8261"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad0b6f45d3008cd7d29d340195e68459a" id="r_ad0b6f45d3008cd7d29d340195e68459a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classsf_1_1SoundBuffer.html">SoundBuffer</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ad0b6f45d3008cd7d29d340195e68459a">operator=</a> (const <a class="el" href="classsf_1_1SoundBuffer.html">SoundBuffer</a> &amp;right)</td></tr>
<tr class="memdesc:ad0b6f45d3008cd7d29d340195e68459a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Overload of assignment operator. <br /></td></tr>
<tr class="separator:ad0b6f45d3008cd7d29d340195e68459a"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="friends" name="friends"></a>
Friends</h2></td></tr>
<tr class="memitem:a50914f77c7cf4fb97616c898c5291f4b" id="r_a50914f77c7cf4fb97616c898c5291f4b"><td class="memItemLeft" align="right" valign="top">class&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a50914f77c7cf4fb97616c898c5291f4b">Sound</a></td></tr>
<tr class="separator:a50914f77c7cf4fb97616c898c5291f4b"><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>Storage for audio samples defining a sound. </p>
<p>A sound buffer holds the data of a sound, which is an array of audio samples.</p>
<p>A sample is a 16 bit signed integer that defines the amplitude of the sound at a given time. The sound is then reconstituted by playing these samples at a high rate (for example, 44100 samples per second is the standard rate used for playing CDs). In short, audio samples are like texture pixels, and a <code><a class="el" href="classsf_1_1SoundBuffer.html" title="Storage for audio samples defining a sound.">sf::SoundBuffer</a></code> is similar to a <code><a class="el" href="classsf_1_1Texture.html" title="Image living on the graphics card that can be used for drawing.">sf::Texture</a></code>.</p>
<p>A sound buffer can be loaded from a file, from memory, from a custom stream (see <code><a class="el" href="classsf_1_1InputStream.html" title="Abstract class for custom file input streams.">sf::InputStream</a></code>) or directly from an array of samples. It can also be saved back to a file.</p>
<p><a class="el" href="classsf_1_1Sound.html" title="Regular sound that can be played in the audio environment.">Sound</a> buffers alone are not very useful: they hold the audio data but cannot be played. To do so, you need to use the <code><a class="el" href="classsf_1_1Sound.html" title="Regular sound that can be played in the audio environment.">sf::Sound</a></code> class, which provides functions to play/pause/stop the sound as well as changing the way it is outputted (volume, pitch, 3D position, ...). This separation allows more flexibility and better performances: indeed a <code><a class="el" href="classsf_1_1SoundBuffer.html" title="Storage for audio samples defining a sound.">sf::SoundBuffer</a></code> is a heavy resource, and any operation on it is slow (often too slow for real-time applications). On the other side, a <code><a class="el" href="classsf_1_1Sound.html" title="Regular sound that can be played in the audio environment.">sf::Sound</a></code> is a lightweight object, which can use the audio data of a sound buffer and change the way it is played without actually modifying that data. Note that it is also possible to bind several <code><a class="el" href="classsf_1_1Sound.html" title="Regular sound that can be played in the audio environment.">sf::Sound</a></code> instances to the same <code><a class="el" href="classsf_1_1SoundBuffer.html" title="Storage for audio samples defining a sound.">sf::SoundBuffer</a></code>.</p>
<p>It is important to note that the <code><a class="el" href="classsf_1_1Sound.html" title="Regular sound that can be played in the audio environment.">sf::Sound</a></code> instance doesn't copy the buffer that it uses, it only keeps a reference to it. Thus, a <code><a class="el" href="classsf_1_1SoundBuffer.html" title="Storage for audio samples defining a sound.">sf::SoundBuffer</a></code> must not be destructed while it is used by a <code><a class="el" href="classsf_1_1Sound.html" title="Regular sound that can be played in the audio environment.">sf::Sound</a></code> (i.e. never write a function that uses a local <code><a class="el" href="classsf_1_1SoundBuffer.html" title="Storage for audio samples defining a sound.">sf::SoundBuffer</a></code> instance for loading a sound).</p>
<p>When loading sound samples from an array, a channel map needs to be provided, which specifies the mapping of the position in the sample frame to the sound channel. For example when you have six samples in a frame and a 5.1 sound system, the channel map defines how each of those samples map to which speaker channel.</p>
<p>Usage example: </p><div class="fragment"><div class="line"><span class="comment">// Load a new sound buffer from a file</span></div>
<div class="line"><span class="keyword">const</span> <a class="code hl_class" href="classsf_1_1SoundBuffer.html">sf::SoundBuffer</a> buffer(<span class="stringliteral">&quot;sound.wav&quot;</span>);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create a sound source bound to the buffer</span></div>
<div class="line"><a class="code hl_class" href="classsf_1_1Sound.html">sf::Sound</a> sound1(buffer);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Play the sound</span></div>
<div class="line">sound1.play();</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create another sound source bound to the same buffer</span></div>
<div class="line"><a class="code hl_class" href="classsf_1_1Sound.html">sf::Sound</a> sound2(buffer);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Play it with a higher pitch -- the first sound remains unchanged</span></div>
<div class="line">sound2.setPitch(2);</div>
<div class="line">sound2.play();</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Load samples with a channel map</span></div>
<div class="line"><span class="keyword">auto</span> samples = std::vector&lt;std::int16_t&gt;();</div>
<div class="line"><span class="comment">// ...</span></div>
<div class="line"><span class="keyword">auto</span> channelMap = std::vector&lt;sf::SoundChannel&gt;{</div>
<div class="line"> <a class="code hl_enumvalue" href="group__audio.html#gga9800c7f3d5e7a9c9310f707b2c995ff3a3a86c1ecef856c6360b14ee920abd2d4">sf::SoundChannel::FrontLeft</a>,</div>
<div class="line"> <a class="code hl_enumvalue" href="group__audio.html#gga9800c7f3d5e7a9c9310f707b2c995ff3ad446ecb2171ed693701ea6bd61081da1">sf::SoundChannel::FrontCenter</a>,</div>
<div class="line"> <a class="code hl_enumvalue" href="group__audio.html#gga9800c7f3d5e7a9c9310f707b2c995ff3a17a1a1897fa234ffd995f32ff31c4075">sf::SoundChannel::FrontRight</a>,</div>
<div class="line"> <a class="code hl_enumvalue" href="group__audio.html#gga9800c7f3d5e7a9c9310f707b2c995ff3aa07ea17eb99337c60ed9ad770cf2bb55">sf::SoundChannel::BackRight</a>,</div>
<div class="line"> <a class="code hl_enumvalue" href="group__audio.html#gga9800c7f3d5e7a9c9310f707b2c995ff3abff6f014d4c53710a1ad968e9b401ccb">sf::SoundChannel::BackLeft</a>,</div>
<div class="line"> <a class="code hl_enumvalue" href="group__audio.html#gga9800c7f3d5e7a9c9310f707b2c995ff3aadf637c910a4d16c3ad4f03b31063215">sf::SoundChannel::LowFrequencyEffects</a></div>
<div class="line">};</div>
<div class="line"><span class="keyword">auto</span> soundBuffer = <a class="code hl_class" href="classsf_1_1SoundBuffer.html">sf::SoundBuffer</a>(samples.data(), samples.size(), channelMap.size(), 44100, channelMap);</div>
<div class="line"><span class="keyword">auto</span> sound = <a class="code hl_class" href="classsf_1_1Sound.html">sf::Sound</a>(soundBuffer);</div>
<div class="ttc" id="aclasssf_1_1SoundBuffer_html"><div class="ttname"><a href="classsf_1_1SoundBuffer.html">sf::SoundBuffer</a></div><div class="ttdoc">Storage for audio samples defining a sound.</div><div class="ttdef"><b>Definition</b> <a href="SoundBuffer_8hpp_source.html#l00054">SoundBuffer.hpp:55</a></div></div>
<div class="ttc" id="aclasssf_1_1Sound_html"><div class="ttname"><a href="classsf_1_1Sound.html">sf::Sound</a></div><div class="ttdoc">Regular sound that can be played in the audio environment.</div><div class="ttdef"><b>Definition</b> <a href="Sound_8hpp_source.html#l00047">Sound.hpp:48</a></div></div>
<div class="ttc" id="agroup__audio_html_gga9800c7f3d5e7a9c9310f707b2c995ff3a17a1a1897fa234ffd995f32ff31c4075"><div class="ttname"><a href="group__audio.html#gga9800c7f3d5e7a9c9310f707b2c995ff3a17a1a1897fa234ffd995f32ff31c4075">sf::SoundChannel::FrontRight</a></div><div class="ttdeci">@ FrontRight</div></div>
<div class="ttc" id="agroup__audio_html_gga9800c7f3d5e7a9c9310f707b2c995ff3a3a86c1ecef856c6360b14ee920abd2d4"><div class="ttname"><a href="group__audio.html#gga9800c7f3d5e7a9c9310f707b2c995ff3a3a86c1ecef856c6360b14ee920abd2d4">sf::SoundChannel::FrontLeft</a></div><div class="ttdeci">@ FrontLeft</div></div>
<div class="ttc" id="agroup__audio_html_gga9800c7f3d5e7a9c9310f707b2c995ff3aa07ea17eb99337c60ed9ad770cf2bb55"><div class="ttname"><a href="group__audio.html#gga9800c7f3d5e7a9c9310f707b2c995ff3aa07ea17eb99337c60ed9ad770cf2bb55">sf::SoundChannel::BackRight</a></div><div class="ttdeci">@ BackRight</div></div>
<div class="ttc" id="agroup__audio_html_gga9800c7f3d5e7a9c9310f707b2c995ff3aadf637c910a4d16c3ad4f03b31063215"><div class="ttname"><a href="group__audio.html#gga9800c7f3d5e7a9c9310f707b2c995ff3aadf637c910a4d16c3ad4f03b31063215">sf::SoundChannel::LowFrequencyEffects</a></div><div class="ttdeci">@ LowFrequencyEffects</div></div>
<div class="ttc" id="agroup__audio_html_gga9800c7f3d5e7a9c9310f707b2c995ff3abff6f014d4c53710a1ad968e9b401ccb"><div class="ttname"><a href="group__audio.html#gga9800c7f3d5e7a9c9310f707b2c995ff3abff6f014d4c53710a1ad968e9b401ccb">sf::SoundChannel::BackLeft</a></div><div class="ttdeci">@ BackLeft</div></div>
<div class="ttc" id="agroup__audio_html_gga9800c7f3d5e7a9c9310f707b2c995ff3ad446ecb2171ed693701ea6bd61081da1"><div class="ttname"><a href="group__audio.html#gga9800c7f3d5e7a9c9310f707b2c995ff3ad446ecb2171ed693701ea6bd61081da1">sf::SoundChannel::FrontCenter</a></div><div class="ttdeci">@ FrontCenter</div></div>
</div><!-- fragment --><dl class="section see"><dt>See also</dt><dd><code><a class="el" href="classsf_1_1Sound.html" title="Regular sound that can be played in the audio environment.">sf::Sound</a></code>, <code><a class="el" href="classsf_1_1SoundBufferRecorder.html" title="Specialized SoundRecorder which stores the captured audio data into a sound buffer.">sf::SoundBufferRecorder</a></code> </dd></dl>
<p class="definition">Definition at line <a class="el" href="SoundBuffer_8hpp_source.html#l00054">54</a> of file <a class="el" href="SoundBuffer_8hpp_source.html">SoundBuffer.hpp</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a7e322e6d110d54650e729c41112c4666" name="a7e322e6d110d54650e729c41112c4666"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7e322e6d110d54650e729c41112c4666">&#9670;&#160;</a></span>SoundBuffer() <span class="overload">[1/6]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">sf::SoundBuffer::SoundBuffer </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 empty sound buffer that does not contain any samples. </p>
</div>
</div>
<a id="aaf000fc741ff27015907e8588263f4a6" name="aaf000fc741ff27015907e8588263f4a6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aaf000fc741ff27015907e8588263f4a6">&#9670;&#160;</a></span>SoundBuffer() <span class="overload">[2/6]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">sf::SoundBuffer::SoundBuffer </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classsf_1_1SoundBuffer.html">SoundBuffer</a> &amp;</td> <td class="paramname"><span class="paramname"><em>copy</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Copy constructor. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">copy</td><td>Instance to copy </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a id="a1b2344bb0444fd4ce864369a95df00c2" name="a1b2344bb0444fd4ce864369a95df00c2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1b2344bb0444fd4ce864369a95df00c2">&#9670;&#160;</a></span>SoundBuffer() <span class="overload">[3/6]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">sf::SoundBuffer::SoundBuffer </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 the sound buffer from a file. </p>
<p>See the documentation of <code><a class="el" href="classsf_1_1InputSoundFile.html" title="Provide read access to sound files.">sf::InputSoundFile</a></code> for the list of supported formats.</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 loading was unsuccessful</td></tr>
</table>
</dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><code><a class="el" href="#af8cfa5599739a7edae69c5cba273d33f" title="Load the sound buffer from a file in memory.">loadFromMemory</a></code>, <code><a class="el" href="#ad292156b1e01f6dabd4c0c277d5e079e" title="Load the sound buffer from a custom stream.">loadFromStream</a></code>, <code><a class="el" href="#a8189b2f4dc98bfaeefa49cd2c5a0fc33" title="Load the sound buffer from an array of audio samples.">loadFromSamples</a></code>, <code><a class="el" href="#ab6a37b1508233b505db66a0e47304ae8" title="Save the sound buffer to an audio file.">saveToFile</a></code> </dd></dl>
</div>
</div>
<a id="af34d1a5bb6db60aead02493090600891" name="af34d1a5bb6db60aead02493090600891"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af34d1a5bb6db60aead02493090600891">&#9670;&#160;</a></span>SoundBuffer() <span class="overload">[4/6]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">sf::SoundBuffer::SoundBuffer </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 the sound buffer from a file in memory. </p>
<p>See the documentation of <code><a class="el" href="classsf_1_1InputSoundFile.html" title="Provide read access to sound files.">sf::InputSoundFile</a></code> for the list of supported formats.</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 loading was unsuccessful</td></tr>
</table>
</dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><code><a class="el" href="#a54a9a27b31c1a787fd0ae65936f6a09d" title="Load the sound buffer from a file.">loadFromFile</a></code>, <code><a class="el" href="#ad292156b1e01f6dabd4c0c277d5e079e" title="Load the sound buffer from a custom stream.">loadFromStream</a></code>, <code><a class="el" href="#a8189b2f4dc98bfaeefa49cd2c5a0fc33" title="Load the sound buffer from an array of audio samples.">loadFromSamples</a></code> </dd></dl>
</div>
</div>
<a id="aee16d82812f9c803a55159bb44df891c" name="aee16d82812f9c803a55159bb44df891c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aee16d82812f9c803a55159bb44df891c">&#9670;&#160;</a></span>SoundBuffer() <span class="overload">[5/6]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">sf::SoundBuffer::SoundBuffer </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 the sound buffer from a custom stream. </p>
<p>See the documentation of <code><a class="el" href="classsf_1_1InputSoundFile.html" title="Provide read access to sound files.">sf::InputSoundFile</a></code> for the list of supported formats.</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 loading was unsuccessful</td></tr>
</table>
</dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><code><a class="el" href="#a54a9a27b31c1a787fd0ae65936f6a09d" title="Load the sound buffer from a file.">loadFromFile</a></code>, <code><a class="el" href="#af8cfa5599739a7edae69c5cba273d33f" title="Load the sound buffer from a file in memory.">loadFromMemory</a></code>, <code><a class="el" href="#a8189b2f4dc98bfaeefa49cd2c5a0fc33" title="Load the sound buffer from an array of audio samples.">loadFromSamples</a></code> </dd></dl>
</div>
</div>
<a id="a4a1a60c07dac5f12d189f2b628fb607a" name="a4a1a60c07dac5f12d189f2b628fb607a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4a1a60c07dac5f12d189f2b628fb607a">&#9670;&#160;</a></span>SoundBuffer() <span class="overload">[6/6]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">sf::SoundBuffer::SoundBuffer </td>
<td>(</td>
<td class="paramtype">const 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>sampleCount</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned int</td> <td class="paramname"><span class="paramname"><em>channelCount</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned int</td> <td class="paramname"><span class="paramname"><em>sampleRate</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::vector&lt; <a class="el" href="group__audio.html#ga9800c7f3d5e7a9c9310f707b2c995ff3">SoundChannel</a> &gt; &amp;</td> <td class="paramname"><span class="paramname"><em>channelMap</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Construct the sound buffer from an array of audio samples. </p>
<p>The assumed format of the audio samples is 16 bit signed integer.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">samples</td><td>Pointer to the array of samples in memory </td></tr>
<tr><td class="paramname">sampleCount</td><td>Number of samples in the array </td></tr>
<tr><td class="paramname">channelCount</td><td>Number of channels (1 = mono, 2 = stereo, ...) </td></tr>
<tr><td class="paramname">sampleRate</td><td>Sample rate (number of samples to play per second) </td></tr>
<tr><td class="paramname">channelMap</td><td>Map of position in sample frame to sound channel</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 loading was unsuccessful</td></tr>
</table>
</dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><code><a class="el" href="#a54a9a27b31c1a787fd0ae65936f6a09d" title="Load the sound buffer from a file.">loadFromFile</a></code>, <code><a class="el" href="#af8cfa5599739a7edae69c5cba273d33f" title="Load the sound buffer from a file in memory.">loadFromMemory</a></code>, <code><a class="el" href="#ab6a37b1508233b505db66a0e47304ae8" title="Save the sound buffer to an audio file.">saveToFile</a></code> </dd></dl>
</div>
</div>
<a id="aea240161724ffba74a0d6a9e277d3cd5" name="aea240161724ffba74a0d6a9e277d3cd5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aea240161724ffba74a0d6a9e277d3cd5">&#9670;&#160;</a></span>~SoundBuffer()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">sf::SoundBuffer::~SoundBuffer </td>
<td>(</td>
<td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Destructor. </p>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a127707b831d875ed790eef1aa2b9fcc3" name="a127707b831d875ed790eef1aa2b9fcc3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a127707b831d875ed790eef1aa2b9fcc3">&#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::SoundBuffer::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>
<p>If the sound is mono then the number of channels will be 1, 2 for stereo, etc.</p>
<dl class="section return"><dt>Returns</dt><dd>Number of channels</dd></dl>
<dl class="section see"><dt>See also</dt><dd><code><a class="el" href="#a2c2cf0078ce0549246ecc4a1646212b4" title="Get the sample rate of the sound.">getSampleRate</a></code>, <code><a class="el" href="#a604d63466e4b89f9495147a215d4415c" title="Get the map of position in sample frame to sound channel.">getChannelMap</a></code>, <code><a class="el" href="#a280a581d9b360fd16121714c51fc8261" title="Get the total duration of the sound.">getDuration</a></code> </dd></dl>
</div>
</div>
<a id="a604d63466e4b89f9495147a215d4415c" name="a604d63466e4b89f9495147a215d4415c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a604d63466e4b89f9495147a215d4415c">&#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">std::vector&lt; <a class="el" href="group__audio.html#ga9800c7f3d5e7a9c9310f707b2c995ff3">SoundChannel</a> &gt; sf::SoundBuffer::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="#a2c2cf0078ce0549246ecc4a1646212b4" title="Get the sample rate of the sound.">getSampleRate</a></code>, <code><a class="el" href="#a127707b831d875ed790eef1aa2b9fcc3" title="Get the number of channels used by the sound.">getChannelCount</a></code>, <code><a class="el" href="#a280a581d9b360fd16121714c51fc8261" title="Get the total duration of the sound.">getDuration</a></code> </dd></dl>
</div>
</div>
<a id="a280a581d9b360fd16121714c51fc8261" name="a280a581d9b360fd16121714c51fc8261"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a280a581d9b360fd16121714c51fc8261">&#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::SoundBuffer::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. </p>
<dl class="section return"><dt>Returns</dt><dd><a class="el" href="classsf_1_1Sound.html" title="Regular sound that can be played in the audio environment.">Sound</a> duration</dd></dl>
<dl class="section see"><dt>See also</dt><dd><code><a class="el" href="#a2c2cf0078ce0549246ecc4a1646212b4" title="Get the sample rate of the sound.">getSampleRate</a></code>, <code><a class="el" href="#a127707b831d875ed790eef1aa2b9fcc3" title="Get the number of channels used by the sound.">getChannelCount</a></code>, <code><a class="el" href="#a604d63466e4b89f9495147a215d4415c" title="Get the map of position in sample frame to sound channel.">getChannelMap</a></code> </dd></dl>
</div>
</div>
<a id="a7dc9181bddf117b596e15cb5ffbf7c97" name="a7dc9181bddf117b596e15cb5ffbf7c97"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7dc9181bddf117b596e15cb5ffbf7c97">&#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::SoundBuffer::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 number of samples stored in the buffer. </p>
<p>The array of samples can be accessed with the <code><a class="el" href="#a5ae1d0f4170add05ed9a8345f4745674" title="Get the array of audio samples stored in the buffer.">getSamples()</a></code> function.</p>
<dl class="section return"><dt>Returns</dt><dd>Number of samples</dd></dl>
<dl class="section see"><dt>See also</dt><dd><code><a class="el" href="#a5ae1d0f4170add05ed9a8345f4745674" title="Get the array of audio samples stored in the buffer.">getSamples</a></code> </dd></dl>
</div>
</div>
<a id="a2c2cf0078ce0549246ecc4a1646212b4" name="a2c2cf0078ce0549246ecc4a1646212b4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2c2cf0078ce0549246ecc4a1646212b4">&#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::SoundBuffer::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>
<p>The sample rate is the number of samples played per second. The higher, the better the quality (for example, 44100 samples/s is CD quality).</p>
<dl class="section return"><dt>Returns</dt><dd>Sample rate (number of samples per second)</dd></dl>
<dl class="section see"><dt>See also</dt><dd><code><a class="el" href="#a127707b831d875ed790eef1aa2b9fcc3" title="Get the number of channels used by the sound.">getChannelCount</a></code>, <code><a class="el" href="#a604d63466e4b89f9495147a215d4415c" title="Get the map of position in sample frame to sound channel.">getChannelMap</a></code>, <code><a class="el" href="#a280a581d9b360fd16121714c51fc8261" title="Get the total duration of the sound.">getDuration</a></code> </dd></dl>
</div>
</div>
<a id="a5ae1d0f4170add05ed9a8345f4745674" name="a5ae1d0f4170add05ed9a8345f4745674"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5ae1d0f4170add05ed9a8345f4745674">&#9670;&#160;</a></span>getSamples()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">const std::int16_t * sf::SoundBuffer::getSamples </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 array of audio samples stored in the buffer. </p>
<p>The format of the returned samples is 16 bit signed integer. The total number of samples in this array is given by the <code><a class="el" href="#a7dc9181bddf117b596e15cb5ffbf7c97" title="Get the number of samples stored in the buffer.">getSampleCount()</a></code> function.</p>
<dl class="section return"><dt>Returns</dt><dd>Read-only pointer to the array of sound samples</dd></dl>
<dl class="section see"><dt>See also</dt><dd><code><a class="el" href="#a7dc9181bddf117b596e15cb5ffbf7c97" title="Get the number of samples stored in the buffer.">getSampleCount</a></code> </dd></dl>
</div>
</div>
<a id="a54a9a27b31c1a787fd0ae65936f6a09d" name="a54a9a27b31c1a787fd0ae65936f6a09d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a54a9a27b31c1a787fd0ae65936f6a09d">&#9670;&#160;</a></span>loadFromFile()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">bool sf::SoundBuffer::loadFromFile </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>Load the sound buffer from a file. </p>
<p>See the documentation of <code><a class="el" href="classsf_1_1InputSoundFile.html" title="Provide read access to sound files.">sf::InputSoundFile</a></code> for the list of supported formats.</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 loading succeeded, <code>false</code> if it failed</dd></dl>
<dl class="section see"><dt>See also</dt><dd><code><a class="el" href="#af8cfa5599739a7edae69c5cba273d33f" title="Load the sound buffer from a file in memory.">loadFromMemory</a></code>, <code><a class="el" href="#ad292156b1e01f6dabd4c0c277d5e079e" title="Load the sound buffer from a custom stream.">loadFromStream</a></code>, <code><a class="el" href="#a8189b2f4dc98bfaeefa49cd2c5a0fc33" title="Load the sound buffer from an array of audio samples.">loadFromSamples</a></code>, <code><a class="el" href="#ab6a37b1508233b505db66a0e47304ae8" title="Save the sound buffer to an audio file.">saveToFile</a></code> </dd></dl>
</div>
</div>
<a id="af8cfa5599739a7edae69c5cba273d33f" name="af8cfa5599739a7edae69c5cba273d33f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af8cfa5599739a7edae69c5cba273d33f">&#9670;&#160;</a></span>loadFromMemory()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">bool sf::SoundBuffer::loadFromMemory </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>Load the sound buffer from a file in memory. </p>
<p>See the documentation of <code><a class="el" href="classsf_1_1InputSoundFile.html" title="Provide read access to sound files.">sf::InputSoundFile</a></code> for the list of supported formats.</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 loading succeeded, <code>false</code> if it failed</dd></dl>
<dl class="section see"><dt>See also</dt><dd><code><a class="el" href="#a54a9a27b31c1a787fd0ae65936f6a09d" title="Load the sound buffer from a file.">loadFromFile</a></code>, <code><a class="el" href="#ad292156b1e01f6dabd4c0c277d5e079e" title="Load the sound buffer from a custom stream.">loadFromStream</a></code>, <code><a class="el" href="#a8189b2f4dc98bfaeefa49cd2c5a0fc33" title="Load the sound buffer from an array of audio samples.">loadFromSamples</a></code> </dd></dl>
</div>
</div>
<a id="a8189b2f4dc98bfaeefa49cd2c5a0fc33" name="a8189b2f4dc98bfaeefa49cd2c5a0fc33"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8189b2f4dc98bfaeefa49cd2c5a0fc33">&#9670;&#160;</a></span>loadFromSamples()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">bool sf::SoundBuffer::loadFromSamples </td>
<td>(</td>
<td class="paramtype">const 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>sampleCount</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned int</td> <td class="paramname"><span class="paramname"><em>channelCount</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned int</td> <td class="paramname"><span class="paramname"><em>sampleRate</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::vector&lt; <a class="el" href="group__audio.html#ga9800c7f3d5e7a9c9310f707b2c995ff3">SoundChannel</a> &gt; &amp;</td> <td class="paramname"><span class="paramname"><em>channelMap</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>Load the sound buffer from an array of audio samples. </p>
<p>The assumed format of the audio samples is 16 bit signed integer.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">samples</td><td>Pointer to the array of samples in memory </td></tr>
<tr><td class="paramname">sampleCount</td><td>Number of samples in the array </td></tr>
<tr><td class="paramname">channelCount</td><td>Number of channels (1 = mono, 2 = stereo, ...) </td></tr>
<tr><td class="paramname">sampleRate</td><td>Sample rate (number of samples to play per second) </td></tr>
<tr><td class="paramname">channelMap</td><td>Map of position in sample frame to sound channel</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>true</code> if loading succeeded, <code>false</code> if it failed</dd></dl>
<dl class="section see"><dt>See also</dt><dd><code><a class="el" href="#a54a9a27b31c1a787fd0ae65936f6a09d" title="Load the sound buffer from a file.">loadFromFile</a></code>, <code><a class="el" href="#af8cfa5599739a7edae69c5cba273d33f" title="Load the sound buffer from a file in memory.">loadFromMemory</a></code>, <code><a class="el" href="#ab6a37b1508233b505db66a0e47304ae8" title="Save the sound buffer to an audio file.">saveToFile</a></code> </dd></dl>
</div>
</div>
<a id="ad292156b1e01f6dabd4c0c277d5e079e" name="ad292156b1e01f6dabd4c0c277d5e079e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad292156b1e01f6dabd4c0c277d5e079e">&#9670;&#160;</a></span>loadFromStream()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">bool sf::SoundBuffer::loadFromStream </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>Load the sound buffer from a custom stream. </p>
<p>See the documentation of <code><a class="el" href="classsf_1_1InputSoundFile.html" title="Provide read access to sound files.">sf::InputSoundFile</a></code> for the list of supported formats.</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 loading succeeded, <code>false</code> if it failed</dd></dl>
<dl class="section see"><dt>See also</dt><dd><code><a class="el" href="#a54a9a27b31c1a787fd0ae65936f6a09d" title="Load the sound buffer from a file.">loadFromFile</a></code>, <code><a class="el" href="#af8cfa5599739a7edae69c5cba273d33f" title="Load the sound buffer from a file in memory.">loadFromMemory</a></code>, <code><a class="el" href="#a8189b2f4dc98bfaeefa49cd2c5a0fc33" title="Load the sound buffer from an array of audio samples.">loadFromSamples</a></code> </dd></dl>
</div>
</div>
<a id="ad0b6f45d3008cd7d29d340195e68459a" name="ad0b6f45d3008cd7d29d340195e68459a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad0b6f45d3008cd7d29d340195e68459a">&#9670;&#160;</a></span>operator=()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classsf_1_1SoundBuffer.html">SoundBuffer</a> &amp; sf::SoundBuffer::operator= </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classsf_1_1SoundBuffer.html">SoundBuffer</a> &amp;</td> <td class="paramname"><span class="paramname"><em>right</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Overload of assignment operator. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">right</td><td>Instance to assign</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Reference to self </dd></dl>
</div>
</div>
<a id="ab6a37b1508233b505db66a0e47304ae8" name="ab6a37b1508233b505db66a0e47304ae8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab6a37b1508233b505db66a0e47304ae8">&#9670;&#160;</a></span>saveToFile()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">bool sf::SoundBuffer::saveToFile </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> 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>Save the sound buffer to an audio file. </p>
<p>See the documentation of <code><a class="el" href="classsf_1_1OutputSoundFile.html" title="Provide write access to sound files.">sf::OutputSoundFile</a></code> for the list of supported formats.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">filename</td><td>Path of the sound file to write</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>true</code> if saving succeeded, <code>false</code> if it failed </dd></dl>
</div>
</div>
<h2 class="groupheader">Friends And Related Symbol Documentation</h2>
<a id="a50914f77c7cf4fb97616c898c5291f4b" name="a50914f77c7cf4fb97616c898c5291f4b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a50914f77c7cf4fb97616c898c5291f4b">&#9670;&#160;</a></span>Sound</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">friend class <a class="el" href="classsf_1_1Sound.html">Sound</a></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">friend</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="SoundBuffer_8hpp_source.html#l00317">317</a> of file <a class="el" href="SoundBuffer_8hpp_source.html">SoundBuffer.hpp</a>.</p>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="SoundBuffer_8hpp_source.html">SoundBuffer.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>