Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bad97183153701b09df5fae1052b1c30 > files > 128

crystalspace-doc-1.2.1-5mdv2010.0.i586.rpm

<!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>Crystal Space 1.2.1: CS::SndSys::PCMSampleConverter Class Reference (Crystal Space 1.2.1 Public API Reference)</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<table border="0" cellpadding="0" cellspacing="0" width="100%" class="head">
 <tr height="59">
  <td class="head" width="202" valign="bottom" style="padding-left:0;"><a href="http://www.crystalspace3d.org/"><img src="csblur.png" width="236" height="59" alt="CrystalSpace" border="0"></a></td>
  <td class="head"><h2>Public API Reference</h2></td>
 </tr>
 <tr height="11">
  <td colspan="2" class="headshadow" valign="top" style="padding-left:0;"><img src="csblurb.png" width="236" height="11" alt="" border="0"></td>
 </tr>
</table>
<div class="content">
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</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="classes.html"><span>Classes</span></a></li>
    <li><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  </ul>
</div>
<div class="tabs">
  <ul>
    <li><a href="classes.html"><span>Alphabetical&nbsp;List</span></a></li>
    <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
    <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
    <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
  </ul>
</div>
<div class="nav">
<a class="el" href="namespaceCS.html">CS</a>::<a class="el" href="namespaceCS_1_1SndSys.html">SndSys</a>::<a class="el" href="classCS_1_1SndSys_1_1PCMSampleConverter.html">PCMSampleConverter</a></div>
<h1>CS::SndSys::PCMSampleConverter Class Reference</h1><!-- doxytag: class="CS::SndSys::PCMSampleConverter" -->A <a class="el" href="classCS_1_1SndSys_1_1PCMSampleConverter.html" title="A PCMSampleConverter object converts PCM data from one format to another.">PCMSampleConverter</a> object converts PCM data from one format to another.  
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="convert_8h-source.html">csplugincommon/sndsys/convert.h</a>&gt;</code>
<p>

<p>
<a href="classCS_1_1SndSys_1_1PCMSampleConverter-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCS_1_1SndSys_1_1PCMSampleConverter.html#37ac375ff754462f60c171e6c16d11cc">ConvertBuffer</a> (const void *source, size_t source_len, void *dest, int dest_channels, int dest_bitspersample, int dest_frequency)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Convert a buffer of PCM data from the currently set source format to the desired dest format.  <a href="#37ac375ff754462f60c171e6c16d11cc"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCS_1_1SndSys_1_1PCMSampleConverter.html#69e9cb5b6a07be2293225060c70d0a15">GetRequiredOutputBufferMultiple</a> (int dest_channels, int dest_bitspersample, int dest_frequency)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return a multiplier that relates input buffer samples/size to output buffer samples/size.  <a href="#69e9cb5b6a07be2293225060c70d0a15"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCS_1_1SndSys_1_1PCMSampleConverter.html#ff600470124d5b919f1a489be8ed908f">PCMSampleConverter</a> (int source_channels, int source_bitspersample, int source_frequency, bool swap16=false)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create a <a class="el" href="classCS_1_1SndSys_1_1PCMSampleConverter.html" title="A PCMSampleConverter object converts PCM data from one format to another.">PCMSampleConverter</a> with initial source properties provided.  <a href="#ff600470124d5b919f1a489be8ed908f"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCS_1_1SndSys_1_1PCMSampleConverter.html#44c8074a80383cd7a0f43cdbfd7fff28">SetSourceProperties</a> (int source_channels, int source_bitspersample, int source_frequency)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Adjust the source properties for data being presented in the next call to ConvertBuffer.  <a href="#44c8074a80383cd7a0f43cdbfd7fff28"></a><br></td></tr>
<tr><td colspan="2"><br><h2>Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="70e82d8486b0076de29741816f80145c"></a><!-- doxytag: member="CS::SndSys::PCMSampleConverter::last_sample" ref="70e82d8486b0076de29741816f80145c" args="[CS_SOUND_ELEMENT_MAX_CHANNELS]" -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCS_1_1SndSys_1_1PCMSampleConverter.html#70e82d8486b0076de29741816f80145c">last_sample</a> [CS_SOUND_ELEMENT_MAX_CHANNELS]</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="c6eef20af5e344f482599e5374ddee4b"></a><!-- doxytag: member="CS::SndSys::PCMSampleConverter::position_offset" ref="c6eef20af5e344f482599e5374ddee4b" args="" -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCS_1_1SndSys_1_1PCMSampleConverter.html#c6eef20af5e344f482599e5374ddee4b">position_offset</a></td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="fa4a2bafed16ba790bc11ba7efc3abe0"></a><!-- doxytag: member="CS::SndSys::PCMSampleConverter::src_bytes" ref="fa4a2bafed16ba790bc11ba7efc3abe0" args="" -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCS_1_1SndSys_1_1PCMSampleConverter.html#fa4a2bafed16ba790bc11ba7efc3abe0">src_bytes</a></td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="5e5861a7fc5d54e2d46353a70515f911"></a><!-- doxytag: member="CS::SndSys::PCMSampleConverter::src_channels" ref="5e5861a7fc5d54e2d46353a70515f911" args="" -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCS_1_1SndSys_1_1PCMSampleConverter.html#5e5861a7fc5d54e2d46353a70515f911">src_channels</a></td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="4237ae3a26ab9e22f02ecb112d02df87"></a><!-- doxytag: member="CS::SndSys::PCMSampleConverter::src_frequency" ref="4237ae3a26ab9e22f02ecb112d02df87" args="" -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCS_1_1SndSys_1_1PCMSampleConverter.html#4237ae3a26ab9e22f02ecb112d02df87">src_frequency</a></td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="44285cd8226e6cd619aef599e4ef87ea"></a><!-- doxytag: member="CS::SndSys::PCMSampleConverter::swap_16" ref="44285cd8226e6cd619aef599e4ef87ea" args="" -->
bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCS_1_1SndSys_1_1PCMSampleConverter.html#44285cd8226e6cd619aef599e4ef87ea">swap_16</a></td></tr>

