<!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;"/> <meta charset="utf-8"/> <!--<link rel='stylesheet' type='text/css' href="https://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic"/>--> <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> </head> <body> <div id="banner-container"> <div id="banner"> <span id="sfml">SFML 2.5.1</span> </div> </div> <div id="content"> <!-- Generated by Doxygen 1.8.14 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</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> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="classes.html"><span>Class Index</span></a></li> <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><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_1SoundFileWriter.html">SoundFileWriter</a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="summary"> <a href="#pub-methods">Public Member Functions</a> | <a href="classsf_1_1SoundFileWriter-members.html">List of all members</a> </div> <div class="headertitle"> <div class="title">sf::SoundFileWriter Class Reference<span class="mlabels"><span class="mlabel">abstract</span></span><div class="ingroups"><a class="el" href="group__audio.html">Audio module</a></div></div> </div> </div><!--header--> <div class="contents"> <p>Abstract base class for sound file encoding. <a href="classsf_1_1SoundFileWriter.html#details">More...</a></p> <p><code>#include <<a class="el" href="SoundFileWriter_8hpp_source.html">SoundFileWriter.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:a76944fc158688f35050bd5b592c90270"><td class="memItemLeft" align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundFileWriter.html#a76944fc158688f35050bd5b592c90270">~SoundFileWriter</a> ()</td></tr> <tr class="memdesc:a76944fc158688f35050bd5b592c90270"><td class="mdescLeft"> </td><td class="mdescRight">Virtual destructor. <a href="#a76944fc158688f35050bd5b592c90270">More...</a><br /></td></tr> <tr class="separator:a76944fc158688f35050bd5b592c90270"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a5c92bcaaa880ef4d3eaab18dae1d3d07"><td class="memItemLeft" align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundFileWriter.html#a5c92bcaaa880ef4d3eaab18dae1d3d07">open</a> (const std::string &filename, unsigned int sampleRate, unsigned int channelCount)=0</td></tr> <tr class="memdesc:a5c92bcaaa880ef4d3eaab18dae1d3d07"><td class="mdescLeft"> </td><td class="mdescRight">Open a sound file for writing. <a href="#a5c92bcaaa880ef4d3eaab18dae1d3d07">More...</a><br /></td></tr> <tr class="separator:a5c92bcaaa880ef4d3eaab18dae1d3d07"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a4ce597e7682d22c5b2c98d77e931a1da"><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundFileWriter.html#a4ce597e7682d22c5b2c98d77e931a1da">write</a> (const Int16 *samples, Uint64 count)=0</td></tr> <tr class="memdesc:a4ce597e7682d22c5b2c98d77e931a1da"><td class="mdescLeft"> </td><td class="mdescRight">Write audio samples to the open file. <a href="#a4ce597e7682d22c5b2c98d77e931a1da">More...</a><br /></td></tr> <tr class="separator:a4ce597e7682d22c5b2c98d77e931a1da"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <div class="textblock"><p>Abstract base class for sound file encoding. </p> <p>This class allows users to write audio file formats not natively supported by SFML, and thus extend the set of supported writable audio formats.</p> <p>A valid sound file writer must override the open and write functions, as well as providing a static check function; the latter is used by SFML to find a suitable writer for a given filename.</p> <p>To register a new writer, use the <a class="el" href="classsf_1_1SoundFileFactory.html#abb6e082ea3fedf22c8648113d1be5755" title="Register a new writer. ">sf::SoundFileFactory::registerWriter</a> template function.</p> <p>Usage example: </p><div class="fragment"><div class="line"><span class="keyword">class </span>MySoundFileWriter : <span class="keyword">public</span> <a class="code" href="classsf_1_1SoundFileWriter.html">sf::SoundFileWriter</a></div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line"></div><div class="line"> <span class="keyword">static</span> <span class="keywordtype">bool</span> check(<span class="keyword">const</span> std::string& filename)</div><div class="line"> {</div><div class="line"> <span class="comment">// typically, check the extension</span></div><div class="line"> <span class="comment">// return true if the writer can handle the format</span></div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classsf_1_1SoundFileWriter.html#a5c92bcaaa880ef4d3eaab18dae1d3d07">open</a>(<span class="keyword">const</span> std::string& filename, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> sampleRate, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channelCount)</div><div class="line"> {</div><div class="line"> <span class="comment">// open the file 'filename' for writing,</span></div><div class="line"> <span class="comment">// write the given sample rate and channel count to the file header</span></div><div class="line"> <span class="comment">// return true on success</span></div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1SoundFileWriter.html#a4ce597e7682d22c5b2c98d77e931a1da">write</a>(<span class="keyword">const</span> sf::Int16* samples, sf::Uint64 count)</div><div class="line"> {</div><div class="line"> <span class="comment">// write 'count' samples stored at address 'samples',</span></div><div class="line"> <span class="comment">// convert them (for example to normalized float) if the format requires it</span></div><div class="line"> }</div><div class="line">};</div><div class="line"></div><div class="line">sf::SoundFileFactory::registerWriter<MySoundFileWriter>();</div></div><!-- fragment --><dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1OutputSoundFile.html" title="Provide write access to sound files. ">sf::OutputSoundFile</a>, <a class="el" href="classsf_1_1SoundFileFactory.html" title="Manages and instantiates sound file readers and writers. ">sf::SoundFileFactory</a>, <a class="el" href="classsf_1_1SoundFileReader.html" title="Abstract base class for sound file decoding. ">sf::SoundFileReader</a> </dd></dl> <p class="definition">Definition at line <a class="el" href="SoundFileWriter_8hpp_source.html#l00041">41</a> of file <a class="el" href="SoundFileWriter_8hpp_source.html">SoundFileWriter.hpp</a>.</p> </div><h2 class="groupheader">Constructor & Destructor Documentation</h2> <a id="a76944fc158688f35050bd5b592c90270"></a> <h2 class="memtitle"><span class="permalink"><a href="#a76944fc158688f35050bd5b592c90270">◆ </a></span>~SoundFileWriter()</h2> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">virtual sf::SoundFileWriter::~SoundFileWriter </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">virtual</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>Virtual destructor. </p> <p class="definition">Definition at line <a class="el" href="SoundFileWriter_8hpp_source.html#l00049">49</a> of file <a class="el" href="SoundFileWriter_8hpp_source.html">SoundFileWriter.hpp</a>.</p> </div> </div> <h2 class="groupheader">Member Function Documentation</h2> <a id="a5c92bcaaa880ef4d3eaab18dae1d3d07"></a> <h2 class="memtitle"><span class="permalink"><a href="#a5c92bcaaa880ef4d3eaab18dae1d3d07">◆ </a></span>open()</h2> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">virtual bool sf::SoundFileWriter::open </td> <td>(</td> <td class="paramtype">const std::string & </td> <td class="paramname"><em>filename</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 class="paramkey"></td> <td></td> <td class="paramtype">unsigned int </td> <td class="paramname"><em>channelCount</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">pure virtual</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>Open a sound file for writing. </p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">filename</td><td>Path of the file to open </td></tr> <tr><td class="paramname">sampleRate</td><td>Sample rate of the sound </td></tr> <tr><td class="paramname">channelCount</td><td>Number of channels of the sound</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>True if the file was successfully opened </dd></dl> </div> </div> <a id="a4ce597e7682d22c5b2c98d77e931a1da"></a> <h2 class="memtitle"><span class="permalink"><a href="#a4ce597e7682d22c5b2c98d77e931a1da">◆ </a></span>write()</h2> <div class="memitem"> <div class="memproto"> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">virtual void sf::SoundFileWriter::write </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">Uint64 </td> <td class="paramname"><em>count</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">pure virtual</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>Write audio samples to the open file. </p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">samples</td><td>Pointer to the sample array to write </td></tr> <tr><td class="paramname">count</td><td>Number of samples to write </td></tr> </table> </dd> </dl> </div> </div> <hr/>The documentation for this class was generated from the following file:<ul> <li><a class="el" href="SoundFileWriter_8hpp_source.html">SoundFileWriter.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 © Laurent Gomila :: Documentation generated by <a href="http://www.doxygen.org/" title="doxygen website">doxygen</a> :: </div> </div> </body> </html>