diff options
author | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
commit | 0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch) | |
tree | 2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/a02299.html | |
download | nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip |
Initial commit
Diffstat (limited to 'docs/doxygen/nel/a02299.html')
-rw-r--r-- | docs/doxygen/nel/a02299.html | 1691 |
1 files changed, 1691 insertions, 0 deletions
diff --git a/docs/doxygen/nel/a02299.html b/docs/doxygen/nel/a02299.html new file mode 100644 index 00000000..812d0957 --- /dev/null +++ b/docs/doxygen/nel/a02299.html @@ -0,0 +1,1691 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> +<title>NeL: NLSOUND::CBufferDSound class Reference</title> +<link href="doxygen.css" rel="stylesheet" type="text/css"> +</head><body> +<!-- Generated by Doxygen 1.3.6 --> +<div class="qindex"> <form class="search" action="search.php" method="get"> +<a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a> | <span class="search"><u>S</u>earch for <input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div> +<h1>NLSOUND::CBufferDSound Class Reference</h1><code>#include <<a class="el" href="a05521.html">buffer_dsound.h</a>></code> +<p> +<p>Inheritance diagram for NLSOUND::CBufferDSound: +<p><center><img src="a02299.png" usemap="#NLSOUND::CBufferDSound_map" border="0" alt=""></center> +<map name="NLSOUND::CBufferDSound_map"> +<area href="a02298.html" alt="NLSOUND::IBuffer" shape="rect" coords="0,0,167,24"> +</map> +<hr><a name="_details"></a><h2>Detailed Description</h2> +Buffer for the DSound implementation of the audio driver.<p> +A buffer represents a sound file loaded in RAM.<p> +<dl compact><dt><b>Author:</b></dt><dd>Peter Hanappe, Olivier Cado <p> +Nevrax France </dd></dl> +<dl compact><dt><b>Date:</b></dt><dd>2002 </dd></dl> + +<p> + +<p> +Definition at line <a class="el" href="a05521.html#l00045">45</a> of file <a class="el" href="a05521.html">buffer_dsound.h</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> </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda0">CBufferDSound</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor. <a href="#NLSOUND_1_1CBufferDSounda0"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual bool </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda1">fillBuffer</a> (void *<a class="el" href="a04223.html#a652">src</a>, <a class="el" href="a04558.html#a11">uint32</a> bufsize)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Set the buffer size and fill the buffer. Return true if ok. Call <a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda16">setFormat()</a> first. <a href="#NLSOUND_1_1CBufferDSounda1"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual bool </td><td class="memItemRight" valign=bottom><a class="el" href="a02298.html#NLSOUND_1_1IBuffera1">fillMore</a> (void *<a class="el" href="a04223.html#a652">src</a>, <a class="el" href="a04558.html#a11">uint32</a> srcsize)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual <a class="el" href="a04558.html#a11">uint32</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda3">getBufferADPCMEncoded</a> (std::vector< <a class="el" href="a04558.html#a7">uint8</a> > &result)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual <a class="el" href="a04558.html#a11">uint32</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda4">getBufferMono16</a> (std::vector< <a class="el" href="a04558.html#a8">sint16</a> > &result)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual <a class="el" href="a04558.html#a7">uint8</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda5">getData</a> () const </td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Return a pointer to the sample data. <a href="#NLSOUND_1_1CBufferDSounda5"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual float </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda6">getDuration</a> () const </td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the duration (in ms) of the sample in the buffer. <a href="#NLSOUND_1_1CBufferDSounda6"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual void </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda7">getFormat</a> (<a class="el" href="a05381.html#a80">TSampleFormat</a> &<a class="el" href="a04223.html#a641">format</a>, <a class="el" href="a04558.html#a15">uint</a> &freq) const </td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the format and frequency. <a href="#NLSOUND_1_1CBufferDSounda7"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual const <a class="el" href="a05378.html#a236">NLMISC::TStringId</a> & </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda8">getName</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the name of the buffer. <a href="#NLSOUND_1_1CBufferDSounda8"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual <a class="el" href="a04558.html#a11">uint32</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda9">getSize</a> () const </td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the size of the buffer, in bytes. <a href="#NLSOUND_1_1CBufferDSounda9"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual bool </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda10">isBufferLoaded</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Return true if the buffer is loaded. Used for async load/unload. <a href="#NLSOUND_1_1CBufferDSounda10"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual bool </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda11">isFillMoreSupported</a> () const </td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual bool </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda12">isStereo</a> () const </td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Return true if the buffer is stereo, false if mono. <a href="#NLSOUND_1_1CBufferDSounda12"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual void </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda13">presetName</a> (const <a class="el" href="a05378.html#a236">NLMISC::TStringId</a> &bufferName)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual bool </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda14">readRawBuffer</a> (const std::string &name, <a class="el" href="a04558.html#a7">uint8</a> *rawData, <a class="el" href="a04558.html#a15">uint</a> dataSize, <a class="el" href="a05381.html#a80">TSampleFormat</a> <a class="el" href="a04223.html#a641">format</a>, <a class="el" href="a04558.html#a11">uint32</a> frequency)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual bool </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda15">readWavBuffer</a> (const std::string &name, <a class="el" href="a04558.html#a7">uint8</a> *wavData, <a class="el" href="a04558.html#a15">uint</a> dataSize)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Load a sound file in the buffer. Throws an exception is an error occurs. <a href="#NLSOUND_1_1CBufferDSounda15"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual void </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda16">setFormat</a> (<a class="el" href="a05381.html#a80">TSampleFormat</a> <a class="el" href="a04223.html#a641">format</a>, <a class="el" href="a04558.html#a15">uint</a> freq)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Set the sample format. Example: freq=44100. <a href="#NLSOUND_1_1CBufferDSounda16"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual void </td><td class="memItemRight" valign=bottom><a class="el" href="a02298.html#NLSOUND_1_1IBuffera11">setSize</a> (<a class="el" href="a04558.html#a11">uint32</a> <a class="el" href="a04223.html#a587">size</a>)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Force the buffer size without filling data (if <a class="el" href="a02298.html#NLSOUND_1_1IBuffera7">isFillMoreSupported()</a> only). <a href="#NLSOUND_1_1IBuffera11"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda18">~CBufferDSound</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Destructor. <a href="#NLSOUND_1_1CBufferDSounda18"></a><br><br></td></tr> +<tr><td colspan=2><br><h2>Static Public Member Functions</h2></td></tr> +<tr><td colspan="2"><div class="groupHeader">Source properties</div></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02298.html#NLSOUND_1_1IBufferz1304_2">decodeADPCM</a> (<a class="el" href="a04558.html#a7">uint8</a> *indata, <a class="el" href="a04558.html#a8">sint16</a> *outdata, <a class="el" href="a04558.html#a15">uint</a> nbSample, TADPCMState &state)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02298.html#NLSOUND_1_1IBufferz1304_3">encodeADPCM</a> (<a class="el" href="a04558.html#a8">sint16</a> *indata, <a class="el" href="a04558.html#a7">uint8</a> *outdata, <a class="el" href="a04558.html#a15">uint</a> nbSample, TADPCMState &state)</td></tr> + +<tr><td colspan="2"><div class="groupHeader">Source properties</div></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02298.html#NLSOUND_1_1IBufferz1304_2">decodeADPCM</a> (<a class="el" href="a04558.html#a7">uint8</a> *indata, <a class="el" href="a04558.html#a8">sint16</a> *outdata, <a class="el" href="a04558.html#a15">uint</a> nbSample, TADPCMState &state)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02298.html#NLSOUND_1_1IBufferz1304_3">encodeADPCM</a> (<a class="el" href="a04558.html#a8">sint16</a> *indata, <a class="el" href="a04558.html#a7">uint8</a> *outdata, <a class="el" href="a04558.html#a15">uint</a> nbSample, TADPCMState &state)</td></tr> + +<tr><td colspan=2><br><h2>Private Attributes</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a04558.html#a7">uint8</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a05381.html#a80">TSampleFormat</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSoundr1">_Format</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a04558.html#a15">uint</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSoundr2">_Freq</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a05378.html#a236">NLMISC::TStringId</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSoundr3">_Name</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a04558.html#a11">uint32</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02299.html#NLSOUND_1_1CBufferDSoundr4">_Size</a></td></tr> + +</table> +<hr><h2>Constructor & Destructor Documentation</h2> +<a class="anchor" name="NLSOUND_1_1CBufferDSounda0" doxytag="NLSOUND::CBufferDSound::CBufferDSound" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> NLSOUND::CBufferDSound::CBufferDSound </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Constructor. +<p> + +<p> +Definition at line <a class="el" href="a05520.html#l00131">131</a> of file <a class="el" href="a05520.html">buffer_dsound.cpp</a>. +<p> +References <a class="el" href="a05521.html#l00118">_Format</a>, <a class="el" href="a05521.html#l00120">_Freq</a>, <a class="el" href="a05520.html#l00044">NLSOUND::EmptyString</a>, and <a class="el" href="a05381.html#a80a19">NLSOUND::Mono16</a>. +<p> +<div class="fragment"><pre>00132 { +00133 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr3">_Name</a> = CSoundDriverDSound::instance()->getStringMapper()->map(EmptyString); +00134 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a> = NULL; +00135 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr4">_Size</a> = 0; +00136 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr1">_Format</a> = <a class="code" href="a05381.html#a80a19">Mono16</a>; +00137 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr2">_Freq</a> = 0; +00138 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSounda18" doxytag="NLSOUND::CBufferDSound::~CBufferDSound" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> NLSOUND::CBufferDSound::~<a class="el" href="a02299.html">CBufferDSound</a> </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Destructor. +<p> + +<p> +Definition at line <a class="el" href="a05520.html#l00140">140</a> of file <a class="el" href="a05520.html">buffer_dsound.cpp</a>. +<p> +<div class="fragment"><pre>00141 { +00142 <span class="comment">// nldebug("Destroying DirectSound buffer %s (%p)", CSoundDriverDSound::instance()->getStringMapper()->unmap(_Name).c_str(), this);</span> +00143 +00144 <span class="keywordflow">if</span> (<a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a> != NULL) +00145 { +00146 <span class="keyword">delete</span>[] <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a>; +00147 } +00148 } +</pre></div> </td> + </tr> +</table> +<hr><h2>Member Function Documentation</h2> +<a class="anchor" name="NLSOUND_1_1IBufferz1304_2" doxytag="NLSOUND::CBufferDSound::decodeADPCM" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLSOUND::IBuffer::decodeADPCM </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a04558.html#a7">uint8</a> * </td> + <td class="mdname" nowrap> <em>indata</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a8">sint16</a> * </td> + <td class="mdname" nowrap> <em>outdata</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>nbSample</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a03845.html">TADPCMState</a> & </td> + <td class="mdname" nowrap> <em>state</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static, inherited]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Unoptimized utility function designed to build ADPCM encoded sample bank file. Return the number of sample in the buffer. +<p> +Definition at line <a class="el" href="a05516.html#l00164">164</a> of file <a class="el" href="a05516.html">buffer.cpp</a>. +<p> +References <a class="el" href="a05516.html#l00031">NLSOUND::IBuffer::_IndexTable</a>, <a class="el" href="a05516.html#l00037">NLSOUND::IBuffer::_StepsizeTable</a>, <a class="el" href="a05646.html#l00225">index</a>, <a class="el" href="a05517.html#l00092">NLSOUND::IBuffer::TADPCMState::PreviousSample</a>, <a class="el" href="a05981.html#l00097">sint16</a>, <a class="el" href="a05517.html#l00094">NLSOUND::IBuffer::TADPCMState::StepIndex</a>, <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a05981.html#l00096">uint8</a>. +<p> +<div class="fragment"><pre>00165 { +00166 <a class="code" href="a04558.html#a7">uint8</a> *inp; <span class="comment">/* Input buffer pointer */</span> +00167 <a class="code" href="a04558.html#a8">sint16</a> *outp; <span class="comment">/* output buffer pointer */</span> +00168 <span class="keywordtype">int</span> sign; <span class="comment">/* Current adpcm sign bit */</span> +00169 <span class="keywordtype">int</span> delta; <span class="comment">/* Current adpcm output value */</span> +00170 <span class="keywordtype">int</span> step; <span class="comment">/* Stepsize */</span> +00171 <span class="keywordtype">int</span> valpred; <span class="comment">/* Predicted value */</span> +00172 <span class="keywordtype">int</span> vpdiff; <span class="comment">/* Current change to valpred */</span> +00173 <span class="keywordtype">int</span> <a class="code" href="a04223.html#a566">index</a>; <span class="comment">/* Current step change index */</span> +00174 <span class="keywordtype">int</span> inputbuffer; <span class="comment">/* place to keep next 4-bit value */</span> +00175 <span class="keywordtype">int</span> bufferstep; <span class="comment">/* toggle between inputbuffer/input */</span> +00176 +00177 outp = outdata; +00178 inp = indata; +00179 +00180 valpred = state.PreviousSample; +00181 <a class="code" href="a04223.html#a566">index</a> = state.StepIndex; +00182 step = _StepsizeTable[<a class="code" href="a04223.html#a566">index</a>]; +00183 +00184 bufferstep = 0; +00185 +00186 <span class="keywordflow">for</span> ( ; nbSample > 0 ; nbSample-- ) +00187 { +00188 +00189 <span class="comment">/* Step 1 - get the delta value */</span> +00190 <span class="keywordflow">if</span> ( bufferstep ) +00191 { +00192 delta = inputbuffer & 0xf; +00193 } +00194 <span class="keywordflow">else</span> +00195 { +00196 inputbuffer = *inp++; +00197 delta = (inputbuffer >> 4) & 0xf; +00198 } +00199 bufferstep = !bufferstep; +00200 +00201 <span class="comment">/* Step 2 - Find new index value (for later) */</span> +00202 <a class="code" href="a04223.html#a566">index</a> += _IndexTable[delta]; +00203 <span class="keywordflow">if</span> ( <a class="code" href="a04223.html#a566">index</a> < 0 ) +00204 <a class="code" href="a04223.html#a566">index</a> = 0; +00205 <span class="keywordflow">if</span> ( <a class="code" href="a04223.html#a566">index</a> > 88 ) +00206 <a class="code" href="a04223.html#a566">index</a> = 88; +00207 +00208 <span class="comment">/* Step 3 - Separate sign and magnitude */</span> +00209 sign = delta & 8; +00210 delta = delta & 7; +00211 +00212 <span class="comment">/* Step 4 - Compute difference and new predicted value */</span> +00213 <span class="comment">/*</span> +00214 <span class="comment"> ** Computes 'vpdiff = (delta+0.5)*step/4', but see comment</span> +00215 <span class="comment"> ** in adpcm_coder.</span> +00216 <span class="comment"> */</span> +00217 vpdiff = step >> 3; +00218 <span class="keywordflow">if</span> ( delta & 4 ) +00219 vpdiff += step; +00220 <span class="keywordflow">if</span> ( delta & 2 ) +00221 vpdiff += step>>1; +00222 <span class="keywordflow">if</span> ( delta & 1 ) +00223 vpdiff += step>>2; +00224 +00225 <span class="keywordflow">if</span> ( sign ) +00226 valpred -= vpdiff; +00227 <span class="keywordflow">else</span> +00228 valpred += vpdiff; +00229 +00230 <span class="comment">/* Step 5 - clamp output value */</span> +00231 <span class="keywordflow">if</span> ( valpred > 32767 ) +00232 valpred = 32767; +00233 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( valpred < -32768 ) +00234 valpred = -32768; +00235 +00236 <span class="comment">/* Step 6 - Update step value */</span> +00237 step = _StepsizeTable[<a class="code" href="a04223.html#a566">index</a>]; +00238 +00239 <span class="comment">/* Step 7 - Output value */</span> +00240 *outp++ = valpred; +00241 } +00242 +00243 state.PreviousSample = valpred; +00244 state.StepIndex = <a class="code" href="a04223.html#a566">index</a>; +00245 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1IBufferz1304_3" doxytag="NLSOUND::CBufferDSound::encodeADPCM" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLSOUND::IBuffer::encodeADPCM </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a04558.html#a8">sint16</a> * </td> + <td class="mdname" nowrap> <em>indata</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a7">uint8</a> * </td> + <td class="mdname" nowrap> <em>outdata</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>nbSample</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a03845.html">TADPCMState</a> & </td> + <td class="mdname" nowrap> <em>state</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static, inherited]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Unoptimized utility function designed to build ADPCM encoded sample bank file. Return the number of sample in the buffer. +<p> +Definition at line <a class="el" href="a05516.html#l00051">51</a> of file <a class="el" href="a05516.html">buffer.cpp</a>. +<p> +References <a class="el" href="a05516.html#l00031">NLSOUND::IBuffer::_IndexTable</a>, <a class="el" href="a05516.html#l00037">NLSOUND::IBuffer::_StepsizeTable</a>, <a class="el" href="a05646.html#l00225">index</a>, <a class="el" href="a05517.html#l00092">NLSOUND::IBuffer::TADPCMState::PreviousSample</a>, <a class="el" href="a05981.html#l00097">sint16</a>, <a class="el" href="a05517.html#l00094">NLSOUND::IBuffer::TADPCMState::StepIndex</a>, <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a05981.html#l00096">uint8</a>. +<p> +Referenced by <a class="el" href="a05520.html#l00451">getBufferADPCMEncoded()</a>. +<p> +<div class="fragment"><pre>00052 { +00053 <a class="code" href="a04558.html#a8">sint16</a> *inp; <span class="comment">/* Input buffer pointer */</span> +00054 <a class="code" href="a04558.html#a7">uint8</a> *outp; <span class="comment">/* output buffer pointer */</span> +00055 <span class="keywordtype">int</span> val; <span class="comment">/* Current input sample value */</span> +00056 <span class="keywordtype">int</span> sign; <span class="comment">/* Current adpcm sign bit */</span> +00057 <span class="keywordtype">int</span> delta; <span class="comment">/* Current adpcm output value */</span> +00058 <span class="keywordtype">int</span> diff; <span class="comment">/* Difference between val and valprev */</span> +00059 <span class="keywordtype">int</span> step; <span class="comment">/* Stepsize */</span> +00060 <span class="keywordtype">int</span> valpred; <span class="comment">/* Predicted output value */</span> +00061 <span class="keywordtype">int</span> vpdiff; <span class="comment">/* Current change to valpred */</span> +00062 <span class="keywordtype">int</span> <a class="code" href="a04223.html#a566">index</a>; <span class="comment">/* Current step change index */</span> +00063 <span class="keywordtype">int</span> outputbuffer; <span class="comment">/* place to keep previous 4-bit value */</span> +00064 <span class="keywordtype">int</span> bufferstep; <span class="comment">/* toggle between outputbuffer/output */</span> +00065 +00066 outp = outdata; +00067 inp = indata; +00068 +00069 valpred = state.PreviousSample; +00070 <a class="code" href="a04223.html#a566">index</a> = state.StepIndex; +00071 step = _StepsizeTable[<a class="code" href="a04223.html#a566">index</a>]; +00072 +00073 bufferstep = 1; +00074 +00075 <span class="keywordflow">for</span> ( ; nbSample > 0 ; nbSample-- ) +00076 { +00077 val = *inp++; +00078 +00079 <span class="comment">/* Step 1 - compute difference with previous value */</span> +00080 diff = val - valpred; +00081 sign = (diff < 0) ? 8 : 0; +00082 <span class="keywordflow">if</span> ( sign ) diff = (-diff); +00083 +00084 <span class="comment">/* Step 2 - Divide and clamp */</span> +00085 <span class="comment">/* Note:</span> +00086 <span class="comment"> ** This code *approximately* computes:</span> +00087 <span class="comment"> ** delta = diff*4/step;</span> +00088 <span class="comment"> ** vpdiff = (delta+0.5)*step/4;</span> +00089 <span class="comment"> ** but in shift step bits are dropped. The net result of this is</span> +00090 <span class="comment"> ** that even if you have fast mul/div hardware you cannot put it to</span> +00091 <span class="comment"> ** good use since the fixup would be too expensive.</span> +00092 <span class="comment"> */</span> +00093 delta = 0; +00094 vpdiff = (step >> 3); +00095 +00096 <span class="keywordflow">if</span> ( diff >= step ) +00097 { +00098 delta = 4; +00099 diff -= step; +00100 vpdiff += step; +00101 } +00102 step >>= 1; +00103 <span class="keywordflow">if</span> ( diff >= step ) +00104 { +00105 delta |= 2; +00106 diff -= step; +00107 vpdiff += step; +00108 } +00109 step >>= 1; +00110 <span class="keywordflow">if</span> ( diff >= step ) +00111 { +00112 delta |= 1; +00113 vpdiff += step; +00114 } +00115 +00116 <span class="comment">/* Step 3 - Update previous value */</span> +00117 <span class="keywordflow">if</span> ( sign ) +00118 valpred -= vpdiff; +00119 <span class="keywordflow">else</span> +00120 valpred += vpdiff; +00121 +00122 <span class="comment">/* Step 4 - Clamp previous value to 16 bits */</span> +00123 <span class="keywordflow">if</span> ( valpred > 32767 ) +00124 { +00125 printf(<span class="stringliteral">"over+ %d\n"</span>,valpred); +00126 valpred = 32767; +00127 } +00128 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( valpred < -32768 ) +00129 { +00130 printf(<span class="stringliteral">"over- %d\n"</span>,valpred); +00131 valpred = -32768; +00132 } +00133 +00134 <span class="comment">/* Step 5 - Assemble value, update index and step values */</span> +00135 delta |= sign; +00136 +00137 <a class="code" href="a04223.html#a566">index</a> += _IndexTable[delta]; +00138 <span class="keywordflow">if</span> ( <a class="code" href="a04223.html#a566">index</a> < 0 ) +00139 <a class="code" href="a04223.html#a566">index</a> = 0; +00140 <span class="keywordflow">if</span> ( <a class="code" href="a04223.html#a566">index</a> > 88 ) +00141 <a class="code" href="a04223.html#a566">index</a> = 88; +00142 step = _StepsizeTable[<a class="code" href="a04223.html#a566">index</a>]; +00143 +00144 <span class="comment">/* Step 6 - Output value */</span> +00145 <span class="keywordflow">if</span> ( bufferstep ) +00146 { +00147 outputbuffer = (delta << 4) & 0xf0; +00148 } +00149 <span class="keywordflow">else</span> +00150 { +00151 *outp++ = (delta & 0x0f) | outputbuffer; +00152 } +00153 bufferstep = !bufferstep; +00154 } +00155 +00156 <span class="comment">/* Output last step, if needed */</span> +00157 <span class="keywordflow">if</span> ( !bufferstep ) +00158 *outp++ = outputbuffer; +00159 +00160 state.PreviousSample = valpred; +00161 state.StepIndex = <a class="code" href="a04223.html#a566">index</a>; +00162 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSounda1" doxytag="NLSOUND::CBufferDSound::fillBuffer" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool NLSOUND::CBufferDSound::fillBuffer </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">void * </td> + <td class="mdname" nowrap> <em>src</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a11">uint32</a> </td> + <td class="mdname" nowrap> <em>bufsize</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Set the buffer size and fill the buffer. Return true if ok. Call <a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda16">setFormat()</a> first. +<p> + +<p> +Implements <a class="el" href="a02298.html#NLSOUND_1_1IBuffera0">NLSOUND::IBuffer</a>. +<p> +Definition at line <a class="el" href="a05520.html#l00163">163</a> of file <a class="el" href="a05520.html">buffer_dsound.cpp</a>. +<p> +References <a class="el" href="a05646.html#l01124">src</a>, and <a class="el" href="a05981.html#l00100">uint32</a>. +<p> +<div class="fragment"><pre>00164 { +00165 <span class="keywordflow">return</span> <span class="keyword">false</span>; +00166 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1IBuffera1" doxytag="NLSOUND::CBufferDSound::fillMore" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> virtual bool NLSOUND::IBuffer::fillMore </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">void * </td> + <td class="mdname" nowrap> <em>src</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a11">uint32</a> </td> + <td class="mdname" nowrap> <em>srcsize</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [inline, virtual, inherited]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Fill the buffer partially (if <a class="el" href="a02298.html#NLSOUND_1_1IBuffera7">isFillMoreSupported()</a> only), beginning at the pos changed by a previous call to <a class="el" href="a02298.html#NLSOUND_1_1IBuffera1">fillMore()</a>. If the pos+srcsize exceeds the buffer size, the exceeding data is put at the beginning of the buffer. srcsize must be smaller than the buffer size. +<p> +Reimplemented in <a class="el" href="a02297.html#NLSOUND_1_1CBufferALa3">NLSOUND::CBufferAL</a>. +<p> +Definition at line <a class="el" href="a05517.html#l00079">79</a> of file <a class="el" href="a05517.html">buffer.h</a>. +<p> +References <a class="el" href="a05981.html#l00100">uint32</a>. +<p> +Referenced by <a class="el" href="a05927.html#l00048">NLSOUND::ILoader::fillBufferPart()</a>. +<p> +<div class="fragment"><pre>00079 { <span class="keywordflow">throw</span> ESoundDriverNotSupp(); } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSounda3" doxytag="NLSOUND::CBufferDSound::getBufferADPCMEncoded" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a04558.html#a11">uint32</a> NLSOUND::CBufferDSound::getBufferADPCMEncoded </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">std::vector< <a class="el" href="a04558.html#a7">uint8</a> > & </td> + <td class="mdname1" valign="top" nowrap> <em>result</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Unoptimized utility function designed to build ADPCM encoded sample bank file. Return the number of sample in the buffer. +<p> +Implements <a class="el" href="a02298.html#NLSOUND_1_1IBufferz1304_0">NLSOUND::IBuffer</a>. +<p> +Definition at line <a class="el" href="a05520.html#l00451">451</a> of file <a class="el" href="a05520.html">buffer_dsound.cpp</a>. +<p> +References <a class="el" href="a05521.html#l00118">_Format</a>, <a class="el" href="a05516.html#l00051">NLSOUND::IBuffer::encodeADPCM()</a>, <a class="el" href="a05381.html#a80a19">NLSOUND::Mono16</a>, <a class="el" href="a05981.html#l00097">sint16</a>, and <a class="el" href="a05981.html#l00100">uint32</a>. +<p> +<div class="fragment"><pre>00452 { +00453 result.clear(); +00454 +00455 <span class="keywordflow">if</span> (<a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a> == 0) +00456 <span class="keywordflow">return</span> 0; +00457 +00458 <span class="keywordflow">if</span> (<a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr1">_Format</a> != <a class="code" href="a05381.html#a80a19">Mono16</a>) +00459 <span class="keywordflow">return</span> 0; +00460 +00461 <a class="code" href="a04558.html#a11">uint32</a> nbSample = <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr4">_Size</a>/2; +00462 nbSample &= 0xfffffffe; +00463 +00464 result.resize(nbSample / 2); +00465 +00466 TADPCMState state; +00467 state.PreviousSample = 0; +00468 state.StepIndex = 0; +00469 <a class="code" href="a02298.html#NLSOUND_1_1IBufferz1304_3">encodeADPCM</a>((<a class="code" href="a04558.html#a8">sint16</a>*)_Data, &result[0], nbSample, state); +00470 +00471 <span class="keywordflow">return</span> nbSample; +00472 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSounda4" doxytag="NLSOUND::CBufferDSound::getBufferMono16" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a04558.html#a11">uint32</a> NLSOUND::CBufferDSound::getBufferMono16 </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">std::vector< <a class="el" href="a04558.html#a8">sint16</a> > & </td> + <td class="mdname1" valign="top" nowrap> <em>result</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Unoptimized utility function designed to build Mono 16 bits encoded sample bank file. Return the number of sample in the buffer. +<p> +Implements <a class="el" href="a02298.html#NLSOUND_1_1IBufferz1304_1">NLSOUND::IBuffer</a>. +<p> +Definition at line <a class="el" href="a05520.html#l00474">474</a> of file <a class="el" href="a05520.html">buffer_dsound.cpp</a>. +<p> +References <a class="el" href="a05521.html#l00118">_Format</a>, <a class="el" href="a05381.html#a80a19">NLSOUND::Mono16</a>, <a class="el" href="a05981.html#l00097">sint16</a>, <a class="el" href="a05381.html#a80a21">NLSOUND::Stereo16</a>, <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a05981.html#l00100">uint32</a>. +<p> +<div class="fragment"><pre>00475 { +00476 result.clear(); +00477 +00478 <span class="keywordflow">if</span> (<a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a> == 0) +00479 <span class="keywordflow">return</span> 0; +00480 +00481 <span class="keywordflow">if</span> (<a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr1">_Format</a> == <a class="code" href="a05381.html#a80a19">Mono16</a>) +00482 { +00483 <a class="code" href="a04558.html#a15">uint</a> nbSample = <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr4">_Size</a>/2; +00484 nbSample &= 0xfffffffe; +00485 +00486 result.reserve(nbSample); +00487 result.insert(result.begin(), (<a class="code" href="a04558.html#a8">sint16</a>*)<a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a>, ((<a class="code" href="a04558.html#a8">sint16</a>*)<a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a>)+nbSample); +00488 +00489 <span class="keywordflow">return</span> nbSample; +00490 } +00491 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr1">_Format</a> == <a class="code" href="a05381.html#a80a21">Stereo16</a>) +00492 { +00493 <a class="code" href="a04558.html#a15">uint</a> nbSample = <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr4">_Size</a>/4; +00494 nbSample &= 0xfffffffe; +00495 +00496 <span class="keyword">struct </span>TFrame +00497 { +00498 <a class="code" href="a04558.html#a8">sint16</a> Channel1; +00499 <a class="code" href="a04558.html#a8">sint16</a> Channel2; +00500 }; +00501 result.reserve(nbSample); +00502 <a class="code" href="a06800.html">TFrame</a> *frame = (<a class="code" href="a06800.html">TFrame</a> *)<a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a>; +00503 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i=0; i<nbSample; ++i) +00504 { +00505 result[i] = (frame->Channel1>>1) +(frame->Channel2>>1); +00506 } +00507 +00508 <span class="keywordflow">return</span> nbSample; +00509 } +00510 <span class="keywordflow">else</span> +00511 <span class="keywordflow">return</span> 0; +00512 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSounda5" doxytag="NLSOUND::CBufferDSound::getData" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> virtual <a class="el" href="a04558.html#a7">uint8</a>* NLSOUND::CBufferDSound::getData </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap> const<code> [inline, virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Return a pointer to the sample data. +<p> + +<p> +Definition at line <a class="el" href="a05521.html#l00103">103</a> of file <a class="el" href="a05521.html">buffer_dsound.h</a>. +<p> +References <a class="el" href="a05981.html#l00096">uint8</a>. +<p> +<div class="fragment"><pre>00103 { <span class="keywordflow">return</span> <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a>; } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSounda6" doxytag="NLSOUND::CBufferDSound::getDuration" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> float NLSOUND::CBufferDSound::getDuration </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap> const<code> [virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Return the duration (in ms) of the sample in the buffer. +<p> + +<p> +Implements <a class="el" href="a02298.html#NLSOUND_1_1IBuffera2">NLSOUND::IBuffer</a>. +<p> +Definition at line <a class="el" href="a05520.html#l00169">169</a> of file <a class="el" href="a05520.html">buffer_dsound.cpp</a>. +<p> +References <a class="el" href="a05521.html#l00118">_Format</a>, <a class="el" href="a05521.html#l00120">_Freq</a>, <a class="el" href="a05381.html#a80a19">NLSOUND::Mono16</a>, <a class="el" href="a05381.html#a80a18">NLSOUND::Mono16ADPCM</a>, <a class="el" href="a05381.html#a80a17">NLSOUND::Mono8</a>, <a class="el" href="a05381.html#a80a21">NLSOUND::Stereo16</a>, and <a class="el" href="a05381.html#a80a20">NLSOUND::Stereo8</a>. +<p> +<div class="fragment"><pre>00170 { +00171 <span class="keywordtype">float</span> frames = (<span class="keywordtype">float</span>) <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr4">_Size</a>; +00172 +00173 <span class="keywordflow">switch</span> (<a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr1">_Format</a>) +00174 { +00175 <span class="keywordflow">case</span> <a class="code" href="a05381.html#a80a17">Mono8</a>: +00176 <span class="keywordflow">break</span>; +00177 <span class="keywordflow">case</span> <a class="code" href="a05381.html#a80a18">Mono16ADPCM</a>: +00178 frames *= 2.0f; +00179 <span class="keywordflow">break</span>; +00180 <span class="keywordflow">case</span> <a class="code" href="a05381.html#a80a19">Mono16</a>: +00181 frames /= 2.0f; +00182 <span class="keywordflow">break</span>; +00183 <span class="keywordflow">case</span> <a class="code" href="a05381.html#a80a20">Stereo8</a>: +00184 frames /= 2.0f; +00185 <span class="keywordflow">break</span>; +00186 <span class="keywordflow">case</span> <a class="code" href="a05381.html#a80a21">Stereo16</a>: +00187 frames /= 4.0f; +00188 <span class="keywordflow">break</span>; +00189 } +00190 +00191 <span class="keywordflow">return</span> 1000.0f * frames / (<span class="keywordtype">float</span>) <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr2">_Freq</a>; +00192 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSounda7" doxytag="NLSOUND::CBufferDSound::getFormat" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> virtual void NLSOUND::CBufferDSound::getFormat </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a05381.html#a80">TSampleFormat</a> & </td> + <td class="mdname" nowrap> <em>format</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> & </td> + <td class="mdname" nowrap> <em>freq</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"> const<code> [inline, virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Return the format and frequency. +<p> + +<p> +Implements <a class="el" href="a02298.html#NLSOUND_1_1IBuffera3">NLSOUND::IBuffer</a>. +<p> +Definition at line <a class="el" href="a05521.html#l00072">72</a> of file <a class="el" href="a05521.html">buffer_dsound.h</a>. +<p> +References <a class="el" href="a05521.html#l00118">_Format</a>, <a class="el" href="a05521.html#l00120">_Freq</a>, <a class="el" href="a05646.html#l01016">format</a>, and <a class="el" href="a05981.html#l00105">uint</a>. +<p> +<div class="fragment"><pre>00072 { <a class="code" href="a04223.html#a641">format</a> = <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr1">_Format</a>; freq = <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr2">_Freq</a>; } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSounda8" doxytag="NLSOUND::CBufferDSound::getName" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> virtual const <a class="el" href="a05378.html#a236">NLMISC::TStringId</a>& NLSOUND::CBufferDSound::getName </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">void </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [inline, virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Return the name of the buffer. +<p> + +<p> +Implements <a class="el" href="a02298.html#NLSOUND_1_1IBuffera4">NLSOUND::IBuffer</a>. +<p> +Definition at line <a class="el" href="a05521.html#l00106">106</a> of file <a class="el" href="a05521.html">buffer_dsound.h</a>. +<p> +<div class="fragment"><pre>00106 { <span class="keywordflow">return</span> <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr3">_Name</a>; } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSounda9" doxytag="NLSOUND::CBufferDSound::getSize" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> virtual <a class="el" href="a04558.html#a11">uint32</a> NLSOUND::CBufferDSound::getSize </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">void </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap> const<code> [inline, virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Return the size of the buffer, in bytes. +<p> + +<p> +Implements <a class="el" href="a02298.html#NLSOUND_1_1IBuffera5">NLSOUND::IBuffer</a>. +<p> +Definition at line <a class="el" href="a05521.html#l00063">63</a> of file <a class="el" href="a05521.html">buffer_dsound.h</a>. +<p> +References <a class="el" href="a05981.html#l00100">uint32</a>. +<p> +<div class="fragment"><pre>00063 { <span class="keywordflow">return</span> <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr4">_Size</a>; } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSounda10" doxytag="NLSOUND::CBufferDSound::isBufferLoaded" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> virtual bool NLSOUND::CBufferDSound::isBufferLoaded </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [inline, virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Return true if the buffer is loaded. Used for async load/unload. +<p> + +<p> +Implements <a class="el" href="a02298.html#NLSOUND_1_1IBuffera6">NLSOUND::IBuffer</a>. +<p> +Definition at line <a class="el" href="a05521.html#l00108">108</a> of file <a class="el" href="a05521.html">buffer_dsound.h</a>. +<p> +<div class="fragment"><pre>00108 { <span class="keywordflow">return</span> <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a> != 0; } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSounda11" doxytag="NLSOUND::CBufferDSound::isFillMoreSupported" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> virtual bool NLSOUND::CBufferDSound::isFillMoreSupported </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap> const<code> [inline, virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Return true if the buffer is able to be fill part by part, false if it must be filled in one call (OpenAL 1.0 -> false) +<p> +Implements <a class="el" href="a02298.html#NLSOUND_1_1IBuffera7">NLSOUND::IBuffer</a>. +<p> +Definition at line <a class="el" href="a05521.html#l00078">78</a> of file <a class="el" href="a05521.html">buffer_dsound.h</a>. +<p> +<div class="fragment"><pre>00078 { <span class="keywordflow">return</span> <span class="keyword">false</span>; } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSounda12" doxytag="NLSOUND::CBufferDSound::isStereo" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> virtual bool NLSOUND::CBufferDSound::isStereo </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap> const<code> [inline, virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Return true if the buffer is stereo, false if mono. +<p> + +<p> +Implements <a class="el" href="a02298.html#NLSOUND_1_1IBuffera8">NLSOUND::IBuffer</a>. +<p> +Definition at line <a class="el" href="a05521.html#l00069">69</a> of file <a class="el" href="a05521.html">buffer_dsound.h</a>. +<p> +References <a class="el" href="a05521.html#l00118">_Format</a>, <a class="el" href="a05381.html#a80a21">NLSOUND::Stereo16</a>, and <a class="el" href="a05381.html#a80a20">NLSOUND::Stereo8</a>. +<p> +<div class="fragment"><pre>00069 { <span class="keywordflow">return</span> (<a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr1">_Format</a> == <a class="code" href="a05381.html#a80a20">Stereo8</a>) || (<a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr1">_Format</a> == <a class="code" href="a05381.html#a80a21">Stereo16</a>); } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSounda13" doxytag="NLSOUND::CBufferDSound::presetName" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLSOUND::CBufferDSound::presetName </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const <a class="el" href="a05378.html#a236">NLMISC::TStringId</a> & </td> + <td class="mdname1" valign="top" nowrap> <em>bufferName</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Preset the name of the buffer. Used for async loading to give a name before the buffer is effectivly loaded. If the name after loading of the buffer doesn't match the preset name, the load will assert. +<p> +Implements <a class="el" href="a02298.html#NLSOUND_1_1IBuffera9">NLSOUND::IBuffer</a>. +<p> +Definition at line <a class="el" href="a05520.html#l00150">150</a> of file <a class="el" href="a05520.html">buffer_dsound.cpp</a>. +<p> +<div class="fragment"><pre>00151 { +00152 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr3">_Name</a> = bufferName; +00153 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSounda14" doxytag="NLSOUND::CBufferDSound::readRawBuffer" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool NLSOUND::CBufferDSound::readRawBuffer </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname" nowrap> <em>name</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a7">uint8</a> * </td> + <td class="mdname" nowrap> <em>rawData</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>dataSize</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a05381.html#a80">TSampleFormat</a> </td> + <td class="mdname" nowrap> <em>format</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a11">uint32</a> </td> + <td class="mdname" nowrap> <em>frequency</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05520.html#l00416">416</a> of file <a class="el" href="a05520.html">buffer_dsound.cpp</a>. +<p> +References <a class="el" href="a05521.html#l00118">_Format</a>, <a class="el" href="a05521.html#l00120">_Freq</a>, <a class="el" href="a05646.html#l01016">format</a>, <a class="el" href="a05622.html#l00333">nlassertex</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a05981.html#l00100">uint32</a>, and <a class="el" href="a05981.html#l00096">uint8</a>. +<p> +<div class="fragment"><pre>00417 { +00418 NL_ALLOC_CONTEXT(NLSOUND_CBufferDSound); +00419 <span class="comment">// free any existing data</span> +00420 <span class="keywordflow">if</span> (<a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a> != NULL) +00421 { +00422 free(_Data); +00423 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a> = NULL; +00424 } +00425 +00426 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr1">_Format</a> = <a class="code" href="a04223.html#a641">format</a>; +00427 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr4">_Size</a> = dataSize; +00428 <span class="comment">// Allocate the sample buffer</span> +00429 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a> = <span class="keyword">new</span> <a class="code" href="a04558.html#a7">uint8</a> [<a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr4">_Size</a>]; +00430 +00431 <span class="comment">// read in the format data</span> +00432 memcpy(_Data, rawData, dataSize); +00433 +00434 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr2">_Freq</a> = frequency; +00435 +00436 +00437 <span class="comment">// Allocate the sample buffer</span> +00438 +00439 <span class="keyword">static</span> NLMISC::TStringId empty(CSoundDriverDSound::instance()->getStringMapper()->map(<span class="stringliteral">""</span>)); +00440 NLMISC::TStringId nameId = CSoundDriverDSound::instance()->getStringMapper()->map(CFile::getFilenameWithoutExtension(name)); +00441 <span class="comment">// if name is preseted, the name must match.</span> +00442 <span class="keywordflow">if</span> (<a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr3">_Name</a> != empty) +00443 { +00444 <a class="code" href="a04199.html#a8">nlassertex</a>(nameId == _Name, (<span class="stringliteral">"The preseted name and buffer name doen't match !"</span>)); +00445 } +00446 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr3">_Name</a> = nameId; +00447 +00448 <span class="keywordflow">return</span> <span class="keyword">true</span>; +00449 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSounda15" doxytag="NLSOUND::CBufferDSound::readWavBuffer" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool NLSOUND::CBufferDSound::readWavBuffer </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname" nowrap> <em>name</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a7">uint8</a> * </td> + <td class="mdname" nowrap> <em>wavData</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>dataSize</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Load a sound file in the buffer. Throws an exception is an error occurs. +<p> +Fill the buffer partially (if <a class="el" href="a02299.html#NLSOUND_1_1CBufferDSounda11">isFillMoreSupported()</a> only), beginning at the pos changed by a previous call to <a class="el" href="a02298.html#NLSOUND_1_1IBuffera1">fillMore()</a>. If the pos+srcsize exceeds the buffer size, the exceeding data is put at the beginning of the buffer. srcsize must be smaller than the buffer size. +<p> +Definition at line <a class="el" href="a05520.html#l00196">196</a> of file <a class="el" href="a05520.html">buffer_dsound.cpp</a>. +<p> +References <a class="el" href="a05521.html#l00118">_Format</a>, <a class="el" href="a05521.html#l00120">_Freq</a>, <a class="el" href="a05646.html#l00649">buffer</a>, <a class="el" href="a05646.html#l01016">format</a>, <a class="el" href="a05381.html#a80a19">NLSOUND::Mono16</a>, <a class="el" href="a05381.html#a80a17">NLSOUND::Mono8</a>, <a class="el" href="a05622.html#l00333">nlassertex</a>, <a class="el" href="a05646.html#l01124">num</a>, <a class="el" href="a05981.html#l00104">sint</a>, <a class="el" href="a05981.html#l00099">sint32</a>, <a class="el" href="a05646.html#l00645">size</a>, <a class="el" href="a05381.html#a80a21">NLSOUND::Stereo16</a>, <a class="el" href="a05381.html#a80a20">NLSOUND::Stereo8</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a05981.html#l00100">uint32</a>, and <a class="el" href="a05981.html#l00096">uint8</a>. +<p> +<div class="fragment"><pre>00197 { +00198 NL_ALLOC_CONTEXT(NLSOUND_CBufferDSound); +00199 <a class="code" href="a04558.html#a14">sint</a> error; +00200 <a class="code" href="a04558.html#a10">sint32</a> <a class="code" href="a04223.html#a653">num</a>; +00201 HMMIO hmmio; +00202 WAVEFORMATEX <a class="code" href="a04223.html#a641">format</a>; +00203 MMCKINFO riff_chunk; +00204 MMCKINFO data_chunk; +00205 MMCKINFO chunk; +00206 +00207 +00208 <span class="keywordflow">if</span> (<a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a> != NULL) +00209 { +00210 <span class="keyword">delete</span> [] <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a>; +00211 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a> = NULL; +00212 } +00213 +00214 <span class="comment">/* NLMISC::CIFile ifile(file);</span> +00215 <span class="comment"> uint size = ifile.getFileSize();</span> +00216 <span class="comment"> uint8 *buffer = new uint8[ifile.getFileSize()];</span> +00217 <span class="comment"> ifile.serialBuffer(buffer, size);</span> +00218 <span class="comment">*/</span> +00219 <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a587">size</a> = dataSize; +00220 <a class="code" href="a04558.html#a7">uint8</a> *<a class="code" href="a04223.html#a589">buffer</a> = wavData; +00221 +00222 MMIOINFO mmioInfo; +00223 memset(&mmioInfo, 0, <span class="keyword">sizeof</span>(mmioInfo)); +00224 mmioInfo.pchBuffer = (<span class="keywordtype">char</span>*)<a class="code" href="a04223.html#a589">buffer</a>; +00225 mmioInfo.fccIOProc = FOURCC_MEM; +00226 mmioInfo.cchBuffer = <a class="code" href="a04223.html#a587">size</a>; +00227 +00228 +00229 hmmio = mmioOpen(NULL, &mmioInfo, MMIO_READ | MMIO_DENYWRITE); +00230 +00231 <span class="keywordflow">if</span> (hmmio == NULL) +00232 { +00233 <span class="keyword">delete</span> [] <a class="code" href="a04223.html#a589">buffer</a>; +00234 <span class="keywordflow">throw</span> ESoundDriver(<span class="stringliteral">"Failed to open the file"</span>); +00235 } +00236 +00237 +00238 <span class="comment">// Check it's a WAVE file </span> +00239 riff_chunk.ckid = FOURCC_RIFF; +00240 +00241 error = (<a class="code" href="a04558.html#a14">sint</a>) mmioDescend(hmmio, &riff_chunk, NULL, 0); +00242 +00243 <span class="keywordflow">if</span> ((error != 0) || (riff_chunk.ckid != FOURCC_RIFF) || (riff_chunk.fccType != mmioFOURCC(<span class="charliteral">'W'</span>, <span class="charliteral">'A'</span>, <span class="charliteral">'V'</span>, <span class="charliteral">'E'</span>))) +00244 { +00245 mmioClose(hmmio, 0); +00246 <span class="keyword">delete</span> <a class="code" href="a04223.html#a589">buffer</a>; +00247 <span class="keywordflow">throw</span> ESoundDriver(<span class="stringliteral">"Not a WAVE file"</span>); +00248 } +00249 +00250 +00251 <span class="comment">// Search the format chunk </span> +00252 chunk.ckid = mmioFOURCC(<span class="charliteral">'f'</span>, <span class="charliteral">'m'</span>, <span class="charliteral">'t'</span>, <span class="charliteral">' '</span>); +00253 +00254 error = (<a class="code" href="a04558.html#a14">sint</a>) mmioDescend(hmmio, &chunk, &riff_chunk, MMIO_FINDCHUNK); +00255 +00256 <span class="keywordflow">if</span> (error != 0) +00257 { +00258 mmioClose(hmmio, 0); +00259 +00260 <span class="keyword">delete</span> [] <a class="code" href="a04223.html#a589">buffer</a>; +00261 <span class="keywordflow">throw</span> ESoundDriver(<span class="stringliteral">"Couldn't find the format chunk"</span>); +00262 } +00263 +00264 <span class="keywordflow">if</span> (chunk.cksize < (<span class="keywordtype">long</span>) <span class="keyword">sizeof</span>(PCMWAVEFORMAT)) +00265 { +00266 mmioClose(hmmio, 0); +00267 <span class="keyword">delete</span> [] <a class="code" href="a04223.html#a589">buffer</a>; +00268 <span class="keywordflow">throw</span> ESoundDriver(<span class="stringliteral">"Invalid format chunk size"</span>); +00269 } +00270 +00271 +00272 <span class="comment">// read in the format data</span> +00273 +00274 <a class="code" href="a04223.html#a653">num</a> = mmioRead(hmmio, (HPSTR) &format, (<span class="keywordtype">long</span>) <span class="keyword">sizeof</span>(format)); +00275 <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a653">num</a> != (<span class="keywordtype">long</span>) <span class="keyword">sizeof</span>(<a class="code" href="a04223.html#a641">format</a>)) +00276 { +00277 mmioClose(hmmio, 0); +00278 <span class="keyword">delete</span> [] <a class="code" href="a04223.html#a589">buffer</a>; +00279 <span class="keywordflow">throw</span> ESoundDriver(<span class="stringliteral">"Read failed"</span>); +00280 } +00281 +00282 <a class="code" href="a04223.html#a641">format</a>.cbSize = 0; +00283 +00284 <span class="comment">// Get out of the format chunk</span> +00285 +00286 <span class="keywordflow">if</span> (mmioAscend(hmmio, &chunk, 0) != 0) +00287 { +00288 mmioClose(hmmio, 0); +00289 <span class="keyword">delete</span> [] <a class="code" href="a04223.html#a589">buffer</a>; +00290 <span class="keywordflow">throw</span> ESoundDriver(<span class="stringliteral">"Read failed"</span>); +00291 } +00292 +00293 +00294 <span class="comment">// copy the format data </span> +00295 +00296 <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a641">format</a>.wFormatTag != WAVE_FORMAT_PCM) +00297 { +00298 mmioClose(hmmio, 0); +00299 <span class="keyword">delete</span> [] <a class="code" href="a04223.html#a589">buffer</a>; +00300 <span class="keywordflow">throw</span> ESoundDriver(<span class="stringliteral">"Unsupported sample format"</span>); +00301 } +00302 +00303 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr2">_Freq</a> = <a class="code" href="a04223.html#a641">format</a>.nSamplesPerSec; +00304 +00305 <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a641">format</a>.nChannels == 1) +00306 { +00307 <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a641">format</a>.wBitsPerSample == 8) +00308 { +00309 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr1">_Format</a> = <a class="code" href="a05381.html#a80a17">Mono8</a>; +00310 } +00311 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a641">format</a>.wBitsPerSample == 16) +00312 { +00313 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr1">_Format</a> = <a class="code" href="a05381.html#a80a19">Mono16</a>; +00314 } +00315 <span class="keywordflow">else</span> +00316 { +00317 mmioClose(hmmio, 0); +00318 <span class="keyword">delete</span> [] <a class="code" href="a04223.html#a589">buffer</a>; +00319 <span class="keywordflow">throw</span> ESoundDriver(<span class="stringliteral">"Unsupported sample size"</span>); +00320 } +00321 } +00322 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a641">format</a>.nChannels == 2) +00323 { +00324 <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a641">format</a>.wBitsPerSample == 8) +00325 { +00326 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr1">_Format</a> = <a class="code" href="a05381.html#a80a20">Stereo8</a>; +00327 } +00328 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a641">format</a>.wBitsPerSample == 16) +00329 { +00330 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr1">_Format</a> = <a class="code" href="a05381.html#a80a21">Stereo16</a>; +00331 } +00332 <span class="keywordflow">else</span> +00333 { +00334 mmioClose(hmmio, 0); +00335 <span class="keyword">delete</span> [] <a class="code" href="a04223.html#a589">buffer</a>; +00336 <span class="keywordflow">throw</span> ESoundDriver(<span class="stringliteral">"Unsupported sample size"</span>); +00337 } +00338 } +00339 <span class="keywordflow">else</span> <span class="comment">// Shouldn't normally happen</span> +00340 { +00341 mmioClose(hmmio, 0); +00342 <span class="keyword">delete</span> [] <a class="code" href="a04223.html#a589">buffer</a>; +00343 <span class="keywordflow">throw</span> ESoundDriver(<span class="stringliteral">"Unsupported number of channels"</span>); +00344 } +00345 +00346 +00347 <span class="comment">// Set the file position to the beginning of the data chunk */</span> +00348 +00349 <a class="code" href="a04558.html#a10">sint32</a> pos = mmioSeek(hmmio, riff_chunk.dwDataOffset + <span class="keyword">sizeof</span>(FOURCC), SEEK_SET); +00350 +00351 <span class="keywordflow">if</span> (pos < 0) +00352 { +00353 mmioClose(hmmio, 0); +00354 <span class="keyword">delete</span> [] <a class="code" href="a04223.html#a589">buffer</a>; +00355 <span class="keywordflow">throw</span> ESoundDriver(<span class="stringliteral">"Read to set the read position"</span>); +00356 } +00357 +00358 data_chunk.ckid = mmioFOURCC(<span class="charliteral">'d'</span>, <span class="charliteral">'a'</span>, <span class="charliteral">'t'</span>, <span class="charliteral">'a'</span>); +00359 +00360 <span class="keywordflow">if</span> (mmioDescend(hmmio, &data_chunk, &riff_chunk, MMIO_FINDCHUNK) != 0) +00361 { +00362 mmioClose(hmmio, 0); +00363 <span class="keyword">delete</span> [] <a class="code" href="a04223.html#a589">buffer</a>; +00364 <span class="keywordflow">throw</span> ESoundDriver(<span class="stringliteral">"Read to set the read position"</span>); +00365 } +00366 +00367 +00368 <span class="comment">// Allocate the sample buffer</span> +00369 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr4">_Size</a> = data_chunk.cksize; +00370 +00371 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a> = <span class="keyword">new</span> <a class="code" href="a04558.html#a7">uint8</a>[<a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr4">_Size</a>]; +00372 +00373 <span class="keywordflow">if</span> (<a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a> == NULL) +00374 { +00375 mmioClose(hmmio, 0); +00376 <span class="keyword">delete</span> [] <a class="code" href="a04223.html#a589">buffer</a>; +00377 <span class="keywordflow">throw</span> ESoundDriver(<span class="stringliteral">"Out of memory"</span>); +00378 } +00379 +00380 +00381 <span class="comment">// Read the sample data</span> +00382 +00383 <a class="code" href="a04223.html#a653">num</a> = mmioRead(hmmio, (HPSTR) _Data, _Size); +00384 +00385 <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a653">num</a> < 0) +00386 { +00387 <span class="keyword">delete</span> [] <a class="code" href="a04223.html#a589">buffer</a>; +00388 <span class="keywordflow">throw</span> ESoundDriver(<span class="stringliteral">"Failed to read the samples"</span>); +00389 } +00390 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((<a class="code" href="a04558.html#a11">uint32</a>) <a class="code" href="a04223.html#a653">num</a> < <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr4">_Size</a>) +00391 { +00392 <span class="comment">// FIXME: print warning or throw exception ???</span> +00393 <span class="keywordtype">char</span>* p = (<span class="keywordtype">char</span>*) <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">_Data</a>; +00394 ZeroMemory(p + num, _Size - num); +00395 } +00396 +00397 +00398 mmioClose(hmmio, 0); +00399 +00400 <span class="comment">// delete [] buffer;</span> +00401 +00402 <span class="keyword">static</span> NLMISC::TStringId empty(CSoundDriverDSound::instance()->getStringMapper()->map(<span class="stringliteral">""</span>)); +00403 <span class="comment">// NLMISC::TStringId name = CSoundDriverDSound::instance()->getStringMapper()->map(CFile::getFilenameWithoutExtension(file));</span> +00404 NLMISC::TStringId nameId = CSoundDriverDSound::instance()->getStringMapper()->map(CFile::getFilenameWithoutExtension(name)); +00405 <span class="comment">// if name is preseted, the name must match.</span> +00406 <span class="keywordflow">if</span> (<a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr3">_Name</a> != empty) +00407 { +00408 <a class="code" href="a04199.html#a8">nlassertex</a>(nameId == _Name, (<span class="stringliteral">"The preseted name and buffer name doen't match !"</span>)); +00409 } +00410 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr3">_Name</a> = nameId; +00411 +00412 <span class="keywordflow">return</span> <span class="keyword">true</span>; +00413 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSounda16" doxytag="NLSOUND::CBufferDSound::setFormat" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLSOUND::CBufferDSound::setFormat </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a05381.html#a80">TSampleFormat</a> </td> + <td class="mdname" nowrap> <em>format</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>freq</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Set the sample format. Example: freq=44100. +<p> + +<p> +Implements <a class="el" href="a02298.html#NLSOUND_1_1IBuffera10">NLSOUND::IBuffer</a>. +<p> +Definition at line <a class="el" href="a05520.html#l00156">156</a> of file <a class="el" href="a05520.html">buffer_dsound.cpp</a>. +<p> +References <a class="el" href="a05521.html#l00118">_Format</a>, <a class="el" href="a05521.html#l00120">_Freq</a>, <a class="el" href="a05646.html#l01016">format</a>, and <a class="el" href="a05981.html#l00105">uint</a>. +<p> +<div class="fragment"><pre>00157 { +00158 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr1">_Format</a> = <a class="code" href="a04223.html#a641">format</a>; +00159 <a class="code" href="a02299.html#NLSOUND_1_1CBufferDSoundr2">_Freq</a> = freq; +00160 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1IBuffera11" doxytag="NLSOUND::CBufferDSound::setSize" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> virtual void NLSOUND::IBuffer::setSize </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a04558.html#a11">uint32</a> </td> + <td class="mdname1" valign="top" nowrap> <em>size</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [inline, virtual, inherited]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Force the buffer size without filling data (if <a class="el" href="a02298.html#NLSOUND_1_1IBuffera7">isFillMoreSupported()</a> only). +<p> + +<p> +Reimplemented in <a class="el" href="a02297.html#NLSOUND_1_1CBufferALa16">NLSOUND::CBufferAL</a>. +<p> +Definition at line <a class="el" href="a05517.html#l00073">73</a> of file <a class="el" href="a05517.html">buffer.h</a>. +<p> +References <a class="el" href="a05646.html#l00645">size</a>, and <a class="el" href="a05981.html#l00100">uint32</a>. +<p> +<div class="fragment"><pre>00073 { <span class="keywordflow">throw</span> ESoundDriverNotSupp(); } +</pre></div> </td> + </tr> +</table> +<hr><h2>Field Documentation</h2> +<a class="anchor" name="NLSOUND_1_1CBufferDSoundr0" doxytag="NLSOUND::CBufferDSound::_Data" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a04558.html#a7">uint8</a>* <a class="el" href="a02299.html#NLSOUND_1_1CBufferDSoundr0">NLSOUND::CBufferDSound::_Data</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05521.html#l00114">114</a> of file <a class="el" href="a05521.html">buffer_dsound.h</a>. </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSoundr1" doxytag="NLSOUND::CBufferDSound::_Format" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a05381.html#a80">TSampleFormat</a> <a class="el" href="a02299.html#NLSOUND_1_1CBufferDSoundr1">NLSOUND::CBufferDSound::_Format</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05521.html#l00118">118</a> of file <a class="el" href="a05521.html">buffer_dsound.h</a>. +<p> +Referenced by <a class="el" href="a05520.html#l00131">CBufferDSound()</a>, <a class="el" href="a05520.html#l00451">getBufferADPCMEncoded()</a>, <a class="el" href="a05520.html#l00474">getBufferMono16()</a>, <a class="el" href="a05520.html#l00169">getDuration()</a>, <a class="el" href="a05521.html#l00072">getFormat()</a>, <a class="el" href="a05521.html#l00069">isStereo()</a>, <a class="el" href="a05520.html#l00416">readRawBuffer()</a>, <a class="el" href="a05520.html#l00196">readWavBuffer()</a>, and <a class="el" href="a05520.html#l00156">setFormat()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSoundr2" doxytag="NLSOUND::CBufferDSound::_Freq" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a04558.html#a15">uint</a> <a class="el" href="a02299.html#NLSOUND_1_1CBufferDSoundr2">NLSOUND::CBufferDSound::_Freq</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05521.html#l00120">120</a> of file <a class="el" href="a05521.html">buffer_dsound.h</a>. +<p> +Referenced by <a class="el" href="a05520.html#l00131">CBufferDSound()</a>, <a class="el" href="a05520.html#l00169">getDuration()</a>, <a class="el" href="a05521.html#l00072">getFormat()</a>, <a class="el" href="a05520.html#l00416">readRawBuffer()</a>, <a class="el" href="a05520.html#l00196">readWavBuffer()</a>, and <a class="el" href="a05520.html#l00156">setFormat()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSoundr3" doxytag="NLSOUND::CBufferDSound::_Name" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a05378.html#a236">NLMISC::TStringId</a> <a class="el" href="a02299.html#NLSOUND_1_1CBufferDSoundr3">NLSOUND::CBufferDSound::_Name</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05521.html#l00112">112</a> of file <a class="el" href="a05521.html">buffer_dsound.h</a>. </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CBufferDSoundr4" doxytag="NLSOUND::CBufferDSound::_Size" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a04558.html#a11">uint32</a> <a class="el" href="a02299.html#NLSOUND_1_1CBufferDSoundr4">NLSOUND::CBufferDSound::_Size</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05521.html#l00116">116</a> of file <a class="el" href="a05521.html">buffer_dsound.h</a>. </td> + </tr> +</table> +<hr>The documentation for this class was generated from the following files:<ul> +<li><a class="el" href="a05521.html">buffer_dsound.h</a><li><a class="el" href="a05520.html">buffer_dsound.cpp</a></ul> +<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 14:34:08 2004 for NeL by +<a href="http://www.doxygen.org/index.html"> +<img src="doxygen.png" alt="doxygen" align="middle" border=0 > +</a>1.3.6 </small></address> +</body> +</html> |