⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classpsoundchannel.html

📁 pwlib开发文档
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>PSoundChannel class Reference</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.2.18 --><center><a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; </center><hr><h1>PSoundChannel Class Reference</h1><code>#include &lt;<a class="el" href="sound_8h-source.html">sound.h</a>&gt;</code><p><p>Inheritance diagram for PSoundChannel:<p><center><img src="classPSoundChannel.png" usemap="#PSoundChannel_map" border="0" alt=""></center><map name="PSoundChannel_map"><area href="classPChannel.html" alt="PChannel" shape="rect" coords="0,56,103,80"><area href="classPObject.html" alt="PObject" shape="rect" coords="0,0,103,24"></map><a href="classPSoundChannel-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0><tr><td></td></tr><tr><td colspan=2><br><h2>Construction</h2></td></tr><tr><td nowrap align=right valign=top>enum &nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z387_0">Directions</a> { <a class="el" href="classPSoundChannel.html#z387_0s0">Recorder</a>, <a class="el" href="classPSoundChannel.html#z387_0s1">Player</a> }</td></tr><tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z387_1">PSoundChannel</a> ()</td></tr><tr><td>&nbsp;</td><td><font size=-1><em>Create a sound channel.</em> <a href="#z387_1"></a><em></em></font><br><br></td></tr><tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z387_2">PSoundChannel</a> (const <a class="el" href="classPString.html">PString</a> &amp;device, <a class="el" href="classPSoundChannel.html#z387_0">Directions</a> dir, unsigned numChannels=1, unsigned sampleRate=8000, unsigned bitsPerSample=16)</td></tr><tr><td nowrap align=right valign=top>virtual&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z387_3">~PSoundChannel</a> ()</td></tr><tr><td colspan=2><br><h2>Channel set up functions</h2></td></tr><tr><td nowrap align=right valign=top>enum &nbsp;</td><td valign=bottom>{ <a class="el" href="classPSoundChannel.html#z391_0s2">MaxVolume</a> =  100 }</td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z391_1">SetFormat</a> (unsigned numChannels=1, unsigned sampleRate=8000, unsigned bitsPerSample=16)</td></tr><tr><td nowrap align=right valign=top>virtual unsigned&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z391_2">GetChannels</a> () const</td></tr><tr><td>&nbsp;</td><td><font size=-1><em>Get the number of channels (mono/stereo) in the sound.</em> <a href="#z391_2"></a><em></em></font><br><br></td></tr><tr><td nowrap align=right valign=top>virtual unsigned&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z391_3">GetSampleRate</a> () const</td></tr><tr><td>&nbsp;</td><td><font size=-1><em>Get the sample rate in samples per second.</em> <a href="#z391_3"></a><em></em></font><br><br></td></tr><tr><td nowrap align=right valign=top>virtual unsigned&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z391_4">GetSampleSize</a> () const</td></tr><tr><td>&nbsp;</td><td><font size=-1><em>Get the sample size in bits per sample.</em> <a href="#z391_4"></a><em></em></font><br><br></td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z391_5">SetBuffers</a> (PINDEX size, PINDEX count=2)</td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z391_6">GetBuffers</a> (PINDEX &amp;size, PINDEX &amp;count)</td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z391_7">SetVolume</a> (unsigned volume)</td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z391_8">GetVolume</a> (unsigned &amp;volume)</td></tr><tr><td colspan=2><br><h2>Open functions</h2></td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z389_0">Open</a> (const <a class="el" href="classPString.html">PString</a> &amp;device, <a class="el" href="classPSoundChannel.html#z387_0">Directions</a> dir, unsigned numChannels=1, unsigned sampleRate=8000, unsigned bitsPerSample=16)</td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z389_1">IsOpen</a> () const</td></tr><tr><td nowrap align=right valign=top>virtual int&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z389_2">GetHandle</a> () const</td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z389_3">Abort</a> ()</td></tr><tr><td nowrap align=right valign=top><a class="el" href="classPStringList.html">PStringList</a>&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z389_4">GetDriverNames</a> (<a class="el" href="classPPluginManager.html">PPluginManager</a> *pluginMgr=NULL)</td></tr><tr><td nowrap align=right valign=top><a class="el" href="classPStringList.html">PStringList</a>&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z389_5">GetDeviceNames</a> (const <a class="el" href="classPString.html">PString</a> &amp;driverName, const <a class="el" href="classPSoundChannel.html#z387_0">PSoundChannel::Directions</a>, <a class="el" href="classPPluginManager.html">PPluginManager</a> *pluginMgr=NULL)</td></tr><tr><td nowrap align=right valign=top>PSoundChannel *&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z389_6">CreateChannel</a> (const <a class="el" href="classPString.html">PString</a> &amp;driverName, <a class="el" href="classPPluginManager.html">PPluginManager</a> *pluginMgr=NULL)</td></tr><tr><td nowrap align=right valign=top>PSoundChannel *&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z389_7">CreateOpenedChannel</a> (const <a class="el" href="classPString.html">PString</a> &amp;driverName, const <a class="el" href="classPString.html">PString</a> &amp;deviceName, const <a class="el" href="classPSoundChannel.html#z387_0">PSoundChannel::Directions</a>, unsigned numChannels=1, unsigned sampleRate=8000, unsigned bitsPerSample=16)</td></tr><tr><td nowrap align=right valign=top><a class="el" href="classPString.html">PString</a>&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z389_8">GetDefaultDevice</a> (<a class="el" href="classPSoundChannel.html#z387_0">Directions</a> dir)</td></tr><tr><td nowrap align=right valign=top><a class="el" href="classPStringList.html">PStringList</a>&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z389_9">GetDeviceNames</a> (<a class="el" href="classPSoundChannel.html#z387_0">Directions</a> dir)</td></tr><tr><td colspan=2><br><h2>Public Types</h2></td></tr><tr><td colspan=2><br><h2>Public Methods</h2></td></tr><tr><td colspan="2"><div class="groupHeader">Play functions</div></td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z393_0">Write</a> (const void *buf, PINDEX len)</td></tr><tr><td nowrap align=right valign=top>PINDEX&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z393_1">GetLastWriteCount</a> () const</td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z393_2">PlaySound</a> (const <a class="el" href="classPSound.html">PSound</a> &amp;sound, BOOL wait=TRUE)</td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z393_3">PlayFile</a> (const <a class="el" href="classPFilePath.html">PFilePath</a> &amp;file, BOOL wait=TRUE)</td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z393_4">HasPlayCompleted</a> ()</td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z393_5">WaitForPlayCompletion</a> ()</td></tr><tr><td colspan="2"><div class="groupHeader">Record functions</div></td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z395_0">Read</a> (void *buf, PINDEX len)</td></tr><tr><td nowrap align=right valign=top>PINDEX&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z395_1">GetLastReadCount</a> () const</td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z395_2">RecordSound</a> (<a class="el" href="classPSound.html">PSound</a> &amp;sound)</td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z395_3">RecordFile</a> (const <a class="el" href="classPFilePath.html">PFilePath</a> &amp;file)</td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z395_4">StartRecording</a> ()</td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z395_5">IsRecordBufferFull</a> ()</td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z395_6">AreAllRecordBuffersFull</a> ()</td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z395_7">WaitForRecordBufferFull</a> ()</td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#z395_8">WaitForAllRecordBuffersFull</a> ()</td></tr><tr><td colspan=2><br><h2>Protected Attributes</h2></td></tr><tr><td nowrap align=right valign=top>PSoundChannel *&nbsp;</td><td valign=bottom><a class="el" href="classPSoundChannel.html#n0">baseChannel</a></td></tr></table><hr><a name="_details"></a><h2>Detailed Description</h2>This class is both an abstract class for a generalised sound channel,  and an implementation of PSoundChannel for old code that is not plugin-aware. When instantiated, it selects the first plugin of the base class "PSoundChannel"<p>As an abstract class, this represents a sound schannel. Drivers for real, platform dependent sound hardware will be ancestors of this class and can be found in the plugins section of PWLib.<p>A sound driver is either playing or recording. If simultaneous playing and recording is desired, two instances of PSoundChannel must be created.<p>The sound is buffered and the size and number of buffers should be set before playing/recording. Each call to <a class="el" href="classPSoundChannel.html#z393_0">Write()</a> will use one buffer, so care needs to be taken not to use a large number of small writes but tailor the buffers to the size of each write you make.<p>Similarly for reading, an entire buffer must be read before any of it is available to a <a class="el" href="classPSoundChannel.html#z395_0">Read()</a> call. Note that once a buffer is filled you can read it a byte at a time if desired, but as soon as all the data in the buffer is used returned, the next read will wait until the entire next buffer is read from the hardware. So again, tailor the number and size of buffers to the application. To avoid being blocked until the buffer fills, you can use the <a class="el" href="classPSoundChannel.html#z395_4">StartRecording()</a> function to initiate the buffer filling, and the IsRecordingBufferFull() function to determine when the <a class="el" href="classPSoundChannel.html#z395_0">Read()</a> function will no longer block.<p>Note that this sound channel is implicitly a linear PCM channel. No data conversion is performed on data to/from the channel. <p><hr><h2>Member Enumeration Documentation</h2><a name="z391_0" doxytag="PSoundChannel::@12"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> anonymous enum      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p><dl compact><dt><b>Enumeration values: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em><a name="z391_0s2" doxytag="MaxVolume"></a><em>MaxVolume</em></em>&nbsp;</td><td></td></tr></table></dl>    </td>  </tr></table><a name="z387_0" doxytag="PSoundChannel::Directions"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> enum PSoundChannel::Directions      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p><dl compact><dt><b>Enumeration values: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em><a name="z387_0s0" doxytag="Recorder"></a><em>Recorder</em></em>&nbsp;</td><td></td></tr><tr><td valign=top><em><a name="z387_0s1" doxytag="Player"></a><em>Player</em></em>&nbsp;</td><td></td></tr></table></dl>    </td>  </tr></table><hr><h2>Constructor &amp; Destructor Documentation</h2><a name="z387_1" doxytag="PSoundChannel::PSoundChannel"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> PSoundChannel::PSoundChannel </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="mdname1" valign="top" nowrap>&nbsp;          </td>          <td class="md" valign="top">)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Create a sound channel.<p>    </td>  </tr></table><a name="z387_2" doxytag="PSoundChannel::PSoundChannel"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> PSoundChannel::PSoundChannel </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">const <a class="el" href="classPString.html">PString</a> &amp;&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>device</em>, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap><a class="el" href="classPSoundChannel.html#z387_0">Directions</a>&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>dir</em>, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>unsigned&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>numChannels</em> = 1, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>unsigned&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>sampleRate</em> = 8000, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>unsigned&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>bitsPerSample</em> = 16</td>        </tr>        <tr>          <td></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Create a sound channel. Create a reference to the sound drivers for the platform. <dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>dir</em>&nbsp;</td><td>Name of sound driver/device </td></tr><tr><td valign=top><em>numChannels</em>&nbsp;</td><td>Sound I/O direction </td></tr><tr><td valign=top><em>sampleRate</em>&nbsp;</td><td>Number of channels eg mono/stereo </td></tr><tr><td valign=top><em>bitsPerSample</em>&nbsp;</td><td>Samples per second Number of bits per sample </td></tr></table></dl>    </td>  </tr></table><a name="z387_3" doxytag="PSoundChannel::~PSoundChannel"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> virtual PSoundChannel::~PSoundChannel </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="mdname1" valign="top" nowrap>&nbsp;          </td>          <td class="md" valign="top">)&nbsp;</td>          <td class="md" nowrap><code> [virtual]</code></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>    </td>  </tr></table><hr><h2>Member Function Documentation</h2><a name="z389_3" doxytag="PSoundChannel::Abort"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> virtual BOOL PSoundChannel::Abort </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="mdname1" valign="top" nowrap>&nbsp;          </td>          <td class="md" valign="top">)&nbsp;</td>          <td class="md" nowrap><code> [inline, virtual]</code></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Abort the background playing/recording of the sound channel.<p><dl compact><dt><b>Returns: </b></dt><dd> TRUE if the sound has successfully been aborted. </dl>    </td>  </tr></table><a name="z395_6" doxytag="PSoundChannel::AreAllRecordBuffersFull"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> virtual BOOL PSoundChannel::AreAllRecordBuffersFull </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="mdname1" valign="top" nowrap>&nbsp;          </td>          <td class="md" valign="top">)&nbsp;</td>          <td class="md" nowrap><code> [inline, virtual]</code></td>        </tr>      </table>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -