diff options
author | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
commit | 0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch) | |
tree | 2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/a02194.html | |
download | nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip |
Initial commit
Diffstat (limited to 'docs/doxygen/nel/a02194.html')
-rw-r--r-- | docs/doxygen/nel/a02194.html | 1142 |
1 files changed, 1142 insertions, 0 deletions
diff --git a/docs/doxygen/nel/a02194.html b/docs/doxygen/nel/a02194.html new file mode 100644 index 00000000..d3aeb819 --- /dev/null +++ b/docs/doxygen/nel/a02194.html @@ -0,0 +1,1142 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> +<title>NeL: NLSOUND::CAmbiantSource class Reference</title> +<link href="doxygen.css" rel="stylesheet" type="text/css"> +</head><body> +<!-- Generated by Doxygen 1.3.6 --> +<div class="qindex"> <form class="search" action="search.php" method="get"> +<a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a> | <span class="search"><u>S</u>earch for <input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div> +<h1>NLSOUND::CAmbiantSource Class Reference</h1><code>#include <<a class="el" href="a05428.html">ambiant_source.h</a>></code> +<p> +<hr><a name="_details"></a><h2>Detailed Description</h2> +Stereo mix of a envsound, seen as a source (see <a class="el" href="a02457.html">CEnvSoundUser</a>)<p> +Plays a stereo mix made up of two channels for crossfading random ambiant sounds, plus a third channel for random sparse sounds.<p> +<dl compact><dt><b>Author:</b></dt><dd>Olivier Cado <p> +Nevrax France </dd></dl> +<dl compact><dt><b>Date:</b></dt><dd>2001 </dd></dl> + +<p> + +<p> +Definition at line <a class="el" href="a05428.html#l00050">50</a> of file <a class="el" href="a05428.html">ambiant_source.h</a>.<table border=0 cellpadding=0 cellspacing=0> +<tr><td></td></tr> +<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top> </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcea0">CAmbiantSource</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor. <a href="#NLSOUND_1_1CAmbiantSourcea0"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual void </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcea1">enable</a> (bool toplay, float gain)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Enable (play with high priority) and set general gain, or disable (stop and set low priority). <a href="#NLSOUND_1_1CAmbiantSourcea1"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03395.html">CSimpleSource</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcea2">getChannels</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the stereo channels (EDIT). <a href="#NLSOUND_1_1CAmbiantSourcea2"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual void </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcea3">initPos</a> (const <a class="el" href="a03128.html">NLMISC::CVector</a> *posvector)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcea4">setProperties</a> (std::vector< <a class="el" href="a02246.html">TSoundId</a> > &ambiantsounds, std::vector< <a class="el" href="a02246.html">TSoundId</a> > &sparsesounds, <a class="el" href="a04558.html#a11">uint32</a> crossfadeTimeMs=4000, <a class="el" href="a04558.html#a11">uint32</a> sustainTimeMs=16000, <a class="el" href="a04558.html#a11">uint32</a> sparseAvgPeriodMs=30000)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Set properties (EDIT). <a href="#NLSOUND_1_1CAmbiantSourcea4"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual void </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcea5">update</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Update. <a href="#NLSOUND_1_1CAmbiantSourcea5"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcea6">~CAmbiantSource</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Destructor. <a href="#NLSOUND_1_1CAmbiantSourcea6"></a><br><br></td></tr> +<tr><td colspan=2><br><h2>Static Public Member Functions</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcee0">init</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Static init (call at the very beginning). <a href="#NLSOUND_1_1CAmbiantSourcee0"></a><br><br></td></tr> +<tr><td colspan=2><br><h2>Protected Member Functions</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a05378.html#a242">NLMISC::TTime</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourceb0">calcPosInCycle</a> (bool &crossfade, <a class="el" href="a04558.html#a11">uint32</a> &leadchannel)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Calc pos in cycle. <a href="#NLSOUND_1_1CAmbiantSourceb0"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourceb1">calcRandomSparseSoundTime</a> (<a class="el" href="a02246.html">TSoundId</a> currentsparesound)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Calculate the next time a sparse sound plays (set NULL for no current sound). <a href="#NLSOUND_1_1CAmbiantSourceb1"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a02246.html">TSoundId</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourceb2">getRandomSound</a> (const std::vector< <a class="el" href="a02246.html">CSound</a> * > &bank) const </td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Select a random sound in a bank. <a href="#NLSOUND_1_1CAmbiantSourceb2"></a><br><br></td></tr> +<tr><td colspan=2><br><h2>Private Attributes</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>std::vector< <a class="el" href="a02246.html">CSound</a> * > </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer0">_AmbiantSounds</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a04558.html#a11">uint32</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer1">_CrossfadeTime</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a05378.html#a242">NLMISC::TTime</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer2">_NextSparseSoundTime</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer3">_Play</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer4">_RandomSoundChosen</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a04558.html#a11">uint32</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer5">_SparseAvgPeriod</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>std::vector< <a class="el" href="a02246.html">CSound</a> * > </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer6">_SparseSounds</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a05378.html#a242">NLMISC::TTime</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer7">_StartTime</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03395.html">CSimpleSource</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a> [3]</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>float </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer9">_StereoGain</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer10">_Sustain</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a04558.html#a11">uint32</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer11">_SustainTime</a></td></tr> + +</table> +<hr><h2>Constructor & Destructor Documentation</h2> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcea0" doxytag="NLSOUND::CAmbiantSource::CAmbiantSource" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> NLSOUND::CAmbiantSource::CAmbiantSource </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Constructor. +<p> + +<p> +Definition at line <a class="el" href="a05427.html#l00047">47</a> of file <a class="el" href="a05427.html">ambiant_source.cpp</a>. +<p> +References <a class="el" href="a05428.html#l00101">_StereoChannels</a>, <a class="el" href="a05677.html#l00045">AMBIANT_CH1</a>, <a class="el" href="a05677.html#l00046">AMBIANT_CH2</a>, <a class="el" href="a06390.html#l00093">NLSOUND::CSimpleSource::setLooping()</a>, and <a class="el" href="a05981.html#l00100">uint32</a>. +<p> +<div class="fragment"><pre>00047 : <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer3">_Play</a>(<span class="keyword">false</span>), +00048 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer9">_StereoGain</a>(0.0f), +00049 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer10">_Sustain</a>(<span class="keyword">false</span>), +00050 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer4">_RandomSoundChosen</a>(<span class="keyword">false</span>), +00051 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer2">_NextSparseSoundTime</a>(0), +00052 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer1">_CrossfadeTime</a>(4000), +00053 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer11">_SustainTime</a>(8000), +00054 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer5">_SparseAvgPeriod</a>(20000) +00055 { +00056 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[<a class="code" href="a04254.html#a1">AMBIANT_CH1</a>].setLooping( <span class="keyword">true</span> ); +00057 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[<a class="code" href="a04254.html#a2">AMBIANT_CH2</a>].setLooping( <span class="keyword">true</span> ); +00058 <span class="comment">//_StereoChannels[SPARSE_CH].setLooping( false );</span> +00059 +00060 srand( (<a class="code" href="a04558.html#a11">uint32</a>)CTime::getLocalTime() ); +00061 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcea6" doxytag="NLSOUND::CAmbiantSource::~CAmbiantSource" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> NLSOUND::CAmbiantSource::~<a class="el" href="a02194.html">CAmbiantSource</a> </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Destructor. +<p> + +<p> +Definition at line <a class="el" href="a05427.html#l00067">67</a> of file <a class="el" href="a05427.html">ambiant_source.cpp</a>. +<p> +References <a class="el" href="a05428.html#l00101">_StereoChannels</a>, <a class="el" href="a05677.html#l00045">AMBIANT_CH1</a>, <a class="el" href="a05677.html#l00046">AMBIANT_CH2</a>, and <a class="el" href="a05677.html#l00047">SPARSE_CH</a>. +<p> +<div class="fragment"><pre>00068 { +00069 CAudioMixerUser::instance()->removeMySource( &_StereoChannels[AMBIANT_CH1] ); +00070 CAudioMixerUser::instance()->removeMySource( &_StereoChannels[AMBIANT_CH2] ); +00071 CAudioMixerUser::instance()->removeMySource( &_StereoChannels[SPARSE_CH] ); +00072 +00073 <span class="comment">// Delete sounds: now done in CAudioMixerUser::~CAudioMixerUser()</span> +00074 <span class="comment">/*vector<CSound*>::iterator ipsnds;</span> +00075 <span class="comment"> for ( ipsnds=_AmbiantSounds.begin(); ipsnds!=_AmbiantSounds.end(); ++ipsnds )</span> +00076 <span class="comment"> {</span> +00077 <span class="comment"> nldebug( "Deleting ambiant sound" );</span> +00078 <span class="comment"> delete (*ipsnds);</span> +00079 <span class="comment"> }</span> +00080 <span class="comment"> for ( ipsnds=_SparseSounds.begin(); ipsnds!=_SparseSounds.end(); ++ipsnds )</span> +00081 <span class="comment"> {</span> +00082 <span class="comment"> nldebug( "Deleting sparse sound" );</span> +00083 <span class="comment"> delete (*ipsnds);</span> +00084 <span class="comment"> }</span> +00085 <span class="comment"> */</span> +00086 } +</pre></div> </td> + </tr> +</table> +<hr><h2>Member Function Documentation</h2> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourceb0" doxytag="NLSOUND::CAmbiantSource::calcPosInCycle" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> TTime NLSOUND::CAmbiantSource::calcPosInCycle </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">bool & </td> + <td class="mdname" nowrap> <em>crossfade</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a11">uint32</a> & </td> + <td class="mdname" nowrap> <em>leadchannel</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [protected]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Calc pos in cycle. +<p> + +<p> +Definition at line <a class="el" href="a05427.html#l00212">212</a> of file <a class="el" href="a05427.html">ambiant_source.cpp</a>. +<p> +References <a class="el" href="a05428.html#l00114">_CrossfadeTime</a>, <a class="el" href="a05428.html#l00115">_SustainTime</a>, and <a class="el" href="a05981.html#l00100">uint32</a>. +<p> +Referenced by <a class="el" href="a05427.html#l00130">enable()</a>, and <a class="el" href="a05427.html#l00239">update()</a>. +<p> +<div class="fragment"><pre>00213 { +00214 <a class="code" href="a05378.html#a242">TTime</a> pos = CTime::getLocalTime(); +00215 <a class="code" href="a04558.html#a11">uint32</a> cycletime = <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer1">_CrossfadeTime</a> + <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer11">_SustainTime</a>; +00216 pos = pos % (cycletime*2); +00217 +00218 <span class="comment">// Calc which channel will be the lead one</span> +00219 <span class="keywordflow">if</span> ( pos < cycletime ) +00220 { +00221 leadchannel = 0; +00222 } +00223 <span class="keywordflow">else</span> +00224 { +00225 leadchannel = 1; +00226 pos = pos - (cycletime); +00227 } +00228 +00229 <span class="comment">// Calc if the pos is in the first part (crossfade) or in the other part (sustain)</span> +00230 crossfade = ( pos < <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer1">_CrossfadeTime</a> ); +00231 +00232 <span class="keywordflow">return</span> pos; +00233 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourceb1" doxytag="NLSOUND::CAmbiantSource::calcRandomSparseSoundTime" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLSOUND::CAmbiantSource::calcRandomSparseSoundTime </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a02246.html">TSoundId</a> </td> + <td class="mdname1" valign="top" nowrap> <em>currentsparesound</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [protected]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Calculate the next time a sparse sound plays (set NULL for no current sound). +<p> + +<p> +Definition at line <a class="el" href="a05427.html#l00353">353</a> of file <a class="el" href="a05427.html">ambiant_source.cpp</a>. +<p> +References <a class="el" href="a05428.html#l00111">_NextSparseSoundTime</a>, <a class="el" href="a05428.html#l00116">_SparseAvgPeriod</a>, <a class="el" href="a02246.html#NLSOUND_1_1CSounda5">NLSOUND::CSound::getDuration()</a>, <a class="el" href="a05622.html#l00101">nldebug</a>, <a class="el" href="a06630.html#l00069">NLSOUND::TSoundId</a>, <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a05981.html#l00100">uint32</a>. +<p> +Referenced by <a class="el" href="a05427.html#l00130">enable()</a>, and <a class="el" href="a05427.html#l00239">update()</a>. +<p> +<div class="fragment"><pre>00354 { +00355 <a class="code" href="a04558.html#a11">uint32</a> delay = (<a class="code" href="a04558.html#a15">uint</a>)((<span class="keywordtype">float</span>)rand() * (<span class="keywordtype">float</span>)(<a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer5">_SparseAvgPeriod</a>*2) / (<span class="keywordtype">float</span>)RAND_MAX); +00356 +00357 <span class="comment">// Check the next sound will play after the current one</span> +00358 <span class="keywordflow">if</span> ( currentsparesound != NULL ) +00359 { +00360 <a class="code" href="a04558.html#a11">uint32</a> soundlength = currentsparesound->getDuration(); +00361 <span class="keywordflow">if</span> ( delay <= soundlength ) +00362 { +00363 delay = soundlength+1; +00364 } +00365 } +00366 +00367 <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"AM: EnvSound: Next sparse sound will play in %u ms"</span>, delay ); +00368 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer2">_NextSparseSoundTime</a> = CTime::getLocalTime() + delay; +00369 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcea1" doxytag="NLSOUND::CAmbiantSource::enable" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLSOUND::CAmbiantSource::enable </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">bool </td> + <td class="mdname" nowrap> <em>toplay</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>float </td> + <td class="mdname" nowrap> <em>gain</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Enable (play with high priority) and set general gain, or disable (stop and set low priority). +<p> + +<p> +Definition at line <a class="el" href="a05427.html#l00130">130</a> of file <a class="el" href="a05427.html">ambiant_source.cpp</a>. +<p> +References <a class="el" href="a05428.html#l00105">_AmbiantSounds</a>, <a class="el" href="a05428.html#l00098">_Play</a>, <a class="el" href="a05428.html#l00101">_StereoChannels</a>, <a class="el" href="a05428.html#l00102">_StereoGain</a>, <a class="el" href="a05677.html#l00045">AMBIANT_CH1</a>, <a class="el" href="a05427.html#l00212">calcPosInCycle()</a>, <a class="el" href="a05427.html#l00353">calcRandomSparseSoundTime()</a>, <a class="el" href="a06391.html#l00069">NLSOUND::CSimpleSource::getSound()</a>, <a class="el" href="a05381.html#a82a65">NLSOUND::HighPri</a>, <a class="el" href="a05381.html#a82a67">NLSOUND::LowPri</a>, <a class="el" href="a05622.html#l00101">nldebug</a>, <a class="el" href="a06390.html#l00126">NLSOUND::CSimpleSource::play()</a>, <a class="el" href="a06427.html#l00076">NLSOUND::CSourceCommon::setPriority()</a>, <a class="el" href="a05677.html#l00047">SPARSE_CH</a>, <a class="el" href="a06390.html#l00217">NLSOUND::CSimpleSource::stop()</a>, and <a class="el" href="a05981.html#l00100">uint32</a>. +<p> +<div class="fragment"><pre>00131 { +00132 <span class="comment">// Calc position in cycle</span> +00133 <span class="keywordtype">bool</span> crossfade; +00134 <a class="code" href="a04558.html#a11">uint32</a> leadchannel; +00135 <span class="keywordflow">if</span> ( <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer0">_AmbiantSounds</a>.size() > 1 ) +00136 { +00137 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourceb0">calcPosInCycle</a>( crossfade, leadchannel ); +00138 } +00139 <span class="keywordflow">else</span> +00140 { +00141 crossfade = <span class="keyword">false</span>; +00142 leadchannel = <a class="code" href="a04254.html#a1">AMBIANT_CH1</a>; +00143 } +00144 +00145 <span class="comment">// Enable/disable</span> +00146 <span class="keywordflow">if</span> ( toplay ) +00147 { +00148 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer9">_StereoGain</a> = gain; +00149 +00150 <span class="keywordflow">if</span> ( ! <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer3">_Play</a> ) +00151 { +00152 <span class="comment">// Start lead channel</span> +00153 <span class="keywordflow">if</span> ( <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[leadchannel].getSound() != NULL ) +00154 { +00155 <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"AM: Envsound: Switch on channel %u"</span>, leadchannel ); +00156 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[leadchannel].setPriority( HighPri ) ; +00157 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[leadchannel].play(); +00158 } +00159 +00160 <span class="comment">// If crossfading, start back channel</span> +00161 <span class="keywordflow">if</span> ( crossfade && (<a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[1-leadchannel].getSound() != NULL) ) +00162 { +00163 <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"AM: Envsound: Switch on channel %u"</span>, 1-leadchannel ); +00164 _StereoChannels[1-leadchannel].setPriority( HighPri ) ; +00165 _StereoChannels[1-leadchannel].play(); +00166 } +00167 +00168 <span class="comment">// Calc when the next spare sound will play</span> +00169 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourceb1">calcRandomSparseSoundTime</a>( NULL ); +00170 +00171 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer3">_Play</a> = <span class="keyword">true</span>; +00172 } +00173 <span class="comment">// The SPARSE_CH is added only when needed</span> +00174 } +00175 <span class="keywordflow">else</span> +00176 { +00177 <span class="keywordflow">if</span> ( <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer3">_Play</a> ) +00178 { +00179 <span class="comment">// Stop lead channel</span> +00180 <span class="keywordflow">if</span> ( <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[leadchannel].getSound() != NULL ) +00181 { +00182 <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"AM: Envsound: Switch off channel %u"</span>, leadchannel ); +00183 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[leadchannel].stop(); +00184 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[leadchannel].setPriority( LowPri ); +00185 } +00186 +00187 <span class="comment">// If crossfading, stop back channel</span> +00188 <span class="keywordflow">if</span> ( crossfade && (<a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[1-leadchannel].getSound() != NULL) ) +00189 { +00190 <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"AM: Envsound: Switch off channel %u"</span>, 1-leadchannel ); +00191 _StereoChannels[1-leadchannel].stop(); +00192 _StereoChannels[1-leadchannel].setPriority( LowPri ); +00193 } +00194 +00195 <span class="comment">// Stop spare channel, anyway</span> +00196 <span class="keywordflow">if</span> ( _StereoChannels[<a class="code" href="a04254.html#a3">SPARSE_CH</a>].getSound() != NULL ) +00197 { +00198 <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"AM: Envsound: Switch off sparse channel"</span> ); +00199 _StereoChannels[<a class="code" href="a04254.html#a3">SPARSE_CH</a>].stop(); +00200 _StereoChannels[<a class="code" href="a04254.html#a3">SPARSE_CH</a>].setPriority( LowPri ); +00201 } +00202 +00203 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer3">_Play</a> = <span class="keyword">false</span>; +00204 } +00205 } +00206 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcea2" doxytag="NLSOUND::CAmbiantSource::getChannels" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a03395.html">CSimpleSource</a>* NLSOUND::CAmbiantSource::getChannels </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [inline]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Return the stereo channels (EDIT). +<p> + +<p> +Definition at line <a class="el" href="a05428.html#l00079">79</a> of file <a class="el" href="a05428.html">ambiant_source.h</a>. +<p> +References <a class="el" href="a05428.html#l00101">_StereoChannels</a>. +<p> +<div class="fragment"><pre>00079 { <span class="keywordflow">return</span> <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>; } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourceb2" doxytag="NLSOUND::CAmbiantSource::getRandomSound" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a02246.html">TSoundId</a> NLSOUND::CAmbiantSource::getRandomSound </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::vector< <a class="el" href="a02246.html">CSound</a> * > & </td> + <td class="mdname1" valign="top" nowrap> <em>bank</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap> const<code> [protected]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Select a random sound in a bank. +<p> + +<p> +Definition at line <a class="el" href="a05427.html#l00336">336</a> of file <a class="el" href="a05427.html">ambiant_source.cpp</a>. +<p> +References <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05622.html#l00101">nldebug</a>, <a class="el" href="a05646.html#l00993">r</a>, <a class="el" href="a06630.html#l00069">NLSOUND::TSoundId</a>, and <a class="el" href="a05981.html#l00100">uint32</a>. +<p> +Referenced by <a class="el" href="a05427.html#l00092">initPos()</a>, and <a class="el" href="a05427.html#l00239">update()</a>. +<p> +<div class="fragment"><pre>00337 { +00338 <a class="code" href="a04199.html#a6">nlassert</a>( ! bank.empty() ); +00339 <span class="comment">// Note: does not work with a very big size (rand()*bank.size() would overflow)</span> +00340 <a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a628">r</a> = rand()*bank.size()/(RAND_MAX+1); +00341 <a class="code" href="a04199.html#a6">nlassert</a>( r < bank.size() ); +00342 <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"AM: EnvSound: Prepared random sound number %u of %u"</span>, r, bank.size()-1 ); +00343 +00344 <span class="keywordflow">return</span> bank[<a class="code" href="a04223.html#a628">r</a>]; +00345 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcee0" doxytag="NLSOUND::CAmbiantSource::init" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLSOUND::CAmbiantSource::init </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">void </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [inline, static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Static init (call at the very beginning). +<p> + +<p> +Definition at line <a class="el" href="a05428.html#l00059">59</a> of file <a class="el" href="a05428.html">ambiant_source.h</a>. +<p> +<div class="fragment"><pre>00060 { +00061 <span class="comment">//NLMISC_REGISTER_CLASS(CAmbiantSource); </span> +00062 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcea3" doxytag="NLSOUND::CAmbiantSource::initPos" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLSOUND::CAmbiantSource::initPos </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const <a class="el" href="a03128.html">NLMISC::CVector</a> * </td> + <td class="mdname1" valign="top" nowrap> <em>posvector</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Init. You can pass a position vector to link to (if the playable has stereo source(s)) When reading from a stream, call <a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcee0">init()</a> *after* serial(). +<p> +Definition at line <a class="el" href="a05427.html#l00092">92</a> of file <a class="el" href="a05427.html">ambiant_source.cpp</a>. +<p> +References <a class="el" href="a05428.html#l00105">_AmbiantSounds</a>, <a class="el" href="a05428.html#l00105">_SparseSounds</a>, <a class="el" href="a05428.html#l00101">_StereoChannels</a>, <a class="el" href="a05677.html#l00045">AMBIANT_CH1</a>, <a class="el" href="a05677.html#l00046">AMBIANT_CH2</a>, <a class="el" href="a05427.html#l00336">getRandomSound()</a>, <a class="el" href="a05381.html#a82a67">NLSOUND::LowPri</a>, <a class="el" href="a06428.html#l00088">NLSOUND::CSourceCommon::set3DPositionVector()</a>, <a class="el" href="a06390.html#l00326">NLSOUND::CSimpleSource::setGain()</a>, <a class="el" href="a06427.html#l00076">NLSOUND::CSourceCommon::setPriority()</a>, and <a class="el" href="a05677.html#l00047">SPARSE_CH</a>. +<p> +<div class="fragment"><pre>00093 { +00094 <span class="comment">// Initialize ambiant sound channels</span> +00095 <span class="keywordflow">if</span> ( ! <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer0">_AmbiantSounds</a>.empty() ) +00096 { +00097 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[<a class="code" href="a04254.html#a1">AMBIANT_CH1</a>].set3DPositionVector( posvector ); +00098 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[<a class="code" href="a04254.html#a1">AMBIANT_CH1</a>].setSound( <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourceb2">getRandomSound</a>( _AmbiantSounds ) ); +00099 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[<a class="code" href="a04254.html#a1">AMBIANT_CH1</a>].setGain( 0.0f ); +00100 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[<a class="code" href="a04254.html#a1">AMBIANT_CH1</a>].setPriority( LowPri); +00101 CAudioMixerUser::instance()->addSource( &_StereoChannels[AMBIANT_CH1] ); +00102 CAudioMixerUser::instance()->giveTrack( &_StereoChannels[AMBIANT_CH1] ); +00103 +00104 <span class="keywordflow">if</span> ( <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer0">_AmbiantSounds</a>.size() > 1 ) +00105 { +00106 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[<a class="code" href="a04254.html#a2">AMBIANT_CH2</a>].set3DPositionVector( posvector ); +00107 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[<a class="code" href="a04254.html#a2">AMBIANT_CH2</a>].setSound( <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourceb2">getRandomSound</a>( _AmbiantSounds ) ); +00108 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[<a class="code" href="a04254.html#a2">AMBIANT_CH2</a>].setGain( 0.0f ); +00109 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[<a class="code" href="a04254.html#a2">AMBIANT_CH2</a>].setPriority( LowPri); +00110 CAudioMixerUser::instance()->addSource( &_StereoChannels[AMBIANT_CH2] ); +00111 CAudioMixerUser::instance()->giveTrack( &_StereoChannels[AMBIANT_CH2] ); +00112 } +00113 } +00114 +00115 <span class="comment">// Initialize sparse sounds channel</span> +00116 <span class="keywordflow">if</span> ( ! <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer6">_SparseSounds</a>.empty() ) +00117 { +00118 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[<a class="code" href="a04254.html#a3">SPARSE_CH</a>].set3DPositionVector( posvector ); +00119 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[<a class="code" href="a04254.html#a3">SPARSE_CH</a>].setPriority( LowPri ); +00120 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[<a class="code" href="a04254.html#a3">SPARSE_CH</a>].setSound( <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourceb2">getRandomSound</a>( _SparseSounds ) ); +00121 CAudioMixerUser::instance()->addSource( &_StereoChannels[SPARSE_CH] ); +00122 CAudioMixerUser::instance()->giveTrack( &_StereoChannels[SPARSE_CH] ); +00123 } +00124 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcea4" doxytag="NLSOUND::CAmbiantSource::setProperties" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLSOUND::CAmbiantSource::setProperties </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">std::vector< <a class="el" href="a02246.html">TSoundId</a> > & </td> + <td class="mdname" nowrap> <em>ambiantsounds</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>std::vector< <a class="el" href="a02246.html">TSoundId</a> > & </td> + <td class="mdname" nowrap> <em>sparsesounds</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a11">uint32</a> </td> + <td class="mdname" nowrap> <em>crossfadeTimeMs</em> = 4000, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a11">uint32</a> </td> + <td class="mdname" nowrap> <em>sustainTimeMs</em> = 16000, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a11">uint32</a> </td> + <td class="mdname" nowrap> <em>sparseAvgPeriodMs</em> = 30000</td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Set properties (EDIT). +<p> + +<p> +Definition at line <a class="el" href="a05427.html#l00406">406</a> of file <a class="el" href="a05427.html">ambiant_source.cpp</a>. +<p> +References <a class="el" href="a05428.html#l00105">_AmbiantSounds</a>, <a class="el" href="a05428.html#l00114">_CrossfadeTime</a>, <a class="el" href="a05428.html#l00116">_SparseAvgPeriod</a>, <a class="el" href="a05428.html#l00105">_SparseSounds</a>, <a class="el" href="a05428.html#l00115">_SustainTime</a>, and <a class="el" href="a05981.html#l00100">uint32</a>. +<p> +<div class="fragment"><pre>00410 { +00411 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer0">_AmbiantSounds</a> = ambiantsounds; +00412 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer6">_SparseSounds</a> = sparsesounds; +00413 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer1">_CrossfadeTime</a> = crossfadeTimeMs; +00414 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer11">_SustainTime</a> = sustainTimeMs; +00415 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer5">_SparseAvgPeriod</a> = sparseAvgPeriodMs; +00416 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcea5" doxytag="NLSOUND::CAmbiantSource::update" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLSOUND::CAmbiantSource::update </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Update. +<p> + +<p> +Definition at line <a class="el" href="a05427.html#l00239">239</a> of file <a class="el" href="a05427.html">ambiant_source.cpp</a>. +<p> +References <a class="el" href="a05428.html#l00105">_AmbiantSounds</a>, <a class="el" href="a05428.html#l00114">_CrossfadeTime</a>, <a class="el" href="a05428.html#l00111">_NextSparseSoundTime</a>, <a class="el" href="a05428.html#l00098">_Play</a>, <a class="el" href="a05428.html#l00105">_SparseSounds</a>, <a class="el" href="a05428.html#l00101">_StereoChannels</a>, <a class="el" href="a05428.html#l00102">_StereoGain</a>, <a class="el" href="a05428.html#l00109">_Sustain</a>, <a class="el" href="a05677.html#l00045">AMBIANT_CH1</a>, <a class="el" href="a05427.html#l00212">calcPosInCycle()</a>, <a class="el" href="a05427.html#l00353">calcRandomSparseSoundTime()</a>, <a class="el" href="a05427.html#l00336">getRandomSound()</a>, <a class="el" href="a06391.html#l00069">NLSOUND::CSimpleSource::getSound()</a>, <a class="el" href="a06391.html#l00129">NLSOUND::CSimpleSource::getTrack()</a>, <a class="el" href="a05381.html#a82a65">NLSOUND::HighPri</a>, <a class="el" href="a05381.html#a82a66">NLSOUND::MidPri</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05622.html#l00101">nldebug</a>, <a class="el" href="a06390.html#l00126">NLSOUND::CSimpleSource::play()</a>, <a class="el" href="a06427.html#l00076">NLSOUND::CSourceCommon::setPriority()</a>, <a class="el" href="a06390.html#l00337">NLSOUND::CSimpleSource::setRelativeGain()</a>, <a class="el" href="a05677.html#l00047">SPARSE_CH</a>, <a class="el" href="a06390.html#l00217">NLSOUND::CSimpleSource::stop()</a>, <a class="el" href="a06630.html#l00069">NLSOUND::TSoundId</a>, and <a class="el" href="a05981.html#l00100">uint32</a>. +<p> +<div class="fragment"><pre>00240 { +00241 <span class="keywordflow">if</span> ( (!<a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer3">_Play</a>) || (<a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer9">_StereoGain</a>==0.0f) ) +00242 { +00243 <span class="keywordflow">return</span>; +00244 } +00245 +00246 <span class="comment">// Calc pos in cycle</span> +00247 <span class="keywordtype">bool</span> crossfade; +00248 <a class="code" href="a04558.html#a11">uint32</a> leadchannel, backchannel=0; +00249 <a class="code" href="a05378.html#a242">TTime</a> posInCycle=0; +00250 <span class="keywordflow">if</span> ( <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer0">_AmbiantSounds</a>.size() > 1 ) +00251 { +00252 posInCycle = <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourceb0">calcPosInCycle</a>( crossfade, leadchannel ); +00253 backchannel = 1 - leadchannel; +00254 } +00255 <span class="keywordflow">else</span> +00256 { +00257 <span class="comment">// If there is less than 2 sounds, no crossfade, always sustain (a single sound must be looping)</span> +00258 crossfade = <span class="keyword">false</span>; +00259 leadchannel = <a class="code" href="a04254.html#a1">AMBIANT_CH1</a>; +00260 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer10">_Sustain</a> = <span class="keyword">true</span>; +00261 } +00262 +00263 <span class="comment">// Crossfade the first two sources</span> +00264 <span class="keywordflow">if</span> ( crossfade ) +00265 { +00266 <span class="comment">// Attack</span> +00267 <span class="keywordtype">float</span> ratio = (<span class="keywordtype">float</span>)posInCycle / (<span class="keywordtype">float</span>)<a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer1">_CrossfadeTime</a>; +00268 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[leadchannel].setRelativeGain( ratio*_StereoGain ); +00269 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[backchannel].setRelativeGain( (1.0f - ratio)*_StereoGain ); +00270 +00271 <span class="comment">// Start next sound</span> +00272 <span class="keywordflow">if</span> ( <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer10">_Sustain</a> ) +00273 { +00274 <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"AM: EnvSound: Beginning crossfade: channel #%u rising"</span>, leadchannel ); +00275 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[leadchannel].setPriority( HighPri ) ; +00276 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[leadchannel].play(); +00277 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer10">_Sustain</a> = <span class="keyword">false</span>; +00278 } +00279 } +00280 <span class="keywordflow">else</span> +00281 { +00282 <span class="comment">// Set sustain gain (takes into account the possible changes to _StereoGain)</span> +00283 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[leadchannel].setRelativeGain( _StereoGain ); +00284 +00285 <span class="comment">// Prepare next ambiant sound</span> +00286 <span class="keywordflow">if</span> ( ! <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer10">_Sustain</a> ) +00287 { +00288 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer10">_Sustain</a> = <span class="keyword">true</span>; +00289 <a class="code" href="a05381.html#a62">TSoundId</a> nextsound = <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourceb2">getRandomSound</a>( _AmbiantSounds ); +00290 <span class="preprocessor">#ifdef ENVSOUND_DONT_DUPLICATE_AMBIANT</span> +00291 <span class="preprocessor"></span> <a class="code" href="a04199.html#a6">nlassert</a>( <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer0">_AmbiantSounds</a>.size() > 1 ); <span class="comment">// or infinite loop</span> +00292 <span class="keywordflow">while</span> ( nextsound == <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[leadchannel].getSound() ) +00293 { +00294 <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"AM: EnvSound: Avoiding ambiant sound duplication..."</span> ); +00295 nextsound = <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourceb2">getRandomSound</a>( _AmbiantSounds ); +00296 } +00297 <span class="preprocessor">#endif</span> +00298 <span class="preprocessor"></span> <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"AM: EnvSound: Sustain: channel #1"</span> ); +00299 _StereoChannels[backchannel].setRelativeGain( 0.0f ); +00300 _StereoChannels[backchannel].stop(); <span class="comment">// we don't set the priority to LowPri</span> +00301 _StereoChannels[backchannel].setSound( nextsound ); +00302 } +00303 } +00304 +00305 <span class="comment">// Add a short random sound into the third source</span> +00306 <span class="keywordflow">if</span> ( ! <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer6">_SparseSounds</a>.empty() ) +00307 { +00308 <span class="comment">// Set sustain gain (takes into account the possible changes to _StereoGain)</span> +00309 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[<a class="code" href="a04254.html#a3">SPARSE_CH</a>].setRelativeGain( _StereoGain ); +00310 +00311 <span class="comment">// Start next sparse sound</span> +00312 <a class="code" href="a05378.html#a242">TTime</a> now = CTime::getLocalTime(); +00313 <span class="keywordflow">if</span> ( now > <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer2">_NextSparseSoundTime</a> ) +00314 { +00315 <a class="code" href="a05381.html#a62">TSoundId</a> nextsound = <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourceb2">getRandomSound</a>( _SparseSounds ); +00316 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[<a class="code" href="a04254.html#a3">SPARSE_CH</a>].stop(); +00317 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[<a class="code" href="a04254.html#a3">SPARSE_CH</a>].setSound( nextsound ); +00318 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[<a class="code" href="a04254.html#a3">SPARSE_CH</a>].setPriority( MidPri ); +00319 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[<a class="code" href="a04254.html#a3">SPARSE_CH</a>].play(); +00320 <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"AM: EnvSound: Playing sparse sound"</span> ); +00321 <span class="keywordflow">if</span> ( <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">_StereoChannels</a>[<a class="code" href="a04254.html#a3">SPARSE_CH</a>].getTrack() == NULL ) +00322 { +00323 <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"AM: Ensound: Switch on sparse channel"</span> ); +00324 <a class="code" href="a04199.html#a6">nlassert</a>( _StereoChannels[SPARSE_CH].getSound() != NULL ); +00325 } +00326 <span class="comment">// Does not leave the track</span> +00327 <a class="code" href="a02194.html#NLSOUND_1_1CAmbiantSourceb1">calcRandomSparseSoundTime</a>( nextsound ); +00328 } +00329 } +00330 } +</pre></div> </td> + </tr> +</table> +<hr><h2>Field Documentation</h2> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcer0" doxytag="NLSOUND::CAmbiantSource::_AmbiantSounds" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> std::vector<<a class="el" href="a02246.html">CSound</a>*> <a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer0">NLSOUND::CAmbiantSource::_AmbiantSounds</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05428.html#l00105">105</a> of file <a class="el" href="a05428.html">ambiant_source.h</a>. +<p> +Referenced by <a class="el" href="a05427.html#l00130">enable()</a>, <a class="el" href="a05427.html#l00092">initPos()</a>, <a class="el" href="a05427.html#l00406">setProperties()</a>, and <a class="el" href="a05427.html#l00239">update()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcer1" doxytag="NLSOUND::CAmbiantSource::_CrossfadeTime" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a04558.html#a11">uint32</a> <a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer1">NLSOUND::CAmbiantSource::_CrossfadeTime</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05428.html#l00114">114</a> of file <a class="el" href="a05428.html">ambiant_source.h</a>. +<p> +Referenced by <a class="el" href="a05427.html#l00212">calcPosInCycle()</a>, <a class="el" href="a05427.html#l00406">setProperties()</a>, and <a class="el" href="a05427.html#l00239">update()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcer2" doxytag="NLSOUND::CAmbiantSource::_NextSparseSoundTime" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a05378.html#a242">NLMISC::TTime</a> <a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer2">NLSOUND::CAmbiantSource::_NextSparseSoundTime</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05428.html#l00111">111</a> of file <a class="el" href="a05428.html">ambiant_source.h</a>. +<p> +Referenced by <a class="el" href="a05427.html#l00353">calcRandomSparseSoundTime()</a>, and <a class="el" href="a05427.html#l00239">update()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcer3" doxytag="NLSOUND::CAmbiantSource::_Play" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool <a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer3">NLSOUND::CAmbiantSource::_Play</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05428.html#l00098">98</a> of file <a class="el" href="a05428.html">ambiant_source.h</a>. +<p> +Referenced by <a class="el" href="a05427.html#l00130">enable()</a>, and <a class="el" href="a05427.html#l00239">update()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcer4" doxytag="NLSOUND::CAmbiantSource::_RandomSoundChosen" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool <a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer4">NLSOUND::CAmbiantSource::_RandomSoundChosen</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05428.html#l00110">110</a> of file <a class="el" href="a05428.html">ambiant_source.h</a>. </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcer5" doxytag="NLSOUND::CAmbiantSource::_SparseAvgPeriod" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a04558.html#a11">uint32</a> <a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer5">NLSOUND::CAmbiantSource::_SparseAvgPeriod</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05428.html#l00116">116</a> of file <a class="el" href="a05428.html">ambiant_source.h</a>. +<p> +Referenced by <a class="el" href="a05427.html#l00353">calcRandomSparseSoundTime()</a>, and <a class="el" href="a05427.html#l00406">setProperties()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcer6" doxytag="NLSOUND::CAmbiantSource::_SparseSounds" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> std::vector<<a class="el" href="a02246.html">CSound</a>*> <a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer6">NLSOUND::CAmbiantSource::_SparseSounds</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05428.html#l00105">105</a> of file <a class="el" href="a05428.html">ambiant_source.h</a>. +<p> +Referenced by <a class="el" href="a05427.html#l00092">initPos()</a>, <a class="el" href="a05427.html#l00406">setProperties()</a>, and <a class="el" href="a05427.html#l00239">update()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcer7" doxytag="NLSOUND::CAmbiantSource::_StartTime" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a05378.html#a242">NLMISC::TTime</a> <a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer7">NLSOUND::CAmbiantSource::_StartTime</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05428.html#l00108">108</a> of file <a class="el" href="a05428.html">ambiant_source.h</a>. </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcer8" doxytag="NLSOUND::CAmbiantSource::_StereoChannels" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a03395.html">CSimpleSource</a> <a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer8">NLSOUND::CAmbiantSource::_StereoChannels</a>[ 3 ]<code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05428.html#l00101">101</a> of file <a class="el" href="a05428.html">ambiant_source.h</a>. +<p> +Referenced by <a class="el" href="a05427.html#l00047">CAmbiantSource()</a>, <a class="el" href="a05427.html#l00130">enable()</a>, <a class="el" href="a05428.html#l00079">getChannels()</a>, <a class="el" href="a05427.html#l00092">initPos()</a>, <a class="el" href="a05427.html#l00239">update()</a>, and <a class="el" href="a05427.html#l00067">~CAmbiantSource()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcer9" doxytag="NLSOUND::CAmbiantSource::_StereoGain" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> float <a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer9">NLSOUND::CAmbiantSource::_StereoGain</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05428.html#l00102">102</a> of file <a class="el" href="a05428.html">ambiant_source.h</a>. +<p> +Referenced by <a class="el" href="a05427.html#l00130">enable()</a>, and <a class="el" href="a05427.html#l00239">update()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcer10" doxytag="NLSOUND::CAmbiantSource::_Sustain" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool <a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer10">NLSOUND::CAmbiantSource::_Sustain</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05428.html#l00109">109</a> of file <a class="el" href="a05428.html">ambiant_source.h</a>. +<p> +Referenced by <a class="el" href="a05427.html#l00239">update()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLSOUND_1_1CAmbiantSourcer11" doxytag="NLSOUND::CAmbiantSource::_SustainTime" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a04558.html#a11">uint32</a> <a class="el" href="a02194.html#NLSOUND_1_1CAmbiantSourcer11">NLSOUND::CAmbiantSource::_SustainTime</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05428.html#l00115">115</a> of file <a class="el" href="a05428.html">ambiant_source.h</a>. +<p> +Referenced by <a class="el" href="a05427.html#l00212">calcPosInCycle()</a>, and <a class="el" href="a05427.html#l00406">setProperties()</a>. </td> + </tr> +</table> +<hr>The documentation for this class was generated from the following files:<ul> +<li><a class="el" href="a05428.html">ambiant_source.h</a><li><a class="el" href="a05427.html">ambiant_source.cpp</a></ul> +<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 14:28:05 2004 for NeL by +<a href="http://www.doxygen.org/index.html"> +<img src="doxygen.png" alt="doxygen" align="middle" border=0 > +</a>1.3.6 </small></address> +</body> +</html> |