<head>
<title>SFML - Simple and Fast Multimedia Library</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<link rel="stylesheet" type="text/css" href="doxygen.css" title="default" media="screen,print" />
</head>
<body>
<div id="banner-container">
<div id="banner">
<span id="sfml">SFML</span>
</div>
</div>
<div id="content">
<!-- Generated by Doxygen 1.8.2 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.htm"><span>Main Page</span></a></li>
<li><a href="modules.htm"><span>Modules</span></a></li>
<li class="current"><a href="annotated.htm"><span>Classes</span></a></li>
<li><a href="files.htm"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.htm"><span>Class List</span></a></li>
<li><a href="classes.htm"><span>Class Index</span></a></li>
<li><a href="hierarchy.htm"><span>Class Hierarchy</span></a></li>
<li><a href="functions.htm"><span>Class Members</span></a></li>
</ul>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><b>sf</b></li><li class="navelem"><a class="el" href="classsf_1_1SoundBuffer.htm">SoundBuffer</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> |
<a href="#friends">Friends</a> |
<a href="classsf_1_1SoundBuffer-members.htm">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.htm">Audio module</a></div></div> </div>
</div><!--header-->
<div class="contents">
<p>Storage for audio samples defining a sound.
<a href="classsf_1_1SoundBuffer.htm#details">More...</a></p>
<p><code>#include <<a class="el" href="SoundBuffer_8hpp_source.htm">SoundBuffer.hpp</a>></code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a0cabfbfe19b831bf7d5c9592d92ef233"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.htm#a0cabfbfe19b831bf7d5c9592d92ef233">SoundBuffer</a> ()</td></tr>
<tr class="memdesc:a0cabfbfe19b831bf7d5c9592d92ef233"><td class="mdescLeft"> </td><td class="mdescRight">Default constructor. <a href="#a0cabfbfe19b831bf7d5c9592d92ef233"></a><br/></td></tr>
<tr class="separator:a0cabfbfe19b831bf7d5c9592d92ef233"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aaf000fc741ff27015907e8588263f4a6"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.htm#aaf000fc741ff27015907e8588263f4a6">SoundBuffer</a> (const <a class="el" href="classsf_1_1SoundBuffer.htm">SoundBuffer</a> ©)</td></tr>
<tr class="memdesc:aaf000fc741ff27015907e8588263f4a6"><td class="mdescLeft"> </td><td class="mdescRight">Copy constructor. <a href="#aaf000fc741ff27015907e8588263f4a6"></a><br/></td></tr>
<tr class="separator:aaf000fc741ff27015907e8588263f4a6"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aea240161724ffba74a0d6a9e277d3cd5"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.htm#aea240161724ffba74a0d6a9e277d3cd5">~SoundBuffer</a> ()</td></tr>
<tr class="memdesc:aea240161724ffba74a0d6a9e277d3cd5"><td class="mdescLeft"> </td><td class="mdescRight">Destructor. <a href="#aea240161724ffba74a0d6a9e277d3cd5"></a><br/></td></tr>
<tr class="separator:aea240161724ffba74a0d6a9e277d3cd5"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a2be6a8025c97eb622a7dff6cf2594394"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.htm#a2be6a8025c97eb622a7dff6cf2594394">loadFromFile</a> (const std::string &filename)</td></tr>
<tr class="memdesc:a2be6a8025c97eb622a7dff6cf2594394"><td class="mdescLeft"> </td><td class="mdescRight">Load the sound buffer from a file. <a href="#a2be6a8025c97eb622a7dff6cf2594394"></a><br/></td></tr>
<tr class="separator:a2be6a8025c97eb622a7dff6cf2594394"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:af8cfa5599739a7edae69c5cba273d33f"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.htm#af8cfa5599739a7edae69c5cba273d33f">loadFromMemory</a> (const void *data, std::size_t sizeInBytes)</td></tr>
<tr class="memdesc:af8cfa5599739a7edae69c5cba273d33f"><td class="mdescLeft"> </td><td class="mdescRight">Load the sound buffer from a file in memory. <a href="#af8cfa5599739a7edae69c5cba273d33f"></a><br/></td></tr>
<tr class="separator:af8cfa5599739a7edae69c5cba273d33f"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ad292156b1e01f6dabd4c0c277d5e079e"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.htm#ad292156b1e01f6dabd4c0c277d5e079e">loadFromStream</a> (<a class="el" href="classsf_1_1InputStream.htm">InputStream</a> &stream)</td></tr>
<tr class="memdesc:ad292156b1e01f6dabd4c0c277d5e079e"><td class="mdescLeft"> </td><td class="mdescRight">Load the sound buffer from a custom stream. <a href="#ad292156b1e01f6dabd4c0c277d5e079e"></a><br/></td></tr>
<tr class="separator:ad292156b1e01f6dabd4c0c277d5e079e"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a63da986e144b578135edd48e51c565e8"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.htm#a63da986e144b578135edd48e51c565e8">loadFromSamples</a> (const Int16 *samples, std::size_t sampleCount, unsigned int channelCount, unsigned int sampleRate)</td></tr>
<tr class="memdesc:a63da986e144b578135edd48e51c565e8"><td class="mdescLeft"> </td><td class="mdescRight">Load the sound buffer from an array of audio samples. <a href="#a63da986e144b578135edd48e51c565e8"></a><br/></td></tr>
<tr class="separator:a63da986e144b578135edd48e51c565e8"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ab2083dc1a934c64959d9e3f162328a76"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.htm#ab2083dc1a934c64959d9e3f162328a76">saveToFile</a> (const std::string &filename) const </td></tr>
<tr class="memdesc:ab2083dc1a934c64959d9e3f162328a76"><td class="mdescLeft"> </td><td class="mdescRight">Save the sound buffer to an audio file. <a href="#ab2083dc1a934c64959d9e3f162328a76"></a><br/></td></tr>
<tr class="separator:ab2083dc1a934c64959d9e3f162328a76"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a4ba0c1e5b5be500af42de30b1360eb2e"><td class="memItemLeft" align="right" valign="top">const Int16 * </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.htm#a4ba0c1e5b5be500af42de30b1360eb2e">getSamples</a> () const </td></tr>
<tr class="memdesc:a4ba0c1e5b5be500af42de30b1360eb2e"><td class="mdescLeft"> </td><td class="mdescRight">Get the array of audio samples stored in the buffer. <a href="#a4ba0c1e5b5be500af42de30b1360eb2e"></a><br/></td></tr>
<tr class="separator:a4ba0c1e5b5be500af42de30b1360eb2e"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a2df1f1ae89213adee1494b95bb583f9d"><td class="memItemLeft" align="right" valign="top">std::size_t </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.htm#a2df1f1ae89213adee1494b95bb583f9d">getSampleCount</a> () const </td></tr>
<tr class="memdesc:a2df1f1ae89213adee1494b95bb583f9d"><td class="mdescLeft"> </td><td class="mdescRight">Get the number of samples stored in the buffer. <a href="#a2df1f1ae89213adee1494b95bb583f9d"></a><br/></td></tr>
<tr class="separator:a2df1f1ae89213adee1494b95bb583f9d"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a8cdfaea2ad1d05f81fa67442566c166e"><td class="memItemLeft" align="right" valign="top">unsigned int </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.htm#a8cdfaea2ad1d05f81fa67442566c166e">getSampleRate</a> () const </td></tr>
<tr class="memdesc:a8cdfaea2ad1d05f81fa67442566c166e"><td class="mdescLeft"> </td><td class="mdescRight">Get the sample rate of the sound. <a href="#a8cdfaea2ad1d05f81fa67442566c166e"></a><br/></td></tr>
<tr class="separator:a8cdfaea2ad1d05f81fa67442566c166e"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a0a2890747db3811fb8d969d3e3abd0d1"><td class="memItemLeft" align="right" valign="top">unsigned int </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.htm#a0a2890747db3811fb8d969d3e3abd0d1">getChannelCount</a> () const </td></tr>
<tr class="memdesc:a0a2890747db3811fb8d969d3e3abd0d1"><td class="mdescLeft"> </td><td class="mdescRight">Get the number of channels used by the sound. <a href="#a0a2890747db3811fb8d969d3e3abd0d1"></a><br/></td></tr>
<tr class="separator:a0a2890747db3811fb8d969d3e3abd0d1"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aee681c7a0f3dff4c4d0c9f8bbdb51bb0"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classsf_1_1Time.htm">Time</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.htm#aee681c7a0f3dff4c4d0c9f8bbdb51bb0">getDuration</a> () const </td></tr>
<tr class="memdesc:aee681c7a0f3dff4c4d0c9f8bbdb51bb0"><td class="mdescLeft"> </td><td class="mdescRight">Get the total duration of the sound. <a href="#aee681c7a0f3dff4c4d0c9f8bbdb51bb0"></a><br/></td></tr>
<tr class="separator:aee681c7a0f3dff4c4d0c9f8bbdb51bb0"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:adcc786b60bbd95be1551368fafd274a7"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classsf_1_1SoundBuffer.htm">SoundBuffer</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundBuffer.htm#adcc786b60bbd95be1551368fafd274a7">operator=</a> (const <a class="el" href="classsf_1_1SoundBuffer.htm">SoundBuffer</a> &right)</td></tr>
<tr class="memdesc:adcc786b60bbd95be1551368fafd274a7"><td class="mdescLeft"> </td><td class="mdescRight">Overload of assignment operator. <a href="#adcc786b60bbd95be1551368fafd274a7"></a><br/></td></tr>
<tr class="separator:adcc786b60bbd95be1551368fafd274a7"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="friends"></a>
Friends</h2></td></tr>
<tr class="memitem:a50914f77c7cf4fb97616c898c5291f4b"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a50914f77c7cf4fb97616c898c5291f4b"></a>
class </td><td class="memItemRight" valign="bottom"><b>Sound</b></td></tr>
<tr class="separator:a50914f77c7cf4fb97616c898c5291f4b"><td class="memSeparator" colspan="2"> </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 bits signed integer that defines the amplitude of the sound at a given time. The sound is then restituted 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 <a class="el" href="classsf_1_1SoundBuffer.htm" title="Storage for audio samples defining a sound.">sf::SoundBuffer</a> is similar to a <a class="el" href="classsf_1_1Texture.htm" title="Image living on the graphics card that can be used for drawing.">sf::Texture</a>.</p>
<p>A sound buffer can be loaded from a file (see <a class="el" href="classsf_1_1SoundBuffer.htm#a2be6a8025c97eb622a7dff6cf2594394" title="Load the sound buffer from a file.">loadFromFile()</a> for the complete list of supported formats), from memory, from a custom stream (see <a class="el" href="classsf_1_1InputStream.htm" title="Abstract class for custom file input streams.">sf::InputStream</a>) 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.htm" 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 <a class="el" href="classsf_1_1Sound.htm" title="Regular sound that can be played in the audio environment.">sf::Sound</a> 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 <a class="el" href="classsf_1_1SoundBuffer.htm" title="Storage for audio samples defining a sound.">sf::SoundBuffer</a> is a heavy resource, and any operation on it is slow (often too slow for real-time applications). On the other side, a <a class="el" href="classsf_1_1Sound.htm" title="Regular sound that can be played in the audio environment.">sf::Sound</a> 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 <a class="el" href="classsf_1_1Sound.htm" title="Regular sound that can be played in the audio environment.">sf::Sound</a> instances to the same <a class="el" href="classsf_1_1SoundBuffer.htm" title="Storage for audio samples defining a sound.">sf::SoundBuffer</a>.</p>
<p>It is important to note that the <a class="el" href="classsf_1_1Sound.htm" title="Regular sound that can be played in the audio environment.">sf::Sound</a> instance doesn't copy the buffer that it uses, it only keeps a reference to it. Thus, a <a class="el" href="classsf_1_1SoundBuffer.htm" title="Storage for audio samples defining a sound.">sf::SoundBuffer</a> must not be destructed while it is used by a <a class="el" href="classsf_1_1Sound.htm" title="Regular sound that can be played in the audio environment.">sf::Sound</a> (i.e. never write a function that uses a local <a class="el" href="classsf_1_1SoundBuffer.htm" title="Storage for audio samples defining a sound.">sf::SoundBuffer</a> instance for loading a sound).</p>
<p>Usage example: </p>
<div class="fragment"><div class="line"><span class="comment">// Declare a new sound buffer</span></div>
<div class="line"><a class="code" href="classsf_1_1SoundBuffer.htm" title="Storage for audio samples defining a sound.">sf::SoundBuffer</a> buffer;</div>
<div class="line"></div>
<div class="line"><span class="comment">// Load it from a file</span></div>
<div class="line"><span class="keywordflow">if</span> (!buffer.<a class="code" href="classsf_1_1SoundBuffer.htm#a2be6a8025c97eb622a7dff6cf2594394" title="Load the sound buffer from a file.">loadFromFile</a>(<span class="stringliteral">"sound.wav"</span>))</div>
<div class="line">{</div>
<div class="line"> <span class="comment">// error...</span></div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="comment">// Create a sound source and bind it to the buffer</span></div>
<div class="line"><a class="code" href="classsf_1_1Sound.htm" title="Regular sound that can be played in the audio environment.">sf::Sound</a> sound1;</div>
<div class="line">sound1.<a class="code" href="classsf_1_1Sound.htm#a8b395e9713d0efa48a18628c8ec1972e" title="Set the source buffer containing the audio data to play.">setBuffer</a>(buffer);</div>
<div class="line"></div>
<div class="line"><span class="comment">// Play the sound</span></div>
<div class="line">sound1.<a class="code" href="classsf_1_1Sound.htm#a2953ffe632536e72e696fd880ced2532" title="Start or resume playing the sound.">play</a>();</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" href="classsf_1_1Sound.htm" title="Regular sound that can be played in the audio environment.">sf::Sound</a> sound2;</div>
<div class="line">sound2.<a class="code" href="classsf_1_1Sound.htm#a8b395e9713d0efa48a18628c8ec1972e" title="Set the source buffer containing the audio data to play.">setBuffer</a>(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.<a class="code" href="classsf_1_1SoundSource.htm#a72a13695ed48b7f7b55e7cd4431f4bb6" title="Set the pitch of the sound.">setPitch</a>(2);</div>
<div class="line">sound2.<a class="code" href="classsf_1_1Sound.htm#a2953ffe632536e72e696fd880ced2532" title="Start or resume playing the sound.">play</a>();</div>
</div><!-- fragment --><dl class="section see"><dt>See Also</dt><dd><a class="el" href="classsf_1_1Sound.htm" title="Regular sound that can be played in the audio environment.">sf::Sound</a>, <a class="el" href="classsf_1_1SoundBufferRecorder.htm" title="Specialized SoundRecorder which stores the captured audio data into a sound buffer.">sf::SoundBufferRecorder</a> </dd></dl>
<p>Definition at line <a class="el" href="SoundBuffer_8hpp_source.htm#l00052">52</a> of file <a class="el" href="SoundBuffer_8hpp_source.htm">SoundBuffer.hpp</a>.</p>
</div><h2 class="groupheader">Constructor & Destructor Documentation</h2>
<a class="anchor" id="a0cabfbfe19b831bf7d5c9592d92ef233"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">sf::SoundBuffer::SoundBuffer </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Default constructor. </p>
</div>
</div>
<a class="anchor" id="aaf000fc741ff27015907e8588263f4a6"></a>
<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.htm">SoundBuffer</a> & </td>
<td class="paramname"><em>copy</em></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 class="anchor" id="aea240161724ffba74a0d6a9e277d3cd5"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">sf::SoundBuffer::~SoundBuffer </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Destructor. </p>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a0a2890747db3811fb8d969d3e3abd0d1"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">unsigned int sf::SoundBuffer::getChannelCount </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</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><a class="el" href="classsf_1_1SoundBuffer.htm#a8cdfaea2ad1d05f81fa67442566c166e" title="Get the sample rate of the sound.">getSampleRate</a>, <a class="el" href="classsf_1_1SoundBuffer.htm#aee681c7a0f3dff4c4d0c9f8bbdb51bb0" title="Get the total duration of the sound.">getDuration</a> </dd></dl>
</div>
</div>
<a class="anchor" id="aee681c7a0f3dff4c4d0c9f8bbdb51bb0"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classsf_1_1Time.htm">Time</a> sf::SoundBuffer::getDuration </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</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.htm" 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><a class="el" href="classsf_1_1SoundBuffer.htm#a8cdfaea2ad1d05f81fa67442566c166e" title="Get the sample rate of the sound.">getSampleRate</a>, <a class="el" href="classsf_1_1SoundBuffer.htm#a0a2890747db3811fb8d969d3e3abd0d1" title="Get the number of channels used by the sound.">getChannelCount</a> </dd></dl>
</div>
</div>
<a class="anchor" id="a2df1f1ae89213adee1494b95bb583f9d"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">std::size_t sf::SoundBuffer::getSampleCount </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</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 <a class="el" href="classsf_1_1SoundBuffer.htm#a4ba0c1e5b5be500af42de30b1360eb2e" title="Get the array of audio samples stored in the buffer.">getSamples()</a> function.</p>
<dl class="section return"><dt>Returns</dt><dd>Number of samples</dd></dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classsf_1_1SoundBuffer.htm#a4ba0c1e5b5be500af42de30b1360eb2e" title="Get the array of audio samples stored in the buffer.">getSamples</a> </dd></dl>
</div>
</div>
<a class="anchor" id="a8cdfaea2ad1d05f81fa67442566c166e"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">unsigned int sf::SoundBuffer::getSampleRate </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</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><a class="el" href="classsf_1_1SoundBuffer.htm#a0a2890747db3811fb8d969d3e3abd0d1" title="Get the number of channels used by the sound.">getChannelCount</a>, <a class="el" href="classsf_1_1SoundBuffer.htm#aee681c7a0f3dff4c4d0c9f8bbdb51bb0" title="Get the total duration of the sound.">getDuration</a> </dd></dl>
</div>
</div>
<a class="anchor" id="a4ba0c1e5b5be500af42de30b1360eb2e"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">const Int16* sf::SoundBuffer::getSamples </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</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 bits signed integer (sf::Int16). The total number of samples in this array is given by the <a class="el" href="classsf_1_1SoundBuffer.htm#a2df1f1ae89213adee1494b95bb583f9d" title="Get the number of samples stored in the buffer.">getSampleCount()</a> 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><a class="el" href="classsf_1_1SoundBuffer.htm#a2df1f1ae89213adee1494b95bb583f9d" title="Get the number of samples stored in the buffer.">getSampleCount</a> </dd></dl>
</div>
</div>
<a class="anchor" id="a2be6a8025c97eb622a7dff6cf2594394"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool sf::SoundBuffer::loadFromFile </td>
<td>(</td>
<td class="paramtype">const std::string & </td>
<td class="paramname"><em>filename</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Load the sound buffer from a file. </p>
<p>Here is a complete list of all the supported audio formats: ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.</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>True if loading succeeded, false if it failed</dd></dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classsf_1_1SoundBuffer.htm#af8cfa5599739a7edae69c5cba273d33f" title="Load the sound buffer from a file in memory.">loadFromMemory</a>, <a class="el" href="classsf_1_1SoundBuffer.htm#ad292156b1e01f6dabd4c0c277d5e079e" title="Load the sound buffer from a custom stream.">loadFromStream</a>, <a class="el" href="classsf_1_1SoundBuffer.htm#a63da986e144b578135edd48e51c565e8" title="Load the sound buffer from an array of audio samples.">loadFromSamples</a>, <a class="el" href="classsf_1_1SoundBuffer.htm#ab2083dc1a934c64959d9e3f162328a76" title="Save the sound buffer to an audio file.">saveToFile</a> </dd></dl>
</div>
</div>
<a class="anchor" id="af8cfa5599739a7edae69c5cba273d33f"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool sf::SoundBuffer::loadFromMemory </td>
<td>(</td>
<td class="paramtype">const void * </td>
<td class="paramname"><em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">std::size_t </td>
<td class="paramname"><em>sizeInBytes</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Load the sound buffer from a file in memory. </p>
<p>Here is a complete list of all the supported audio formats: ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.</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>True if loading succeeded, false if it failed</dd></dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classsf_1_1SoundBuffer.htm#a2be6a8025c97eb622a7dff6cf2594394" title="Load the sound buffer from a file.">loadFromFile</a>, <a class="el" href="classsf_1_1SoundBuffer.htm#ad292156b1e01f6dabd4c0c277d5e079e" title="Load the sound buffer from a custom stream.">loadFromStream</a>, <a class="el" href="classsf_1_1SoundBuffer.htm#a63da986e144b578135edd48e51c565e8" title="Load the sound buffer from an array of audio samples.">loadFromSamples</a> </dd></dl>
</div>
</div>
<a class="anchor" id="a63da986e144b578135edd48e51c565e8"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool sf::SoundBuffer::loadFromSamples </td>
<td>(</td>
<td class="paramtype">const Int16 * </td>
<td class="paramname"><em>samples</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">std::size_t </td>
<td class="paramname"><em>sampleCount</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned int </td>
<td class="paramname"><em>channelCount</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned int </td>
<td class="paramname"><em>sampleRate</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></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 bits signed integer (sf::Int16).</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>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>True if loading succeeded, false if it failed</dd></dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classsf_1_1SoundBuffer.htm#a2be6a8025c97eb622a7dff6cf2594394" title="Load the sound buffer from a file.">loadFromFile</a>, <a class="el" href="classsf_1_1SoundBuffer.htm#af8cfa5599739a7edae69c5cba273d33f" title="Load the sound buffer from a file in memory.">loadFromMemory</a>, <a class="el" href="classsf_1_1SoundBuffer.htm#ab2083dc1a934c64959d9e3f162328a76" title="Save the sound buffer to an audio file.">saveToFile</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ad292156b1e01f6dabd4c0c277d5e079e"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool sf::SoundBuffer::loadFromStream </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classsf_1_1InputStream.htm">InputStream</a> & </td>
<td class="paramname"><em>stream</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Load the sound buffer from a custom stream. </p>
<p>Here is a complete list of all the supported audio formats: ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.</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>True if loading succeeded, false if it failed</dd></dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classsf_1_1SoundBuffer.htm#a2be6a8025c97eb622a7dff6cf2594394" title="Load the sound buffer from a file.">loadFromFile</a>, <a class="el" href="classsf_1_1SoundBuffer.htm#af8cfa5599739a7edae69c5cba273d33f" title="Load the sound buffer from a file in memory.">loadFromMemory</a>, <a class="el" href="classsf_1_1SoundBuffer.htm#a63da986e144b578135edd48e51c565e8" title="Load the sound buffer from an array of audio samples.">loadFromSamples</a> </dd></dl>
</div>
</div>
<a class="anchor" id="adcc786b60bbd95be1551368fafd274a7"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classsf_1_1SoundBuffer.htm">SoundBuffer</a>& sf::SoundBuffer::operator= </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classsf_1_1SoundBuffer.htm">SoundBuffer</a> & </td>
<td class="paramname"><em>right</em></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 class="anchor" id="ab2083dc1a934c64959d9e3f162328a76"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool sf::SoundBuffer::saveToFile </td>
<td>(</td>
<td class="paramtype">const std::string & </td>
<td class="paramname"><em>filename</em></td><td>)</td>
<td> const</td>
</tr>
</table>
</div><div class="memdoc">
<p>Save the sound buffer to an audio file. </p>
<p>Here is a complete list of all the supported audio formats: ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.</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>True if saving succeeded, false if it failed</dd></dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classsf_1_1SoundBuffer.htm#a2be6a8025c97eb622a7dff6cf2594394" title="Load the sound buffer from a file.">loadFromFile</a>, <a class="el" href="classsf_1_1SoundBuffer.htm#af8cfa5599739a7edae69c5cba273d33f" title="Load the sound buffer from a file in memory.">loadFromMemory</a>, <a class="el" href="classsf_1_1SoundBuffer.htm#a63da986e144b578135edd48e51c565e8" title="Load the sound buffer from an array of audio samples.">loadFromSamples</a> </dd></dl>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="SoundBuffer_8hpp_source.htm">SoundBuffer.hpp</a></li>
</ul>
</div><!-- contents -->
</div>
<div id="footer-container">
<div id="footer">
Copyright � Laurent Gomila ::
</div>
</div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-41898676-1', 'srchub.org');
ga('send', 'pageview');