619 lines
40 KiB
HTML
619 lines
40 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;"/>
|
|
<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_1SoundRecorder.html">SoundRecorder</a></li> </ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="summary">
|
|
<a href="#pub-methods">Public Member Functions</a> |
|
|
<a href="#pub-static-methods">Static Public Member Functions</a> |
|
|
<a href="#pro-methods">Protected Member Functions</a> |
|
|
<a href="classsf_1_1SoundRecorder-members.html">List of all members</a> </div>
|
|
<div class="headertitle">
|
|
<div class="title">sf::SoundRecorder 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 capturing sound data.
|
|
<a href="classsf_1_1SoundRecorder.html#details">More...</a></p>
|
|
|
|
<p><code>#include <<a class="el" href="SoundRecorder_8hpp_source.html">SoundRecorder.hpp</a>></code></p>
|
|
<div class="dynheader">
|
|
Inheritance diagram for sf::SoundRecorder:</div>
|
|
<div class="dyncontent">
|
|
<div class="center">
|
|
<img src="classsf_1_1SoundRecorder.png" usemap="#sf::SoundRecorder_map" alt=""/>
|
|
<map id="sf::SoundRecorder_map" name="sf::SoundRecorder_map">
|
|
<area href="classsf_1_1AlResource.html" title="Base class for classes that require an OpenAL context. " alt="sf::AlResource" shape="rect" coords="0,0,152,24"/>
|
|
<area href="classsf_1_1SoundBufferRecorder.html" title="Specialized SoundRecorder which stores the captured audio data into a sound buffer. " alt="sf::SoundBufferRecorder" shape="rect" coords="0,112,152,136"/>
|
|
</map>
|
|
</div></div>
|
|
<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:acc599e61aaa47edaae88cf43f0a43549"><td class="memItemLeft" align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundRecorder.html#acc599e61aaa47edaae88cf43f0a43549">~SoundRecorder</a> ()</td></tr>
|
|
<tr class="memdesc:acc599e61aaa47edaae88cf43f0a43549"><td class="mdescLeft"> </td><td class="mdescRight">destructor <a href="#acc599e61aaa47edaae88cf43f0a43549">More...</a><br /></td></tr>
|
|
<tr class="separator:acc599e61aaa47edaae88cf43f0a43549"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a715f0fd2f228c83d79aaedca562ae51f"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundRecorder.html#a715f0fd2f228c83d79aaedca562ae51f">start</a> (unsigned int sampleRate=44100)</td></tr>
|
|
<tr class="memdesc:a715f0fd2f228c83d79aaedca562ae51f"><td class="mdescLeft"> </td><td class="mdescRight">Start the capture. <a href="#a715f0fd2f228c83d79aaedca562ae51f">More...</a><br /></td></tr>
|
|
<tr class="separator:a715f0fd2f228c83d79aaedca562ae51f"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a8d9c8346aa9aa409cfed4a1101159c4c"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundRecorder.html#a8d9c8346aa9aa409cfed4a1101159c4c">stop</a> ()</td></tr>
|
|
<tr class="memdesc:a8d9c8346aa9aa409cfed4a1101159c4c"><td class="mdescLeft"> </td><td class="mdescRight">Stop the capture. <a href="#a8d9c8346aa9aa409cfed4a1101159c4c">More...</a><br /></td></tr>
|
|
<tr class="separator:a8d9c8346aa9aa409cfed4a1101159c4c"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:aed292c297a3e0d627db4eb5c18f58c44"><td class="memItemLeft" align="right" valign="top">unsigned int </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundRecorder.html#aed292c297a3e0d627db4eb5c18f58c44">getSampleRate</a> () const</td></tr>
|
|
<tr class="memdesc:aed292c297a3e0d627db4eb5c18f58c44"><td class="mdescLeft"> </td><td class="mdescRight">Get the sample rate. <a href="#aed292c297a3e0d627db4eb5c18f58c44">More...</a><br /></td></tr>
|
|
<tr class="separator:aed292c297a3e0d627db4eb5c18f58c44"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a8eb3e473292c16e874322815836d3cd3"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundRecorder.html#a8eb3e473292c16e874322815836d3cd3">setDevice</a> (const std::string &name)</td></tr>
|
|
<tr class="memdesc:a8eb3e473292c16e874322815836d3cd3"><td class="mdescLeft"> </td><td class="mdescRight">Set the audio capture device. <a href="#a8eb3e473292c16e874322815836d3cd3">More...</a><br /></td></tr>
|
|
<tr class="separator:a8eb3e473292c16e874322815836d3cd3"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ab16cd53c6884cbf3380c017cee72ba81"><td class="memItemLeft" align="right" valign="top">const std::string & </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundRecorder.html#ab16cd53c6884cbf3380c017cee72ba81">getDevice</a> () const</td></tr>
|
|
<tr class="memdesc:ab16cd53c6884cbf3380c017cee72ba81"><td class="mdescLeft"> </td><td class="mdescRight">Get the name of the current audio capture device. <a href="#ab16cd53c6884cbf3380c017cee72ba81">More...</a><br /></td></tr>
|
|
<tr class="separator:ab16cd53c6884cbf3380c017cee72ba81"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ae4e22ba67d12a74966eb05fad55a317c"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundRecorder.html#ae4e22ba67d12a74966eb05fad55a317c">setChannelCount</a> (unsigned int channelCount)</td></tr>
|
|
<tr class="memdesc:ae4e22ba67d12a74966eb05fad55a317c"><td class="mdescLeft"> </td><td class="mdescRight">Set the channel count of the audio capture device. <a href="#ae4e22ba67d12a74966eb05fad55a317c">More...</a><br /></td></tr>
|
|
<tr class="separator:ae4e22ba67d12a74966eb05fad55a317c"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a610e98e7a73b316ce26b7c55234f86e9"><td class="memItemLeft" align="right" valign="top">unsigned int </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundRecorder.html#a610e98e7a73b316ce26b7c55234f86e9">getChannelCount</a> () const</td></tr>
|
|
<tr class="memdesc:a610e98e7a73b316ce26b7c55234f86e9"><td class="mdescLeft"> </td><td class="mdescRight">Get the number of channels used by this recorder. <a href="#a610e98e7a73b316ce26b7c55234f86e9">More...</a><br /></td></tr>
|
|
<tr class="separator:a610e98e7a73b316ce26b7c55234f86e9"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table><table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
|
|
Static Public Member Functions</h2></td></tr>
|
|
<tr class="memitem:a26198c5c11efcd61f426f326fe314afe"><td class="memItemLeft" align="right" valign="top">static std::vector< std::string > </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundRecorder.html#a26198c5c11efcd61f426f326fe314afe">getAvailableDevices</a> ()</td></tr>
|
|
<tr class="memdesc:a26198c5c11efcd61f426f326fe314afe"><td class="mdescLeft"> </td><td class="mdescRight">Get a list of the names of all available audio capture devices. <a href="#a26198c5c11efcd61f426f326fe314afe">More...</a><br /></td></tr>
|
|
<tr class="separator:a26198c5c11efcd61f426f326fe314afe"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ad1d450a80642dab4b632999d72a1bf23"><td class="memItemLeft" align="right" valign="top">static std::string </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundRecorder.html#ad1d450a80642dab4b632999d72a1bf23">getDefaultDevice</a> ()</td></tr>
|
|
<tr class="memdesc:ad1d450a80642dab4b632999d72a1bf23"><td class="mdescLeft"> </td><td class="mdescRight">Get the name of the default audio capture device. <a href="#ad1d450a80642dab4b632999d72a1bf23">More...</a><br /></td></tr>
|
|
<tr class="separator:ad1d450a80642dab4b632999d72a1bf23"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:aab2bd0fee9e48d6cfd449b1cb078ce5a"><td class="memItemLeft" align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundRecorder.html#aab2bd0fee9e48d6cfd449b1cb078ce5a">isAvailable</a> ()</td></tr>
|
|
<tr class="memdesc:aab2bd0fee9e48d6cfd449b1cb078ce5a"><td class="mdescLeft"> </td><td class="mdescRight">Check if the system supports audio capture. <a href="#aab2bd0fee9e48d6cfd449b1cb078ce5a">More...</a><br /></td></tr>
|
|
<tr class="separator:aab2bd0fee9e48d6cfd449b1cb078ce5a"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table><table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
|
|
Protected Member Functions</h2></td></tr>
|
|
<tr class="memitem:a50ebad413c4f157408a0fa49f23212a9"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundRecorder.html#a50ebad413c4f157408a0fa49f23212a9">SoundRecorder</a> ()</td></tr>
|
|
<tr class="memdesc:a50ebad413c4f157408a0fa49f23212a9"><td class="mdescLeft"> </td><td class="mdescRight">Default constructor. <a href="#a50ebad413c4f157408a0fa49f23212a9">More...</a><br /></td></tr>
|
|
<tr class="separator:a50ebad413c4f157408a0fa49f23212a9"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a85b7fb8a86c08b5084f8f142767bccf6"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundRecorder.html#a85b7fb8a86c08b5084f8f142767bccf6">setProcessingInterval</a> (<a class="el" href="classsf_1_1Time.html">Time</a> interval)</td></tr>
|
|
<tr class="memdesc:a85b7fb8a86c08b5084f8f142767bccf6"><td class="mdescLeft"> </td><td class="mdescRight">Set the processing interval. <a href="#a85b7fb8a86c08b5084f8f142767bccf6">More...</a><br /></td></tr>
|
|
<tr class="separator:a85b7fb8a86c08b5084f8f142767bccf6"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a7af418fb036201d3f85745bef78ce77f"><td class="memItemLeft" align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundRecorder.html#a7af418fb036201d3f85745bef78ce77f">onStart</a> ()</td></tr>
|
|
<tr class="memdesc:a7af418fb036201d3f85745bef78ce77f"><td class="mdescLeft"> </td><td class="mdescRight">Start capturing audio data. <a href="#a7af418fb036201d3f85745bef78ce77f">More...</a><br /></td></tr>
|
|
<tr class="separator:a7af418fb036201d3f85745bef78ce77f"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a2670124cbe7a87c7e46b4840807f4fd7"><td class="memItemLeft" align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundRecorder.html#a2670124cbe7a87c7e46b4840807f4fd7">onProcessSamples</a> (const Int16 *samples, std::size_t sampleCount)=0</td></tr>
|
|
<tr class="memdesc:a2670124cbe7a87c7e46b4840807f4fd7"><td class="mdescLeft"> </td><td class="mdescRight">Process a new chunk of recorded samples. <a href="#a2670124cbe7a87c7e46b4840807f4fd7">More...</a><br /></td></tr>
|
|
<tr class="separator:a2670124cbe7a87c7e46b4840807f4fd7"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:aefc36138ca1e96c658301280e4a31b64"><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1SoundRecorder.html#aefc36138ca1e96c658301280e4a31b64">onStop</a> ()</td></tr>
|
|
<tr class="memdesc:aefc36138ca1e96c658301280e4a31b64"><td class="mdescLeft"> </td><td class="mdescRight">Stop capturing audio data. <a href="#aefc36138ca1e96c658301280e4a31b64">More...</a><br /></td></tr>
|
|
<tr class="separator:aefc36138ca1e96c658301280e4a31b64"><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 capturing sound data. </p>
|
|
<p><a class="el" href="classsf_1_1SoundBuffer.html" title="Storage for audio samples defining a sound. ">sf::SoundBuffer</a> provides a simple interface to access the audio recording capabilities of the computer (the microphone).</p>
|
|
<p>As an abstract base class, it only cares about capturing sound samples, the task of making something useful with them is left to the derived class. Note that SFML provides a built-in specialization for saving the captured data to a sound buffer (see <a class="el" href="classsf_1_1SoundBufferRecorder.html" title="Specialized SoundRecorder which stores the captured audio data into a sound buffer. ">sf::SoundBufferRecorder</a>).</p>
|
|
<p>A derived class has only one virtual function to override: </p><ul>
|
|
<li>onProcessSamples provides the new chunks of audio samples while the capture happens</li>
|
|
</ul>
|
|
<p>Moreover, two additional virtual functions can be overridden as well if necessary: </p><ul>
|
|
<li>onStart is called before the capture happens, to perform custom initializations </li>
|
|
<li>onStop is called after the capture ends, to perform custom cleanup</li>
|
|
</ul>
|
|
<p>A derived class can also control the frequency of the onProcessSamples calls, with the setProcessingInterval protected function. The default interval is chosen so that recording thread doesn't consume too much CPU, but it can be changed to a smaller value if you need to process the recorded data in real time, for example.</p>
|
|
<p>The audio capture feature may not be supported or activated on every platform, thus it is recommended to check its availability with the <a class="el" href="classsf_1_1SoundRecorder.html#aab2bd0fee9e48d6cfd449b1cb078ce5a" title="Check if the system supports audio capture. ">isAvailable()</a> function. If it returns false, then any attempt to use an audio recorder will fail.</p>
|
|
<p>If you have multiple sound input devices connected to your computer (for example: microphone, external soundcard, webcam mic, ...) you can get a list of all available devices through the <a class="el" href="classsf_1_1SoundRecorder.html#a26198c5c11efcd61f426f326fe314afe" title="Get a list of the names of all available audio capture devices. ">getAvailableDevices()</a> function. You can then select a device by calling <a class="el" href="classsf_1_1SoundRecorder.html#a8eb3e473292c16e874322815836d3cd3" title="Set the audio capture device. ">setDevice()</a> with the appropriate device. Otherwise the default capturing device will be used.</p>
|
|
<p>By default the recording is in 16-bit mono. Using the setChannelCount method you can change the number of channels used by the audio capture device to record. Note that you have to decide whether you want to record in mono or stereo before starting the recording.</p>
|
|
<p>It is important to note that the audio capture happens in a separate thread, so that it doesn't block the rest of the program. In particular, the onProcessSamples virtual function (but not onStart and not onStop) will be called from this separate thread. It is important to keep this in mind, because you may have to take care of synchronization issues if you share data between threads. Another thing to bear in mind is that you must call <a class="el" href="classsf_1_1SoundRecorder.html#a8d9c8346aa9aa409cfed4a1101159c4c" title="Stop the capture. ">stop()</a> in the destructor of your derived class, so that the recording thread finishes before your object is destroyed.</p>
|
|
<p>Usage example: </p><div class="fragment"><div class="line"><span class="keyword">class </span>CustomRecorder : <span class="keyword">public</span> <a class="code" href="classsf_1_1SoundRecorder.html">sf::SoundRecorder</a></div><div class="line">{</div><div class="line"> ~CustomRecorder()</div><div class="line"> {</div><div class="line"> <span class="comment">// Make sure to stop the recording thread</span></div><div class="line"> <a class="code" href="classsf_1_1SoundRecorder.html#a8d9c8346aa9aa409cfed4a1101159c4c">stop</a>();</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_1SoundRecorder.html#a7af418fb036201d3f85745bef78ce77f">onStart</a>() <span class="comment">// optional</span></div><div class="line"> {</div><div class="line"> <span class="comment">// Initialize whatever has to be done before the capture starts</span></div><div class="line"> ...</div><div class="line"></div><div class="line"> <span class="comment">// Return true to start playing</span></div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">true</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_1SoundRecorder.html#a2670124cbe7a87c7e46b4840807f4fd7">onProcessSamples</a>(<span class="keyword">const</span> Int16* samples, std::size_t sampleCount)</div><div class="line"> {</div><div class="line"> <span class="comment">// Do something with the new chunk of samples (store them, send them, ...)</span></div><div class="line"> ...</div><div class="line"></div><div class="line"> <span class="comment">// Return true to continue playing</span></div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">true</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_1SoundRecorder.html#aefc36138ca1e96c658301280e4a31b64">onStop</a>() <span class="comment">// optional</span></div><div class="line"> {</div><div class="line"> <span class="comment">// Clean up whatever has to be done after the capture ends</span></div><div class="line"> ...</div><div class="line"> }</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">// Usage</span></div><div class="line"><span class="keywordflow">if</span> (CustomRecorder::isAvailable())</div><div class="line">{</div><div class="line"> CustomRecorder recorder;</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (!recorder.start())</div><div class="line"> <span class="keywordflow">return</span> -1;</div><div class="line"></div><div class="line"> ...</div><div class="line"> recorder.stop();</div><div class="line">}</div></div><!-- fragment --><dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1SoundBufferRecorder.html" title="Specialized SoundRecorder which stores the captured audio data into a sound buffer. ">sf::SoundBufferRecorder</a> </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="SoundRecorder_8hpp_source.html#l00045">45</a> of file <a class="el" href="SoundRecorder_8hpp_source.html">SoundRecorder.hpp</a>.</p>
|
|
</div><h2 class="groupheader">Constructor & Destructor Documentation</h2>
|
|
<a id="acc599e61aaa47edaae88cf43f0a43549"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#acc599e61aaa47edaae88cf43f0a43549">◆ </a></span>~SoundRecorder()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">virtual sf::SoundRecorder::~SoundRecorder </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">virtual</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>destructor </p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a50ebad413c4f157408a0fa49f23212a9"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a50ebad413c4f157408a0fa49f23212a9">◆ </a></span>SoundRecorder()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">sf::SoundRecorder::SoundRecorder </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">protected</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Default constructor. </p>
|
|
<p>This constructor is only meant to be called by derived classes. </p>
|
|
|
|
</div>
|
|
</div>
|
|
<h2 class="groupheader">Member Function Documentation</h2>
|
|
<a id="a26198c5c11efcd61f426f326fe314afe"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a26198c5c11efcd61f426f326fe314afe">◆ </a></span>getAvailableDevices()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">static std::vector<std::string> sf::SoundRecorder::getAvailableDevices </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">static</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Get a list of the names of all available audio capture devices. </p>
|
|
<p>This function returns a vector of strings, containing the names of all available audio capture devices.</p>
|
|
<dl class="section return"><dt>Returns</dt><dd>A vector of strings containing the names </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a610e98e7a73b316ce26b7c55234f86e9"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a610e98e7a73b316ce26b7c55234f86e9">◆ </a></span>getChannelCount()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">unsigned int sf::SoundRecorder::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 this recorder. </p>
|
|
<p>Currently only mono and stereo are supported, so the value is either 1 (for mono) or 2 (for stereo).</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_1SoundRecorder.html#ae4e22ba67d12a74966eb05fad55a317c" title="Set the channel count of the audio capture device. ">setChannelCount</a> </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="ad1d450a80642dab4b632999d72a1bf23"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ad1d450a80642dab4b632999d72a1bf23">◆ </a></span>getDefaultDevice()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">static std::string sf::SoundRecorder::getDefaultDevice </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">static</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Get the name of the default audio capture device. </p>
|
|
<p>This function returns the name of the default audio capture device. If none is available, an empty string is returned.</p>
|
|
<dl class="section return"><dt>Returns</dt><dd>The name of the default audio capture device </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="ab16cd53c6884cbf3380c017cee72ba81"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ab16cd53c6884cbf3380c017cee72ba81">◆ </a></span>getDevice()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">const std::string& sf::SoundRecorder::getDevice </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td> const</td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Get the name of the current audio capture device. </p>
|
|
<dl class="section return"><dt>Returns</dt><dd>The name of the current audio capture device </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="aed292c297a3e0d627db4eb5c18f58c44"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#aed292c297a3e0d627db4eb5c18f58c44">◆ </a></span>getSampleRate()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">unsigned int sf::SoundRecorder::getSampleRate </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td> const</td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Get the sample rate. </p>
|
|
<p>The sample rate defines the number of audio samples captured per second. The higher, the better the quality (for example, 44100 samples/sec is CD quality).</p>
|
|
<dl class="section return"><dt>Returns</dt><dd>Sample rate, in samples per second </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="aab2bd0fee9e48d6cfd449b1cb078ce5a"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#aab2bd0fee9e48d6cfd449b1cb078ce5a">◆ </a></span>isAvailable()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">static bool sf::SoundRecorder::isAvailable </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">static</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Check if the system supports audio capture. </p>
|
|
<p>This function should always be called before using the audio capture features. If it returns false, then any attempt to use <a class="el" href="classsf_1_1SoundRecorder.html" title="Abstract base class for capturing sound data. ">sf::SoundRecorder</a> or one of its derived classes will fail.</p>
|
|
<dl class="section return"><dt>Returns</dt><dd>True if audio capture is supported, false otherwise </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a2670124cbe7a87c7e46b4840807f4fd7"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a2670124cbe7a87c7e46b4840807f4fd7">◆ </a></span>onProcessSamples()</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::SoundRecorder::onProcessSamples </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></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">pure virtual</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Process a new chunk of recorded samples. </p>
|
|
<p>This virtual function is called every time a new chunk of recorded data is available. The derived class can then do whatever it wants with it (storing it, playing it, sending it over the network, etc.).</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">samples</td><td>Pointer to the new chunk of recorded samples </td></tr>
|
|
<tr><td class="paramname">sampleCount</td><td>Number of samples pointed by <em>samples</em> </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>True to continue the capture, or false to stop it </dd></dl>
|
|
|
|
<p>Implemented in <a class="el" href="classsf_1_1SoundBufferRecorder.html#a9ceb94de14632ae8c1b78faf603b4767">sf::SoundBufferRecorder</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a7af418fb036201d3f85745bef78ce77f"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a7af418fb036201d3f85745bef78ce77f">◆ </a></span>onStart()</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::SoundRecorder::onStart </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">virtual</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Start capturing audio data. </p>
|
|
<p>This virtual function may be overridden by a derived class if something has to be done every time a new capture starts. If not, this function can be ignored; the default implementation does nothing.</p>
|
|
<dl class="section return"><dt>Returns</dt><dd>True to start the capture, or false to abort it </dd></dl>
|
|
|
|
<p>Reimplemented in <a class="el" href="classsf_1_1SoundBufferRecorder.html#a531a7445fc8a48eaf9fc039c83f17c6f">sf::SoundBufferRecorder</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="aefc36138ca1e96c658301280e4a31b64"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#aefc36138ca1e96c658301280e4a31b64">◆ </a></span>onStop()</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::SoundRecorder::onStop </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">virtual</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Stop capturing audio data. </p>
|
|
<p>This virtual function may be overridden by a derived class if something has to be done every time the capture ends. If not, this function can be ignored; the default implementation does nothing. </p>
|
|
|
|
<p>Reimplemented in <a class="el" href="classsf_1_1SoundBufferRecorder.html#ab8e53849312413431873a5869d509f1e">sf::SoundBufferRecorder</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="ae4e22ba67d12a74966eb05fad55a317c"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ae4e22ba67d12a74966eb05fad55a317c">◆ </a></span>setChannelCount()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void sf::SoundRecorder::setChannelCount </td>
|
|
<td>(</td>
|
|
<td class="paramtype">unsigned int </td>
|
|
<td class="paramname"><em>channelCount</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Set the channel count of the audio capture device. </p>
|
|
<p>This method allows you to specify the number of channels used for recording. Currently only 16-bit mono and 16-bit stereo are supported.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">channelCount</td><td>Number of channels. Currently only mono (1) and stereo (2) are supported.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1SoundRecorder.html#a610e98e7a73b316ce26b7c55234f86e9" title="Get the number of channels used by this recorder. ">getChannelCount</a> </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a8eb3e473292c16e874322815836d3cd3"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a8eb3e473292c16e874322815836d3cd3">◆ </a></span>setDevice()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">bool sf::SoundRecorder::setDevice </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const std::string & </td>
|
|
<td class="paramname"><em>name</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Set the audio capture device. </p>
|
|
<p>This function sets the audio capture device to the device with the given <em>name</em>. It can be called on the fly (i.e: while recording). If you do so while recording and opening the device fails, it stops the recording.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">name</td><td>The name of the audio capture device</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>True, if it was able to set the requested device</dd></dl>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1SoundRecorder.html#a26198c5c11efcd61f426f326fe314afe" title="Get a list of the names of all available audio capture devices. ">getAvailableDevices</a>, <a class="el" href="classsf_1_1SoundRecorder.html#ad1d450a80642dab4b632999d72a1bf23" title="Get the name of the default audio capture device. ">getDefaultDevice</a> </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a85b7fb8a86c08b5084f8f142767bccf6"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a85b7fb8a86c08b5084f8f142767bccf6">◆ </a></span>setProcessingInterval()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void sf::SoundRecorder::setProcessingInterval </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="classsf_1_1Time.html">Time</a> </td>
|
|
<td class="paramname"><em>interval</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">protected</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Set the processing interval. </p>
|
|
<p>The processing interval controls the period between calls to the onProcessSamples function. You may want to use a small interval if you want to process the recorded data in real time, for example.</p>
|
|
<p>Note: this is only a hint, the actual period may vary. So don't rely on this parameter to implement precise timing.</p>
|
|
<p>The default processing interval is 100 ms.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">interval</td><td>Processing interval </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a715f0fd2f228c83d79aaedca562ae51f"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a715f0fd2f228c83d79aaedca562ae51f">◆ </a></span>start()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">bool sf::SoundRecorder::start </td>
|
|
<td>(</td>
|
|
<td class="paramtype">unsigned int </td>
|
|
<td class="paramname"><em>sampleRate</em> = <code>44100</code></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Start the capture. </p>
|
|
<p>The <em>sampleRate</em> parameter defines the number of audio samples captured per second. The higher, the better the quality (for example, 44100 samples/sec is CD quality). This function uses its own thread so that it doesn't block the rest of the program while the capture runs. Please note that only one capture can happen at the same time. You can select which capture device will be used, by passing the name to the <a class="el" href="classsf_1_1SoundRecorder.html#a8eb3e473292c16e874322815836d3cd3" title="Set the audio capture device. ">setDevice()</a> method. If none was selected before, the default capture device will be used. You can get a list of the names of all available capture devices by calling <a class="el" href="classsf_1_1SoundRecorder.html#a26198c5c11efcd61f426f326fe314afe" title="Get a list of the names of all available audio capture devices. ">getAvailableDevices()</a>.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">sampleRate</td><td>Desired capture rate, in number of samples per second</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>True, if start of capture was successful</dd></dl>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1SoundRecorder.html#a8d9c8346aa9aa409cfed4a1101159c4c" title="Stop the capture. ">stop</a>, <a class="el" href="classsf_1_1SoundRecorder.html#a26198c5c11efcd61f426f326fe314afe" title="Get a list of the names of all available audio capture devices. ">getAvailableDevices</a> </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a8d9c8346aa9aa409cfed4a1101159c4c"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a8d9c8346aa9aa409cfed4a1101159c4c">◆ </a></span>stop()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void sf::SoundRecorder::stop </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Stop the capture. </p>
|
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classsf_1_1SoundRecorder.html#a715f0fd2f228c83d79aaedca562ae51f" title="Start the capture. ">start</a> </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<hr/>The documentation for this class was generated from the following file:<ul>
|
|
<li><a class="el" href="SoundRecorder_8hpp_source.html">SoundRecorder.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>
|