</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
A <a class="el" href="classCS_1_1SndSys_1_1PCMSampleConverter.html" title="A PCMSampleConverter object converts PCM data from one format to another.">PCMSampleConverter</a> object converts PCM data from one format to another. 
<p>
The converter can convert between different number of channels, bits per sample and sampling frequency.<p>
UNCOMPRESSED PCM SAMPLES ONLY!<p>
8 and 16 bit samples are supported.<p>
When converting between streams with different numbers of channels, mono source streams will have audio data copied to the second channel. If the destination is a stereo (2 channel) output, this will duplicate the mono/left stream onto the right stream. Additional channels will be left in silence. Converting a mono sample to a 5.1 sample will result in identical samples in streams 0 and 1 and silence in all other streams.<p>
Frequency conversion is performed using linear interpolation between adjacent samples. If a direct-ratio conversion is performed (for example, if a 44100 khz stream is converted into a 11025 stream) then only direct data points will be considered and the rest will be thrown out.<p>
Frequency conversion can be used to alter the playback speed of stream. If the output format should be 22050 khz and you specify 11025 khz, the sound will play twice as fast (no, this isn't a typo - the slower output data is read at a faster rate, causing the data to be traversed faster). Internally, speed can be stepped in 1/CS_SOUND INTERNAL_FREQUENCY_DIVISOR increments from the source frequency. This means if you specify more accurate than this increment, truncation to the next lowest value will occur. If you have a source at 44100 khz and specify an output at 44101 khz, the rate will most likely be reduced to 44100 khz - so no frequency conversion will take place.<p>
Beware of very high frequency conversion rates! If your source audio is of poor sampling rate (11025 khz), increasing the speed of playback will make it sound worse! At some point it will degenerate into indistinguishable noise. If you intend to speed up playback it's best to start with a higher sampling rate (44100 khz). 
<p>Definition at line <a class="el" href="convert_8h-source.html#l00101">101</a> of file <a class="el" href="convert_8h-source.html">convert.h</a>.</p>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="ff600470124d5b919f1a489be8ed908f"></a><!-- doxytag: member="CS::SndSys::PCMSampleConverter::PCMSampleConverter" ref="ff600470124d5b919f1a489be8ed908f" args="(int source_channels, int source_bitspersample, int source_frequency, bool swap16=false)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">CS::SndSys::PCMSampleConverter::PCMSampleConverter           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>source_channels</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>source_bitspersample</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>source_frequency</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>swap16</em> = <code>false</code></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Create a <a class="el" href="classCS_1_1SndSys_1_1PCMSampleConverter.html" title="A PCMSampleConverter object converts PCM data from one format to another.">PCMSampleConverter</a> with initial source properties provided. 
<p>

</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="37ac375ff754462f60c171e6c16d11cc"></a><!-- doxytag: member="CS::SndSys::PCMSampleConverter::ConvertBuffer" ref="37ac375ff754462f60c171e6c16d11cc" args="(const void *source, size_t source_len, void *dest, int dest_channels, int dest_bitspersample, int dest_frequency)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int CS::SndSys::PCMSampleConverter::ConvertBuffer           </td>
          <td>(</td>
          <td class="paramtype">const void *&nbsp;</td>
          <td class="paramname"> <em>source</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&nbsp;</td>
          <td class="paramname"> <em>source_len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>dest</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>dest_channels</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>dest_bitspersample</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>dest_frequency</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Convert a buffer of PCM data from the currently set source format to the desired dest format. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>source</em>&nbsp;</td><td></td></tr>
    <tr><td valign="top"></td><td valign="top"><em>source_len</em>&nbsp;</td><td></td></tr>
    <tr><td valign="top"></td><td valign="top"><em>dest</em>&nbsp;</td><td></td></tr>
    <tr><td valign="top"></td><td valign="top"><em>dest_channels</em>&nbsp;</td><td></td></tr>
    <tr><td valign="top"></td><td valign="top"><em>dest_bitspersample</em>&nbsp;</td><td></td></tr>
    <tr><td valign="top"></td><td valign="top"><em>dest_frequency</em>&nbsp;</td><td></td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="69e9cb5b6a07be2293225060c70d0a15"></a><!-- doxytag: member="CS::SndSys::PCMSampleConverter::GetRequiredOutputBufferMultiple" ref="69e9cb5b6a07be2293225060c70d0a15" args="(int dest_channels, int dest_bitspersample, int dest_frequency)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int CS::SndSys::PCMSampleConverter::GetRequiredOutputBufferMultiple           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>dest_channels</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>dest_bitspersample</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>dest_frequency</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Return a multiplier that relates input buffer samples/size to output buffer samples/size. 
<p>
Note that in many cases one extra source sample should be presumed to be present. To be safe, use ((source_samples+1)*source_sample_size*GetRequiredOutputBufferMultiple()) for the size. The value returned will be constant for a given source format and destination format.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>dest_channels</em>&nbsp;</td><td></td></tr>
    <tr><td valign="top"></td><td valign="top"><em>dest_bitspersample</em>&nbsp;</td><td></td></tr>
    <tr><td valign="top"></td><td valign="top"><em>dest_frequency</em>&nbsp;</td><td></td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="44c8074a80383cd7a0f43cdbfd7fff28"></a><!-- doxytag: member="CS::SndSys::PCMSampleConverter::SetSourceProperties" ref="44c8074a80383cd7a0f43cdbfd7fff28" args="(int source_channels, int source_bitspersample, int source_frequency)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void CS::SndSys::PCMSampleConverter::SetSourceProperties           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>source_channels</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>source_bitspersample</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>source_frequency</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Adjust the source properties for data being presented in the next call to ConvertBuffer. 
<p>
This is primarily intended for variable-rate audio formats such as some Ogg and MP3 files. <dl class="remark" compact><dt><b>Remarks:</b></dt><dd>At this time this function does not properly consider the transition between formats at the proper location and instead presumes the transition is at the last "step" from the previous buffer.</dd></dl>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>source_channels</em>&nbsp;</td><td></td></tr>
    <tr><td valign="top"></td><td valign="top"><em>source_bitspersample</em>&nbsp;</td><td></td></tr>
    <tr><td valign="top"></td><td valign="top"><em>source_frequency</em>&nbsp;</td><td></td></tr>
  </table>
</dl>

</div>
</div><p>
<hr>The documentation for this class was generated from the following file:<ul>
<li>csplugincommon/sndsys/<a class="el" href="convert_8h-source.html">convert.h</a></ul>
<hr size="1"><address><small>Generated for Crystal Space 1.2.1 by 
<a href="http://www.doxygen.org/index.html">doxygen</a> 1.5.3 
</small></address> </div></body> </html>