aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/audio__mixer__user_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/audio__mixer__user_8cpp-source.html
downloadnevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz
nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip
Initial commit
Diffstat (limited to 'docs/doxygen/nel/audio__mixer__user_8cpp-source.html')
-rw-r--r--docs/doxygen/nel/audio__mixer__user_8cpp-source.html1410
1 files changed, 1410 insertions, 0 deletions
diff --git a/docs/doxygen/nel/audio__mixer__user_8cpp-source.html b/docs/doxygen/nel/audio__mixer__user_8cpp-source.html
new file mode 100644
index 00000000..49451df0
--- /dev/null
+++ b/docs/doxygen/nel/audio__mixer__user_8cpp-source.html
@@ -0,0 +1,1410 @@
+<!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>audio_mixer_user.cpp</h1><a href="audio__mixer__user_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 <font class="preprocessor">#include "<a class="code" href="stdsound_8h.html">stdsound.h</a>"</font>
+00027
+00028 <font class="comment">//#include "env_sound_user.h"</font>
+00029 <font class="comment">//#include "env_effect.h"</font>
+00030 <font class="preprocessor">#include "<a class="code" href="simple__sound_8h.html">simple_sound.h</a>"</font>
+00031 <font class="preprocessor">#include "<a class="code" href="complex__sound_8h.html">complex_sound.h</a>"</font>
+00032 <font class="comment">//#include "ambiant_source.h"</font>
+00033 <font class="comment">//#include "bounding_sphere.h"</font>
+00034 <font class="comment">//#include "bounding_box.h"</font>
+00035 <font class="preprocessor">#include "<a class="code" href="buffer_8h.html">driver/buffer.h</a>"</font>
+00036 <font class="preprocessor">#include "<a class="code" href="sample__bank_8h.html">sample_bank.h</a>"</font>
+00037 <font class="preprocessor">#include "<a class="code" href="sound__bank_8h.html">sound_bank.h</a>"</font>
+00038 <font class="preprocessor">#include "<a class="code" href="background__sound__manager_8h.html">background_sound_manager.h</a>"</font>
+00039 <font class="preprocessor">#include "<a class="code" href="simple__source_8h.html">simple_source.h</a>"</font>
+00040 <font class="preprocessor">#include "<a class="code" href="complex__source_8h.html">complex_source.h</a>"</font>
+00041 <font class="preprocessor">#include "<a class="code" href="background__source_8h.html">background_source.h</a>"</font>
+00042
+00043
+00044 <font class="preprocessor">#include "<a class="code" href="file_8h.html">nel/misc/file.h</a>"</font>
+00045 <font class="preprocessor">#include "<a class="code" href="path_8h.html">nel/misc/path.h</a>"</font>
+00046 <font class="preprocessor">#include "<a class="code" href="time__nl_8h.html">nel/misc/time_nl.h</a>"</font>
+00047 <font class="preprocessor">#include "<a class="code" href="command_8h.html">nel/misc/command.h</a>"</font>
+00048
+00049 <font class="preprocessor">#include "<a class="code" href="context__sound_8h.html">context_sound.h</a>"</font>
+00050 <font class="preprocessor">#include &lt;iomanip.h&gt;</font>
+00051
+00052 <font class="comment">//#include &lt;crtdbg.h&gt;</font>
+00053
+00054 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
+00055
+00056 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
+00057
+00058
+00059 <font class="keyword">namespace </font>NLSOUND {
+00060
+00061
+00062 <font class="preprocessor">#ifdef _DEBUG</font>
+00063 <font class="preprocessor"></font>CAudioMixerUser::IMixerEvent *CurrentEvent = 0;
+00064 <font class="preprocessor">#endif</font>
+00065 <font class="preprocessor"></font>
+00066
+<a name="l00067"></a><a class="code" href="audio__mixer__user_8cpp.html#a0">00067</a> <font class="preprocessor">#define NL_TRACE_MIXER 0</font>
+00068 <font class="preprocessor"></font>
+00069 <font class="preprocessor">#if NL_TRACE_MIXER</font>
+00070 <font class="preprocessor"></font><font class="preprocessor">#define _profile(_a) nldebug ## _a</font>
+00071 <font class="preprocessor"></font><font class="preprocessor">#else</font>
+<a name="l00072"></a><a class="code" href="audio__mixer__user_8cpp.html#a1">00072</a> <font class="preprocessor"></font><font class="preprocessor">#define _profile(_a) </font>
+00073 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
+00074 <font class="preprocessor"></font>
+00075 <font class="comment">// The audio mixer singleton instance</font>
+<a name="l00076"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#r0">00076</a> CAudioMixerUser *CAudioMixerUser::_Instance = NULL;
+00077
+00078 <font class="comment">// Return the priority cstring (debug info)</font>
+00079 <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="namespaceNLSOUND.html#a15">PriToCStr</a> [<a class="code" href="namespaceNLSOUND.html#a82a14">NbSoundPriorities</a>] = { <font class="stringliteral">"XH"</font>, <font class="stringliteral">"HI"</font>, <font class="stringliteral">"MD"</font>, <font class="stringliteral">"LO"</font> };
+00080
+00081
+00082 <font class="comment">// ******************************************************************</font>
+00083
+00084 <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="namespaceNLSOUND.html#a75">getPriorityStr</a>( <a class="code" href="namespaceNLSOUND.html#a82">TSoundPriority</a> p )
+00085 {
+00086 <a class="code" href="debug_8h.html#a6">nlassert</a>( ((uint)p) &lt; <a class="code" href="namespaceNLSOUND.html#a82a14">NbSoundPriorities</a> );
+00087 <font class="keywordflow">return</font> <a class="code" href="namespaceNLSOUND.html#a15">PriToCStr</a>[p];
+00088 }
+00089
+00090
+00091 <font class="comment">// ******************************************************************</font>
+00092
+<a name="l00093"></a><a class="code" href="classNLSOUND_1_1UAudioMixer.html#d0">00093</a> UAudioMixer *UAudioMixer::createAudioMixer()
+00094 {
+00095 <font class="keywordflow">return</font> <font class="keyword">new</font> CAudioMixerUser();
+00096 }
+00097
+00098
+00099 <font class="comment">// ******************************************************************</font>
+00100
+<a name="l00101"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a0">00101</a> CAudioMixerUser::CAudioMixerUser() : _SoundDriver(NULL),
+00102 _ListenPosition(CVector::Null),
+00103 <font class="comment">// _EnvSounds(NULL),</font>
+00104 <font class="comment">// _BalancePeriod(0),</font>
+00105 _CurEnvEffect(NULL),
+00106 _NbTracks(0),
+00107 _MaxNbTracks(0),
+00108 _Leaving(false),
+00109 _BackgroundSoundManager(0),
+00110 _PlayingSources(0)
+00111 {
+00112 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#r0">_Instance</a> == NULL )
+00113 {
+00114 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#r0">_Instance</a> = <font class="keyword">this</font>;
+00115
+00116 <font class="preprocessor">#if NL_PROFILE_MIXER</font>
+00117 <font class="preprocessor"></font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m7">_UpdateTime</a> = 0.0;
+00118 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m8">_CreateTime</a> = 0.0;
+00119 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m9">_UpdateCount</a> = 0;
+00120 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m10">_CreateCount</a> = 0;
+00121 <font class="preprocessor">#endif</font>
+00122 <font class="preprocessor"></font>
+00123 }
+00124 <font class="keywordflow">else</font>
+00125 {
+00126 <a class="code" href="debug_8h.html#a3">nlerror</a>( <font class="stringliteral">"Audio mixer singleton instanciated twice"</font> );
+00127 }
+00128 }
+00129
+00130
+00131 <font class="comment">// ******************************************************************</font>
+00132
+<a name="l00133"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a1">00133</a> CAudioMixerUser::~CAudioMixerUser()
+00134 {
+00135 <a class="code" href="debug_8h.html#a0">nldebug</a>( <font class="stringliteral">"AM: Releasing..."</font> );
+00136
+00137 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a> != 0)
+00138 <font class="keyword">delete</font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a>;
+00139 <font class="comment">// CBackgroundSoundManager::release();</font>
+00140
+00141 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a5">reset</a>();
+00142
+00143 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m5">_Leaving</a> = <font class="keyword">true</font>;
+00144
+00145 <font class="comment">// Release the sound bank</font>
+00146 CSoundBank::release();
+00147 <font class="comment">// Release all the SampleBanks</font>
+00148 CSampleBank::releaseAll();
+00149
+00150 <font class="comment">// Tracks</font>
+00151 uint i;
+00152 <font class="keywordflow">for</font> ( i=0; i!=<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>; i++ )
+00153 {
+00154 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i] )
+00155 <font class="keyword">delete</font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i];
+00156 }
+00157
+00158 <font class="comment">// Sound driver</font>
+00159 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o5">_SoundDriver</a> != NULL )
+00160 <font class="keyword">delete</font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o5">_SoundDriver</a>;
+00161
+00162 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#r0">_Instance</a> = NULL;
+00163
+00164 <a class="code" href="debug_8h.html#a0">nldebug</a>( <font class="stringliteral">"AM: Released"</font> );
+00165 }
+00166
+00167
+<a name="l00168"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a3">00168</a> <font class="keywordtype">void</font> CAudioMixerUser::setPriorityReserve(<a class="code" href="namespaceNLSOUND.html#a82">TSoundPriority</a> priorityChannel, uint reserve)
+00169 {
+00170 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o2">_PriorityReserve</a>[priorityChannel] = <a class="code" href="bit__set_8cpp.html#a0">min</a>(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>, reserve);
+00171 }
+00172
+<a name="l00173"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a4">00173</a> <font class="keywordtype">void</font> CAudioMixerUser::setLowWaterMark(uint <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>)
+00174 {
+00175 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o4">_LowWaterMark</a> = <a class="code" href="bit__set_8cpp.html#a0">min</a>(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>);
+00176 }
+00177
+00178
+00179 <font class="comment">// ******************************************************************</font>
+00180
+<a name="l00181"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a30">00181</a> <font class="keywordtype">void</font> CAudioMixerUser::writeProfile(std::ostream&amp; out)
+00182 {
+00183 <font class="comment">// compute number of muted source</font>
+00184 uint nb = 0;
+00185
+00186 <font class="comment">/* TSourceContainer::iterator first(_Sources.begin()), last(_Sources.end());</font>
+00187 <font class="comment"> for (; first != last; ++first)</font>
+00188 <font class="comment"> {</font>
+00189 <font class="comment"> CSimpleSource *psu = *first;</font>
+00190 <font class="comment"> if (psu-&gt;getTrack() == NULL)</font>
+00191 <font class="comment"> {</font>
+00192 <font class="comment"> ++nb;</font>
+00193 <font class="comment"> }</font>
+00194 <font class="comment"> }</font>
+00195 <font class="comment">*/</font>
+00196 <font class="comment">/* hash_set&lt;CSimpleSource*&gt;::const_iterator ips;</font>
+00197 <font class="comment"> for ( ips=_Sources.begin(); ips!=_Sources.end(); ++ips )</font>
+00198 <font class="comment"> {</font>
+00199 <font class="comment"> CSimpleSource *psu = *ips;</font>
+00200 <font class="comment"> if (psu-&gt;getTrack() == NULL)</font>
+00201 <font class="comment"> {</font>
+00202 <font class="comment"> ++nb;</font>
+00203 <font class="comment"> }</font>
+00204 <font class="comment"> }</font>
+00205 <font class="comment">*/</font>
+00206 out &lt;&lt; <font class="stringliteral">"Mixer: \n"</font>;
+00207 out &lt;&lt; <font class="stringliteral">"Playing sources: "</font> &lt;&lt; <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a23">getPlayingSourcesNumber</a>() &lt;&lt; <font class="stringliteral">" \n"</font>;
+00208 out &lt;&lt; <font class="stringliteral">"Available tracks: "</font> &lt;&lt; <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a24">getNumberAvailableTracks</a>() &lt;&lt; <font class="stringliteral">" \n"</font>;
+00209 <font class="comment">// out &lt;&lt; "Muted sources: " &lt;&lt; nb &lt;&lt; " \n";</font>
+00210 <font class="comment">// out &lt;&lt; "Muted sources: " &lt;&lt; max(0, sint(_PlayingSources.size())-sint(_NbTracks)) &lt;&lt; " \n";</font>
+00211 out &lt;&lt; <font class="stringliteral">"Muted sources: "</font> &lt;&lt; max(0, <a class="code" href="memory__common_8h.html#a14">sint</a>(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m1">_PlayingSources</a>)-<a class="code" href="memory__common_8h.html#a14">sint</a>(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>)) &lt;&lt; <font class="stringliteral">" \n"</font>;
+00212 out &lt;&lt; <font class="stringliteral">"Sources waiting for play: "</font> &lt;&lt; <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.size() &lt;&lt; <font class="stringliteral">" \n"</font>;
+00213 out &lt;&lt; <font class="stringliteral">"HighestPri: "</font> &lt;&lt; <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o3">_ReserveUsage</a>[<a class="code" href="namespaceNLSOUND.html#a82a10">HighestPri</a>] &lt;&lt; <font class="stringliteral">" \n"</font>;
+00214 out &lt;&lt; <font class="stringliteral">"HighPri: "</font> &lt;&lt; <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o3">_ReserveUsage</a>[<a class="code" href="namespaceNLSOUND.html#a82a11">HighPri</a>] &lt;&lt; <font class="stringliteral">" \n"</font>;
+00215 out &lt;&lt; <font class="stringliteral">"MidPri: "</font> &lt;&lt; <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o3">_ReserveUsage</a>[<a class="code" href="namespaceNLSOUND.html#a82a12">MidPri</a>] &lt;&lt; <font class="stringliteral">" \n"</font>;
+00216 out &lt;&lt; <font class="stringliteral">"LowPri: "</font> &lt;&lt; <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o3">_ReserveUsage</a>[<a class="code" href="namespaceNLSOUND.html#a82a13">LowPri</a>] &lt;&lt; <font class="stringliteral">" \n"</font>;
+00217 out &lt;&lt; <font class="stringliteral">"Average update time: "</font> &lt;&lt; std::setw(10) &lt;&lt; (1000.0 * <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m7">_UpdateTime</a> / <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m9">_UpdateCount</a>) &lt;&lt; <font class="stringliteral">" msec\n"</font>;
+00218 out &lt;&lt; <font class="stringliteral">"Average create time: "</font> &lt;&lt; std::setw(10) &lt;&lt;(1000.0 * <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m8">_CreateTime</a> / <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m10">_CreateCount</a>) &lt;&lt; <font class="stringliteral">" msec\n"</font>;
+00219 out &lt;&lt; <font class="stringliteral">"Estimated CPU: "</font> &lt;&lt; std::setiosflags(ios::right) &lt;&lt; std::setprecision(6) &lt;&lt; std::setw(10) &lt;&lt; (100.0 * 1000.0 * (<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m7">_UpdateTime</a> + <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m8">_CreateTime</a>) / <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a51">curTime</a>()) &lt;&lt; <font class="stringliteral">"%\n"</font>;
+00220
+00221 <font class="keywordflow">if</font> (_SoundDriver)
+00222 {
+00223 out &lt;&lt; <font class="stringliteral">"\n"</font>;
+00224 out &lt;&lt; <font class="stringliteral">"Driver: \n"</font>;
+00225 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o5">_SoundDriver</a>-&gt;writeProfile(out);
+00226 }
+00227 }
+00228
+00229 <font class="comment">// ******************************************************************</font>
+00230
+<a name="l00231"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a50">00231</a> <font class="keywordtype">void</font> CAudioMixerUser::addSourceWaitingForPlay(CSimpleSource *source)
+00232 {
+00233 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.push_back(source);
+00234 }
+00235
+00236
+00237 <font class="comment">// ******************************************************************</font>
+00238
+<a name="l00239"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a5">00239</a> <font class="keywordtype">void</font> CAudioMixerUser::reset()
+00240 {
+00241 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m5">_Leaving</a> = <font class="keyword">true</font>;
+00242
+00243 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.clear();
+00244
+00245 <font class="comment">// Stop tracks</font>
+00246 uint i;
+00247 <font class="keywordflow">for</font> ( i=0; i!=<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>; i++ )
+00248 {
+00249 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i] )
+00250 {
+00251 CSimpleSource* <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a> = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i]-&gt;getSource();
+00252
+00253 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a> &amp;&amp; <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;isPlaying())
+00254 {
+00255 <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;stop();
+00256 }
+00257 }
+00258 }
+00259
+00260 <font class="comment">// Sources</font>
+00261 <font class="keywordflow">while</font> (!<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.empty())
+00262 {
+00263 <font class="comment">//removeSource( _Sources.begin(), true ); // 3D sources, the envsounds were removed above</font>
+00264 CSourceCommon *source = *(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.begin());
+00265 <font class="keywordflow">if</font> (source-&gt;isPlaying())
+00266 source-&gt;stop();
+00267 <font class="keywordflow">else</font>
+00268 <font class="keyword">delete</font> source;
+00269 }
+00270
+00271 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m5">_Leaving</a> = <font class="keyword">false</font>;
+00272 }
+00273
+00274 <font class="comment">// ******************************************************************</font>
+00275
+<a name="l00276"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a2">00276</a> <font class="keywordtype">void</font> CAudioMixerUser::init( <font class="comment">/*uint32 balance_period */</font>)
+00277 {
+00278 <a class="code" href="debug_8h.html#a0">nldebug</a>( <font class="stringliteral">"AM: Init..."</font> );
+00279
+00280 <a class="code" href="audio__mixer__user_8cpp.html#a1">_profile</a>(( <font class="stringliteral">"AM: ---------------------------------------------------------------"</font> ));
+00281 <a class="code" href="audio__mixer__user_8cpp.html#a1">_profile</a>(( <font class="stringliteral">"AM: DRIVER: %s"</font>, NLSOUND_DLL_NAME ));
+00282
+00283 <font class="comment">// Init sound driver</font>
+00284 <font class="keywordflow">try</font>
+00285 {
+00286 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o5">_SoundDriver</a> = ISoundDriver::createDriver();
+00287 }
+00288 <font class="keywordflow">catch</font>(...)
+00289 {
+00290 <font class="keyword">delete</font> <font class="keyword">this</font>;
+00291 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#r0">_Instance</a> = NULL;
+00292 <font class="keywordflow">throw</font>;
+00293 }
+00294
+00295 uint i;
+00296
+00297
+00298 <font class="comment">// Init registrable classes</font>
+00299 <font class="keyword">static</font> <font class="keywordtype">bool</font> initialized = <font class="keyword">false</font>;
+00300 <font class="keywordflow">if</font> (!initialized)
+00301 {
+00302 <font class="comment">// CSimpleSource::init();</font>
+00303 initialized = <font class="keyword">true</font>;
+00304 }
+00305
+00306 <font class="comment">// Init listener</font>
+00307 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o7">_Listener</a>.init( <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o5">_SoundDriver</a> );
+00308
+00309 <font class="comment">// Init tracks (physical sources)</font>
+00310 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a> = <a class="code" href="namespaceNLSOUND.html#a16">MAX_TRACKS</a>; <font class="comment">// could be chosen by the user, or according to the capabilities of the sound card</font>
+00311 <font class="keywordflow">for</font> ( i=0; i&lt;<a class="code" href="namespaceNLSOUND.html#a16">MAX_TRACKS</a>; i++ )
+00312 {
+00313 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i] = NULL;
+00314 }
+00315 <font class="keywordflow">try</font>
+00316 {
+00317 <font class="keywordflow">for</font> ( i=0; i!=<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>; i++ )
+00318 {
+00319 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i] = <font class="keyword">new</font> CTrack();
+00320 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i]-&gt;init( <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o5">_SoundDriver</a> );
+00321 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.push_back(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i]);
+00322 }
+00323 }
+00324 <font class="keywordflow">catch</font> ( ESoundDriver &amp; )
+00325 {
+00326 <font class="comment">// If the source generation failed, keep only the generated number of sources</font>
+00327 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a> = i;
+00328 <font class="comment">//delete _Tracks[i]; // Bug: the desctructor would not work because the source's name is invalid</font>
+00329 }
+00330
+00331 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m4">_MaxNbTracks</a> = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>;
+00332
+00333 <font class="comment">// Init the reserve stuff.</font>
+00334 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o4">_LowWaterMark</a> = 0;
+00335 <font class="keywordflow">for</font> (i=0; i&lt;<a class="code" href="namespaceNLSOUND.html#a82a14">NbSoundPriorities</a>; ++i)
+00336 {
+00337 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o2">_PriorityReserve</a>[i] = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>;
+00338 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o3">_ReserveUsage</a>[i] = 0;
+00339 }
+00340
+00341 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m6">_StartTime</a> = CTime::getLocalTime();
+00342
+00343 <font class="comment">// Create the background sound manager.</font>
+00344 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a> = <font class="keyword">new</font> CBackgroundSoundManager();
+00345
+00346 <font class="comment">// Load the sound bank singleton</font>
+00347 CSoundBank::instance()-&gt;load();
+00348 <a class="code" href="debug_8h.html#a1">nlinfo</a>( <font class="stringliteral">"Initialized audio mixer with %u voices"</font>, <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a> );
+00349 }
+00350
+00351
+00352 <font class="comment">// ******************************************************************</font>
+<a name="l00353"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a40">00353</a> <font class="keywordtype">void</font> CAudioMixerUser::bufferUnloaded(IBuffer *buffer)
+00354 {
+00355 <font class="comment">// check all track to find a track playing this buffer.</font>
+00356 uint i;
+00357 <font class="keywordflow">for</font> ( i=0; i!=<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>; ++i )
+00358 {
+00359 CTrack *track = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i];
+00360 <font class="keywordflow">if</font> ( track &amp;&amp; track-&gt;getSource())
+00361 {
+00362 <font class="keywordflow">if</font> (track-&gt;getSource()-&gt;getBuffer() == buffer)
+00363 {
+00364 track-&gt;getSource()-&gt;stop();
+00365 }
+00366 }
+00367 }
+00368
+00369 }
+00370
+00371
+00372 <font class="comment">// ******************************************************************</font>
+00373
+<a name="l00374"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a6">00374</a> <font class="keywordtype">void</font> CAudioMixerUser::enable( <font class="keywordtype">bool</font> b )
+00375 {
+00376 <font class="comment">// TODO : rewrite this method</font>
+00377
+00378 <a class="code" href="debug_8h.html#a6">nlassert</a>(<font class="keyword">false</font>);
+00379 <font class="comment">/* if ( b )</font>
+00380 <font class="comment"> {</font>
+00381 <font class="comment"> // Reenable</font>
+00382 <font class="comment"> _NbTracks = _MaxNbTracks;</font>
+00383 <font class="comment"> }</font>
+00384 <font class="comment"> else</font>
+00385 <font class="comment"> {</font>
+00386 <font class="comment"> // Disable</font>
+00387 <font class="comment"> uint i;</font>
+00388 <font class="comment"> for ( i=0; i!=_NbTracks; i++ )</font>
+00389 <font class="comment"> {</font>
+00390 <font class="comment"> if ( _Tracks[i] &amp;&amp; ! _Tracks[i]-&gt;isAvailable() )</font>
+00391 <font class="comment"> {</font>
+00392 <font class="comment"> _Tracks[i]-&gt;getSource()-&gt;leaveTrack();</font>
+00393 <font class="comment">// nlassert(_PlayingSources.find(_Tracks[i]-&gt;getSource()) != _PlayingSources.end());</font>
+00394 <font class="comment">// _PlayingSources.erase(_Tracks[i]-&gt;getSource());</font>
+00395 <font class="comment"> }</font>
+00396 <font class="comment"> }</font>
+00397 <font class="comment"> _NbTracks = 0;</font>
+00398 <font class="comment"> }</font>
+00399 <font class="comment">*/</font>
+00400 }
+00401
+00402 <font class="comment">// ******************************************************************</font>
+00403
+<a name="l00404"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a37">00404</a> ISoundDriver* CAudioMixerUser::getSoundDriver()
+00405 {
+00406 <font class="keywordflow">return</font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o5">_SoundDriver</a>;
+00407 }
+00408
+00409 <font class="comment">// ******************************************************************</font>
+00410
+00411 <font class="comment">/*void CAudioMixerUser::computeEnvEffect( const CVector&amp; listenerpos, bool force )</font>
+00412 <font class="comment">{</font>
+00413 <font class="comment"> // Find the first matching, linear search</font>
+00414 <font class="comment"> vector&lt;CEnvEffect*&gt;::iterator ipe;</font>
+00415 <font class="comment"> for ( ipe=_EnvEffects.begin(); ipe!=_EnvEffects.end(); ++ipe )</font>
+00416 <font class="comment"> {</font>
+00417 <font class="comment"> if ( (*ipe)-&gt;include( listenerpos ) )</font>
+00418 <font class="comment"> {</font>
+00419 <font class="comment"> // Set the effect only if it has changed</font>
+00420 <font class="comment"> if ( (_CurEnvEffect != *ipe) || force )</font>
+00421 <font class="comment"> {</font>
+00422 <font class="comment"> _CurEnvEffect = *ipe;</font>
+00423 <font class="comment"> _Listener.getListener()-&gt;setEnvironment( _CurEnvEffect-&gt;getEnvNum(), _CurEnvEffect-&gt;getEnvSize() );</font>
+00424 <font class="comment"> nldebug( "AM: Listener environmental effect changed to %u", _CurEnvEffect-&gt;getEnvNum() );</font>
+00425 <font class="comment"> }</font>
+00426 <font class="comment"> return;</font>
+00427 <font class="comment"> }</font>
+00428 <font class="comment"> }</font>
+00429 <font class="comment"></font>
+00430 <font class="comment"> // If not found, set the default (only if it wasn't the default before)</font>
+00431 <font class="comment"> if ( _CurEnvEffect != NULL )</font>
+00432 <font class="comment"> {</font>
+00433 <font class="comment"> _Listener.getListener()-&gt;setEnvironment( ENVFX_DEFAULT_NUM );</font>
+00434 <font class="comment"> _CurEnvEffect = NULL;</font>
+00435 <font class="comment"> nldebug( "AM: Listener environmental effect reset" );</font>
+00436 <font class="comment"> }</font>
+00437 <font class="comment"></font>
+00438 <font class="comment">}</font>
+00439 <font class="comment">*/</font>
+00440
+00441
+00442 <font class="comment">// ******************************************************************</font>
+00443
+<a name="l00444"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#b0">00444</a> <font class="keywordtype">void</font> CAudioMixerUser::getFreeTracks( uint nb, CTrack **tracks )
+00445 {
+00446 std::vector&lt;CTrack*&gt;::iterator first(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.begin()), last(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.end());
+00447 <font class="keywordflow">for</font> (nb =0; first != last; ++first, ++nb)
+00448 {
+00449 tracks[nb] = *first;
+00450 }
+00451 }
+00452
+00453
+00454 <font class="comment">// ******************************************************************</font>
+00455
+<a name="l00456"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a26">00456</a> <font class="keywordtype">void</font> CAudioMixerUser::applyListenerMove( <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>&amp; listenerpos )
+00457 {
+00458 <font class="comment">// Store position</font>
+00459 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o8">_ListenPosition</a> = listenerpos;
+00460
+00461 <font class="comment">// Environmental effect</font>
+00462 <font class="comment">// computeEnvEffect( listenerpos );</font>
+00463
+00464 <font class="comment">/* // Environment sounds</font>
+00465 <font class="comment"> if ( _EnvSounds != NULL )</font>
+00466 <font class="comment"> {</font>
+00467 <font class="comment"> _EnvSounds-&gt;recompute();</font>
+00468 <font class="comment"> }</font>
+00469 <font class="comment">*/</font>
+00470 }
+00471
+00472 <font class="comment">// ******************************************************************</font>
+00473
+<a name="l00474"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a9">00474</a> <font class="keywordtype">void</font> CAudioMixerUser::reloadSampleBanks(<font class="keywordtype">bool</font> async)
+00475 {
+00476 CSampleBank::reload(async);
+00477 }
+00478
+00479 <font class="comment">// ******************************************************************</font>
+00480
+<a name="l00481"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a42">00481</a> CTrack *CAudioMixerUser::getFreeTrack(CSimpleSource *source)
+00482 {
+00483 <font class="comment">// at least some track free ?</font>
+00484 <font class="keywordflow">if</font> (!<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.empty())
+00485 {
+00486 <font class="comment">// under the low water mark or under the reserve</font>
+00487 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.size() &gt; <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o4">_LowWaterMark</a>
+00488 || <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o3">_ReserveUsage</a>[source-&gt;getPriority()] &lt; <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o2">_PriorityReserve</a>[source-&gt;getPriority()] )
+00489 {
+00490 <font class="comment">// non discardable track or not too many waiting source</font>
+00491 <font class="keywordflow">if</font> (source-&gt;getPriority() == <a class="code" href="namespaceNLSOUND.html#a82a10">HighestPri</a>
+00492 || <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.size() &gt; <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.size())
+00493 {
+00494 CTrack *ret = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.back();
+00495 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.pop_back();
+00496 ret-&gt;setSource(source);
+00497 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o3">_ReserveUsage</a>[source-&gt;getPriority()]++;
+00498 <font class="comment">// nldebug("Track %p assign to source %p", ret, ret-&gt;getSource());</font>
+00499 <font class="keywordflow">return</font> ret;
+00500 }
+00501 }
+00502 }
+00503 <font class="comment">// try to find a track with a source cuttable</font>
+00504 {
+00505 <font class="keywordtype">float</font> d1, d2, t1, t2;
+00506 d1 = (source-&gt;getPos() - <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o8">_ListenPosition</a>).norm();
+00507 t1 = max(0.0f, 1-((d1-source-&gt;getSimpleSound()-&gt;getMinDistance()) / (source-&gt;getSimpleSound()-&gt;getMaxDistance() - source-&gt;getSimpleSound()-&gt;getMinDistance())));
+00508
+00509 <font class="keywordflow">for</font> (uint i=0; i&lt;<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>; ++i)
+00510 {
+00511 CSimpleSource *src2 = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i]-&gt;getSource();
+00512 <font class="keywordflow">if</font> (src2 != 0)
+00513 {
+00514 d2 = (src2-&gt;getPos() - <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o8">_ListenPosition</a>).norm();
+00515 t2 = max(0.0f, 1-((d2-src2-&gt;getSimpleSound()-&gt;getMinDistance()) / (src2-&gt;getSimpleSound()-&gt;getMaxDistance() - src2-&gt;getSimpleSound()-&gt;getMinDistance())));
+00516
+00517 <font class="keyword">const</font> <font class="keywordtype">float</font> tfactor = 1.3f;
+00518 <font class="keywordflow">if</font> (t1 &gt; t2 * tfactor)
+00519 <font class="comment">// if (d1 &lt; d2)</font>
+00520 {
+00521 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Cutting source %p with source %p (%f &gt; %f*%f)"</font>, src2, source, t1, tfactor, t2);
+00522 <font class="comment">// on peut cuter cette voie !</font>
+00523 src2-&gt;stop();
+00524 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.empty())
+00525 {
+00526 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"No free track after cutting a playing sound source !"</font>);
+00527 }
+00528 <font class="keywordflow">else</font>
+00529 {
+00530 CTrack *ret = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.back();
+00531 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.pop_back();
+00532 ret-&gt;setSource(source);
+00533 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Track %p assign to source %p"</font>, ret, ret-&gt;getSource());
+00534 <font class="keywordflow">return</font> ret;
+00535 }
+00536 }
+00537 }
+00538 }
+00539 }
+00540
+00541 <font class="keywordflow">return</font> 0;
+00542 }
+00543
+<a name="l00544"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a43">00544</a> <font class="keywordtype">void</font> CAudioMixerUser::freeTrack(CTrack *track)
+00545 {
+00546 <a class="code" href="debug_8h.html#a6">nlassert</a>(track != 0);
+00547 <a class="code" href="debug_8h.html#a6">nlassert</a>(track-&gt;getSource() != 0);
+00548
+00549 <font class="comment">// nldebug("Track %p free by source %p", track, track-&gt;getSource());</font>
+00550
+00551 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o3">_ReserveUsage</a>[track-&gt;getSource()-&gt;getPriority()]--;
+00552 track-&gt;setSource(0);
+00553 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.push_back(track);
+00554 }
+00555
+00556
+<a name="l00557"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#b1">00557</a> <font class="keywordtype">void</font> CAudioMixerUser::getPlayingSoundsPos(std::vector&lt;std::pair&lt;bool, NLMISC::CVector&gt; &gt; &amp;pos)
+00558 {
+00559 <font class="keywordtype">int</font> nbplay = 0;
+00560 <font class="keywordtype">int</font> nbmute = 0;
+00561 <font class="keywordtype">int</font> nbsrc = 0;
+00562
+00563 TSourceContainer::iterator first(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.begin()), last(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.end());
+00564 <font class="keywordflow">for</font> (; first != last; ++first)
+00565 {
+00566 CSourceCommon *ps = *first;
+00567 <font class="keywordflow">if</font> (ps-&gt;getType() == CSourceCommon::SOURCE_SIMPLE)
+00568 {
+00569 CSimpleSource *source = static_cast&lt;CSimpleSource*&gt;(*first);
+00570 nbsrc++;
+00571
+00572 <font class="keywordflow">if</font> (source-&gt;isPlaying())
+00573 {
+00574 pos.push_back(make_pair(source-&gt;getTrack() == 0, source-&gt;getPos()));
+00575
+00576 <font class="keywordflow">if</font> (source-&gt;getTrack() == 0)
+00577 nbmute++;
+00578 <font class="keywordflow">else</font>
+00579 {
+00580 <font class="comment">// nldebug ("Source %p playing on track %p", source, source-&gt;getTrack());</font>
+00581 nbplay ++;
+00582 }
+00583 }
+00584 }
+00585 }
+00586
+00587 <font class="comment">// nldebug("Total source : %d, playing : %d, muted : %d", nbsrc, nbplay, nbmute);</font>
+00588 }
+00589
+00590
+00591
+<a name="l00592"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a19">00592</a> <font class="keywordtype">void</font> CAudioMixerUser::update()
+00593 {
+00594 <font class="preprocessor">#if NL_PROFILE_MIXER</font>
+00595 <font class="preprocessor"></font> <a class="code" href="namespaceNLMISC.html#a184">TTicks</a> start = CTime::getPerformanceTime();
+00596 <font class="preprocessor">#endif</font>
+00597 <font class="preprocessor"></font>
+00598 <font class="comment">// update the object.</font>
+00599 {
+00600 <font class="comment">// 1st, update the event list</font>
+00601 {
+00602 std::vector&lt;std::pair&lt;IMixerUpdate*, bool&gt; &gt;::iterator first(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n1">_UpdateEventList</a>.begin()), last(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n1">_UpdateEventList</a>.end());
+00603 <font class="keywordflow">for</font> (; first != last; ++first)
+00604 {
+00605 <font class="keywordflow">if</font> (first-&gt;second)
+00606 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n0">_UpdateList</a>.insert(first-&gt;first);
+00607 <font class="keywordflow">else</font>
+00608 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n0">_UpdateList</a>.erase(first-&gt;first);
+00609 }
+00610 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n1">_UpdateEventList</a>.clear();
+00611 }
+00612 <font class="comment">// 2nd, do the update</font>
+00613 {
+00614 TMixerUpdateContainer::iterator first(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n0">_UpdateList</a>.begin()), last(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n0">_UpdateList</a>.end());
+00615 <font class="keywordflow">for</font> (; first != last; ++first)
+00616 {
+00617 <font class="comment">// call the update method.</font>
+00618 const_cast&lt;IMixerUpdate*&gt;(*first)-&gt;onUpdate();
+00619 }
+00620 }
+00621 }
+00622 <font class="comment">// send the event.</font>
+00623 {
+00624 <font class="comment">// 1st, update the event list</font>
+00625 {
+00626 std::vector&lt;std::pair&lt;NLMISC::TTime, IMixerEvent*&gt; &gt;::iterator first(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n4">_EventListUpdate</a>.begin()), last(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n4">_EventListUpdate</a>.end());
+00627 <font class="keywordflow">for</font> (; first != last; ++first)
+00628 {
+00629 <font class="keywordflow">if</font> (first-&gt;first != 0)
+00630 {
+00631 <font class="comment">// add an event</font>
+00632 <font class="comment">// nldebug ("Add event %p", first-&gt;second);</font>
+00633 TTimedEventContainer::iterator it(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.insert(*first));
+00634 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n3">_Events</a>.insert(make_pair(first-&gt;second, it));
+00635 }
+00636 <font class="keywordflow">else</font>
+00637 {
+00638 <font class="comment">// remove the events</font>
+00639 pair&lt;TEventContainer::iterator, TEventContainer::iterator&gt; <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a> = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n3">_Events</a>.equal_range(first-&gt;second);
+00640 TEventContainer::iterator first2(<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.first), last2(<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.second);
+00641 <font class="keywordflow">for</font> (; first2 != last2; ++first2)
+00642 {
+00643 <font class="comment">// remove the event</font>
+00644 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Remove event %p"</font>, first2-&gt;second-&gt;second);
+00645 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.erase(first2-&gt;second);
+00646 }
+00647 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n3">_Events</a>.erase(<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.first, <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.second);
+00648 }
+00649 }
+00650
+00651 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n4">_EventListUpdate</a>.clear();
+00652 }
+00653 <font class="comment">// 2nd, call the events</font>
+00654 <a class="code" href="namespaceNLMISC.html#a183">TTime</a> now = <a class="code" href="classNLMISC_1_1CTime.html#d1">NLMISC::CTime::getLocalTime</a>();
+00655 <font class="keywordflow">while</font> (!<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.empty() &amp;&amp; <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.begin()-&gt;first &lt;= now)
+00656 {
+00657 <font class="preprocessor">#ifdef _DEBUG</font>
+00658 <font class="preprocessor"></font> CurrentEvent = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.begin()-&gt;second;
+00659 <font class="preprocessor">#endif</font>
+00660 <font class="preprocessor"></font><font class="comment">// nldebug("Sending Event %p", _EventList.begin()-&gt;second);</font>
+00661 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.begin()-&gt;second-&gt;onEvent();
+00662 TEventContainer::iterator it(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n3">_Events</a>.lower_bound(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.begin()-&gt;second));
+00663 <font class="keywordflow">while</font> (it-&gt;first == <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.begin()-&gt;second)
+00664 {
+00665 <font class="keywordflow">if</font> (it-&gt;second == <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.begin())
+00666 {
+00667 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n3">_Events</a>.erase(it);
+00668 <font class="keywordflow">break</font>;
+00669 }
+00670 it++;
+00671 }
+00672 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.erase(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.begin());
+00673 <font class="preprocessor">#ifdef _DEBUG</font>
+00674 <font class="preprocessor"></font> CurrentEvent = 0;
+00675 <font class="preprocessor">#endif</font>
+00676 <font class="preprocessor"></font> }
+00677 }
+00678
+00679 <font class="comment">// update the background sound</font>
+00680 <font class="comment">// _BackgroundSoundManager-&gt;update();</font>
+00681
+00682 <font class="comment">// Check all playing track and stop any terminated buffer.</font>
+00683 <font class="keywordflow">for</font> (uint i=0; i&lt;<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>; ++i)
+00684 {
+00685 <font class="keywordflow">if</font> (!<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i]-&gt;isPlaying())
+00686 {
+00687 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i]-&gt;getSource() != 0)
+00688 {
+00689 CSimpleSource *source = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i]-&gt;getSource();
+00690 source-&gt;stop();
+00691 }
+00692
+00693 <font class="comment">// try to play any waiting source.</font>
+00694 <font class="keywordflow">if</font> (!<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.empty())
+00695 {
+00696 <font class="comment">// check if the source still exist before trying to play it</font>
+00697 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.find(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.front()) != <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.end())
+00698 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.front()-&gt;play();
+00699 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Before POP Sources waiting : %u"</font>, <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.size());
+00700 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.pop_front();
+00701 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"After POP Sources waiting : %u"</font>, <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.size());
+00702 }
+00703 }
+00704 }
+00705
+00706 <font class="comment">// Debug info</font>
+00707 <font class="comment">/*uint32 i;</font>
+00708 <font class="comment"> nldebug( "List of the %u tracks", _NbTracks );</font>
+00709 <font class="comment"> for ( i=0; i!=_NbTracks; i++ )</font>
+00710 <font class="comment"> {</font>
+00711 <font class="comment"> CSimpleSource *su;</font>
+00712 <font class="comment"> if ( su = _Tracks[i]-&gt;getSource() )</font>
+00713 <font class="comment"> {</font>
+00714 <font class="comment"> nldebug( "%u: %p %s %s %s %s, vol %u",</font>
+00715 <font class="comment"> i, &amp;_Tracks[i]-&gt;DrvSource, _Tracks[i]-&gt;isAvailable()?"FREE":"USED",</font>
+00716 <font class="comment"> _Tracks[i]-&gt;isAvailable()?"":(su-&gt;isPlaying()?"PLAYING":"STOPPED"),</font>
+00717 <font class="comment"> _Tracks[i]-&gt;isAvailable()?"":PriToCStr[su-&gt;getPriority()],</font>
+00718 <font class="comment"> _Tracks[i]-&gt;isAvailable()?"":(su-&gt;getSound()?su-&gt;getSound()-&gt;getFilename().c_str():""),</font>
+00719 <font class="comment"> (uint)(su-&gt;getGain()*100.0f) );</font>
+00720 <font class="comment"> }</font>
+00721 <font class="comment"> }*/</font>
+00722
+00723 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o5">_SoundDriver</a>-&gt;commit3DChanges();
+00724
+00725 <font class="preprocessor">#if NL_PROFILE_MIXER</font>
+00726 <font class="preprocessor"></font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m7">_UpdateTime</a> = CTime::ticksToSecond(CTime::getPerformanceTime() - start);
+00727 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m9">_UpdateCount</a>++;
+00728 <font class="preprocessor">#endif</font>
+00729 <font class="preprocessor"></font>
+00730 <font class="comment">/* // display the track using...</font>
+00731 <font class="comment"> {</font>
+00732 <font class="comment"> char tmp[2048] = "";</font>
+00733 <font class="comment"> string str;</font>
+00734 <font class="comment"></font>
+00735 <font class="comment"> for (uint i=0; i&lt;_NbTracks/2; ++i)</font>
+00736 <font class="comment"> {</font>
+00737 <font class="comment"> sprintf(tmp, "[%2u]%8p ", i, _Tracks[i]-&gt;getSource());</font>
+00738 <font class="comment"> str += tmp;</font>
+00739 <font class="comment"> }</font>
+00740 <font class="comment"> nldebug((string("Status1: ")+str).c_str());</font>
+00741 <font class="comment"> str = "";</font>
+00742 <font class="comment"> for (i=_NbTracks/2; i&lt;_NbTracks; ++i)</font>
+00743 <font class="comment"> {</font>
+00744 <font class="comment"> sprintf(tmp, "[%2u]%8p ", i, _Tracks[i]-&gt;getSource());</font>
+00745 <font class="comment"> str += tmp;</font>
+00746 <font class="comment"> }</font>
+00747 <font class="comment">// nldebug((string("Status2: ")+str).c_str());</font>
+00748 <font class="comment"> }</font>
+00749 <font class="comment">*/</font>
+00750 }
+00751
+00752
+00753 <font class="comment">// ******************************************************************</font>
+00754
+<a name="l00755"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a11">00755</a> <a class="code" href="namespaceNLSOUND.html#a8">TSoundId</a> CAudioMixerUser::getSoundId( <font class="keyword">const</font> std::string &amp;name )
+00756 {
+00757 <font class="keywordflow">return</font> CSoundBank::instance()-&gt;getSound(name);
+00758 }
+00759
+00760 <font class="comment">// ******************************************************************</font>
+00761
+<a name="l00762"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a14">00762</a> <font class="keywordtype">void</font> CAudioMixerUser::addSource( CSourceCommon *source )
+00763 {
+00764 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.find(source) == <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.end());
+00765 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.insert( source );
+00766
+00767 <font class="comment">// _profile(( "AM: ADDSOURCE, SOUND: %d, TRACK: %p, NAME=%s", source-&gt;getSound(), source-&gt;getTrack(),</font>
+00768 <font class="comment">// source-&gt;getSound() &amp;&amp; (source-&gt;getSound()-&gt;getName()!="") ? source-&gt;getSound()-&gt;getName().c_str() : "" ));</font>
+00769
+00770 }
+00771
+00772
+00773 <font class="comment">// ******************************************************************</font>
+00774
+<a name="l00775"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a13">00775</a> USource *CAudioMixerUser::createSource( <a class="code" href="namespaceNLSOUND.html#a8">TSoundId</a> <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>, <font class="keywordtype">bool</font> spawn, <a class="code" href="namespaceNLSOUND.html#a9">TSpawnEndCallback</a> cb, <font class="keywordtype">void</font> *userParam, CSoundContext *context )
+00776 {
+00777 <font class="preprocessor">#if NL_PROFILE_MIXER</font>
+00778 <font class="preprocessor"></font> <a class="code" href="namespaceNLMISC.html#a184">TTicks</a> start = CTime::getPerformanceTime();
+00779 <font class="preprocessor">#endif</font>
+00780 <font class="preprocessor"></font>
+00781 <a class="code" href="audio__mixer__user_8cpp.html#a1">_profile</a>(( <font class="stringliteral">"AM: [%u]---------------------------------------------------------------"</font>, <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a51">curTime</a>() ));
+00782 <a class="code" href="audio__mixer__user_8cpp.html#a1">_profile</a>(( <font class="stringliteral">"AM: CREATESOURCE: SOUND=%p, NAME=%s, TIME=%d"</font>, <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>-&gt;getName().c_str(), <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a51">curTime</a>() ));
+00783 <a class="code" href="audio__mixer__user_8cpp.html#a1">_profile</a>(( <font class="stringliteral">"AM: SOURCES: %d, PLAYING: %d, TRACKS: %d"</font>, <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a22">getSourcesNumber</a>(), <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a23">getPlayingSourcesNumber</a>(), <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a24">getNumberAvailableTracks</a>() ));
+00784
+00785 <font class="keywordflow">if</font> ( <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a> == NULL )
+00786 {
+00787 <a class="code" href="audio__mixer__user_8cpp.html#a1">_profile</a>((<font class="stringliteral">"AM: FAILED CREATESOURCE"</font>));
+00788 <a class="code" href="debug_8h.html#a0">nldebug</a>( <font class="stringliteral">"AM: Sound not created: invalid sound id"</font> );
+00789 <font class="keywordflow">return</font> NULL;
+00790 }
+00791
+00792 USource *ret = NULL;
+00793
+00794 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>-&gt;getSoundType() == CSound::SOUND_SIMPLE)
+00795 {
+00796 CSimpleSound *simpleSound = static_cast&lt;CSimpleSound *&gt;(id);
+00797 <font class="comment">// This is a simple sound</font>
+00798 <font class="keywordflow">if</font> (simpleSound-&gt;getBuffer() == NULL)
+00799 {
+00800 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"Can't create the sound '%s'"</font>, simpleSound-&gt;getBuffername().c_str());
+00801 <font class="keywordflow">return</font> NULL;
+00802 }
+00803
+00804 <font class="comment">// Create source</font>
+00805 CSimpleSource *source = <font class="keyword">new</font> CSimpleSource( simpleSound, spawn, cb, userParam);
+00806
+00807 <font class="comment">// nldebug("Mixer : source %p created", source);</font>
+00808
+00809 <font class="keywordflow">if</font> (source-&gt;getBuffer() != 0)
+00810 {
+00811 <font class="comment">// Link the position to the listener position if it'a stereo source</font>
+00812 <font class="keywordflow">if</font> ( source-&gt;getBuffer()-&gt;isStereo() )
+00813 {
+00814 source-&gt;set3DPositionVector( &amp;<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o8">_ListenPosition</a> );
+00815 }
+00816 }
+00817 <font class="keywordflow">else</font>
+00818 {
+00819 <a class="code" href="debug_8h.html#a6">nlassert</a>(<font class="keyword">false</font>); <font class="comment">// FIXME</font>
+00820 }
+00821 ret = source;
+00822 }
+00823 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>-&gt;getSoundType() == CSound::SOUND_COMPLEX)
+00824 {
+00825 CComplexSound *complexSound = static_cast&lt;CComplexSound*&gt;(id);
+00826 <font class="comment">// This is a pattern sound.</font>
+00827 ret = <font class="keyword">new</font> CComplexSource(complexSound, spawn, cb, userParam);
+00828 }
+00829 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>-&gt;getSoundType() == CSound::SOUND_BACKGROUND)
+00830 {
+00831 <font class="comment">// This is a background sound.</font>
+00832 CBackgroundSound *bgSound = static_cast&lt;CBackgroundSound *&gt;(id);
+00833 ret = <font class="keyword">new</font> CBackgroundSource(bgSound, spawn, cb, userParam);
+00834 }
+00835 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>-&gt;getSoundType() == CSound::SOUND_CONTEXT)
+00836 {
+00837 <font class="comment">// This is a context sound.</font>
+00838 <font class="keywordflow">if</font> (context != 0)
+00839 {
+00840 CContextSound *ctxSound = static_cast&lt;CContextSound *&gt;(id);
+00841 <font class="comment">// nlassert(context != 0);</font>
+00842 CSound *sound = ctxSound-&gt;getContextSound(*context);
+00843 <font class="keywordflow">if</font> (sound != 0)
+00844 {
+00845 ret = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a12">createSource</a>(sound, spawn, cb, userParam);
+00846 <font class="comment">// Set the volume of the source according to the context volume</font>
+00847 <font class="keywordflow">if</font> (ret != 0)
+00848 ret-&gt;setGain(ret-&gt;getGain() * ctxSound-&gt;getGain());
+00849 }
+00850 <font class="keywordflow">else</font>
+00851 ret = 0;
+00852 }
+00853 <font class="keywordflow">else</font>
+00854 ret = 0;
+00855 }
+00856 <font class="keywordflow">else</font>
+00857 {
+00858 <font class="comment">// nlassertex(false, ("Unknown sound class !"));</font>
+00859 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"Unknow sound class : %u"</font>, <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>-&gt;getSoundType());
+00860 }
+00861
+00862 <font class="preprocessor">#if NL_PROFILE_MIXER</font>
+00863 <font class="preprocessor"></font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m8">_CreateTime</a> = CTime::ticksToSecond(CTime::getPerformanceTime() - start);
+00864 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m10">_CreateCount</a>++;
+00865 <font class="preprocessor">#endif</font>
+00866 <font class="preprocessor"></font>
+00867 <font class="comment">//nldebug( "AM: Source created" ); </font>
+00868 <font class="keywordflow">return</font> ret;
+00869 }
+00870
+00871
+00872 <font class="comment">// ******************************************************************</font>
+00873
+<a name="l00874"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a12">00874</a> USource *CAudioMixerUser::createSource( <font class="keyword">const</font> std::string &amp;name, <font class="keywordtype">bool</font> spawn, <a class="code" href="namespaceNLSOUND.html#a9">TSpawnEndCallback</a> cb, <font class="keywordtype">void</font> *userParam, CSoundContext *context)
+00875 {
+00876 <font class="keywordflow">return</font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a12">createSource</a>( <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a11">getSoundId</a>( name ), spawn, cb, userParam, context );
+00877 }
+00878
+00879
+00880 <font class="comment">// ******************************************************************</font>
+00881
+<a name="l00882"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a15">00882</a> <font class="keywordtype">void</font> CAudioMixerUser::removeSource( CSourceCommon *source )
+00883 {
+00884 <a class="code" href="debug_8h.html#a6">nlassert</a>( source != NULL );
+00885
+00886 size_t n = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.erase(source);
+00887 <a class="code" href="debug_8h.html#a6">nlassert</a>(n == 1);
+00888 }
+00889
+00890
+00891 <font class="comment">// ******************************************************************</font>
+00892
+<a name="l00893"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a18">00893</a> <font class="keywordtype">void</font> CAudioMixerUser::selectEnvEffects( <font class="keyword">const</font> std::string &amp;tag )
+00894 {
+00895 <a class="code" href="debug_8h.html#a8">nlassertex</a>(<font class="keyword">false</font>, (<font class="stringliteral">"Not implemented yet"</font>));
+00896 <font class="comment">/* // Select Env</font>
+00897 <font class="comment"> vector&lt;CEnvEffect*&gt;::iterator ipe;</font>
+00898 <font class="comment"> for ( ipe=_EnvEffects.begin(); ipe!=_EnvEffects.end(); ++ipe )</font>
+00899 <font class="comment"> {</font>
+00900 <font class="comment"> (*ipe)-&gt;selectEnv( tag );</font>
+00901 <font class="comment"> }</font>
+00902 <font class="comment"></font>
+00903 <font class="comment"> // Compute</font>
+00904 <font class="comment"> CVector pos;</font>
+00905 <font class="comment"> _Listener.getPos( pos );</font>
+00906 <font class="comment"> computeEnvEffect( pos, true );</font>
+00907 <font class="comment">*/</font>
+00908 }
+00909
+00910
+00911 <font class="comment">// ******************************************************************</font>
+00912
+00913 <font class="comment">/*</font>
+00914 <font class="comment">void CAudioMixerUser::loadEnvEffects( const char *filename )</font>
+00915 <font class="comment">{</font>
+00916 <font class="comment"> nlassert( filename != NULL );</font>
+00917 <font class="comment"> nlinfo( "Loading environmental effects from %s...", filename );</font>
+00918 <font class="comment"></font>
+00919 <font class="comment"> // Unload previous env effects</font>
+00920 <font class="comment"> vector&lt;CEnvEffect*&gt;::iterator ipe;</font>
+00921 <font class="comment"> for ( ipe=_EnvEffects.begin(); ipe!=_EnvEffects.end(); ++ipe )</font>
+00922 <font class="comment"> {</font>
+00923 <font class="comment"> delete (*ipe);</font>
+00924 <font class="comment"> }</font>
+00925 <font class="comment"> _EnvEffects.clear();</font>
+00926 <font class="comment"></font>
+00927 <font class="comment"> string str = CPath::lookup( filename, false );</font>
+00928 <font class="comment"></font>
+00929 <font class="comment"> // Load env effects</font>
+00930 <font class="comment"> CIFile file;</font>
+00931 <font class="comment"> if ( !str.empty() &amp;&amp; file.open(str) )</font>
+00932 <font class="comment"> {</font>
+00933 <font class="comment"> uint32 n = CEnvEffect::load( _EnvEffects, file );</font>
+00934 <font class="comment"> nldebug( "AM: Loaded %u environmental effects", n );</font>
+00935 <font class="comment"> }</font>
+00936 <font class="comment"> else</font>
+00937 <font class="comment"> {</font>
+00938 <font class="comment"> nlwarning( "AM: Environmental effects file not found" );</font>
+00939 <font class="comment"> }</font>
+00940 <font class="comment">}</font>
+00941 <font class="comment">*/</font>
+00942
+00943 <font class="comment">// ******************************************************************</font>
+00944
+<a name="l00945"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a7">00945</a> uint32 CAudioMixerUser::loadSampleBank(<font class="keywordtype">bool</font> async, <font class="keyword">const</font> std::string &amp;filename, std::vector&lt;std::string&gt; *notfoundfiles )
+00946 {
+00947 <font class="comment">// nlassert( filename != NULL );</font>
+00948
+00949 string path = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o9">_SamplePath</a>;
+00950 path.append(<font class="stringliteral">"/"</font>).append(filename);
+00951
+00952 <a class="code" href="debug_8h.html#a0">nldebug</a>( <font class="stringliteral">"Loading samples from %s..."</font>, path.c_str() );
+00953
+00954 CSampleBank* bank = CSampleBank::findSampleBank(path);
+00955 <font class="keywordflow">if</font> (bank == NULL)
+00956 {
+00957 <font class="comment">// create a new sample bank</font>
+00958 <font class="comment">//_CrtCheckMemory();</font>
+00959 bank = <font class="keyword">new</font> CSampleBank(path, <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o5">_SoundDriver</a>);
+00960 <font class="comment">//_CrtCheckMemory();</font>
+00961 }
+00962
+00963 <font class="keywordflow">try</font>
+00964 {
+00965 bank-&gt;load(async);
+00966 }
+00967 <font class="keywordflow">catch</font> (Exception&amp; e)
+00968 {
+00969 <font class="keywordflow">if</font> (notfoundfiles) {
+00970 notfoundfiles-&gt;push_back(path);
+00971 }
+00972 string reason = e.what();
+00973 <a class="code" href="debug_8h.html#a2">nlwarning</a>( <font class="stringliteral">"AM: Failed to load the samples: %s"</font>, reason.c_str() );
+00974 }
+00975
+00976
+00977 <font class="keywordflow">return</font> bank-&gt;countSamples();
+00978 }
+00979
+<a name="l00980"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a8">00980</a> <font class="keywordtype">bool</font> CAudioMixerUser::unloadSampleBank( <font class="keyword">const</font> std::string &amp;filename)
+00981 {
+00982 string path = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o9">_SamplePath</a>;
+00983 path.append(<font class="stringliteral">"/"</font>).append(filename);
+00984
+00985 <a class="code" href="debug_8h.html#a0">nldebug</a>( <font class="stringliteral">"Unloading samples from %s..."</font>, path.c_str() );
+00986 CSampleBank *pbank = CSampleBank::findSampleBank(path);
+00987
+00988 <font class="keywordflow">if</font> (pbank != NULL)
+00989 {
+00990 <font class="comment">// ok, the bank exist.</font>
+00991 <font class="keywordflow">return</font> pbank-&gt;unload();
+00992 }
+00993 <font class="keywordflow">else</font>
+00994 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00995
+00996 }
+00997
+00998 <font class="comment">// ******************************************************************</font>
+00999
+<a name="l01000"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a20">01000</a> <font class="keywordtype">void</font> CAudioMixerUser::getSoundNames( std::vector&lt;std::string&gt;&amp; names )<font class="keyword"> const</font>
+01001 <font class="keyword"></font>{
+01002 CSoundBank::instance()-&gt;getNames(names);
+01003 }
+01004
+01005
+01006 <font class="comment">// ******************************************************************</font>
+01007
+<a name="l01008"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a23">01008</a> uint CAudioMixerUser::getPlayingSourcesNumber()<font class="keyword"> const</font>
+01009 <font class="keyword"></font>{
+01010 <font class="keywordflow">return</font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m1">_PlayingSources</a>;
+01011 }
+01012
+01013 <font class="comment">// ******************************************************************</font>
+01014
+<a name="l01015"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a24">01015</a> uint CAudioMixerUser::getNumberAvailableTracks()<font class="keyword"> const</font>
+01016 <font class="keyword"></font>{
+01017 <font class="keywordflow">return</font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.size();
+01018 }
+01019
+01020
+01021 <font class="comment">// ******************************************************************</font>
+01022
+<a name="l01023"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a25">01023</a> string CAudioMixerUser::getSourcesStats()<font class="keyword"> const</font>
+01024 <font class="keyword"></font>{
+01025 <font class="comment">// TODO : rewrite log output</font>
+01026
+01027 string <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
+01028 TSourceContainer::iterator ips;
+01029 <font class="keywordflow">for</font> ( ips=<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.begin(); ips!=<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.end(); ++ips )
+01030 {
+01031 <font class="keywordflow">if</font> ( (*ips)-&gt;isPlaying() )
+01032 {
+01033 <font class="comment">// char line [80];</font>
+01034
+01035 <font class="comment">/* nlassert( (*ips)-&gt;getSound() &amp;&amp; (*ips)-&gt;getSimpleSound()-&gt;getBuffer() );</font>
+01036 <font class="comment"> smprintf( line, 80, "%s: %u%% %s %s",</font>
+01037 <font class="comment"> (*ips)-&gt;getSound()-&gt;getName().c_str(),</font>
+01038 <font class="comment"> (uint32)((*ips)-&gt;getGain()*100.0f),</font>
+01039 <font class="comment"> (*ips)-&gt;getBuffer()-&gt;isStereo()?"ST":"MO",</font>
+01040 <font class="comment"> PriToCStr[(*ips)-&gt;getPriority()] );</font>
+01041 <font class="comment"> s += string(line) + "\n";</font>
+01042 <font class="comment">*/</font> }
+01043 }
+01044 <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
+01045
+01046 }
+01047
+01048 <font class="comment">// ******************************************************************</font>
+01049 <font class="comment">/*</font>
+01050 <font class="comment">void CAudioMixerUser::loadEnvSounds( const char *filename, UEnvSound **treeRoot )</font>
+01051 <font class="comment">{</font>
+01052 <font class="comment"> nlassert( filename != NULL );</font>
+01053 <font class="comment"> nlinfo( "Loading environment sounds from %s...", filename );</font>
+01054 <font class="comment"></font>
+01055 <font class="comment"> string str = CPath::lookup( filename, false );</font>
+01056 <font class="comment"></font>
+01057 <font class="comment"> CIFile file;</font>
+01058 <font class="comment"> if ( !str.empty() &amp;&amp; file.open( str ) )</font>
+01059 <font class="comment"> {</font>
+01060 <font class="comment"> uint32 n = 0; //CEnvSoundUser::load( _EnvSounds, file );</font>
+01061 <font class="comment"> nldebug( "AM: Loaded %u environment sounds", n );</font>
+01062 <font class="comment"> }</font>
+01063 <font class="comment"> else</font>
+01064 <font class="comment"> {</font>
+01065 <font class="comment"> nlwarning( "AM: Environment sounds file not found: %s", filename );</font>
+01066 <font class="comment"> }</font>
+01067 <font class="comment"> if ( treeRoot != NULL )</font>
+01068 <font class="comment"> {</font>
+01069 <font class="comment"> *treeRoot = _EnvSounds;</font>
+01070 <font class="comment"> }</font>
+01071 <font class="comment">}</font>
+01072 <font class="comment">*/</font>
+01073
+01074 <font class="comment">// ******************************************************************</font>
+01075
+<a name="l01076"></a><a class="code" href="structNLSOUND_1_1CompareSources.html">01076</a> <font class="keyword">struct </font>CompareSources : <font class="keyword">public</font> binary_function&lt;const CSimpleSource*, const CSimpleSource*, bool&gt;
+01077 {
+01078 <font class="comment">// Constructor</font>
+<a name="l01079"></a><a class="code" href="structNLSOUND_1_1CompareSources.html#a0">01079</a> <a class="code" href="structNLSOUND_1_1CompareSources.html#a0">CompareSources</a>( <font class="keyword">const</font> CVector &amp;pos ) : <a class="code" href="structNLSOUND_1_1CompareSources.html#m0">_Pos</a>(pos) {}
+01080
+01081 <font class="comment">// Operator()</font>
+<a name="l01082"></a><a class="code" href="structNLSOUND_1_1CompareSources.html#a1">01082</a> <font class="keywordtype">bool</font> <a class="code" href="structNLSOUND_1_1CompareSources.html#a1">operator()</a>( <font class="keyword">const</font> CSimpleSource *s1, <font class="keyword">const</font> CSimpleSource *s2 )
+01083 {
+01084 <font class="keywordflow">if</font> (s1-&gt;getPriority() &lt; s2-&gt;getPriority())
+01085 {
+01086 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+01087 }
+01088 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (s1-&gt;getPriority() == s2-&gt;getPriority())
+01089 {
+01090 <font class="comment">// Equal priority, test distances to the listener</font>
+01091 <font class="keyword">const</font> CVector &amp;src1pos = s1-&gt;getPos();
+01092 <font class="keyword">const</font> CVector &amp;src2pos = s2-&gt;getPos();;
+01093 <font class="keywordflow">return</font> ( (src1pos-<a class="code" href="structNLSOUND_1_1CompareSources.html#m0">_Pos</a>).sqrnorm() &lt; (src2pos-<a class="code" href="structNLSOUND_1_1CompareSources.html#m0">_Pos</a>).sqrnorm() );
+01094 }
+01095 <font class="keywordflow">else</font>
+01096 {
+01097 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+01098 }
+01099 }
+01100
+01101 <font class="comment">// Listener pos</font>
+<a name="l01102"></a><a class="code" href="structNLSOUND_1_1CompareSources.html#m0">01102</a> <font class="keyword">const</font> CVector &amp;<a class="code" href="structNLSOUND_1_1CompareSources.html#m0">_Pos</a>;
+01103 };
+01104
+01105
+01106 <font class="comment">// ******************************************************************</font>
+<a name="l01107"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a10">01107</a> uint32 CAudioMixerUser::getLoadedSampleSize()
+01108 {
+01109 <font class="keywordflow">return</font> CSampleBank::getTotalByteSize();
+01110 }
+01111
+01112
+01113 <font class="comment">// ******************************************************************</font>
+01114 <font class="comment">/*</font>
+01115 <font class="comment">void CAudioMixerUser::redispatchSourcesToTrack()</font>
+01116 <font class="comment">{</font>
+01117 <font class="comment">*/</font> <font class="comment">// TODO : rewrite ?</font>
+01118 <font class="comment">/*</font>
+01119 <font class="comment"> if ( _NbTracks == 0 )</font>
+01120 <font class="comment"> {</font>
+01121 <font class="comment"> return;</font>
+01122 <font class="comment"> }</font>
+01123 <font class="comment"></font>
+01124 <font class="comment"> _profile(( "AM: [%u]---------------------------------------------------------------", curTime() ));</font>
+01125 <font class="comment"> _profile(( "AM: Redispatching sources" ));</font>
+01126 <font class="comment"> </font>
+01127 <font class="comment"> const CVector &amp;listenerpos = _Listener.getPos();</font>
+01128 <font class="comment"></font>
+01129 <font class="comment"> // Get a copy of the sources set (we will modify it)</font>
+01130 <font class="comment"> static TSourceContainer sources_copy; </font>
+01131 <font class="comment"> sources_copy = _PlayingSources;</font>
+01132 <font class="comment"> // FIXME: SWAPTEST</font>
+01133 <font class="comment"> //nlassert( sources_copy.size() &gt;= _NbTracks );</font>
+01134 <font class="comment"></font>
+01135 <font class="comment"> // Select the nbtracks "smallest" sources (the ones that have the higher priorities)</font>
+01136 <font class="comment"> TSourceContainer::iterator ips;</font>
+01137 <font class="comment"> static TSourceContainer selected_sources;</font>
+01138 <font class="comment"> uint32 i;</font>
+01139 <font class="comment"></font>
+01140 <font class="comment"> selected_sources.clear();</font>
+01141 <font class="comment"></font>
+01142 <font class="comment"> // Select the sources</font>
+01143 <font class="comment"></font>
+01144 <font class="comment"> // Select the nbtracks "smallest" sources (the ones that have the higher priorities)</font>
+01145 <font class="comment"> // FIXME: SWAPTEST</font>
+01146 <font class="comment"> //for ( i=0; i!=_NbTracks; i++ )</font>
+01147 <font class="comment"> // TODO : optimize : this is a very BAD PERFORMANCE code</font>
+01148 <font class="comment"> while (!sources_copy.empty() &amp;&amp; (selected_sources.size() &lt; _NbTracks))</font>
+01149 <font class="comment"> {</font>
+01150 <font class="comment"> ips = min_element( sources_copy.begin(), sources_copy.end(), CompareSources( listenerpos ) );</font>
+01151 <font class="comment"></font>
+01152 <font class="comment"> if ((*ips)-&gt;isPlaying())</font>
+01153 <font class="comment"> {</font>
+01154 <font class="comment"> selected_sources.insert( *ips );</font>
+01155 <font class="comment"> }</font>
+01156 <font class="comment"></font>
+01157 <font class="comment"> sources_copy.erase( ips );</font>
+01158 <font class="comment"> }</font>
+01159 <font class="comment"></font>
+01160 <font class="comment"> // Clear the current tracks where the sources are not selected anymore</font>
+01161 <font class="comment"> _profile(( "AM: Total sources: %u", _PlayingSources.size() ));</font>
+01162 <font class="comment"> _profile(( "AM: Selected sources: %u", selected_sources.size() ));</font>
+01163 <font class="comment"> for ( i=0; i!=_NbTracks; i++ )</font>
+01164 <font class="comment"> {</font>
+01165 <font class="comment"> // FIXME: SWAPTEST</font>
+01166 <font class="comment"> if ( _Tracks[i] &amp;&amp; ! _Tracks[i]-&gt;isAvailable() )</font>
+01167 <font class="comment"> {</font>
+01168 <font class="comment"> // Optimization note: instead of searching the source in selected_sources, we could have</font>
+01169 <font class="comment"> // set a boolean in the source object and tested it.</font>
+01170 <font class="comment"> if ( (ips = selected_sources.find( _Tracks[i]-&gt;getSource() )) == selected_sources.end() )</font>
+01171 <font class="comment"> {</font>
+01172 <font class="comment"> // There will be a new source in this track</font>
+01173 <font class="comment"> _profile(( "AM: TRACK: %p: REPLACED, SOURCE: %p", _Tracks[i], _Tracks[i]-&gt;getSource() ));</font>
+01174 <font class="comment"> if (_Tracks[i]-&gt;getSource() != 0)</font>
+01175 <font class="comment"> {</font>
+01176 <font class="comment"> _Tracks[i]-&gt;getSource()-&gt;leaveTrack();</font>
+01177 <font class="comment">// nlassert(_PlayingSources.find(_Tracks[i]-&gt;getSource()) != _PlayingSources.end());</font>
+01178 <font class="comment"> _PlayingSources.erase(_Tracks[i]-&gt;getSource());</font>
+01179 <font class="comment"> }</font>
+01180 <font class="comment"> }</font>
+01181 <font class="comment"> else</font>
+01182 <font class="comment"> {</font>
+01183 <font class="comment"> // The track will remain unchanged</font>
+01184 <font class="comment"> selected_sources.erase( ips );</font>
+01185 <font class="comment"> _profile(( "AM: TRACK: %p: UNCHANGED, SOURCE: %p", _Tracks[i], _Tracks[i]-&gt;getSource() ));</font>
+01186 <font class="comment"> }</font>
+01187 <font class="comment"> }</font>
+01188 <font class="comment"> else</font>
+01189 <font class="comment"> {</font>
+01190 <font class="comment"> _profile(( "AM: TRACK: %p: FREE", _Tracks[i] ));</font>
+01191 <font class="comment"> }</font>
+01192 <font class="comment"> }</font>
+01193 <font class="comment"></font>
+01194 <font class="comment"> if (!selected_sources.empty())</font>
+01195 <font class="comment"> {</font>
+01196 <font class="comment"> // Now, only the sources to add into the tracks remain in selected_sources</font>
+01197 <font class="comment"> CTrack *track [MAX_TRACKS]; // a little bit more than needed (avoiding a "new")</font>
+01198 <font class="comment"> getFreeTracks( selected_sources.size(), track );</font>
+01199 <font class="comment"></font>
+01200 <font class="comment"> _profile(( "AM: Remaining sources: %u", selected_sources.size() ));</font>
+01201 <font class="comment"></font>
+01202 <font class="comment"> for (i=0, ips=selected_sources.begin(); ips!=selected_sources.end(); ++ips )</font>
+01203 <font class="comment"> {</font>
+01204 <font class="comment"> // FIXME: SWAPTEST</font>
+01205 <font class="comment"> (*ips)-&gt;enterTrack( track[i] );</font>
+01206 <font class="comment">// nlassert(_PlayingSources.find(*ips) == _PlayingSources.end());</font>
+01207 <font class="comment">// _PlayingSources.insert(*ips);</font>
+01208 <font class="comment"> // _profile(( "AM: TRACK: %p: ASSIGNED, SOURCE: %p", track[i], track[i]-&gt;getSource() ));</font>
+01209 <font class="comment"> _profile(( "AM: TRACK: %p: ASSIGNED, SOURCE: %p", track[i], *ips ));</font>
+01210 <font class="comment"> i++;</font>
+01211 <font class="comment"> }</font>
+01212 <font class="comment"> }</font>
+01213 <font class="comment">*/</font>
+01214 <font class="comment">//}</font>
+01215
+<a name="l01216"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a16">01216</a> <font class="keywordtype">void</font> CAudioMixerUser::setListenerPos (<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;pos)
+01217 {
+01218 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o7">_Listener</a>.setPos(pos);
+01219 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a>-&gt;setListenerPosition(pos);
+01220 }
+01221
+01222 <a class="code" href="command_8h.html#a0">NLMISC_COMMAND</a> (displaySoundInfo, <font class="stringliteral">"Display information about the audio mixer"</font>, <font class="stringliteral">""</font>)
+01223 {
+01224 <font class="keywordflow">if</font>(args.size() != 0) <font class="keywordflow">return</font> <font class="keyword">false</font>;
+01225
+01226 <font class="keywordflow">if</font> (CAudioMixerUser::instance() == NULL)
+01227 {
+01228 log.displayNL (<font class="stringliteral">"No audio mixer available"</font>);
+01229 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+01230 }
+01231
+01232 log.displayNL (<font class="stringliteral">"%d tracks, MAX_TRACKS = %d, contains:"</font>, CAudioMixerUser::instance()-&gt;_NbTracks, <a class="code" href="namespaceNLSOUND.html#a16">MAX_TRACKS</a>);
+01233
+01234 <font class="keywordflow">for</font> (uint i = 0; i &lt; CAudioMixerUser::instance()-&gt;_NbTracks; i++)
+01235 {
+01236 <font class="keywordflow">if</font> (CAudioMixerUser::instance()-&gt;_Tracks[i] == NULL)
+01237 {
+01238 log.displayNL (<font class="stringliteral">"Track %d is NULL"</font>, i);
+01239 }
+01240 <font class="keywordflow">else</font>
+01241 {
+01242 log.displayNL (<font class="stringliteral">"Track %d %s available and %s playing."</font>, i, (CAudioMixerUser::instance()-&gt;_Tracks[i]-&gt;isAvailable()?<font class="stringliteral">"is"</font>:<font class="stringliteral">"is not"</font>), (CAudioMixerUser::instance()-&gt;_Tracks[i]-&gt;isPlaying()?<font class="stringliteral">"is"</font>:<font class="stringliteral">"is not"</font>));
+01243 <font class="keywordflow">if</font> (CAudioMixerUser::instance()-&gt;_Tracks[i]-&gt;getSource() == NULL)
+01244 {
+01245 log.displayNL (<font class="stringliteral">" CUserSource is NULL"</font>);
+01246 }
+01247 <font class="keywordflow">else</font>
+01248 {
+01249 <font class="keyword">const</font> CVector &amp;pos = CAudioMixerUser::instance()-&gt;_Tracks[i]-&gt;getSource()-&gt;getPos();
+01250 string bufname;
+01251 <font class="keywordflow">if</font> (CAudioMixerUser::instance()-&gt;_Tracks[i]-&gt;getSource()-&gt;getBuffer())
+01252 bufname = CAudioMixerUser::instance()-&gt;_Tracks[i]-&gt;getSource()-&gt;getBuffer()-&gt;getName();
+01253 log.displayNL (<font class="stringliteral">" CUserSource is id %d buffer name '%s' pos %f %f %f"</font>, CAudioMixerUser::instance()-&gt;_Tracks[i]-&gt;getSource()-&gt;getSound(), bufname.c_str(), pos.x, pos.y, pos.z);
+01254 }
+01255 }
+01256 }
+01257
+01258 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+01259 }
+01260
+01261 <font class="keywordtype">void</font> CAudioMixerUser::registerBufferAssoc(CSound *sound, IBuffer *buffer)
+01262 {
+01263 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o10">_BufferToSources</a>[buffer].push_back(sound);
+01264 }
+01265
+01266 <font class="keywordtype">void</font> CAudioMixerUser::unregisterBufferAssoc(CSound *sound, IBuffer *buffer)
+01267 {
+01268 TBufferToSourceContainer::iterator it(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o10">_BufferToSources</a>.find(buffer));
+01269 <font class="keywordflow">if</font> (it != <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o10">_BufferToSources</a>.end())
+01270 {
+01271 std::vector&lt;CSound*&gt;::iterator first(it-&gt;second.begin()), last(it-&gt;second.end());
+01272
+01273 <font class="keywordflow">for</font> (; first != last; ++first)
+01274 {
+01275 <font class="keywordflow">if</font> (*first == sound)
+01276 {
+01277 it-&gt;second.erase(first);
+01278 <font class="keywordflow">break</font>;
+01279 }
+01280 }
+01281 }
+01282 }
+01283
+01284
+01286 <font class="keywordtype">void</font> CAudioMixerUser::registerUpdate(CAudioMixerUser::IMixerUpdate *pmixerUpdate)
+01287 {
+01288 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n1">_UpdateEventList</a>.push_back(make_pair(pmixerUpdate, <font class="keyword">true</font>));
+01289 }
+01291 <font class="keywordtype">void</font> CAudioMixerUser::unregisterUpdate(CAudioMixerUser::IMixerUpdate *pmixerUpdate)
+01292 {
+01293 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n1">_UpdateEventList</a>.push_back(make_pair(pmixerUpdate, <font class="keyword">false</font>));
+01294 }
+01295
+01297 <font class="keywordtype">void</font> CAudioMixerUser::addEvent( CAudioMixerUser::IMixerEvent *pmixerEvent, <font class="keyword">const</font> NLMISC::TTime &amp;date)
+01298 {
+01299 <font class="comment">// nldebug("Adding event %p", pmixerEvent);</font>
+01300 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n4">_EventListUpdate</a>.push_back(make_pair(date, pmixerEvent));
+01301 }
+01303 <font class="keywordtype">void</font> CAudioMixerUser::removeEvents( CAudioMixerUser::IMixerEvent *pmixerEvent)
+01304 {
+01305 <font class="comment">// nldebug("Removing event %p", pmixerEvent);</font>
+01306 <font class="comment">// store the pointer fot future removal.</font>
+01307 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n4">_EventListUpdate</a>.push_back(make_pair(0, pmixerEvent));
+01308 }
+01309
+01310 <font class="keywordtype">void</font> CAudioMixerUser::setBackgroundFlags(<font class="keyword">const</font> TBackgroundFlags &amp;backgroundFlags)
+01311 {
+01312 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a>-&gt;setBackgroundFlags(backgroundFlags);
+01313 }
+01314
+01315 <font class="keywordtype">void</font> CAudioMixerUser::loadBackgroundSoundFromRegion (<font class="keyword">const</font> <a class="code" href="classNLLIGO_1_1CPrimRegion.html">NLLIGO::CPrimRegion</a> &amp;region)
+01316 {
+01317 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a>-&gt;loadSoundsFromRegion(region);
+01318 }
+01319
+01320 <font class="keywordtype">void</font> CAudioMixerUser::loadBackgroundEffectsFromRegion (<font class="keyword">const</font> <a class="code" href="classNLLIGO_1_1CPrimRegion.html">NLLIGO::CPrimRegion</a> &amp;region)
+01321 {
+01322 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a>-&gt;loadEffecsFromRegion(region);
+01323 }
+01324 <font class="keywordtype">void</font> CAudioMixerUser::loadBackgroundSamplesFromRegion (<font class="keyword">const</font> <a class="code" href="classNLLIGO_1_1CPrimRegion.html">NLLIGO::CPrimRegion</a> &amp;region)
+01325 {
+01326 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a>-&gt;loadSamplesFromRegion(region);
+01327 }
+01328
+01329
+01330 <font class="keywordtype">void</font> CAudioMixerUser::playBackgroundSound ()
+01331 {
+01332 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a>-&gt;play ();
+01333 }
+01334
+01335 <font class="keywordtype">void</font> CAudioMixerUser::stopBackgroundSound ()
+01336 {
+01337 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a>-&gt;stop ();
+01338 }
+01339
+01340 <font class="keywordtype">void</font> CAudioMixerUser::loadBackgroundSound (<font class="keyword">const</font> std::string &amp;continent)
+01341 {
+01342 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a>-&gt;load (continent);
+01343 }
+01344
+01345 } <font class="comment">// NLSOUND</font>
+</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>