diff options
Diffstat (limited to '')
-rw-r--r-- | docs/doxygen/nel/complex__source_8cpp-source.html | 669 |
1 files changed, 669 insertions, 0 deletions
diff --git a/docs/doxygen/nel/complex__source_8cpp-source.html b/docs/doxygen/nel/complex__source_8cpp-source.html new file mode 100644 index 00000000..e7d29907 --- /dev/null +++ b/docs/doxygen/nel/complex__source_8cpp-source.html @@ -0,0 +1,669 @@ +<!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> <A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A> </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> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </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> + + +<!-- 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> </td> +</tr></table> +<!-- Generated by Doxygen 1.2.14 --> +<center> +<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <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> </center> +<hr><h1>complex_source.cpp</h1><a href="complex__source_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="preprocessor">#include "<a class="code" href="complex__source_8h.html">complex_source.h</a>"</font> +00029 <font class="preprocessor">#include "<a class="code" href="complex__sound_8h.html">complex_sound.h</a>"</font> +00030 +00031 <font class="keyword">using</font> <font class="keyword">namespace </font>std; +00032 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC; +00033 +00034 <font class="keyword">namespace </font>NLSOUND +00035 { +00036 +<a name="l00037"></a><a class="code" href="classNLSOUND_1_1CComplexSource.html#a0">00037</a> CComplexSource::CComplexSource (CComplexSound *soundPattern, <font class="keywordtype">bool</font> spawn, <a class="code" href="namespaceNLSOUND.html#a9">TSpawnEndCallback</a> cb, <font class="keywordtype">void</font> *cbUserParam) +00038 : CSourceCommon(soundPattern, spawn, cb, cbUserParam), +00039 _Source1(NULL), +00040 _Source2(NULL) +00041 { +00042 <a class="code" href="debug_8h.html#a6">nlassert</a>(soundPattern->getSoundType() == CSound::SOUND_COMPLEX); +00043 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a> = static_cast<CComplexSound*>(soundPattern); +00044 +00045 <font class="comment">// read original parameters</font> +00046 <a class="code" href="classNLSOUND_1_1CSourceCommon.html#n6">_Gain</a> = soundPattern->getGain(); +00047 <a class="code" href="classNLSOUND_1_1CSourceCommon.html#n7">_Pitch</a> = soundPattern->getPitch(); +00048 <a class="code" href="classNLSOUND_1_1CSourceCommon.html#n2">_Looping</a> = soundPattern->getLooping(); +00049 <a class="code" href="classNLSOUND_1_1CSourceCommon.html#n0">_Priority</a> = soundPattern->getPriority(); +00050 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o5">_TickPerSecond</a> = soundPattern->getTicksPerSecond(); +00051 } +00052 +<a name="l00053"></a><a class="code" href="classNLSOUND_1_1CComplexSource.html#a1">00053</a> CComplexSource::~CComplexSource() +00054 { +00055 CAudioMixerUser *mixer = CAudioMixerUser::instance(); +00056 <font class="comment">// security</font> +00057 CAudioMixerUser::instance()->unregisterUpdate(<font class="keyword">this</font>); +00058 CAudioMixerUser::instance()->removeEvents(<font class="keyword">this</font>); +00059 +00060 std::vector<USource *>::iterator first(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o2">_AllSources</a>.begin()), last(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o2">_AllSources</a>.end()); +00061 <font class="keywordflow">for</font> (; first != last; ++first) +00062 { +00063 <font class="comment">//mixer->removeSource(*first);</font> +00064 <font class="keyword">delete</font> *first; +00065 } +00066 } +00067 +00068 +<a name="l00069"></a><a class="code" href="classNLSOUND_1_1CComplexSource.html#a2">00069</a> <font class="keywordtype">void</font> CComplexSource::setSound( <a class="code" href="namespaceNLSOUND.html#a8">TSoundId</a> <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>, CSoundContext *context) +00070 { +00071 } +00072 +<a name="l00073"></a><a class="code" href="classNLSOUND_1_1CComplexSource.html#a3">00073</a> <a class="code" href="namespaceNLSOUND.html#a8">TSoundId</a> CComplexSource::getSound() +00074 { +00075 <font class="keywordflow">return</font> <a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>; +00076 } +00077 <font class="comment">/*</font> +00078 <font class="comment">void CComplexSource::setPriority( TSoundPriority pr, bool redispatch)</font> +00079 <font class="comment">{</font> +00080 <font class="comment">}</font> +00081 <font class="comment"></font> +00082 <font class="comment">void CComplexSource:: setLooping( bool l )</font> +00083 <font class="comment">{</font> +00084 <font class="comment">}</font> +00085 <font class="comment">bool CComplexSource::getLooping() const</font> +00086 <font class="comment">{</font> +00087 <font class="comment"> return false;</font> +00088 <font class="comment">}</font> +00089 <font class="comment">*/</font> +00090 +<a name="l00091"></a><a class="code" href="classNLSOUND_1_1CComplexSource.html#z964_2">00091</a> <font class="keywordtype">bool</font> CComplexSource::isPlaying() +00092 { +00093 <font class="keywordflow">return</font> <a class="code" href="classNLSOUND_1_1CSourceCommon.html#n1">_Playing</a>; +00094 } +00095 +<a name="l00096"></a><a class="code" href="classNLSOUND_1_1CComplexSource.html#z964_0">00096</a> <font class="keywordtype">void</font> CComplexSource::play() +00097 { +00098 CAudioMixerUser *mixer = CAudioMixerUser::instance(); +00099 NLMISC::TTime now = <a class="code" href="classNLMISC_1_1CTime.html#d1">NLMISC::CTime::getLocalTime</a>(); +00100 +00101 <font class="keywordflow">switch</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getPatternMode()) +00102 { +00103 <font class="keywordflow">case</font> CComplexSound::MODE_CHAINED: +00104 { +00105 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o8">_SoundSeqIndex</a> = 0; +00106 <font class="keyword">const</font> vector<uint32> &soundSeq = <a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getSoundSeq(); +00107 <font class="keywordflow">if</font> (!soundSeq.empty()) +00108 { +00109 CSound *sound = mixer->getSoundId(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getSound(soundSeq[<a class="code" href="classNLSOUND_1_1CComplexSource.html#o8">_SoundSeqIndex</a>++])); +00110 +00111 <font class="keywordflow">if</font> (sound == 0) +00112 <font class="keywordflow">return</font>; +00113 +00114 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->doFadeIn()) +00115 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o6">_FadeLength</a> = <a class="code" href="bit__set_8cpp.html#a0">min</a>(<a class="code" href="memory__common_8h.html#a11">uint32</a>(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getFadeLenght()/<a class="code" href="classNLSOUND_1_1CComplexSource.html#o5">_TickPerSecond</a>), sound->getDuration() /2); +00116 <font class="keywordflow">else</font> +00117 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o6">_FadeLength</a> = 0; +00118 +00119 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a> = mixer->createSource(sound, <font class="keyword">false</font>); +00120 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a> == NULL) +00121 <font class="keywordflow">return</font>; +00122 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a>->setRelativeGain(0); +00123 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a>->setPos(<a class="code" href="classNLSOUND_1_1CSourceCommon.html#n3">_Position</a>); +00124 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a>->play(); +00125 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o4">_StartTime2</a> = now; +00126 +00127 <font class="comment">// register for fade in.</font> +00128 mixer->registerUpdate(<font class="keyword">this</font>); +00129 } +00130 } +00131 <font class="keywordflow">break</font>; +00132 <font class="keywordflow">case</font> CComplexSound::MODE_SPARSE: +00133 { +00134 <font class="comment">// use Source1, sound sequence, delay sequence and event.</font> +00135 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o8">_SoundSeqIndex</a> = 0; +00136 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o9">_DelaySeqIndex</a> = 0; +00137 <font class="keyword">const</font> vector<uint32> &soundSeq = <a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getSoundSeq(); +00138 <font class="keywordflow">if</font> (!soundSeq.empty()) +00139 { +00140 CSound *sound = mixer->getSoundId(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getSound(soundSeq[<a class="code" href="classNLSOUND_1_1CComplexSource.html#o8">_SoundSeqIndex</a>++])); +00141 +00142 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a> = mixer->createSource(sound, <font class="keyword">false</font>); +00143 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a> == NULL) +00144 <font class="keywordflow">return</font>; +00145 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->setRelativeGain(<a class="code" href="classNLSOUND_1_1CSourceCommon.html#n6">_Gain</a>); +00146 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->setPos(<a class="code" href="classNLSOUND_1_1CSourceCommon.html#n3">_Position</a>); +00147 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->play(); +00148 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o3">_StartTime1</a> = now; +00149 +00150 <font class="comment">// register event for next sound.</font> +00151 <font class="keyword">const</font> std::vector<uint32> &delaySeq = <a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getDelaySeq(); +00152 <font class="keywordflow">if</font> (!delaySeq.empty() && <a class="code" href="classNLSOUND_1_1CComplexSource.html#o9">_DelaySeqIndex</a> < delaySeq.size()) +00153 { +00154 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o10">_LastSparseEvent</a> = <font class="keyword">false</font>; +00155 <font class="comment">// event for next sound.</font> +00156 mixer->addEvent(<font class="keyword">this</font>, <a class="code" href="memory__common_8h.html#a13">uint64</a>(now + sound->getDuration() + delaySeq[<a class="code" href="classNLSOUND_1_1CComplexSource.html#o9">_DelaySeqIndex</a>++]/<a class="code" href="classNLSOUND_1_1CComplexSource.html#o5">_TickPerSecond</a>)); +00157 } +00158 <font class="keywordflow">else</font> +00159 { +00160 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o10">_LastSparseEvent</a> = <font class="keyword">true</font>; +00161 <font class="comment">// event for stop</font> +00162 mixer->addEvent(<font class="keyword">this</font>, now + sound->getDuration()); +00163 } +00164 } +00165 } +00166 <font class="keywordflow">break</font>; +00167 <font class="keywordflow">case</font> CComplexSound::MODE_ALL_IN_ONE: +00168 { +00169 <font class="comment">// just spanw all the listed source.</font> +00170 <font class="keyword">const</font> std::vector<std::string> &sounds = <a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getSounds(); +00171 +00172 std::vector<std::string>::const_iterator first(sounds.begin()), last(sounds.end()); +00173 +00174 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o2">_AllSources</a>.empty()) +00175 { +00176 <font class="comment">// create the sources</font> +00177 <font class="keywordflow">for</font> (; first != last; ++first) +00178 { +00179 CSound *sound = mixer->getSoundId(*first); +00180 <font class="keywordflow">if</font> (sound != NULL) +00181 { +00182 <a class="code" href="classNLSOUND_1_1USource.html#b0">USource</a> *source = mixer->createSource(sound, <font class="keyword">false</font>); +00183 source->setRelativeGain(<a class="code" href="classNLSOUND_1_1CSourceCommon.html#n6">_Gain</a>); +00184 source->setPos(<a class="code" href="classNLSOUND_1_1CSourceCommon.html#n3">_Position</a>); +00185 source->play(); +00186 +00187 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o2">_AllSources</a>.push_back(source); +00188 } +00189 } +00190 } +00191 <font class="keywordflow">else</font> +00192 { +00193 <font class="comment">// just replay the existing source.</font> +00194 std::vector<USource *>::iterator first(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o2">_AllSources</a>.begin()), last(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o2">_AllSources</a>.end()); +00195 +00196 <font class="keywordflow">for</font> (; first != last; ++first) +00197 { +00198 (*first)->setRelativeGain(<a class="code" href="classNLSOUND_1_1CSourceCommon.html#n6">_Gain</a>); +00199 (*first)->setPos(<a class="code" href="classNLSOUND_1_1CSourceCommon.html#n3">_Position</a>); +00200 (*first)->play(); +00201 } +00202 } +00203 +00204 mixer->addEvent(<font class="keyword">this</font>, <a class="code" href="classNLMISC_1_1CTime.html#d1">NLMISC::CTime::getLocalTime</a>() + <a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getDuration()); +00205 } +00206 <font class="keywordflow">break</font>; +00207 <font class="keywordflow">default</font>: +00208 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Unknow pattern mode. Can't play."</font>); +00209 } +00210 +00211 CSourceCommon::play(); +00212 } +<a name="l00213"></a><a class="code" href="classNLSOUND_1_1CComplexSource.html#z964_1">00213</a> <font class="keywordtype">void</font> CComplexSource::stop() +00214 { +00215 CAudioMixerUser *mixer = CAudioMixerUser::instance(); +00216 <font class="keywordflow">if</font> (_Source1) +00217 { +00218 <font class="comment">// _Source1->stop();</font> +00219 <font class="comment">// mixer->removeSource(_Source1);</font> +00220 <font class="keyword">delete</font> <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>; +00221 +00222 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a> = NULL; +00223 } +00224 <font class="keywordflow">if</font> (_Source2) +00225 { +00226 <font class="comment">// _Source2->stop();</font> +00227 <font class="comment">// mixer->removeSource(_Source2);</font> +00228 <font class="keyword">delete</font> <a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a>; +00229 +00230 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a> = NULL; +00231 } +00232 +00233 std::vector<USource *>::iterator first(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o2">_AllSources</a>.begin()), last(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o2">_AllSources</a>.end()); +00234 <font class="keywordflow">for</font> (; first != last; ++first) +00235 { +00236 <font class="keywordflow">if</font> ((*first)->isPlaying()) +00237 (*first)->stop(); +00238 } +00239 +00240 <font class="keywordflow">switch</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getPatternMode()) +00241 { +00242 <font class="keywordflow">case</font> CComplexSound::MODE_CHAINED: +00243 mixer->unregisterUpdate(<font class="keyword">this</font>); +00244 mixer->removeEvents(<font class="keyword">this</font>); +00245 <font class="keywordflow">break</font>; +00246 <font class="keywordflow">case</font> CComplexSound::MODE_SPARSE: +00247 <font class="keywordflow">case</font> CComplexSound::MODE_ALL_IN_ONE: +00248 mixer->removeEvents(<font class="keyword">this</font>); +00249 <font class="keywordflow">break</font>; +00250 } +00251 +00252 CSourceCommon::stop(); +00253 } +00254 +00255 <font class="comment">/*void CComplexSource::unregisterSpawnCallBack()</font> +00256 <font class="comment">{</font> +00257 <font class="comment">}</font> +00258 <font class="comment">*/</font> +<a name="l00259"></a><a class="code" href="classNLSOUND_1_1CComplexSource.html#a4">00259</a> <font class="keywordtype">void</font> CComplexSource::setPos( <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>& pos ) +00260 { +00261 CSourceCommon::setPos(pos); +00262 +00263 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a> != NULL) +00264 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->setPos(pos); +00265 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a> != NULL) +00266 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a>->setPos(pos); +00267 +00268 std::vector<USource *>::iterator first(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o2">_AllSources</a>.begin()), last(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o2">_AllSources</a>.end()); +00269 <font class="keywordflow">for</font> (; first != last; ++first) +00270 { +00271 (*first)->setPos(pos); +00272 } +00273 } +00274 +<a name="l00275"></a><a class="code" href="classNLSOUND_1_1CComplexSource.html#a5">00275</a> <font class="keywordtype">void</font> CComplexSource::setVelocity( <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>& vel ) +00276 { +00277 CSourceCommon::setVelocity(vel); +00278 +00279 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a> != NULL) +00280 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->setVelocity(vel); +00281 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a> != NULL) +00282 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a>->setVelocity(vel); +00283 +00284 std::vector<USource *>::iterator first(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o2">_AllSources</a>.begin()), last(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o2">_AllSources</a>.end()); +00285 <font class="keywordflow">for</font> (; first != last; ++first) +00286 { +00287 (*first)->setVelocity(vel); +00288 } +00289 } +00290 <font class="comment">/*void CComplexSource::getVelocity( NLMISC::CVector& vel ) const</font> +00291 <font class="comment">{</font> +00292 <font class="comment">}</font> +00293 <font class="comment">*/</font> +<a name="l00294"></a><a class="code" href="classNLSOUND_1_1CComplexSource.html#a6">00294</a> <font class="keywordtype">void</font> CComplexSource::setDirection( <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>& dir ) +00295 { +00296 CSourceCommon::setDirection(dir); +00297 +00298 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a> != NULL) +00299 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->setDirection(dir); +00300 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a> != NULL) +00301 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a>->setDirection(dir); +00302 +00303 std::vector<USource *>::iterator first(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o2">_AllSources</a>.begin()), last(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o2">_AllSources</a>.end()); +00304 <font class="keywordflow">for</font> (; first != last; ++first) +00305 { +00306 (*first)->setDirection(dir); +00307 } +00308 } +00309 <font class="comment">/*</font> +00310 <font class="comment">void CComplexSource::getDirection( NLMISC::CVector& dir ) const</font> +00311 <font class="comment">{</font> +00312 <font class="comment">}</font> +00313 <font class="comment">*/</font> +<a name="l00314"></a><a class="code" href="classNLSOUND_1_1CComplexSource.html#a7">00314</a> <font class="keywordtype">void</font> CComplexSource::setGain( <font class="keywordtype">float</font> gain ) +00315 { +00316 CSourceCommon::setGain(gain); +00317 <font class="comment">// update the gain of the played source.</font> +00318 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a> != NULL) +00319 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->setGain(gain); +00320 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a> != NULL) +00321 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a>->setGain(gain); +00322 +00323 std::vector<USource *>::iterator first(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o2">_AllSources</a>.begin()), last(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o2">_AllSources</a>.end()); +00324 <font class="keywordflow">for</font> (; first != last; ++first) +00325 { +00326 (*first)->setGain(<a class="code" href="classNLSOUND_1_1CSourceCommon.html#n6">_Gain</a>); +00327 } +00328 } +00329 +<a name="l00330"></a><a class="code" href="classNLSOUND_1_1CComplexSource.html#a8">00330</a> <font class="keywordtype">void</font> CComplexSource::setRelativeGain( <font class="keywordtype">float</font> gain ) +00331 { +00332 CSourceCommon::setRelativeGain(gain); +00333 +00334 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a> != NULL) +00335 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->setRelativeGain(gain); +00336 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a> != NULL) +00337 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a>->setRelativeGain(gain); +00338 +00339 std::vector<USource *>::iterator first(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o2">_AllSources</a>.begin()), last(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o2">_AllSources</a>.end()); +00340 <font class="keywordflow">for</font> (; first != last; ++first) +00341 { +00342 (*first)->setRelativeGain(<a class="code" href="classNLSOUND_1_1CSourceCommon.html#n6">_Gain</a>); +00343 } +00344 } +00345 +00346 <font class="comment">/*</font> +00347 <font class="comment">void CComplexSource::setPitch( float pitch )</font> +00348 <font class="comment">{</font> +00349 <font class="comment">}</font> +00350 <font class="comment">float CComplexSource::getPitch() const</font> +00351 <font class="comment">{</font> +00352 <font class="comment"> return 0;</font> +00353 <font class="comment">}</font> +00354 <font class="comment">*/</font> +00355 <font class="comment">/*</font> +00356 <font class="comment">void CComplexSource::setSourceRelativeMode( bool mode )</font> +00357 <font class="comment">{</font> +00358 <font class="comment">}</font> +00359 <font class="comment">bool CComplexSource::getSourceRelativeMode() const</font> +00360 <font class="comment">{</font> +00361 <font class="comment"> return false;</font> +00362 <font class="comment">}</font> +00363 <font class="comment">*/</font> +00364 +<a name="l00365"></a><a class="code" href="classNLSOUND_1_1CComplexSource.html#z964_3">00365</a> uint32 CComplexSource::getTime() +00366 { +00367 <font class="comment">// evaluate the elapsed time.</font> +00368 <font class="keywordflow">if</font> (!<a class="code" href="classNLSOUND_1_1CSourceCommon.html#n1">_Playing</a> || <a class="code" href="classNLSOUND_1_1CSourceCommon.html#n10">_PlayStart</a> == 0) <font class="comment">// not started ?</font> +00369 <font class="keywordflow">return</font> 0; +00370 +00371 <a class="code" href="namespaceNLMISC.html#a183">TTime</a> now = <a class="code" href="classNLMISC_1_1CTime.html#d1">NLMISC::CTime::getLocalTime</a>(); +00372 +00373 <a class="code" href="namespaceNLMISC.html#a183">TTime</a> delta = now - <a class="code" href="classNLSOUND_1_1CSourceCommon.html#n10">_PlayStart</a>; +00374 +00375 <font class="keywordflow">return</font> <a class="code" href="memory__common_8h.html#a11">uint32</a>(delta); +00376 } +00377 +00378 +<a name="l00380"></a><a class="code" href="classNLSOUND_1_1CComplexSource.html#c1">00380</a> <font class="keywordtype">void</font> CComplexSource::onUpdate() +00381 { +00382 <font class="comment">// do the cross fade : </font> +00383 <font class="comment">// - lower sound1, louder sound2, </font> +00384 <font class="comment">// - when max reach, stop the update, swap the sound, delete sound1 and set event for next fade.</font> +00385 +00386 <font class="comment">// can only occur for chained mode.</font> +00387 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getPatternMode() == CComplexSound::MODE_CHAINED); +00388 +00389 CAudioMixerUser *mixer = CAudioMixerUser::instance(); +00390 +00391 <font class="comment">// compute xfade factor.</font> +00392 <a class="code" href="namespaceNLMISC.html#a183">TTime</a> now = <a class="code" href="classNLMISC_1_1CTime.html#d1">NLMISC::CTime::getLocalTime</a>(); +00393 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o6">_FadeLength</a> > 0) +00394 { +00395 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o7">_FadeFactor</a> = float((<font class="keywordtype">double</font>(now) - <font class="keywordtype">double</font>(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o4">_StartTime2</a>)) / <font class="keywordtype">double</font>(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o6">_FadeLength</a>)) ; +00396 <font class="comment">// _FadeFactor = (_FadeFactor*_FadeFactor);</font> +00397 } +00398 <font class="keywordflow">else</font> +00399 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o7">_FadeFactor</a> = 1.0f; +00400 +00401 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Fade factor = %f"</font>, <a class="code" href="classNLSOUND_1_1CComplexSource.html#o7">_FadeFactor</a>); +00402 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o7">_FadeFactor</a> >= 1.0) +00403 { +00404 <font class="comment">// fade end !</font> +00405 <font class="keywordflow">if</font> (_Source1) +00406 { +00407 <font class="comment">// _Source1->stop();</font> +00408 <font class="comment">// mixer->removeSource(_Source1);</font> +00409 <font class="keyword">delete</font> <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>; +00410 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a> = NULL; +00411 } +00412 <font class="keywordflow">if</font> (_Source2) +00413 { +00414 <font class="comment">// set max volume</font> +00415 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a>->setRelativeGain(1.0f * <a class="code" href="classNLSOUND_1_1CSourceCommon.html#n6">_Gain</a>); +00416 <font class="comment">// 'swap' the source</font> +00417 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a> = <a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a>; +00418 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o3">_StartTime1</a> = <a class="code" href="classNLSOUND_1_1CComplexSource.html#o4">_StartTime2</a>; +00419 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a> = NULL; +00420 <font class="comment">// if there is a next sound available, program an event for the next xfade.</font> +00421 CSound *sound2 = NULL; +00422 <font class="comment">// _SoundSeqIndex++;</font> +00423 <font class="keyword">const</font> vector<uint32> &soundSeq = <a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getSoundSeq(); +00424 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o8">_SoundSeqIndex</a> < soundSeq.size()) +00425 { +00426 sound2 = mixer->getSoundId(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getSound(soundSeq[<a class="code" href="classNLSOUND_1_1CComplexSource.html#o8">_SoundSeqIndex</a>++])); +00427 } +00428 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (_Looping) +00429 { +00430 <font class="comment">// restart the sound sequence</font> +00431 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o8">_SoundSeqIndex</a> = 0; +00432 sound2 = mixer->getSoundId(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getSound(soundSeq[<a class="code" href="classNLSOUND_1_1CComplexSource.html#o8">_SoundSeqIndex</a>++])); +00433 } +00434 +00435 +00436 <font class="keywordflow">if</font> (sound2 != NULL) +00437 { +00438 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"CS : Chaining to sound %s"</font>, sound2->getName().c_str()); +00439 CAudioMixerUser *mixer = CAudioMixerUser::instance(); +00440 +00441 <font class="comment">// determine the XFade lenght (if next sound is too short.</font> +00442 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o6">_FadeLength</a> = minof<uint32>(<a class="code" href="memory__common_8h.html#a11">uint32</a>(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getFadeLenght()/<a class="code" href="classNLSOUND_1_1CComplexSource.html#o5">_TickPerSecond</a>), sound2->getDuration() / 2, <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->getSound()->getDuration()/2); +00443 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a> = mixer->createSource(sound2, <font class="keyword">false</font>); +00444 <font class="comment">// there is a next sound, add event for xfade.</font> +00445 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Seting event for sound %s in %u millisec (XFade = %u)."</font>, <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->getSound()->getName().c_str(), <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->getSound()->getDuration(), <a class="code" href="classNLSOUND_1_1CComplexSource.html#o6">_FadeLength</a>); +00446 mixer->addEvent(<font class="keyword">this</font>, <a class="code" href="classNLSOUND_1_1CComplexSource.html#o3">_StartTime1</a> + <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->getSound()->getDuration() - <a class="code" href="classNLSOUND_1_1CComplexSource.html#o6">_FadeLength</a>); +00447 } +00448 <font class="keywordflow">else</font> +00449 { +00450 <font class="comment">// no sound after, just set an event at end of current sound to stop the complex sound.</font> +00451 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Setting last event for sound %s in %u millisec."</font>, <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->getSound()->getName().c_str(), <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->getSound()->getDuration()); +00452 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->doFadeOut()) +00453 { +00454 <font class="comment">// set the event to begin fade out.</font> +00455 mixer->addEvent(<font class="keyword">this</font>, <a class="code" href="classNLSOUND_1_1CComplexSource.html#o3">_StartTime1</a> + <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->getSound()->getDuration() - <a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getFadeLenght()); +00456 } +00457 <font class="keywordflow">else</font> +00458 { +00459 <font class="comment">// set the event at end of sound.</font> +00460 mixer->addEvent(<font class="keyword">this</font>, <a class="code" href="classNLSOUND_1_1CComplexSource.html#o3">_StartTime1</a> + <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->getSound()->getDuration()); +00461 } +00462 } +00463 } +00464 <font class="keywordflow">else</font> +00465 { +00466 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->doFadeOut()) +00467 { +00468 <font class="comment">// update is responsible for stoping the sound.</font> +00469 <a class="code" href="classNLSOUND_1_1CSourceCommon.html#n1">_Playing</a> = <font class="keyword">false</font>; +00470 } +00471 } +00472 <font class="comment">// remove from the update list</font> +00473 mixer->unregisterUpdate(<font class="keyword">this</font>); +00474 } +00475 <font class="keywordflow">else</font> +00476 { +00477 <font class="comment">// do the xfade</font> +00478 <font class="keywordflow">if</font> (_Source1) +00479 { +00480 <font class="comment">// lower the sound 1.</font> +00481 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->setRelativeGain(<font class="keywordtype">float</font>(1.0 - <a class="code" href="classNLSOUND_1_1CComplexSource.html#o7">_FadeFactor</a>) * <a class="code" href="classNLSOUND_1_1CSourceCommon.html#n6">_Gain</a>); +00482 +00483 } +00484 <font class="keywordflow">if</font> (_Source2) +00485 { +00486 <font class="comment">// lower the sound 1.</font> +00487 <font class="comment">// _Source2->setRelativeGain(float(sqrt(_FadeFactor)) * _Gain);</font> +00488 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a>->setRelativeGain(<font class="keywordtype">float</font>(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o7">_FadeFactor</a>) * <a class="code" href="classNLSOUND_1_1CSourceCommon.html#n6">_Gain</a>); +00489 } +00490 } +00491 } +<a name="l00493"></a><a class="code" href="classNLSOUND_1_1CComplexSource.html#c2">00493</a> <font class="keywordtype">void</font> CComplexSource::onEvent() +00494 { +00495 CAudioMixerUser *mixer = CAudioMixerUser::instance(); +00496 NLMISC::TTime now = <a class="code" href="classNLMISC_1_1CTime.html#d1">NLMISC::CTime::getLocalTime</a>(); +00497 +00498 <font class="keywordflow">switch</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getPatternMode()) +00499 { +00500 <font class="keywordflow">case</font> CComplexSound::MODE_CHAINED: +00501 { +00502 <font class="comment">// either it's time to begin a new xfade, or to end this sound.</font> +00503 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a> != NULL) +00504 { +00505 <font class="comment">// start new cross fade.?</font> +00506 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o4">_StartTime2</a> = now; +00507 <font class="comment">// mute the source2</font> +00508 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a>->setRelativeGain(0); +00509 <font class="comment">// start the source 2</font> +00510 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o1">_Source2</a>->play(); +00511 <font class="comment">// register for update.</font> +00512 mixer->registerUpdate(<font class="keyword">this</font>); +00513 } +00514 <font class="keywordflow">else</font> +00515 { +00516 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->doFadeOut()) +00517 { +00518 <font class="comment">// set in update list for fade out.</font> +00519 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o4">_StartTime2</a> = now; +00520 mixer->registerUpdate(<font class="keyword">this</font>); +00521 } +00522 <font class="keywordflow">else</font> +00523 { +00524 <font class="comment">// end the sound.</font> +00525 <font class="comment">// _Source1->stop();</font> +00526 <font class="comment">// mixer->removeSource(_Source1);</font> +00527 <font class="keyword">delete</font> <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>; +00528 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a> = NULL; +00529 <a class="code" href="classNLSOUND_1_1CSourceCommon.html#n1">_Playing</a> = <font class="keyword">false</font>; +00530 } +00531 } +00532 } +00533 <font class="keywordflow">break</font>; +00534 <font class="keywordflow">case</font> CComplexSound::MODE_SPARSE: +00535 { +00536 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a> != NULL) +00537 { +00538 <font class="comment">// _Source1->stop();</font> +00539 <font class="comment">// mixer->removeSource(_Source1);</font> +00540 <font class="keyword">delete</font> <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>; +00541 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a> = NULL; +00542 } +00543 +00544 <font class="keyword">const</font> std::vector<uint32> &delaySeq = <a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getDelaySeq(); +00545 <font class="keyword">const</font> vector<uint32> &soundSeq = <a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getSoundSeq(); +00546 +00547 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSourceCommon.html#n2">_Looping</a> && <a class="code" href="classNLSOUND_1_1CComplexSource.html#o9">_DelaySeqIndex</a> >= delaySeq.size()) +00548 { +00549 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o9">_DelaySeqIndex</a> = 0; +00550 } +00551 +00552 <font class="keywordflow">if</font> (!soundSeq.empty() && !<a class="code" href="classNLSOUND_1_1CComplexSource.html#o10">_LastSparseEvent</a>) +00553 { +00554 <font class="comment">// wrap around sound sequence until there are delays...</font> +00555 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o8">_SoundSeqIndex</a> >= soundSeq.size()) +00556 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o8">_SoundSeqIndex</a> = 0; +00557 +00558 CSound *sound = mixer->getSoundId(<a class="code" href="classNLSOUND_1_1CComplexSource.html#o11">_PatternSound</a>->getSound(soundSeq[<a class="code" href="classNLSOUND_1_1CComplexSource.html#o8">_SoundSeqIndex</a>++])); +00559 +00560 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a> = mixer->createSource(sound, <font class="keyword">false</font>); +00561 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a> == NULL) +00562 { +00563 <a class="code" href="classNLSOUND_1_1CComplexSource.html#z964_1">stop</a>(); +00564 <font class="keywordflow">return</font>; +00565 } +00566 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->setRelativeGain(<a class="code" href="classNLSOUND_1_1CSourceCommon.html#n6">_Gain</a>); +00567 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->setPos(<a class="code" href="classNLSOUND_1_1CSourceCommon.html#n3">_Position</a>); +00568 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o0">_Source1</a>->play(); +00569 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o3">_StartTime1</a> = now; +00570 +00571 <font class="comment">// register event for next sound.</font> +00572 <font class="keywordflow">if</font> (!delaySeq.empty() && <a class="code" href="classNLSOUND_1_1CComplexSource.html#o9">_DelaySeqIndex</a> < delaySeq.size()) +00573 { +00574 <font class="comment">// event for next sound.</font> +00575 mixer->addEvent(<font class="keyword">this</font>, <a class="code" href="memory__common_8h.html#a13">uint64</a>(now + sound->getDuration() + delaySeq[<a class="code" href="classNLSOUND_1_1CComplexSource.html#o9">_DelaySeqIndex</a>++]/<a class="code" href="classNLSOUND_1_1CComplexSource.html#o5">_TickPerSecond</a>)); +00576 } +00577 <font class="keywordflow">else</font> +00578 { +00579 <font class="comment">// event for stop</font> +00580 <a class="code" href="classNLSOUND_1_1CComplexSource.html#o10">_LastSparseEvent</a> = <font class="keyword">true</font>; +00581 mixer->addEvent(<font class="keyword">this</font>, now + sound->getDuration()); +00582 } +00583 } +00584 <font class="keywordflow">else</font> +00585 { +00586 <font class="comment">// this is the event for stop !</font> +00587 <a class="code" href="classNLSOUND_1_1CComplexSource.html#z964_1">stop</a>(); +00588 } +00589 } +00590 <font class="keywordflow">break</font>; +00591 <font class="keywordflow">case</font> CComplexSound::MODE_ALL_IN_ONE: +00592 <font class="comment">// just call the stop method.</font> +00593 <a class="code" href="classNLSOUND_1_1CComplexSource.html#z964_1">stop</a>(); +00594 <font class="keywordflow">break</font>; +00595 <font class="keywordflow">default</font>: +00596 <a class="code" href="debug_8h.html#a6">nlassert</a>(<font class="keyword">false</font>); +00597 } +00598 } +00599 +00600 +00601 +00602 } <font class="comment">// NLSOUND</font> +</pre></div> + +<!-- footer --> +<BR><FONT Size=+5> </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> |