aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/background__sound__manager_8cpp-source.html
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
committerneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
commit0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch)
tree2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/background__sound__manager_8cpp-source.html
downloadnevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz
nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip
Initial commit
Diffstat (limited to 'docs/doxygen/nel/background__sound__manager_8cpp-source.html')
-rw-r--r--docs/doxygen/nel/background__sound__manager_8cpp-source.html818
1 files changed, 818 insertions, 0 deletions
diff --git a/docs/doxygen/nel/background__sound__manager_8cpp-source.html b/docs/doxygen/nel/background__sound__manager_8cpp-source.html
new file mode 100644
index 00000000..6b789b9e
--- /dev/null
+++ b/docs/doxygen/nel/background__sound__manager_8cpp-source.html
@@ -0,0 +1,818 @@
+<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<HTML>
+<HEAD>
+ <TITLE>nevrax.org : docs</TITLE>
+ <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css">
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+</HEAD>
+<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
+
+<!-- uplinks -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ </TR>
+</TABLE>
+
+<!-- banner Nevrax -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
+ <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
+</TABLE>
+
+<!-- main table -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+ <!------ Begin Box ------>
+ <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
+ <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
+ <TABLE cellspacing=0 cellpadding=1 border=0>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr>
+ </TABLE>
+ </TD></TR></TABLE></TD></TR></TABLE>
+ <!------ End Box ------>
+
+ </TD>
+ <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+<!-- title -->
+<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
+<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
+</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
+</td></tr></table>
+&nbsp;
+
+<!-- block -->
+<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD>
+ <TD><B>Documentation</B></TD>
+ <TD ALIGN=RIGHT>&nbsp;</td>
+</tr></table>
+<!-- Generated by Doxygen 1.2.14 -->
+<center>
+<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
+<hr><h1>background_sound_manager.cpp</h1><a href="background__sound__manager_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
+00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font>
+00008 <font class="comment"> *</font>
+00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
+00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
+00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
+00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
+00013 <font class="comment"> * any later version.</font>
+00014 <font class="comment"></font>
+00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
+00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
+00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
+00018 <font class="comment"> * General Public License for more details.</font>
+00019 <font class="comment"></font>
+00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
+00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
+00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
+00023 <font class="comment"> * MA 02111-1307, USA.</font>
+00024 <font class="comment"> */</font>
+00025
+00026
+00027 <font class="preprocessor">#include "<a class="code" href="stdsound_8h.html">stdsound.h</a>"</font>
+00028
+00029 <font class="preprocessor">#include "<a class="code" href="file_8h.html">nel/misc/file.h</a>"</font>
+00030 <font class="preprocessor">#include "<a class="code" href="i__xml_8h.html">nel/misc/i_xml.h</a>"</font>
+00031 <font class="preprocessor">#include "<a class="code" href="path_8h.html">nel/misc/path.h</a>"</font>
+00032
+00033 <font class="preprocessor">#include "<a class="code" href="primitive_8h.html">nel/ligo/primitive.h</a>"</font>
+00034
+00035 <font class="preprocessor">#include "<a class="code" href="u__source_8h.html">nel/sound/u_source.h</a>"</font>
+00036
+00037 <font class="preprocessor">#include "<a class="code" href="background__sound__manager_8h.html">background_sound_manager.h</a>"</font>
+00038 <font class="preprocessor">#include &lt;algorithm&gt;</font>
+00039
+00040 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
+00041 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
+00042 <font class="keyword">using</font> <font class="keyword">namespace </font>NLLIGO;
+00043
+00044
+00045 <font class="keyword">namespace </font>NLSOUND {
+00046
+00047 <font class="comment">// external sound are cliping after 10 meter inside the inner patate</font>
+00048 <font class="keyword">const</font> <font class="keywordtype">float</font> <a class="code" href="namespaceNLSOUND.html#a17">INSIDE_FALLOF</a> = 10.0f;
+00049
+00050 <font class="comment">//UAudioMixer *CBackgroundSoundManager::_AudioMixer = NULL;</font>
+00051
+00052
+<a name="l00053"></a><a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#c0">00053</a> CBackgroundSoundManager::CBackgroundSoundManager()
+00054 : _LastPosition(0,0,0), _Playing(false)
+00055 {
+00056 }
+00057
+<a name="l00058"></a><a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#c1">00058</a> CBackgroundSoundManager::~CBackgroundSoundManager()
+00059 {
+00060 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#a4">unload</a>();
+00061 }
+00062
+<a name="l00063"></a><a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#a11">00063</a> <font class="keyword">const</font> UAudioMixer::TBackgroundFlags &amp;CBackgroundSoundManager::getBackgroundFlags()
+00064 {
+00065 <font class="keywordflow">return</font> <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#o1">_BackgroundFlags</a>;
+00066 }
+00067
+<a name="l00068"></a><a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#a12">00068</a> <font class="keywordtype">void</font> CBackgroundSoundManager::setBackgroundFlags(<font class="keyword">const</font> UAudioMixer::TBackgroundFlags &amp;backgroundFlags)
+00069 {
+00070 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#o1">_BackgroundFlags</a> = backgroundFlags;
+00071 }
+00072
+<a name="l00073"></a><a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#c2">00073</a> <font class="keywordtype">void</font> CBackgroundSoundManager::addSound(<font class="keyword">const</font> std::string &amp;soundName, <font class="keyword">const</font> std::vector&lt;NLLIGO::CPrimVector&gt; &amp;points, <font class="keywordtype">bool</font> isPath)
+00074 {
+00075 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#l0">CAudioMixerUser</a> *mixer = CAudioMixerUser::instance();
+00076 uint layerId = 0;
+00077 uint n = 0;
+00078 string name;
+00079 <font class="comment">// count the number of '-' in the sgtring.</font>
+00080 n = <a class="code" href="cf__gramatical_8cpp.html#a70">std::count</a>(soundName.begin(), soundName.end(), <font class="charliteral">'-'</font>);
+00081
+00082 <font class="keywordflow">if</font> (n == 2)
+00083 {
+00084 <font class="comment">// no layer spec, default to layer A</font>
+00085 uint32 pos1 = soundName.find (<font class="stringliteral">"-"</font>);
+00086 <font class="keywordflow">if</font>(pos1 == string::npos)
+00087 {
+00088 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"zone have the malformated name '%s' missing -name-"</font>, soundName.c_str());
+00089 <font class="keywordflow">return</font>;
+00090 }
+00091 pos1++;
+00092
+00093 uint32 pos2 = soundName.find (<font class="stringliteral">"-"</font>, pos1);
+00094 <font class="keywordflow">if</font>(pos2 == string::npos)
+00095 {
+00096 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"zone have the malformated name '%s' missing -name-"</font>, soundName.c_str());
+00097 <font class="keywordflow">return</font>;
+00098 }
+00099
+00100 name = soundName.substr(pos1, pos2-pos1);
+00101 }
+00102 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (n == 3)
+00103 {
+00104 <font class="comment">// layer spec !</font>
+00105 uint32 pos1 = soundName.find (<font class="stringliteral">"-"</font>);
+00106 uint32 pos2 = soundName.find (<font class="stringliteral">"-"</font>, pos1+1);
+00107 <font class="keywordflow">if</font>(pos1 == string::npos || pos2 == string::npos)
+00108 {
+00109 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"zone have the malformated name '%s' missing -layerId- or -name-"</font>, soundName.c_str());
+00110 <font class="keywordflow">return</font>;
+00111 }
+00112 pos1++;
+00113
+00114 uint32 pos3 = soundName.find (<font class="stringliteral">"-"</font>, pos2+1);
+00115 <font class="keywordflow">if</font>(pos3 == string::npos)
+00116 {
+00117 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"zone have the malformated name '%s' missing -name-"</font>, soundName.c_str());
+00118 <font class="keywordflow">return</font>;
+00119 }
+00120
+00121 <font class="keywordtype">char</font> <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a> = soundName[pos1];
+00122
+00123 <font class="comment">// check caps</font>
+00124 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a> &lt; <font class="charliteral">'a'</font>)
+00125 <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a> + (<font class="charliteral">'a'</font> - <font class="charliteral">'A'</font>);
+00126
+00127 layerId = <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a> - <font class="charliteral">'a'</font>;
+00128
+00129 <a class="code" href="namespaceNLMISC.html#a215">NLMISC::clamp</a>(layerId, 0u, <a class="code" href="namespaceNLSOUND.html#a18">BACKGROUND_LAYER</a>-1);
+00130 pos2++;
+00131
+00132 name = soundName.substr(pos2, pos3-pos2);
+00133 }
+00134 <font class="keywordflow">else</font>
+00135 {
+00136 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"zone have the malformated name '%s"</font>, soundName.c_str());
+00137 <font class="keywordflow">return</font>;
+00138 }
+00139
+00140
+00141 TSoundData sd;
+00142
+00143 sd.SoundName = name;
+00144 sd.Sound = mixer-&gt;getSoundId(sd.SoundName);
+00145 sd.Source = 0;
+00146
+00147 <font class="comment">// Copy the points</font>
+00148 sd.Points.resize (points.size ());
+00149 <font class="keywordflow">for</font> (uint i=0; i&lt;points.size (); i++)
+00150 sd.Points[i] = points[i];
+00151
+00152 sd.Selected = <font class="keyword">false</font>;
+00153 sd.IsPath = isPath;
+00154
+00155 <font class="keywordflow">if</font> (sd.Sound != 0)
+00156 {
+00157 <font class="comment">// the sound is available !</font>
+00158 <font class="comment">// compute bouding box/</font>
+00159 CVector vmin(FLT_MAX, FLT_MAX, 0), vmax(-FLT_MAX, -FLT_MAX, 0);
+00160
+00161 vector&lt;CVector&gt;::iterator first(sd.Points.begin()), last(sd.Points.end());
+00162 <font class="keywordflow">for</font> (; first != last; ++first)
+00163 {
+00164 vmin.x = <a class="code" href="bit__set_8cpp.html#a0">min</a>(first-&gt;x, vmin.x);
+00165 vmin.y = <a class="code" href="bit__set_8cpp.html#a0">min</a>(first-&gt;y, vmin.y);
+00166 vmax.x = max(first-&gt;x, vmax.x);
+00167 vmax.y = max(first-&gt;y, vmax.y);
+00168 }
+00169 sd.MaxBox = vmax;
+00170 sd.MinBox = vmin;
+00171
+00172 <font class="comment">// compute the surface without the sound distance</font>
+00173 sd.Surface = (vmax.x - vmin.x) * (vmax.y - vmin.y);
+00174
+00175 <font class="comment">// add the eard distance of the sound.</font>
+00176 <font class="keywordtype">float</font> dist = sd.Sound-&gt;getMaxDistance();
+00177 sd.MaxBox.x += dist;
+00178 sd.MaxBox.y += dist;
+00179 sd.MinBox.x -= dist;
+00180 sd.MinBox.y -= dist;
+00181
+00182 sd.MaxDist = dist;
+00183
+00184 <font class="comment">// store the sound. </font>
+00185 <font class="comment">// TODO : handle the three layer.</font>
+00186 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#z962_0">_Layers</a>[layerId].push_back(sd);
+00187 }
+00188 <font class="keywordflow">else</font>
+00189 {
+00190 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"The sound '%s' can't be loaded"</font>, sd.SoundName.c_str());
+00191 }
+00192 }
+00193
+00194
+<a name="l00195"></a><a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#a2">00195</a> <font class="keywordtype">void</font> CBackgroundSoundManager::loadSamplesFromRegion(<font class="keyword">const</font> <a class="code" href="classNLLIGO_1_1CPrimRegion.html">NLLIGO::CPrimRegion</a> &amp;region)
+00196 {
+00197 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#z961_0">_Banks</a>.clear();
+00198
+00199 <font class="keywordflow">for</font> (uint i=0; i&lt; region.<a class="code" href="classNLLIGO_1_1CPrimRegion.html#m2">VZones</a>.size(); ++i)
+00200 {
+00201 <font class="keywordflow">if</font> (region.<a class="code" href="classNLLIGO_1_1CPrimRegion.html#m2">VZones</a>[i].VPoints.size() &gt; 2)
+00202 {
+00203 TBanksData bd;
+00204 uint pointCount = region.<a class="code" href="classNLLIGO_1_1CPrimRegion.html#m2">VZones</a>[i].VPoints.size ();
+00205 bd.Points.resize (pointCount);
+00206 <font class="keywordflow">for</font> (uint j=0; j&lt;pointCount; j++)
+00207 {
+00208 bd.Points[j] = region.<a class="code" href="classNLLIGO_1_1CPrimRegion.html#m2">VZones</a>[i].VPoints[j];
+00209 }
+00210
+00211 <font class="comment">// compute bouding box.</font>
+00212 CVector vmin(FLT_MAX, FLT_MAX, 0), vmax(-FLT_MAX, -FLT_MAX, 0);
+00213
+00214 vector&lt;CVector&gt;::iterator first(bd.Points.begin()), last(bd.Points.end());
+00215 <font class="keywordflow">for</font> (; first != last; ++first)
+00216 {
+00217 vmin.x = <a class="code" href="bit__set_8cpp.html#a0">min</a>(first-&gt;x, vmin.x);
+00218 vmin.y = <a class="code" href="bit__set_8cpp.html#a0">min</a>(first-&gt;y, vmin.y);
+00219 vmax.x = max(first-&gt;x, vmax.x);
+00220 vmax.y = max(first-&gt;y, vmax.y);
+00221 }
+00222 bd.MaxBox = vmax;
+00223 bd.MinBox = vmin;
+00224
+00225 <font class="comment">// parse the zone name to find the samples name.</font>
+00226 std::vector&lt;std::string&gt; splitted = <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#c3">split</a>(region.<a class="code" href="classNLLIGO_1_1CPrimRegion.html#m2">VZones</a>[i].Name, <font class="charliteral">'-'</font>);
+00227
+00228 <font class="keywordflow">if</font> (splitted.size() &gt; 2)
+00229 {
+00230 <font class="keywordflow">for</font> (uint j=1; j&lt;splitted.size()-1; ++j)
+00231 {
+00232 bd.Banks.push_back(splitted[j]);
+00233 }
+00234
+00235 <font class="comment">// ok, store it in the container.</font>
+00236 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#z961_0">_Banks</a>.push_back(bd);
+00237 }
+00238 <font class="keywordflow">else</font>
+00239 {
+00240 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"A sample bank patatoid name did'nt contains banks name '%s'"</font>, region.<a class="code" href="classNLLIGO_1_1CPrimRegion.html#m2">VZones</a>[i].Name.c_str());
+00241 }
+00242 }
+00243 <font class="keywordflow">else</font>
+00244 {
+00245 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"A sample bank patatoid have less than 3 points '%s'"</font>, region.<a class="code" href="classNLLIGO_1_1CPrimRegion.html#m2">VZones</a>[i].Name.c_str());
+00246 }
+00247 }
+00248 }
+00249
+<a name="l00250"></a><a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#a1">00250</a> <font class="keywordtype">void</font> CBackgroundSoundManager::loadEffecsFromRegion(<font class="keyword">const</font> <a class="code" href="classNLLIGO_1_1CPrimRegion.html">NLLIGO::CPrimRegion</a> &amp;region)
+00251 {
+00252 }
+00253
+00254 <font class="keywordtype">void</font> CBackgroundSoundManager::loadSoundsFromRegion(<font class="keyword">const</font> CPrimRegion &amp;region)
+00255 {
+00256 uint i;
+00257 <font class="comment">// remember playing state</font>
+00258 <font class="keywordtype">bool</font> oldState = <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#o0">_Playing</a>;
+00259 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#a4">unload</a>();
+00260
+00261 <font class="keywordflow">for</font> (i = 0; i &lt; region.VZones.size(); i++)
+00262 {
+00263 <font class="keywordflow">if</font>(region.VZones[i].VPoints.size()&gt;2)
+00264 {
+00265 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#c2">addSound</a>(region.VZones[i].Name, region.VZones[i].VPoints, <font class="keyword">false</font>);
+00266 }
+00267 <font class="keywordflow">else</font>
+00268 {
+00269 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"A background sound patatoid have less than 3 points '%s'"</font>, region.VZones[i].Name.c_str());
+00270 }
+00271 }
+00272
+00273 <font class="keywordflow">for</font> (i = 0; i &lt; region.VPaths.size(); i++)
+00274 {
+00275 <font class="keywordflow">if</font>(region.VPaths[i].VPoints.size() &gt; 1)
+00276 {
+00277 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#c2">addSound</a>(region.VPaths[i].Name, region.VPaths[i].VPoints, <font class="keyword">true</font>);
+00278 }
+00279 <font class="keywordflow">else</font>
+00280 {
+00281 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"A background sound path have less than 2 points '%s'"</font>, region.VPaths[i].Name.c_str());
+00282 }
+00283 }
+00284 <font class="keywordflow">for</font> (i = 0; i &lt; region.VPoints.size(); i++)
+00285 {
+00286 std::vector&lt;CPrimVector&gt; points;
+00287 points.push_back(region.VPoints[i].Point);
+00288
+00289 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#c2">addSound</a>(region.VPoints[i].Name, points, <font class="keyword">false</font>);
+00290 }
+00291
+00292
+00293 <font class="comment">// restart playing ?</font>
+00294 <font class="keywordflow">if</font> (oldState)
+00295 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#a5">play</a>();
+00296 }
+00297
+00298 <font class="keywordtype">void</font> CBackgroundSoundManager::load (<font class="keyword">const</font> string &amp;continent)
+00299 {
+00300 <font class="comment">// load the sound.</font>
+00301 {
+00302 CIFile <a class="code" href="cf__lexical_8cpp.html#a95">file</a>;
+00303 CPrimRegion region;
+00304 string fn = continent+<font class="stringliteral">"_audio.prim"</font>;
+00305
+00306 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"loading '%s'"</font>, fn.c_str());
+00307
+00308 string path = CPath::lookup(fn, <font class="keyword">false</font>);
+00309
+00310 <font class="keywordflow">if</font>(!path.empty() &amp;&amp; <a class="code" href="cf__lexical_8cpp.html#a95">file</a>.open (path))
+00311 {
+00312 CIXml xml;
+00313 xml.init (<a class="code" href="cf__lexical_8cpp.html#a95">file</a>);
+00314 region.serial(xml);
+00315 <a class="code" href="cf__lexical_8cpp.html#a95">file</a>.close ();
+00316
+00317 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"Region '%s' contains %d zones for the background sounds"</font>, continent.c_str(), region.VZones.size());
+00318
+00319 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#a0">loadSoundsFromRegion</a>(region);
+00320 }
+00321 }
+00322 <font class="comment">// load the effect.</font>
+00323 {
+00324 CIFile <a class="code" href="cf__lexical_8cpp.html#a95">file</a>;
+00325 CPrimRegion region;
+00326 string fn = continent+<font class="stringliteral">"_effects.prim"</font>;
+00327
+00328 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"loading '%s'"</font>, fn.c_str());
+00329
+00330 string path = CPath::lookup(fn, <font class="keyword">false</font>);
+00331
+00332 <font class="keywordflow">if</font>(!path.empty() &amp;&amp; <a class="code" href="cf__lexical_8cpp.html#a95">file</a>.open (path))
+00333 {
+00334 CIXml xml;
+00335 xml.init (<a class="code" href="cf__lexical_8cpp.html#a95">file</a>);
+00336 region.serial(xml);
+00337 <a class="code" href="cf__lexical_8cpp.html#a95">file</a>.close ();
+00338
+00339 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"Region '%s' contains %d zones for the background effetcs"</font>, continent.c_str(), region.VZones.size());
+00340
+00341 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#a1">loadEffecsFromRegion</a>(region);
+00342 }
+00343 }
+00344 <font class="comment">// load the samples banks.</font>
+00345 {
+00346 CIFile <a class="code" href="cf__lexical_8cpp.html#a95">file</a>;
+00347 CPrimRegion region;
+00348 string fn = continent+<font class="stringliteral">"_samples.prim"</font>;
+00349
+00350 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"loading '%s'"</font>, fn.c_str());
+00351
+00352 string path = CPath::lookup(fn, <font class="keyword">false</font>);
+00353
+00354 <font class="keywordflow">if</font>(!path.empty() &amp;&amp; <a class="code" href="cf__lexical_8cpp.html#a95">file</a>.open (path))
+00355 {
+00356 CIXml xml;
+00357 xml.init (<a class="code" href="cf__lexical_8cpp.html#a95">file</a>);
+00358 region.serial(xml);
+00359 <a class="code" href="cf__lexical_8cpp.html#a95">file</a>.close ();
+00360
+00361 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"Region '%s' contains %d zones for the background samples banks"</font>, continent.c_str(), region.VZones.size());
+00362
+00363 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#a2">loadSamplesFromRegion</a>(region);
+00364 }
+00365 }
+00366 }
+00367
+00368
+<a name="l00369"></a><a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#a5">00369</a> <font class="keywordtype">void</font> CBackgroundSoundManager::play ()
+00370 {
+00371 <font class="keywordflow">if</font> (_Playing)
+00372 <font class="keywordflow">return</font>;
+00373
+00374 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#o0">_Playing</a> = <font class="keyword">true</font>;
+00375
+00376 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#a8">updateBackgroundStatus</a>();
+00377 }
+00378
+00379
+<a name="l00380"></a><a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#a6">00380</a> <font class="keywordtype">void</font> CBackgroundSoundManager::stop ()
+00381 {
+00382 <font class="keywordflow">if</font>(!<a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#o0">_Playing</a>)
+00383 <font class="keywordflow">return</font>;
+00384 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#l0">CAudioMixerUser</a> *mixer = CAudioMixerUser::instance();
+00385
+00386 <font class="keywordflow">for</font> (uint i=0; i&lt;<a class="code" href="namespaceNLSOUND.html#a18">BACKGROUND_LAYER</a>; ++i)
+00387 {
+00388 <font class="comment">// stop all playing source</font>
+00389 std::vector&lt;TSoundData&gt;::iterator first(<a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#z962_0">_Layers</a>[i].begin()), last(<a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#z962_0">_Layers</a>[i].end());
+00390 <font class="keywordflow">for</font> (; first != last; ++first)
+00391 {
+00392 <font class="keywordflow">if</font> (first-&gt;Source != 0 &amp;&amp; first-&gt;Source-&gt;isPlaying())
+00393 first-&gt;Source-&gt;stop();
+00394 }
+00395 }
+00396
+00397 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#o0">_Playing</a> = <font class="keyword">false</font>;
+00398 }
+00399
+<a name="l00400"></a><a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#a4">00400</a> <font class="keywordtype">void</font> CBackgroundSoundManager::unload ()
+00401 {
+00402 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#a6">stop</a>();
+00403
+00404 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#l0">CAudioMixerUser</a> *mixer = CAudioMixerUser::instance();
+00405
+00406 <font class="keywordflow">for</font> (uint i=0; i&lt;<a class="code" href="namespaceNLSOUND.html#a18">BACKGROUND_LAYER</a>; ++i)
+00407 {
+00408 <font class="comment">// delete all created source</font>
+00409 std::vector&lt;TSoundData&gt;::iterator first(<a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#z962_0">_Layers</a>[i].begin()), last(<a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#z962_0">_Layers</a>[i].end());
+00410 <font class="keywordflow">for</font> (; first != last; ++first)
+00411 {
+00412 <font class="keywordflow">if</font> (first-&gt;Source)
+00413 <font class="comment">// mixer-&gt;removeSource(first-&gt;Source);</font>
+00414 <font class="keyword">delete</font> first-&gt;Source;
+00415 }
+00416
+00417 <font class="comment">// and free the layer.</font>
+00418 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#z962_0">_Layers</a>[i].clear();
+00419 }
+00420 }
+00421
+00422 <font class="keywordtype">void</font> CBackgroundSoundManager::setListenerPosition (<font class="keyword">const</font> CVector &amp;listenerPosition)
+00423 {
+00424 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#o2">_LastPosition</a> == listenerPosition)
+00425 {
+00426 <font class="keywordflow">return</font>;
+00427 }
+00428 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#o2">_LastPosition</a> = listenerPosition;
+00429
+00430 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#a8">updateBackgroundStatus</a>();
+00431 }
+00432
+<a name="l00433"></a><a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#a8">00433</a> <font class="keywordtype">void</font> CBackgroundSoundManager::updateBackgroundStatus()
+00434 {
+00435 <font class="keywordflow">if</font> (!<a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#o0">_Playing</a>)
+00436 <font class="keywordflow">return</font>;
+00437
+00438 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#l0">CAudioMixerUser</a> *mixer = CAudioMixerUser::instance();
+00439
+00440 <font class="comment">// it s on 2d so we don't have z</font>
+00441 CVector listener = <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#o2">_LastPosition</a>;
+00442 listener.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> = 0.0f;
+00443
+00444 <font class="comment">// compute the list of load/unload banks.</font>
+00445 {
+00446 <font class="comment">// set of bank that must be in ram.</font>
+00447 std::set&lt;std::string&gt; newBanks;
+00448
+00449 std::vector&lt;TBanksData&gt;::iterator first(<a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#z961_0">_Banks</a>.begin()), last(<a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#z961_0">_Banks</a>.end());
+00450 <font class="keywordflow">for</font> (; first != last; ++first)
+00451 {
+00452 <font class="keywordflow">if</font> (listener.x &gt;= first-&gt;MinBox.x &amp;&amp; listener.x &lt;= first-&gt;MaxBox.x
+00453 &amp;&amp; listener.y &gt;= first-&gt;MinBox.y &amp;&amp; listener.y &lt;= first-&gt;MaxBox.y
+00454 )
+00455 {
+00456 <font class="comment">// bounding box ok, </font>
+00457 <font class="keywordflow">if</font> (CPrimZone::contains(listener, first-&gt;Points))
+00458 {
+00459 <font class="comment">// add the banks of this zone in the n</font>
+00460 newBanks.insert(first-&gt;Banks.begin(), first-&gt;Banks.end());
+00461 }
+00462 }
+00463 }
+00464 <font class="comment">// ok, now compute to set : the set of bank to load, and the set of banks to unload.</font>
+00465 std::set&lt;std::string&gt; noChange;
+00466 std::set_intersection(<a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#z961_1">_LoadedBanks</a>.begin(), <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#z961_1">_LoadedBanks</a>.end(), newBanks.begin(), newBanks.end(), std::inserter(noChange, noChange.end()));
+00467
+00468 std::set&lt;std::string&gt; loadList;
+00469 std::set_difference(newBanks.begin(), newBanks.end(), noChange.begin(), noChange.end(), std::inserter(loadList, loadList.end()));
+00470
+00471 std::set&lt;std::string&gt; unloadList;
+00472 std::set_difference(<a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#z961_1">_LoadedBanks</a>.begin(), <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#z961_1">_LoadedBanks</a>.end(), newBanks.begin(), newBanks.end(), std::inserter(unloadList, unloadList.end()));
+00473
+00474 <font class="comment">// and now, load and unload....</font>
+00475 {
+00476 std::set&lt;std::string&gt;::iterator first(loadList.begin()), last(loadList.end());
+00477 <font class="keywordflow">for</font> (; first != last; ++first)
+00478 {
+00479 mixer-&gt;loadSampleBank(<font class="keyword">true</font>, *first);
+00480 }
+00481 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#z961_1">_LoadedBanks</a>.insert(loadList.begin(), loadList.end());
+00482 }
+00483 {
+00484 std::set&lt;std::string&gt;::iterator first(unloadList.begin()), last(unloadList.end());
+00485 <font class="keywordflow">for</font> (; first != last; ++first)
+00486 {
+00487 <font class="keywordflow">if</font> (mixer-&gt;unloadSampleBank(*first))
+00488 {
+00489 <font class="comment">// ok, the bank is unloaded</font>
+00490 <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#z961_1">_LoadedBanks</a>.erase(*first);
+00491 }
+00492 }
+00493 }
+00494 }
+00495
+00496 <font class="comment">// Apply the same algo for each sound layer.</font>
+00497 <font class="keywordflow">for</font> (uint i=0; i&lt;<a class="code" href="namespaceNLSOUND.html#a18">BACKGROUND_LAYER</a>; ++i)
+00498 {
+00499 vector&lt;TSoundData&gt; &amp;layer = <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#z962_0">_Layers</a>[i];
+00500 vector&lt;uint&gt; selectedIndex;
+00501 vector&lt;uint&gt; leaveIndex;
+00502
+00503 selectedIndex.reserve(layer.size());
+00504 leaveIndex.reserve(layer.size());
+00505
+00506 <font class="comment">// extract the list of selected/unselected box</font>
+00507 vector&lt;TSoundData&gt;::iterator first(layer.begin()), last(layer.end());
+00508 <font class="keywordflow">for</font> (uint count = 0; first != last; ++first, ++count)
+00509 {
+00510 <font class="keywordflow">if</font> (listener.x &gt;= first-&gt;MinBox.x &amp;&amp; listener.x &lt;= first-&gt;MaxBox.x
+00511 &amp;&amp; listener.y &gt;= first-&gt;MinBox.y &amp;&amp; listener.y &lt;= first-&gt;MaxBox.y
+00512 <font class="comment">// &amp;&amp; listener.z &gt;= first-&gt;MinBox.z &amp;&amp; listener.z &lt;= first-&gt;MaxBox.z</font>
+00513 )
+00514 {
+00515 <font class="comment">// nldebug("patat %u is selected by box (%s)", count, first-&gt;SoundName.c_str());</font>
+00516 selectedIndex.push_back(count);
+00517 }
+00518 <font class="keywordflow">else</font>
+00519 {
+00520 <font class="comment">// nldebug("patat %u is rejected by box (%s)", count, first-&gt;SoundName.c_str());</font>
+00521 <font class="comment">// listener out of this box.</font>
+00522 <font class="keywordflow">if</font> (first-&gt;Selected &amp;&amp; first-&gt;Source != 0)
+00523 {
+00524 <font class="comment">// we leave this box.</font>
+00525 leaveIndex.push_back(count);
+00526 }
+00527 }
+00528 }
+00529
+00530 <font class="comment">// stop all the sound that are leaved.</font>
+00531 {
+00532 vector&lt;uint&gt;::iterator first(leaveIndex.begin()), last(leaveIndex.end());
+00533 <font class="keywordflow">for</font> (; first != last; ++first)
+00534 {
+00535 TSoundData &amp;sd = layer[*first];
+00536 sd.Selected = <font class="keyword">false</font>;
+00537 <font class="keywordflow">if</font> (sd.Source-&gt;isPlaying())
+00538 sd.Source-&gt;stop();
+00539 }
+00540 }
+00541 <font class="comment">// Compute new source mixing in this layer</font>
+00542 {
+00544 map&lt;float, TSoundStatus&gt; status;
+00545
+00546 <font class="comment">// first loop to compute selected sound gain and position and order the result by surface..</font>
+00547 {
+00548 vector&lt;uint&gt;::iterator first(selectedIndex.begin()), last(selectedIndex.end());
+00549 <font class="keywordflow">for</font> (; first != last; ++first)
+00550 {
+00551 TSoundData &amp;sd = layer[*first];
+00552 CVector pos;
+00553 <font class="keywordtype">float</font> gain;
+00554 <font class="keywordtype">float</font> distance;
+00555
+00556 <font class="comment">// inside the patat ?</font>
+00557
+00558 <font class="keywordflow">if</font>(CPrimZone::contains(listener, sd.Points, distance, pos, sd.IsPath))
+00559 {
+00560 pos = <a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#o2">_LastPosition</a>; <font class="comment">// use the real listener position, not the 0 z centered</font>
+00561 gain = 1.0f;
+00562 <font class="comment">// nlinfo ("inside patate %d name '%s' ", *first, sd.SoundName.c_str());</font>
+00563 }
+00564 <font class="keywordflow">else</font>
+00565 {
+00566 <font class="keywordflow">if</font> (distance &lt; sd.MaxDist)
+00567 {
+00568 <font class="comment">// compute the gain.</font>
+00569 gain = (sd.MaxDist - distance) / sd.MaxDist;
+00570 }
+00571 <font class="keywordflow">else</font>
+00572 {
+00573 <font class="comment">// too far</font>
+00574 gain = 0;
+00575 }
+00576 <font class="comment">//nlinfo ("near patate %d name '%s' from %f ", *first, sd.SoundName.c_str(), distance);</font>
+00577 }
+00578
+00579 <font class="comment">// store the status.</font>
+00580 status.insert(make_pair(sd.Surface, TSoundStatus(sd, pos, gain, distance)));
+00581 }
+00582 }
+00583 <font class="comment">// second loop thrue the surface ordered selected sound.</font>
+00584 {
+00585 <font class="comment">// Sound mixing strategie :</font>
+00586 <font class="comment">// The smallest zone sound mask bigger one</font>
+00587
+00588 <font class="keywordtype">float</font> maskFactor = 1.0f;
+00589
+00590 map&lt;float, TSoundStatus&gt;::iterator first(status.begin()), last(status.end());
+00591 <font class="keywordflow">for</font> (; first != last; ++first)
+00592 {
+00593 TSoundStatus &amp;ss = first-&gt;second;
+00594
+00595 <font class="keywordflow">if</font> (maskFactor &gt; 0.0f &amp;&amp; ss.Gain &gt; 0)
+00596 {
+00597 <font class="keywordtype">float</font> gain = maskFactor * ss.Gain;
+00598 <font class="comment">// maskFactor -= ss.Gain;</font>
+00599
+00600 ss.SoundData.Selected = <font class="keyword">true</font>;
+00601
+00602 <font class="keywordflow">if</font> (ss.Gain == 1)
+00603 {
+00604 <font class="comment">// inside a pattate, then decrease the mask factor will we are more inside the patate</font>
+00605 maskFactor -= first-&gt;second.Distance / <a class="code" href="namespaceNLSOUND.html#a17">INSIDE_FALLOF</a>;
+00606 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(maskFactor, 0.0f, 1.0f);
+00607 }
+00608
+00609 <font class="comment">// start the soond (if needed) and update the volume.</font>
+00610
+00611 <font class="keywordflow">if</font> (ss.SoundData.Source == 0)
+00612 {
+00613 <font class="comment">// try to create the source.</font>
+00614 ss.SoundData.Source = mixer-&gt;createSource(ss.SoundData.Sound, <font class="keyword">false</font>);
+00615 }
+00616 <font class="keywordflow">if</font> (ss.SoundData.Source != 0)
+00617 {
+00618 <font class="comment">// set the volume</font>
+00619 ss.SoundData.Source-&gt;setRelativeGain(gain);
+00620 <font class="comment">// and the position</font>
+00621 ss.Position.z += 5.0f;
+00622 ss.SoundData.Source-&gt;setPos(ss.Position);
+00623
+00624 <font class="comment">// nldebug("Setting source %s at %f", ss.SoundData.SoundName.c_str(), gain);</font>
+00625 <font class="keywordflow">if</font> (!ss.SoundData.Source-&gt;isPlaying())
+00626 {
+00627 <font class="comment">// start the sound is needed.</font>
+00628 ss.SoundData.Source-&gt;play();
+00629 }
+00630 }
+00631 }
+00632 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (ss.SoundData.Source != 0 &amp;&amp; ss.SoundData.Source-&gt;isPlaying())
+00633 {
+00634 <font class="comment">// stop this too far source.</font>
+00635 ss.SoundData.Source-&gt;stop();
+00636 }
+00637 }
+00638 }
+00639 } <font class="comment">// compute source mixing</font>
+00640 } <font class="comment">// for each layer</font>
+00641 }
+00642
+00643 <font class="comment">/*</font>
+00644 <font class="comment">void CBackgroundSoundManager::update ()</font>
+00645 <font class="comment">{</font>
+00646 <font class="comment"></font>
+00647 <font class="comment">}</font>
+00648 <font class="comment">*/</font>
+00649 <font class="comment">/*</font>
+00650 <font class="comment">uint32 CBackgroundSoundManager::getZoneNumber ()</font>
+00651 <font class="comment">{</font>
+00652 <font class="comment">// return BackgroundSounds.size();</font>
+00653 <font class="comment"> return 0;</font>
+00654 <font class="comment">}</font>
+00655 <font class="comment">*/</font>
+00656 <font class="comment">/*</font>
+00657 <font class="comment">const vector&lt;CVector&gt; &amp;CBackgroundSoundManager::getZone(uint32 zone)</font>
+00658 <font class="comment">{</font>
+00659 <font class="comment">// nlassert (zone&lt; BackgroundSounds.size());</font>
+00660 <font class="comment">// return BackgroundSounds[zone].Points;</font>
+00661 <font class="comment"> static vector&lt;CVector&gt; v;</font>
+00662 <font class="comment"> return v;</font>
+00663 <font class="comment">}</font>
+00664 <font class="comment">*/</font>
+<a name="l00665"></a><a class="code" href="classNLSOUND_1_1CBackgroundSoundManager.html#a10">00665</a> CVector CBackgroundSoundManager::getZoneSourcePos(uint32 zone)
+00666 {
+00667 <font class="comment">/* nlassert (zone&lt; BackgroundSounds.size());</font>
+00668 <font class="comment"> CVector pos;</font>
+00669 <font class="comment"> if (BackgroundSounds[zone].SourceDay != NULL)</font>
+00670 <font class="comment"> BackgroundSounds[zone].SourceDay-&gt;getPos(pos);</font>
+00671 <font class="comment"> return pos;</font>
+00672 <font class="comment">*/</font>
+00673 <font class="keywordflow">return</font> CVector();
+00674 }
+00675
+00676
+00677 <font class="comment">/*</font>
+00678 <font class="comment">void CBackgroundSoundManager::setDayNightRatio(float ratio)</font>
+00679 <font class="comment">{</font>
+00680 <font class="comment"> // 0 is day</font>
+00681 <font class="comment"> // 1 is night</font>
+00682 <font class="comment"></font>
+00683 <font class="comment"> nlassert (ratio&gt;=0.0f &amp;&amp; ratio&lt;=1.0f);</font>
+00684 <font class="comment"></font>
+00685 <font class="comment"> if (OldRatio == ratio)</font>
+00686 <font class="comment"> return;</font>
+00687 <font class="comment"> else</font>
+00688 <font class="comment"> OldRatio = ratio;</font>
+00689 <font class="comment"></font>
+00690 <font class="comment"></font>
+00691 <font class="comment"> // recompute all source volume</font>
+00692 <font class="comment"></font>
+00693 <font class="comment"> for (uint i = 0; i &lt; BackgroundSounds.size(); i++)</font>
+00694 <font class="comment"> {</font>
+00695 <font class="comment"> if(ratio == 0.0f)</font>
+00696 <font class="comment"> {</font>
+00697 <font class="comment"> if(BackgroundSounds[i].SourceDay != NULL)</font>
+00698 <font class="comment"> {</font>
+00699 <font class="comment"> BackgroundSounds[i].SourceDay-&gt;setRelativeGain(1.0f);</font>
+00700 <font class="comment"></font>
+00701 <font class="comment"> if (!BackgroundSounds[i].SourceDay-&gt;isPlaying())</font>
+00702 <font class="comment"> BackgroundSounds[i].SourceDay-&gt;play();</font>
+00703 <font class="comment"> }</font>
+00704 <font class="comment"> </font>
+00705 <font class="comment"> if(BackgroundSounds[i].SourceNight != NULL)</font>
+00706 <font class="comment"> {</font>
+00707 <font class="comment"> if (BackgroundSounds[i].SourceNight-&gt;isPlaying())</font>
+00708 <font class="comment"> BackgroundSounds[i].SourceNight-&gt;stop();</font>
+00709 <font class="comment"> }</font>
+00710 <font class="comment"> }</font>
+00711 <font class="comment"> else if (ratio == 1.0f)</font>
+00712 <font class="comment"> {</font>
+00713 <font class="comment"> if(BackgroundSounds[i].SourceDay != NULL)</font>
+00714 <font class="comment"> {</font>
+00715 <font class="comment"> if (BackgroundSounds[i].SourceDay-&gt;isPlaying())</font>
+00716 <font class="comment"> BackgroundSounds[i].SourceDay-&gt;stop();</font>
+00717 <font class="comment"> }</font>
+00718 <font class="comment"></font>
+00719 <font class="comment"> if(BackgroundSounds[i].SourceNight != NULL)</font>
+00720 <font class="comment"> {</font>
+00721 <font class="comment"> BackgroundSounds[i].SourceNight-&gt;setRelativeGain(1.0f);</font>
+00722 <font class="comment"></font>
+00723 <font class="comment"> if (!BackgroundSounds[i].SourceNight-&gt;isPlaying())</font>
+00724 <font class="comment"> BackgroundSounds[i].SourceNight-&gt;play();</font>
+00725 <font class="comment"> }</font>
+00726 <font class="comment"> }</font>
+00727 <font class="comment"> else</font>
+00728 <font class="comment"> {</font>
+00729 <font class="comment"> if(BackgroundSounds[i].SourceDay != NULL)</font>
+00730 <font class="comment"> {</font>
+00731 <font class="comment"> BackgroundSounds[i].SourceDay-&gt;setRelativeGain((1.0f-ratio));</font>
+00732 <font class="comment"></font>
+00733 <font class="comment"> if (!BackgroundSounds[i].SourceDay-&gt;isPlaying())</font>
+00734 <font class="comment"> BackgroundSounds[i].SourceDay-&gt;play();</font>
+00735 <font class="comment"> }</font>
+00736 <font class="comment"></font>
+00737 <font class="comment"> if(BackgroundSounds[i].SourceNight != NULL)</font>
+00738 <font class="comment"> {</font>
+00739 <font class="comment"> BackgroundSounds[i].SourceNight-&gt;setRelativeGain(ratio);</font>
+00740 <font class="comment"></font>
+00741 <font class="comment"> if (!BackgroundSounds[i].SourceNight-&gt;isPlaying())</font>
+00742 <font class="comment"> BackgroundSounds[i].SourceNight-&gt;play();</font>
+00743 <font class="comment"> }</font>
+00744 <font class="comment"> }</font>
+00745 <font class="comment"> }</font>
+00746 <font class="comment"></font>
+00747 <font class="comment">}</font>
+00748 <font class="comment">*/</font>
+00749 } <font class="comment">// NLSOUND</font>
+00750
+</pre></div>
+
+<!-- footer -->
+<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
+</TD>
+<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
+</TR>
+</TABLE>
+</BODY>
+</HTML>