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/sound_8cpp-source.html | |
download | nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip |
Initial commit
Diffstat (limited to '')
-rw-r--r-- | docs/doxygen/nel/sound_8cpp-source.html | 273 |
1 files changed, 273 insertions, 0 deletions
diff --git a/docs/doxygen/nel/sound_8cpp-source.html b/docs/doxygen/nel/sound_8cpp-source.html new file mode 100644 index 00000000..f144b0af --- /dev/null +++ b/docs/doxygen/nel/sound_8cpp-source.html @@ -0,0 +1,273 @@ +<!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>sound.cpp</h1><a href="sound_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="sound_8h.html">sound.h</a>"</font> +00029 <font class="preprocessor">#include "<a class="code" href="path_8h.html">nel/misc/path.h</a>"</font> +00030 <font class="preprocessor">#include "<a class="code" href="sound__bank_8h.html">sound_bank.h</a>"</font> +00031 +00032 <font class="preprocessor">#include "<a class="code" href="simple__sound_8h.html">simple_sound.h</a>"</font> +00033 <font class="preprocessor">#include "<a class="code" href="complex__sound_8h.html">complex_sound.h</a>"</font> +00034 <font class="preprocessor">#include "<a class="code" href="context__sound_8h.html">context_sound.h</a>"</font> +00035 +00036 <font class="keyword">using</font> <font class="keyword">namespace </font>std; +00037 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC; +00038 +00039 +00040 <font class="keyword">namespace </font>NLSOUND { +00041 +<a name="l00042"></a><a class="code" href="classNLSOUND_1_1CSound.html#d0">00042</a> CSound *CSound::createSound(<font class="keyword">const</font> std::string &filename, <a class="code" href="classNLGEORGES_1_1UFormElm.html">NLGEORGES::UFormElm</a>& formRoot) +00043 { +00044 <a class="code" href="classNLSOUND_1_1CSound.html#a0">CSound</a> *ret = NULL; +00045 string soundType; +00046 +00047 <a class="code" href="classNLGEORGES_1_1UFormElm.html">NLGEORGES::UFormElm</a> *psoundType; +00048 +00049 <font class="keywordflow">if</font> (!formRoot.<a class="code" href="classNLGEORGES_1_1UFormElm.html#a0">getNodeByName</a>(&psoundType, <font class="stringliteral">".SoundType"</font>)) +00050 { +00051 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"No SoundType in : %s"</font>, filename.c_str()); +00052 <font class="keywordflow">return</font> 0; +00053 } +00054 +00055 <font class="keywordflow">if</font> (psoundType != NULL) +00056 { +00057 std::string dfnName; +00058 psoundType-><a class="code" href="classNLGEORGES_1_1UFormElm.html#a42">getDfnName</a>(dfnName); +00059 +00060 <font class="keywordflow">if</font> (dfnName == <font class="stringliteral">"simple_sound.dfn"</font>) +00061 { +00062 ret = <font class="keyword">new</font> CSimpleSound(); +00063 ret->importForm(filename, formRoot); +00064 } +00065 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (dfnName == <font class="stringliteral">"complex_sound.dfn"</font>) +00066 { +00067 ret = <font class="keyword">new</font> CComplexSound(); +00068 ret->importForm(filename, formRoot); +00069 } +00070 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (dfnName == <font class="stringliteral">"background_sound.dfn"</font>) +00071 { +00072 ret = <font class="keyword">new</font> CBackgroundSound(); +00073 ret->importForm(filename, formRoot); +00074 } +00075 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (dfnName == <font class="stringliteral">"context_sound.dfn"</font>) +00076 { +00077 ret = <font class="keyword">new</font> CContextSound(); +00078 ret->importForm(filename, formRoot); +00079 } +00080 <font class="keywordflow">else</font> +00081 { +00082 <a class="code" href="debug_8h.html#a8">nlassertex</a>(<font class="keyword">false</font>, (<font class="stringliteral">"SoundType unsuported : %s"</font>, dfnName.c_str())); +00083 } +00084 +00085 } +00086 +00087 <font class="keywordflow">return</font> ret; +00088 } +00089 +00090 +00091 +00092 <font class="comment">/*</font> +00093 <font class="comment"> * Constructor</font> +00094 <font class="comment"> */</font> +<a name="l00095"></a><a class="code" href="classNLSOUND_1_1CSound.html#a0">00095</a> CSound::CSound() : +00096 _Gain(1.0f), +00097 _Pitch(1.0f), +00098 _MaxDist(1000000.0f), +00099 _Priority(<a class="code" href="namespaceNLSOUND.html#a82a12">MidPri</a>), +00100 _Looping(false), +00101 _ConeInnerAngle(6.283185f), +00102 _ConeOuterAngle(6.283185f), +00103 _ConeOuterGain( 1.0f ) +00104 { +00105 } +00106 +<a name="l00107"></a><a class="code" href="classNLSOUND_1_1CSound.html#a1">00107</a> CSound::~CSound() +00108 {} +00109 +00110 +<a name="l00111"></a><a class="code" href="classNLSOUND_1_1CSound.html#a18">00111</a> <font class="keywordtype">void</font> CSound::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>) +00112 { +00113 s.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNLSOUND_1_1CSound.html#n0">_Gain</a>); +00114 s.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNLSOUND_1_1CSound.html#n1">_Pitch</a>); +00115 s.<a class="code" href="classNLMISC_1_1IStream.html#a6">serialEnum</a>(<a class="code" href="classNLSOUND_1_1CSound.html#n2">_Priority</a>); +00116 s.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNLSOUND_1_1CSound.html#n3">_ConeInnerAngle</a>, <a class="code" href="classNLSOUND_1_1CSound.html#n4">_ConeOuterAngle</a>, <a class="code" href="classNLSOUND_1_1CSound.html#n5">_ConeOuterGain</a>); +00117 s.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNLSOUND_1_1CSound.html#n6">_Direction</a>); +00118 s.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNLSOUND_1_1CSound.html#n7">_Looping</a>); +00119 s.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNLSOUND_1_1CSound.html#n8">_MaxDist</a>); +00120 s.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNLSOUND_1_1CSound.html#n9">_Name</a>); +00121 } +00122 +00123 +<a name="l00127"></a><a class="code" href="classNLSOUND_1_1CSound.html#a3">00127</a> <font class="keywordtype">void</font> CSound::importForm(<font class="keyword">const</font> std::string& filename, <a class="code" href="classNLGEORGES_1_1UFormElm.html">NLGEORGES::UFormElm</a>& root) +00128 { +00129 <font class="comment">// Name</font> +00130 <a class="code" href="classNLSOUND_1_1CSound.html#n9">_Name</a> = CFile::getFilenameWithoutExtension(filename); +00131 +00132 <font class="comment">// InternalConeAngle</font> +00133 uint32 inner; +00134 root.<a class="code" href="classNLGEORGES_1_1UFormElm.html#a2">getValueByName</a>(inner, <font class="stringliteral">".InternalConeAngle"</font>); +00135 <font class="keywordflow">if</font> (inner > 360) +00136 { +00137 inner = 360; +00138 } +00139 <a class="code" href="classNLSOUND_1_1CSound.html#n3">_ConeInnerAngle</a> = (float) (<a class="code" href="namespaceNLMISC.html#a7">Pi</a> * inner / 180.0f); <font class="comment">// convert to radians</font> +00140 +00141 <font class="comment">// ExternalConeAngle</font> +00142 uint32 outer; +00143 root.<a class="code" href="classNLGEORGES_1_1UFormElm.html#a2">getValueByName</a>(outer, <font class="stringliteral">".ExternalConeAngle"</font>); +00144 <font class="keywordflow">if</font> (outer > 360) +00145 { +00146 outer = 360; +00147 } +00148 <a class="code" href="classNLSOUND_1_1CSound.html#n4">_ConeOuterAngle</a>= (float) (<a class="code" href="namespaceNLMISC.html#a7">Pi</a> * outer / 180.0f); <font class="comment">// convert to radians</font> +00149 +00150 <font class="comment">// Loop</font> +00151 root.<a class="code" href="classNLGEORGES_1_1UFormElm.html#a2">getValueByName</a>(<a class="code" href="classNLSOUND_1_1CSound.html#n7">_Looping</a>, <font class="stringliteral">".Loop"</font>); +00152 +00153 <font class="comment">// Gain</font> +00154 sint32 gain; +00155 root.<a class="code" href="classNLGEORGES_1_1UFormElm.html#a2">getValueByName</a>(gain, <font class="stringliteral">".Gain"</font>); +00156 <font class="keywordflow">if</font> (gain > 0) +00157 { +00158 gain = 0; +00159 } +00160 <font class="keywordflow">if</font> (gain < -100) +00161 { +00162 gain = -100; +00163 } +00164 <a class="code" href="classNLSOUND_1_1CSound.html#n0">_Gain</a> = (float) pow(10.0, gain / 20.0); <font class="comment">// convert dB to linear gain</font> +00165 +00166 <font class="comment">// External gain</font> +00167 root.<a class="code" href="classNLGEORGES_1_1UFormElm.html#a2">getValueByName</a>(gain, <font class="stringliteral">".ExternalGain"</font>); +00168 <font class="keywordflow">if</font> (gain > 0) +00169 { +00170 gain = 0; +00171 } +00172 <font class="keywordflow">if</font> (gain < -100) +00173 { +00174 gain = -100; +00175 } +00176 <a class="code" href="classNLSOUND_1_1CSound.html#n5">_ConeOuterGain</a> = (float) pow(10.0, gain / 20.0); <font class="comment">// convert dB to linear gain</font> +00177 +00178 <font class="comment">// Direction</font> +00179 <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a366">z</a>; +00180 +00181 root.<a class="code" href="classNLGEORGES_1_1UFormElm.html#a2">getValueByName</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <font class="stringliteral">".Direction.X"</font>); +00182 root.<a class="code" href="classNLGEORGES_1_1UFormElm.html#a2">getValueByName</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, <font class="stringliteral">".Direction.Y"</font>); +00183 root.<a class="code" href="classNLGEORGES_1_1UFormElm.html#a2">getValueByName</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a366">z</a>, <font class="stringliteral">".Direction.Z"</font>); +00184 <a class="code" href="classNLSOUND_1_1CSound.html#n6">_Direction</a> = CVector(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a366">z</a>); +00185 +00186 +00187 <font class="comment">// Pitch</font> +00188 sint32 trans; +00189 root.<a class="code" href="classNLGEORGES_1_1UFormElm.html#a2">getValueByName</a>(trans, <font class="stringliteral">".Transpose"</font>); +00190 <a class="code" href="classNLSOUND_1_1CSound.html#n1">_Pitch</a> = (float) pow(<a class="code" href="namespaceNLSOUND.html#a73">Sqrt12_2</a>, trans); <font class="comment">// convert semi-tones to playback speed</font> +00191 +00192 <font class="comment">// Priority</font> +00193 uint32 prio = 0; +00194 root.<a class="code" href="classNLGEORGES_1_1UFormElm.html#a2">getValueByName</a>(prio, <font class="stringliteral">".Priority"</font>); +00195 <font class="keywordflow">switch</font> (prio) +00196 { +00197 <font class="keywordflow">case</font> 0: <a class="code" href="classNLSOUND_1_1CSound.html#n2">_Priority</a> = <a class="code" href="namespaceNLSOUND.html#a82a13">LowPri</a>; <font class="keywordflow">break</font>; +00198 <font class="keywordflow">default</font>: +00199 <font class="keywordflow">case</font> 1: <a class="code" href="classNLSOUND_1_1CSound.html#n2">_Priority</a> = <a class="code" href="namespaceNLSOUND.html#a82a12">MidPri</a>; <font class="keywordflow">break</font>; +00200 <font class="keywordflow">case</font> 2: <a class="code" href="classNLSOUND_1_1CSound.html#n2">_Priority</a> = <a class="code" href="namespaceNLSOUND.html#a82a11">HighPri</a>; <font class="keywordflow">break</font>; +00201 <font class="keywordflow">case</font> 3: <a class="code" href="classNLSOUND_1_1CSound.html#n2">_Priority</a> = <a class="code" href="namespaceNLSOUND.html#a82a10">HighestPri</a>; <font class="keywordflow">break</font>; +00202 } +00203 } +00204 +00205 +00206 +00207 } <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> |